Author |
Topic: When making maps, can ur teammates never die? |
sam_fisher3000 |
|
General Member Since: Apr 18, 2007 Posts: 816 Last: Jul 16, 2016 [view latest posts] |
|
|
|
|
Scratchy |
|
General Member Since: Feb 10, 2006 Posts: 276 Last: Mar 16, 2009 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 12:16 am |
|
sam_fisher3000 writes...Quote: LoL, go ahead and ask, I dont mind, I am wondering wut scripting is for anyway too.
I understand the script, just the thing has been throwing me off as I look at the stock files too.
I can further clearify what I do know for you...
This script can be applied 2 ways.
1)In your Map GSC
-You can just slap this straight into your Maps GSC. Just make sure you have a Main() function, and call ( thread ally _nodamage ();) for your ally _nodamage () inside your main () function.
2)In an external file, that is called from withing your Map GSC
-You can make a seperate GSC file and name it what ever you want, and slap this script into there as is. Then in your Maps GSC you just call for the script (map\mp\magicscript::main ();) in your Main() function.
As for the script its self...
Code: main()
//^This is the begining for every script in CODscript^
{
Code: thread ally_nodamage();
//^This calls the ally_nodamage function in this script^
}
Code: ally_nodamage()
//^This is where the ally_nodamage function starts^
{
Code: allyteam =getentarray ("ally", "targetname");
//^This make a new variable (allyteam), that equals all entities with the target name ally^
Code:
for(i=0;i<allyteam.size;i++)
//^unsure what this will do, but its a form of a loop^
Code:
allyteam[i/] thread maps\_utility::magic_bullet_shield();
//^this makes variable allyteam run the script _utility and start at the magic_bullet_shield() function^
} |
|
|
|
sam_fisher3000 |
|
General Member Since: Apr 18, 2007 Posts: 816 Last: Jul 16, 2016 [view latest posts] |
|
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 12:56 am |
|
So ur saying that I can make more than one gsc file.
This is my first one
main()
{
maps\_load::main();
level.player takeallweapons();
level.player giveWeapon("m1carbine");
level.player giveWeapon("thompson");
level.player giveWeapon("fraggrenade");
level.player switchToWeapon("thompson");
}
My second one is
main()
{
thread ally_nodamage();
}
ally_nodamage()
{
allyteam =getentarray ("ally", "targetname");
for(i=0;i
allyteam thread maps\_utility::magic_bullet_shield();
}
However, doesnt these two files have the same name or else it wouldnt work? U cant have the same name or else one will replace the other. So well, ur saying that I make another gsc file and apply "(map\mp\magicscript::main();) in your Main() function". I will have to apply it at the beginning right? Then the rest is something else right? I hope I am right.
|
|
|
|
TexasRebel |
General Member Since: May 1, 2006 Posts: 373 Last: Aug 20, 2013 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 12:57 am |
|
for(i=0;i
the first part of the for loop declares a new variable i and sets it to 0. The second part is a logic comparsion, if i is less than the size of allyteam, then execute the loop. The last part increments i by 1.
Say ally team is 5.
then first time through it would execute the code after the for loop, then at the end i= i+1, so i would now hold the value of 1. It would keep performing this until i
Hope this helps if not I can write ya what my intro c++ class book said a year ago. |
|
|
|
sam_fisher3000 |
|
General Member Since: Apr 18, 2007 Posts: 816 Last: Jul 16, 2016 [view latest posts] |
|
|
|
|
Scratchy |
|
General Member Since: Feb 10, 2006 Posts: 276 Last: Mar 16, 2009 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 02:09 am |
|
sam_fisher3000 writes...Quote: So ur saying that I can make more than one gsc file.
This is my first one
main()
{
maps\_load::main();
level.player takeallweapons();
level.player giveWeapon("m1carbine");
level.player giveWeapon("thompson");
level.player giveWeapon("fraggrenade");
level.player switchToWeapon("thompson");
}
My second one is
main()
{
thread ally_nodamage();
}
ally_nodamage()
{
allyteam =getentarray ("ally", "targetname");
for(i=0;i
allyteam thread maps\_utility::magic_bullet_shield();
}
However, doesnt these two files have the same name or else it wouldnt work? U cant have the same name or else one will replace the other. So well, ur saying that I make another gsc file and apply "(map\mp\magicscript::main();) in your Main() function". I will have to apply it at the beginning right? Then the rest is something else right? I hope I am right.
Ok look. You have your Maps GSC, which is named after your map, and is runned when your map is runned. You make another GSC (call it watever you want to) and then call it from your Maps GSC. So here i what it should look like...
main()
{
maps\_load::main();
maps\mp\magic::main();
level.player takeallweapons();
level.player giveWeapon("m1carbine");
level.player giveWeapon("thompson");
level.player giveWeapon("fraggrenade");
level.player switchToWeapon("thompson");
}
^^This one is named after your map^^
Now you have a second GSC file named magic and in it is this...
main()
{
thread ally_nodamage();
}
ally_nodamage()
{
allyteam =getentarray ("ally", "targetname");
for(i=0;i
allyteam thread maps\_utility::magic_bullet_shield();
}
And make sure you have your actors with the targetname ally
edited on Nov. 26, 2007 09:10 pm by Scratchy |
|
|
|
TexasRebel |
General Member Since: May 1, 2006 Posts: 373 Last: Aug 20, 2013 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 02:59 am |
|
i was just trying to give an example of how the for loop works. i is just a dummy variable or counter in this case for the FOR loop.
allyteam.size will be as large as the number of entities you give with the name ally.
Code:
main()
{
maps\_load::main();
level.player takeallweapons();
level.player giveWeapon("m1carbine");
level.player giveWeapon("thompson");
level.player giveWeapon("fraggrenade");
level.player switchToWeapon("thompson");
thread ally_nodamage(); // executes ally_nodamage() function
}
ally_nodamage() // function created by user to keep AI alive
{
//creates new variable and makes it an array to hold entities with the name ally.
allyteam =getentarray ("ally", "targetname");
for(i=0;i<allyteam.size, i++)
{
allyteam thread maps\_utility::magic_bullet_shield();
}
}
that can all be in just one gsc file. Not really sure how to explain it, everything everyone has said should work.
edited on Nov. 26, 2007 10:00 pm by |TM|TexasRebel |
|
|
|
94sniper |
|
General Member Since: Jun 15, 2007 Posts: 907 Last: Jun 22, 2009 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 03:26 am |
|
.KiLL3R. writes...Quote:
u cant hack on SP
with infinite health yeah you can. change the weapon files to your wants. there are lots of ways to hack on sp
By the Way: Haxr = hacker |
|
|
|
.KiLL3R. |
|
General Member Since: Oct 26, 2006 Posts: 1437 Last: Jul 3, 2017 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 06:31 am |
|
hacking the computer anyways...
Code: allyteam =getentarray ("ally", "targetname");
for(i=0;i<allyteam.size;i++)
allyteam[i] thread maps\_utility::magic_bullet_shield();
FOR can also be used just to loop 3 times and so on
Code: for(i=0;i<3;i++)
{
self.health++;
wait 1; //loops once a second for 3 times
}
stuff like break; and continue; are useful
break; breaks the loop xD
continue; makes it go to the next loop
those things can also be used with while()
Code: while(1)
{
if(self.health > 100)
{
wait 0.1;
continue;
}
if(self.sessionstate != "playing")
break;
self.health++;
wait 0.1;
} |
|
|
|
Scratchy |
|
General Member Since: Feb 10, 2006 Posts: 276 Last: Mar 16, 2009 [view latest posts] |
|
|
Category: CoD2 MP Mapping Posted: Tuesday, Nov. 27, 2007 11:07 am |
|
I see now. Your using the counter to access every entity in the array, and then apply the script to it. Ive been doing this in my programming class, but its in another language so it was hard make the "translation"
Im also gonna guess that using "++" will increament the variable by 1? Instead of writing out i=i+1 you just add the double plus signs?
And while we are still on the subject (been looking at stock scripts with confused eyes). While(1) just runs the loop nonstop, or until break or continue?
Originally Posted by 94SniperQuote: with infinite health yeah you can. change the weapon files to your wants. there are lots of ways to hack on sp
By the Way: Haxr = hacker
Haxors are Whackzors
edited on Nov. 27, 2007 06:10 am by Scratchy |
|
|
|