Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 8 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 MP Mapping
CoD 2 mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Previous Page
subscribe
Author Topic: making placed weapons respawn in cod 2
Sweemanz
General Member
Since: Jun 18, 2006
Posts: 93
Last: Sep 20, 2006
[view latest posts]
Level 3
Category: CoD2 MP Mapping
Posted: Friday, Jul. 7, 2006 03:03 am
Thats great dude i wish i had the pacience to code
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Friday, Jul. 7, 2006 12:19 pm
If you get into it, its a good way to build an enjoyabe carrier, and one that makes decent money quickly, 50k+ after the first few professional years up to and over the 100k as you become a pro.

But it is not for everyone. I find that starting with script engine coding is a good way to get a feel if the puzzle solving of coding is for you and if you find enjoyment in it besides the cash.
Share |
Marlow
General Member
Since: Jun 27, 2006
Posts: 150
Last: Mar 6, 2008
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Thursday, Jul. 27, 2006 09:14 pm
OK. The respawn work, but I must be doing something wrong, because my abmbient sounds won't play until a weapon respawns...

Code:
main()
{
	maps\mp\_load::main();
	weaponrespawner("weapons", 5);

}

 
	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);

	ambientPlay("ambient_mp_gobhouse");
	
	game["allies"] = "american";
	game["axis"] = "german";
	game["attackers"] = "allies";
	game["defenders"] = "axis";
	game["american_soldiertype"] = "normandy";
	game["german_soldiertype"] = "normandy";

        // Set some cvars
        setcvar("r_glowbloomintensity0","1");
	setcvar("r_glowbloomintensity1","1");
	setcvar("r_glowskybleedintensity0",".5");

}
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Thursday, Jul. 27, 2006 11:00 pm
You need to keep the lines for ambient play and others in the main function. Not add the to the subroutines that get called for each spawned weapon.

See the corrected code I posted.

I also modified the call to weaponrespawner a little by creating a calling the function with a new thread, that is a parallel job that runs intependent from the one you called it from. Without the word thread before a function call, all lines after that in the main function wait till the function is totally complete.

In your case you want to immediately after you tell the computer to start thinking and monitoring for respawn weapons to continue with next playing the ambient sound.

Threads are the way that you can make the cod2 engine run two sections or more at the same time.


Code:
main()
{
	maps\mp\_load::main();

	level thread weaponrespawner("weapons", 5);

	ambientPlay("ambient_mp_gobhouse");
	
	game["allies"] = "american";
	game["axis"] = "german";
	game["attackers"] = "allies";
	game["defenders"] = "axis";
	game["american_soldiertype"] = "normandy";
	game["german_soldiertype"] = "normandy";

                // Set some cvars
                setcvar("r_glowbloomintensity0","1");
	setcvar("r_glowbloomintensity1","1");
	setcvar("r_glowskybleedintensity0",".5");
}

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);
}
Share |
Marlow
General Member
Since: Jun 27, 2006
Posts: 150
Last: Mar 6, 2008
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Friday, Jul. 28, 2006 02:05 pm
worked like a charm.. Thanks a million.
Share |
dukeofnc
General Member
Since: Jul 24, 2006
Posts: 41
Last: Jun 28, 2007
[view latest posts]
Level 2
Category: CoD2 MP Mapping
Posted: Thursday, Aug. 3, 2006 04:52 pm
sentchy u r the man! Thanks for the great post, Im attempting to use it now. I really like the way you explained this subject, and made it fairly newbproof. I hope if you get some time you can make some tutorials for us newbs!Thanks again.. u rock [rocking]
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 MP Mapping
Posted: Monday, Dec. 25, 2006 02:54 pm
nice script but i had two problems with it:

1. weapon spawned upside down
2. there wasn't a delay between respawn (perhaps cause i used the script in a seperate gsc file?):

Code:
maps\mp\_load::main();
level thread maps\mp\_respawn_weapons::main("respawn_weapon","5");
___________________________________________________
_respawn_weapons.gsc:

main(targetname, defaultrespawndelay)
{ ... }

weapon_think(delaytime)
{ ... }
Share |
JackManic
General Member
Since: Dec 8, 2005
Posts: 9
Last: Oct 26, 2007
[view latest posts]
Level 0
Category: CoD2 MP Mapping
Posted: Friday, Oct. 26, 2007 07:21 am
Do you know if this script will work with a smoke nade cause I can't seem to make it work I set targetname to weapons and copy the script to my gsc file try to run it and it won't respawn maybe you just cant make smoke nades respawn. Any help will be much appreciated.
Share |
Restricted Access Topic is Locked
Page
Previous Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 MP Mapping

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»