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

Members Online

»
0 Active | 7 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 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: Trigger_damage , get damage type
elahmn
General Member
Since: Jan 8, 2009
Posts: 15
Last: Aug 29, 2013
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Thursday, Jan. 6, 2011 11:45 pm
Hi!

I have a model on my map (COD2 MP).
Damage should be inflicted by weapons witch causes explositions, and splash damage such as granade, anti-tank weapons etc. on the model by the players.

I know settakedamage() and setcandamage() is not implemented in Cod2 Mp. So I tried to find other sollutions to detect the:
-amount of the inflected damage
-the inflector (who done the damage)
-and the weapon type (to trigger only for the explositoins...)

I have tried to implement this feature by a trigger_damage. It workes nicely but it respond for every type of damage, like pistol or rifle bullets etc.
(I have set the right flags for the trigger:
PISTOL_NO; RIFLE_NO; MELEE_NO - 35)
And it responds for all damage type.


After It I tried to handle the damage type by a script:

Code:

trig waittill("damage", dmg, who, dir, point, mod, inflictor);

-dmg: the amount of the inflicted damage
-who: the player who done the damage
These two variables works perfectly, but for the others are undefined.

So In Sum up:
-I wants detects specificed damage type with my trigger but the usuall ways... May be I 've done something wrong... but I can't find the sollution for this "bug"...



Thanks for your answers in advance!

Elahmn

ps.: Sorry for my English!
Share |
cskiller86
General Member
Since: Nov 23, 2009
Posts: 528
Last: Oct 25, 2011
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Jan. 7, 2011 09:24 am
If I understand this correctly, you want to damage something only by explosives, no ?

If so, then do this:
Code:
trig waittill("damage", dmg, who, dir, point, mod, inflictor);
if (mod == "MOD_RIFLE_BULLET" || mod == "MOD_PISTOL_BULLET" || mod == "MOD_MELEE")
continue;
// rest of your code follows

The trigger will wait for damage and will run your code only if the damage isn't by bullets or melee.
_INSANE_ taught me this, so you should thank him :)
Share |
elahmn
General Member
Since: Jan 8, 2009
Posts: 15
Last: Aug 29, 2013
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Friday, Jan. 7, 2011 09:39 am
Yes that's it, but as I said the mod variable's value is undefined so I get some runtime errors (undefined cannot be casted to bool)...
(sorry I forgot it in the topic opening post!)

Code:

******* script runtime error *******
cannot cast undefined to bool: (file 'maps/mp/gametypes/bas.gsc', line 763)
  if (mod == "MOD_RIFLE_BULLET" || mod == "MOD_PISTOL_BULLET" || mod == "MOD_MELEE")
          *
started from:
(file 'maps/mp/gametypes/bas.gsc', line 762)
  bunker.top waittill("damage", dmg, who, dir, point, mod, inflictor); 
             *
************************************



edited on Jan. 7, 2011 04:39 am by elahmn

And there is the code witch handle the damages:

Code:

wait_base_dmg(bunker){
	level endon("intermission");
	level endon("round_end");
	//level waittill("round_start");	-nem kell itt lennie mert nezzuk ha nem megy a kor
	while(1){
		bunker.top waittill("damage", dmg, who, dir, point, mod, inflictor);	//nem ad az osszesnek erteket :S
		if(isValidBaseDmg(who, mod, bunker)){
			bunker.base.health-=dmg;
			
			if(bunker.base.model==level._models["bunker_full"] && bunker.base.health<=level.bunker_health/2){	//repedezett
				_set_mid_bunker(bunker);				
			}

			if(bunker.base.health<=0){	//breached
				level notify("announce", "breached", bunker.base.id, bunker.base.team);
				
				_set_breached_bunker(bunker);			//bazis lerombolasa
				player_add_score(who, level.bas_1_obj);	//pontok kiosztasa
				break;
			}
			
			level notify("announce", "under_attack", bunker.base.id, bunker.base.team);	//azert ide kerult hogy nem legyen under_attack+breached
		}
	}
}

and

Code:


isValidBaseDmg(who, mod, bunker){
/*
-ellenoriz tenyleg valos sebzes van-e a bazison,
ha igen 1 ha nem 0
*/
	if(isValidGamer(who)){	//tényleg játszik-e?
		if(who.pers["team"]!=bunker.base.team){	//masiknak a bazisa?
			if(game["num_rounds"]==0 && game["round_restartted"]==0){	//ha meg nem megy a jatek akkor irjunk neki
				if(who.wait_match==false){
					who iprintln(&"BAS_WAIT_TILL_MATCHSTART");
					who.wait_match=true;
				}
				else{
					return 0;
				}
			}
			else{
				if ((mod == "MOD_PROJECTILE") || (mod == "MOD_PROJECTILE_SPLASH")
					|| (mod == "MOD_GRENADE") || (mod == "MOD_GRENADE_SPLASH") 	
					|| (mod == "MOD_ARTILLERY") || (mod == "MOD_ARTILLERY_SPLASH") ){
						//iprintlnBold("Jo sebzes");
						return 1;							
				}
			}
			
		}
	}
	return 0;
}

Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Jan. 7, 2011 09:48 am
I created some setcandamage() structure, mostly based on BraX his code.
If you want it, add me on xfire: Imbackagainiba
Share |
elahmn
General Member
Since: Jan 8, 2009
Posts: 15
Last: Aug 29, 2013
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Friday, Jan. 7, 2011 09:50 am
Thx man!
You've done it with bullettrace?
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Jan. 7, 2011 03:29 pm
yeah pretty sure brax even posted about the setcandamage somewere in these forums if i remember correctly maybe you could do a search for it. i did something similar for my hide and seekv2 mod(hnsv2) i allowed players to be able to bash and tag models now instead of having to throw nades and yes bullet trace plays a big roll in this because you have to know what you are looking at.
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

»