Author |
Topic: trigger_damage - getting info on the player doing the damage |
|DA|DarkDilbert |
|
General Member Since: Jun 5, 2006 Posts: 675 Last: Apr 29, 2008 [view latest posts] |
|
|
|
WHC_Grassy |
General Member Since: Apr 20, 2005 Posts: 1426 Last: Aug 25, 2007 [view latest posts] |
|
|
Category: CoDUO Mapping Posted: Thursday, Aug. 2, 2007 10:14 am |
|
Yup :)
With this little gem you can have any script_model or script_brushmodel take damage and blow up or something without the need to use trigger_damage triggers.
Note this script will only report info to the screen so you can see that the "ent" is in fact notifying that it's taking hits.
It shows all the info you can collect and how to set health levels, and how to reduce health levels with each hit.
Enjoy, Grassy
Code:
collect_dmg_ents() {
ent = getent("dmg_ent","targetname");
if(isDefined(ent))
ent thread monitor_ent_dmg();
}
monitor_ent_dmg() {
// turn on the damage notifies
self settakedamage(true);
// set a base health
health = 1000;
while(1) {
self waittill ("damage", dmg, who, dir, point, mod);
org1 = who getorigin();
org2 = self.origin;
health = health - dmg;
iprintln("***********************");
iprintln("Damage level = " +dmg);
iprintln("Who = " ,who);
iprintln("Who position = " ,org1);
iprintln("Self position = " ,org2);
iprintln("Hit Direction = " +dir);
iprintln("Hit Position = " +point);
iprintln("Direction = " +angles);
iprintln("Damage type = " +mod);
iprintln("Current Health = " +health);
iprintln("***********************");
}
}
|
|
|
|
|DA|DarkDilbert |
|
General Member Since: Jun 5, 2006 Posts: 675 Last: Apr 29, 2008 [view latest posts] |
|
|
|
WHC_Grassy |
General Member Since: Apr 20, 2005 Posts: 1426 Last: Aug 25, 2007 [view latest posts] |
|
|
Category: CoDUO Mapping Posted: Friday, Aug. 3, 2007 01:44 am |
|
Complete code? Define complete.
That bit of code shows all you need to make great scripts. :)
I dont think people realise how good this is, imagine having heaps of objects in your map that react with damage and no triggers used.
And they can all react in a different way too, either by moving, falling, smoking, blow up, or smash.
They can also react to splash damage from grenades.
Imagine you have a cable car in your map that moves back and forwards over a deep valley, you could script it so the cable car detects and accumulates damage, starts smoking and stuttering while moving and eventualy disconnects and falls from the cables to blow up on the valley floor
This can be done without the hassle of making a trigger and then scripting it follow the car.
Imagine you have lots of crates and barrels around your map. A lot of the barrels could be set to take damage and explode if damaged enough, you would never know which ones explode and which ones wont :) Same with crates.
Sorry I've got so many ideas and not enough time to do them all. hehehe.
Maybe I should start making some small tutes with small example maps to explore all this stuff.
But if you still want to persist with triggers, just do this.
trig waittill("trigger",other);
iprintln("Damage done by: " ,other.name);
Regards Grassy |
|
|
|
macklebee |
|
General Member Since: Dec 6, 2006 Posts: 104 Last: Aug 24, 2008 [view latest posts] |
|
|
|
|
|
|DA|DarkDilbert |
|
General Member Since: Jun 5, 2006 Posts: 675 Last: Apr 29, 2008 [view latest posts] |
|
|
Category: CoDUO Mapping Posted: Friday, Aug. 3, 2007 11:50 am |
|
WHC_Grassy writes...Quote: Complete code? Define complete.
That bit of code shows all you need to make great scripts. :)
I dont think people realise how good this is, imagine having heaps of objects in your map that react with damage and no triggers used.
And they can all react in a different way too, either by moving, falling, smoking, blow up, or smash.
They can also react to splash damage from grenades.
Imagine you have a cable car in your map that moves back and forwards over a deep valley, you could script it so the cable car detects and accumulates damage, starts smoking and stuttering while moving and eventualy disconnects and falls from the cables to blow up on the valley floor
This can be done without the hassle of making a trigger and then scripting it follow the car.
Imagine you have lots of crates and barrels around your map. A lot of the barrels could be set to take damage and explode if damaged enough, you would never know which ones explode and which ones wont :) Same with crates.
Sorry I've got so many ideas and not enough time to do them all. hehehe.
Maybe I should start making some small tutes with small example maps to explore all this stuff.
But if you still want to persist with triggers, just do this.
trig waittill("trigger",other);
iprintln("Damage done by: " ,other.name);
Regards Grassy
cheers. unfortunately the maps already been long compiled, and it's one that takes the best part of a century to compile properly, so I'm stuck trying to fix the trigger_damage trigger. As for:
"trig waittill("trigger",other);
iprintln("Damage done by: " ,other.name);"
I should have bloody guessed it was something that simple, doh! cheers again :) I hate C |
|
|
|
|DA|DarkDilbert |
|
General Member Since: Jun 5, 2006 Posts: 675 Last: Apr 29, 2008 [view latest posts] |
|
|
Category: CoDUO Mapping Posted: Friday, Aug. 3, 2007 12:07 pm |
|
about the code, this is the error i get
pair has unmatching types 'string' and 'undefined': (file pair has unmatching types 'string' and 'undefined': (file 'maps\mp\triggertest.gsc', line 52)
iprintln("Hit Position = " +point);
called from:
(file 'maps\mp\triggertest.gsc', line 41)
self waittill ("damage", dmg, who, dir, point, mod);
same with dir, angles and mod. the code works if i disable those lines, but you only get the player's name, location, trigger's location and object health. How do i define dir, angle and all? |
|
|
|
WHC_Grassy |
General Member Since: Apr 20, 2005 Posts: 1426 Last: Aug 25, 2007 [view latest posts] |
|
|
|
|DA|DarkDilbert |
|
General Member Since: Jun 5, 2006 Posts: 675 Last: Apr 29, 2008 [view latest posts] |
|
|
|