Making weapons respawn in mp map ?

Have questions about CoD2 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Making weapons respawn in mp map ?

Post by <LT>YosemiteSam[NL] » September 12th, 2007, 10:20 am

Does someone know how to make weapons respawn in a mp_map ?
And can you make it so that when you pick the weapon up the weapon you drop will fall onto the floor instead of replacing the one you pick up?

User avatar
[SoE]_Zaitsev
Core Staff
Core Staff
Posts: 14220
Joined: October 21st, 2004, 7:17 pm
Location: Holland
Contact:

Post by [SoE]_Zaitsev » September 12th, 2007, 3:19 pm

From all the MP maps I have seen is that whenever you pick up a weapon which has been placed there by the creator of the map it will disappear.

That's just one point from me, I'm no mapper. There must be one here who knows more than me.
matt101harris wrote:big cock was the first thing that came to my head lol

Soviet
Core Staff
Core Staff
Posts: 7760
Joined: April 23rd, 2005, 9:12 pm
Location: Plano, Texas
Contact:

Post by Soviet » September 13th, 2007, 2:27 am

in cod1 radiant you select the gun, press n to bring up the entity editor, and check the respawn box, i think it is the same in cod2. As for the 2nd question, don't think it is possible.
Image
ImageImageImage
Image
"Zaitsev is a cunt." - Pedsdude

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Post by JDogg » September 13th, 2007, 6:58 am

I'm no mapper (and I wont pretend to be) but cant you do it with triggers and some scripting??
Image
Image

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Post by <LT>YosemiteSam[NL] » September 13th, 2007, 9:18 am

Thx, but I found a way (opened the gsc of a map with respawnable weapons :) ) to respawn the weapon, almost totaly done with scripting.
And for that second question, can't be done I guess :?

All-Killer
CJ Worshipper
CJ Worshipper
Posts: 383
Joined: December 16th, 2005, 6:38 pm

Post by All-Killer » September 14th, 2007, 3:36 pm

Actually its possible

In the PAM mod you can drop the weapon on the ground. Look in the PAM iwd for the script.
Image

User avatar
[SoE]_Zaitsev
Core Staff
Core Staff
Posts: 14220
Joined: October 21st, 2004, 7:17 pm
Location: Holland
Contact:

Post by [SoE]_Zaitsev » September 14th, 2007, 7:33 pm

True, but once you pick it up it it disappears.

If I drop the MP44 on the ground, and a player who has an MP44 walks over it, simply picks it up as ammo.

It doesn't work like Sam wants it to work.
matt101harris wrote:big cock was the first thing that came to my head lol

All-Killer
CJ Worshipper
CJ Worshipper
Posts: 383
Joined: December 16th, 2005, 6:38 pm

Post by All-Killer » September 15th, 2007, 11:49 am

Hmm true. Maby drofder knows a way? If it is possible to spawn a trigger trough script and place that around the weapon it could check if you already have a mp44, then leave it on the ground, otherwise pick it up.
Image

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 15th, 2007, 1:24 pm

I am not 100% sure, but I do not think that is possible. It might be, but you are going to have to dig pretty deep.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Post by <LT>YosemiteSam[NL] » September 15th, 2007, 7:26 pm

Ok, when it takes too much time and effort I won't wurry about it anymore :)

However, when you pick up the spawnable weapon, the weapon in your hand takes the place of that weapon. Does that weapon dissapear in a while or does it stay there till the end of the map ?
And if it stays there is it possible to let it dissapear after let's say 1 minute ?

For the spawnable weapon I have this script;

Code: Select all

WeaponRespawner(targetname, defaultrespawndelay)
{
weapons = getentarray(targetname, "targetname");
if(weapons.size > 0)
{
for(i=0; i < weapons.size; i++) 
{
if(!isdefined(weapons[i].script_timescale))
weapons[i].script_timescale = defaultrespawndelay;

// kick off a thread to listen for when the item gets picked up
weapons[i] thread weapon_think(weapons[i].script_timescale);
}
}
}

// self = weapon reference
weapon_think(delaytime)
{
// capture important weapon data first to allow us to respawn them
classname = self.classname;
model = self.model;
count = self.count;
org = self.origin;
angles = self.angles;

targetname = self.targetname;

// Wait till the weapon gets picked up
self waittill("trigger");

// Wait the delay before respawn
wait delaytime;

// respawn the weapon
weapon = spawn(classname, org);
weapon.angles = angles;
weapon.count = count;
weapon setmodel(model); 
weapon.script_timescale = delaytime;
weapon.targetname = targetname;

// Kick off a new thread with the new weapon and kill the old one
weapon thread weapon_think(delaytime);
}
I think the answer to my question is in there somewhere :wink: but I can't figure out where ?

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 16th, 2007, 1:50 am

