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

Members Online

»
0 Active | 44 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

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 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Multiple bombs in sd
Grorigan
General Member
Since: Mar 26, 2011
Posts: 66
Last: Jun 23, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Friday, Nov. 2, 2012 04:31 pm
Hello all ! [wave]

I am trying to modify the sd mod : I want the attackers can plant more than one bomb.
I made that, it works fine. But only one bomb can be defused by defenders, because the trigger "bombtrigger" is unique.
So, I want to know if it is possible to create some new triggers, one by bomb planted ?

Thx for helping !
Share |
Grorigan
General Member
Since: Mar 26, 2011
Posts: 66
Last: Jun 23, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Saturday, Nov. 3, 2012 06:03 pm
I answer to myself :

We can't dynamically create a trigger, except a trigger_radius. So, when an attacker plants a bomb, I create a trigger_radius, and if a defender enters it, I simulate the bomb_trigger actions.

That's not as simple as a bomb_trigger, but it works.

If anyone has a better idea... [tongue]
Share |
Ni3ls
General Member
Since: Nov 7, 2008
Posts: 256
Last: Sep 9, 2017
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Saturday, Nov. 3, 2012 06:08 pm
Yes you can create a trigger_radius and add a hintstring. But how did u managed to simulate it? Could you post the code?
Share |
Grorigan
General Member
Since: Mar 26, 2011
Posts: 66
Last: Jun 23, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Saturday, Nov. 3, 2012 06:24 pm
I am actually scripting the code. All I done for the moment is testing, it is not working well yet.

The problem is : when a defender enters the trigger_radius, I made the hint_usable icon (added as a menu) becoming visible. But when the defenders come out of the trigger, the icon must be invisible. To detect that, I'm now making tests with the "distance()" function.

In fact, the trigger seems to be useless, as I will use the "distance()" function. An array with the origin of each bomb and a thread which is permanently tests if a defender is in a bomb zone makes the work...
The "waittill trigger" become useless.

I don't want to post some bugged or incomplete code. When my tests are ok, be sure I post it here.
Share |
Grorigan
General Member
Since: Mar 26, 2011
Posts: 66
Last: Jun 23, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Nov. 5, 2012 01:56 am
Ok, it works fine !
Hmm, I test several things, but not during a long time, so it can be bugged. Please note it's a first version, and if you find mistakes, please tell me !

I added an image (which is "hint_usable.iwi") and its material in my mod. You know, the hand when you are closed to a trigger_use. They are both in the iw_xx.iwd of the game.
To display it, I added a menu in the hud.menu and command it with the variable 'ui_hint_usable' :

Code:
menuDef 
	{
    	name "HintUsable"
    	fullScreen MENU_FALSE
    	visible MENU_TRUE
		rect -20 30 0 0 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER
		
		itemDef
 	   	{
			name "hint_usable"
			rect 0 0 50 50
			forecolor 1.0 1.0 1.0 1.0
			ownerdraw CG_PLAYER_COMPASS_BACK
			visible MENU_TRUE
			decoration
			background "hint_usable"
			dvarTest "ui_hint_usable"
			showDvar { "1" }
 	   	}
	}


Anyway, that's not the main point.

To be able to plant several bombs, I modified the "bombzone_think" function, when a player is planting a bomb :

Code:
			if(self.progresstime >= plantTime)
			{
				self.progressbackground destroy();
				self.progressbar destroy();
				self unlink();
				
				self.planting = false;
				self.HasABomb = false;
				
				self enableWeapon();
				
				i = level.bombPlanted.size;
				
				if(isdefined(bombzone.target))
				{
					exploder = getent(bombzone.target, "targetname");
					
					if(isdefined(exploder) && isdefined(exploder.script_exploder))
						level.bombexploder[i] = exploder.script_exploder;
				}
				
				plant = self maps\mp\_utility::getPlant();
				level.bombmodel[i] = spawn("script_model", plant.origin);
				level.bombmodel[i].angles = plant.angles;
				level.bombmodel[i] setmodel("xmodel/mp_tntbomb");
				level.bombglow[i] = spawn("script_model", plant.origin);
				level.bombglow[i].angles = plant.angles;
				level.bombglow[i] setmodel("xmodel/mp_tntbomb_obj");
				
				// the trigger of the bomb :
				TriggersBombes[i] = spawn("trigger_radius", level.bombOrigin[i], 0, 30, 30 );
				TriggersBombes[i].targetname = "TriggerBomb";
				TriggersBombes[i] thread bomb_think_sd2(i);
				// the new thread for the bomb :
				thread bomb_countdown_new(i);
				
				if(getcvarint("wrm_bombSounds") == 1) {
					level.bombmodel[i] playSound("Explo_plant_no_tick");
				}
				
				// bomb A = 0, bomb B = 1
				bombIndex = 0;
				if (bombzone.script_label == "B" || bombzone.script_label == "b") {
					bombIndex = 1;
				}
				
				// the parameters of the bomb :
				level.bombPlanted[i] = true;
				level.ObjAorB[i] = bombIndex;
				level.bombOrigin[i] = plant.origin;
				level.bombExploded[i] = false;
				level.bombDefused[i] = false;
				level.bombDefusing[i] = false;
				level.bombtimerstart[i] = gettime();
				
				lpselfnum = self getEntityNumber();
				lpselfguid = self getGuid();
				logPrint("A;" + lpselfguid + ";" + lpselfnum + ";" + self.pers["team"] + ";" + self.name + ";" + "bomb_plant" + "\n");



Here comes the new countdown of a bomb. One is launch for each bomb.

Code:
bomb_countdown_new(i)
{
	level endon("bomb_defused_"+i);
	level endon("intermission");
	
	t = getRandomTime("bombTimer");
	wait t;
	
	level.bombExploded[i] = true;
	level notify("bomb_exploded_"+i);
	
	// trigger exploder if it exists
	if(isdefined(level.bombexploder[i]))
		maps\mp\_utility::exploder(level.bombexploder[i]);
	
	// let's 'destoy' the trigger of the objective that just explosed
	bombzones = getentarray("bombzone", "targetname");
	bombzones[level.ObjAorB[i]].origin = bombzones[level.ObjAorB[i]].origin + (0,0,-5000);
	
	// let's delete the objective on the compass
	objective_delete(level.ObjAouB[i]);
	
	// explode bomb
	origin = level.bombOrigin[i];
	range = 500;
	maxdamage = 2000;
	mindamage = 1000;
	
	if(getcvarint("wrm_bombSounds") == 1)
		level.bombmodel[i] stopLoopSound();
		
	// let's 'destoy' the bomb
	level.bombmodel[i].origin = level.bombmodel[i].origin + (0,0,-5000);
	level.bombglow[i].origin = level.bombglow[i].origin + (0,0,-5000);
	
	playfx(level._effect["bombexplosion"], origin);
	radiusDamage(origin, range, maxdamage, mindamage);
	
	level thread endRound_sd2(NbrObjectifsNonDetruit,NbrBombesRestantes);
}



For each bomb, we need to launch this thread which launch another if a player is in the radius of the trigger_radius of the bomb. This because I wanted to display a 'usable' icon for each player in the defusing zone :

Code:
bomb_think_new(i)
{
// This thread is launched when a new bomb is planted. 'self' is the trigger_radius of the bomb.
	
for(;;)
	{
		self waittill("trigger", player);
		
		if(isPlayer(player)
			&& (player.pers["team"] == game["defenders"])
			&& player isOnGround()
			&& (distance(level.bombOrigin[i] , player.origin) < 35)
			&& player.ThreadAPlayerIsInTheZone != true)
		{
			player.ThreadAPlayerIsInTheZone = true;
			player thread APlayerIsInTheZone(i);
		}
		wait(0.05);
	}
}



When a player in the zone of the trigger of a bomb is using it's 'usebutton', he defusing the bomb :

Code:

APlayerIsInTheZone(i)
{
	self endon("disconnect");
	
	self setclientcvar("ui_hint_usable", 1); // icon 'usable'
	while(isAlive(self)
		&& self isOnGround()
		&& distance(level.bombOrigin[i] , self.origin) < 35
		&& level.bombDefused[i] != true)
	{
		while(isAlive(self)
			&& self useButtonPressed()
			&& level.bombDefusing[i] != true)
		{
			// the player is using its 'usebutton' => defusing, progress bar
			defuseTime = getRandomTime("defuseTime");
			level.barincrement = (level.barsize / (20.0 * defuseTime));
			self.defusing = true;
			level.bombDefusing[i] = true;
			
			TriggersBombes = getentarray("TriggerBombe", "targetname");
			self clientclaimtrigger(TriggersBombes[i]);
			
			if(!isdefined(self.progressbackground))
			{
				self.progressbackground = newClientHudElem(self);
				self.progressbackground.x = 0;
				
				if(level.splitscreen)
					self.progressbackground.y = 70;
				else
					self.progressbackground.y = 104;
				
				self.progressbackground.alignX = "center";
				self.progressbackground.alignY = "middle";
				self.progressbackground.horzAlign= "center_safearea";
				self.progressbackground.vertAlign = "center_safearea";
				self.progressbackground.alpha = 0.5;
			}
			self.progressbackground setShader("black", (level.barsize + 4), 12);
			
			if(!isdefined(self.progressbar))
			{
				self.progressbar = newClientHudElem(self);
				self.progressbar.x = int(level.barsize / (-2.0));
				
				if(level.splitscreen)
					self.progressbar.y = 70;
				else
					self.progressbar.y = 104;
				
				self.progressbar.alignX = "left";
				self.progressbar.alignY = "middle";
				self.progressbar.horzAlign = "center_safearea";
				self.progressbar.vertAlign = "center_safearea";
			}
			self.progressbar setShader("white", 0, 8);
			self.progressbar scaleOverTime(defuseTime, level.barsize, 8);
			
			if(getcvarint("wrm_bombSounds") == 1)
				self playsound("MP_bomb_defuse");
			if(getcvarint("wrm_showBombTimer") != 1)
				self showPlayerBombTimer_sd2(i);
			
			self linkTo(TriggersBombes[i]);
			self disableWeapon();
			
			self.progresstime = 0;
			while(isAlive(self)
				&& self useButtonPressed()
				&& (self.progresstime < defuseTime))
			{
				self.progresstime += 0.05;
				wait 0.05;
			}
			
			self clientreleasetrigger(TriggersBombes[i]);
			
			if(self.progresstime >= defuseTime)
			{
				level.bombDefused[i] = true;
				
				self.progressbackground destroy();
				self.progressbar destroy();
				self unlink();
				self.defusing = false;
				self enableWeapon();
				
				self deletePlayerBombTimer();
				
				level notify("bomb_defused_"+i);
				level.bombmodel stopLoopSound();
				
				// let's 'destroy' the bombglow and the trigger. I put them far away, not delete.
				level.bombglow[i].origin = level.bombglow[i].origin + (0,0,-5000);
				TriggersBombes[i].origin = TriggersBombes[i].origin + (0,0,-5000);
				
				lpselfnum = self getEntityNumber();
				lpselfguid = self getGuid();
				logPrint("A;" + lpselfguid + ";" + lpselfnum + ";" + self.pers["team"] + ";" + self.name + ";" + "bomb_defuse" + "\n");
				
				level thread endRound(self.pers["team"]);
				
			}
			else
			{
				if(isdefined(self.progressbackground))
					self.progressbackground destroy();
				
				if(isdefined(self.progressbar))
					self.progressbar destroy();
					
				if(getcvarint("wrm_showBombTimer") != 1)
					self deletePlayerBombTimer();
				
				self unlink();
				
				self.defusing = false;
				self enableWeapon();
				
				level.bombDefusing[i] = false;
			}
			wait(0.05);
		}
		wait(0.05);
	}
	
	// player out of the zone
	self.ThreadAPlayerIsInTheZone = false;
	self setclientcvar("ui_hint_usable", 0);
}


That's all ! [crazy]

Hope it will be usefull,
Bye !

(And sorry for my bad english, it is not my native language...)
Share |
Ni3ls
General Member
Since: Nov 7, 2008
Posts: 256
Last: Sep 9, 2017
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Monday, Nov. 5, 2012 09:51 am
Well done! It looks very difficult to make. And how about the timer? You always get a timer, to see how much time left. What if there are 2 bombs planted?
Share |
Grorigan
General Member
Since: Mar 26, 2011
Posts: 66
Last: Jun 23, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Nov. 5, 2012 02:00 pm
One timer per bomb :

Code:
// i is the number of the planted bomb :
level.bombtimerstart[i] = gettime();


And the new countdown function is launched by thread for each bomb planted : re-read my new bombzone_think function :

Code:
thread bomb_countdown_new(i);


Players don't see any timer : it is not realistic. Only the player who is defusing a bomb see the timer of the bomb he is defusing [casanova]

If you want, in a few days, when my new sd (should we call it "demolition" ?) is ok and tested in all configurations, I'll post here the entire work, and I'll invite you on my server to play on it. It will be easier to understand the changes.
Share |
Spik3d
General Member
Since: Jan 30, 2008
Posts: 130
Last: Feb 19, 2015
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Monday, Nov. 5, 2012 02:17 pm
Grorigan writes...
Quote:
The problem is : when a defender enters the trigger_radius, I made the hint_usable icon (added as a menu) becoming visible. But when the defenders come out of the trigger, the icon must be invisible. To detect that, I'm now making tests with the "distance()" function.

Please don't.

This is better.

Code:
while(isDefined(mp_player) && mp_player isTouching(trigger))
{
	wait 0.05;
}
Share |
Grorigan
General Member
Since: Mar 26, 2011
Posts: 66
Last: Jun 23, 2013
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Monday, Nov. 5, 2012 10:18 pm
Spik3d writes...
Quote:
Grorigan writes...
Quote:
The problem is : when a defender enters the trigger_radius, I made the hint_usable icon (added as a menu) becoming visible. But when the defenders come out of the trigger, the icon must be invisible. To detect that, I'm now making tests with the "distance()" function.

Please don't.

This is better.

Code:
while(isDefined(mp_player) && mp_player isTouching(trigger))
{
	wait 0.05;
}


So simple, so brilliant ! [eek] [thumbs_up]
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

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

»