I cba to read backwards to find your question you seek... but I will guide you through the code and see if I can help...

Ok, taking the code line/section at a time...

Code: Select all

1.
WeaponRespawner(targetname, defaultrespawndelay)
{
Ok, first off, the FUNCTION is called "WeaponRespawner".
Inside the brackets the function ask for two VARIABLES; "targetname" and "defaultrespawndelay" (I will explain each variable when I get to them in the next section.)

Code: Select all

2.
weapons = getentarray(targetname, "targetname");
This will find all ENTITIES with the targetname you assign when you call the function (See 1.)

Code: Select all

3.
if(weapons.size > 0)
{
This will check to find out if any entities exist, if true, continue. (Size is not a measurement, but a count).

Code: Select all

4.
for(i=0; i < weapons.size; i++)
{
This creates a looping thread which will be called the same amount of times as the amount of weapons there are.

Code: Select all

5.
if(!isdefined(weapons[i].script_timescale))
   weapons[i].script_timescale = defaultrespawndelay;
This will check the weapon (entity) if the variable '.script_timescale' exists. If it does not exist, then a default time you provided (See 1.) will be used.

Code: Select all

6.
weapons[i] thread weapon_think(weapons[i].script_timescale);
This will send the entity into a new function (See 7.) to check for when it gets picked up, the variable which was assigned earlier (See 5.) is also sent.

Code: Select all

}
}
}
Clsoe all open brackets.

Code: Select all

7.
weapon_think(delaytime)
{
New function for checking when a weapon is picked up.

Code: Select all

8.
classname = self.classname;
model = self.model;
count = self.count;
org = self.origin;
angles = self.angles;
targetname = self.targetname;
The function then records all variables for later recall.
The following is collected, classname (determines which type of entity it is), model (the model of the entity), count (not sure what this for), origin (the coordinates of the entity), angles (the angles of the entity), targetname (the name which has been assigned to the entity).

Code: Select all

9.
self waittill("trigger");
Wait until the trigger is used (weapon is picked up),

Code: Select all

10.
wait delaytime;
Wait the delaytime before continuing the function.

Code: Select all

11.
weapon = spawn(classname, org);
Spawn a NEW entity, with the same classname and origin.

Code: Select all

12.
weapon.angles = angles;
weapon.count = count;
weapon setmodel(model);
weapon.script_timescale = delaytime;
weapon.targetname = targetname;
Assign the new entity with same values of the entity recorded earlier.

Code: Select all

13.
weapon thread weapon_think(delaytime);
}
Restart this thread. Once this is called, the current thread ends and the new one begins.

Hopefully something in their answers you question.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Post by <LT>YosemiteSam[NL] » September 17th, 2007, 2:52 pm

Thx, Drof. But my answer isn't in there. What I do know is I have to put a line in between code 10 and 11 which makes the weapon which the player switched the spawnable one with dissapear before spawning the new one.

Btw, count = amount of bullets for the spawnable weapon (to my knowledge).

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 17th, 2007, 3:12 pm

Ok, give me a step-by-step, as detailed as possible on what you want to happen. I'll see if I can fill in the gaps.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Post by <LT>YosemiteSam[NL] » September 17th, 2007, 4:18 pm

ok;

1 - Player picks up spawnable weapon. (Panzershreck in this case)
2 - The weapon he was holding at the moment of pick up replaces the spawnable weapon.

This part works like a charm but I want also the following thing to happen,

3 - The weapon the player was holding now lies on the spot where the panzershreck will spawn again.
4 - I want that weapon to dissapear before the panzershreck respawns.

I think the command for that should go between 10 and 11, should be something like this;

Code: Select all

10. 
wait delaytime;

Code: Select all

Remove weapon ???? which command

Code: Select all

11. 
weapon = spawn(classname, org);

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 18th, 2007, 12:01 am

delete(); is the command you seek.

Just before the weapon respawns, IF the weapon is still in the same place (same origin), then "entity delete();"

if delete doesn't work, try destroy(); I often get these 2 muddled :)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests