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

Members Online

»
0 Active | 107 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
Page
Next Page
subscribe
Author Topic: a little question for the pros
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 05:05 pm
how to trigger a trigger_damage from script ??
or in other words, having an entity to damage a trigger_damage ??

I've just scripted an exploding barrel (with no help :) I'm proud of myself). it works great. here's what I would like it to do (ultimatly), I'm real close from acheiving that (thus the question here) :

-there's a trigger_damage and a script_model of a barrel.
-the damage on the trigger gets monitored.
-once it reaches a certain amount of damage, it sets itself on fire, injuring everyone and everything around them, including itself and other barrels.
-when the damage reaches another amount, it blows itself to oblivion, severly injuring (potentially killing) everyone and everything around them, including other barrels.

what's in bold is what I'm having problem with. note that it works well as is but ....you see that would be real cool if barrels could injured themselves and other barrels. right now if you put two barrels close to each other, one could blow but the other stays intact (kindda unrealistic). I would really like to set up some wicked chain reaction explosion only by monitoring the damage sustain.

I'm using the radiusdamage function to effectively injure the players around the barrel (a mild one in a loop during fire, and a major one-timer during the explosion). BUT, this function fails at triggering the trigger_damage that sets off the whole script. [ohwell] (would have worked well otherwise). thus the barrel explode only by having a player shooting at it again. which is ok .... but not yet perfect.

I tried other means :
- spawning a trigger_hurt .... but never got that to work (even at injuring the player).... and I doubt it would trigger the trigger_damage.
- just put a wait(sometime); to let the fire burn sometime and then blow it up. while this simulates the "barrel injuring itself" quite good, it has of course no effect on other barrels.

man I hoped that radiusdamage would work .... do you think it's the because the origin of it is inside the trigger that it doesn't work ? (actually I just thought of that ... let me try)in the mean time you have an idea that's not toooo complicated... that would be cool [thumbs_up]

btw, I'm willing to share my script here in exchange of a good idea [pimp]
------------------------

so that was the first question.
let me ask a second quick, as a simple curiosity.

can we spawn triggers using (example) :

trig = spawn("trigger_damage", some_origin, some_flag, some_radius);

I tried that line. even tho no error was produced, I never got the trigger to work. that would greatly simplify the code if that ever works ... I would be able to work with an array of entities instead of retrieving several differently named entities that then calls the same function. (barrel1, barrel2, ...)

or ...... do you think that the following code garantees that the correct trigger gets pass with the correct barrel ?? (I don't think so .... but who knows ....)

Code:
barrel = getentarray("barrel", "targetname");
barrel_trig = getentarray("barrel_trig", "targetname");
for( i = 0 ; i < barrel.size ; i++ ) {
barrel[i] thread barrelThink(barrel_trig[i]); }



edited on Jul. 5, 2006 01:08 pm by FlesyM
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 05:13 pm
The easiest way to do this is to, instead of using the trigger_damage, to script the whole chain of events...

How did you set the entity values of the trigger_damage? In other words.. which boxes did you tick?
Share |
magdoom
General Member
Since: May 4, 2006
Posts: 172
Last: Nov 8, 2006
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 05:17 pm
(Ok, dont ask me for how to write a script for this.. I just have an idea)


-Your idea with spawning damage should work. With the proper script, I bet you could get it to spawn a trigger_damage around it (damaging the barrels) and spawn a trigger_hurt (for hurting players) for the damaging itself. you could probably try to get a script written that hurts the barrel a little, then waits a while, then hurts it again, instead of gradually hurting it until it explodes. Maybe after awhile, somone who has had a bit more experience with scripting will reply and give you better ideas :-)


I am still new at scripting, so I have no idea how well this would work. But with the proper scripting, im pretty sure you could do anything.
Share |
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 05:29 pm
The_Caretaker writes...
Quote:
The easiest way to do this is to, instead of using the trigger_damage, to script the whole chain of events...

How did you set the entity values of the trigger_damage? In other words.. which boxes did you tick?


spawnflags 32 (no melee)
that's all.

the whole script revolves around the lines

trig waittill("damage", amount);
accDamage = accDamage + amount;

then start a thread with respect to the amount of accumulated damage. (the accumulate key in the entity doesn't seem to work, to I scripted that myself).

true, I could just script the whole thing wrt time ... coming for a mechanical physics background, it just seems unnatural to do so.... in my mind it would still be simpler if it could react to the damage caused by the script itself (the same damage that already injures players).

edited on Jul. 5, 2006 01:31 pm by FlesyM
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 05:55 pm
why not just use a "trig waittil ("trigger"); and set the damage limit in the key/value for each trigger?
Share |
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 06:00 pm
yeah I just thought of that while smoking.... great idea ! [eek]

I'll let you know ...
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 10:19 pm
FlesyM: Quoting some of your code:

Code:
barrel = getentarray("barrel", "targetname");
barrel_trig = getentarray("barrel_trig", "targetname");
for( i = 0 ; i < barrel.size ; i++ ) {
barrel[i] thread barrelThink(barrel_trig[i]); }


That code most likely will retrieve the correct trigger, but if you delete a trigger by accident and recreate it, then all your barrels and triggers thereafter will be off. (You could check this by looking at the entity numbers in the .map)

A better way would be to give each barrel a unique targetname, such as barrel1, barrel2 and on each trigger entity set the key of "target" to the corresponding barrel1, barrel2, etc..., then in code retrieve the barrel entity through the trigger.target value with an getent.

The code then would need to be changed as follows and would ensure you assign the correct trigger to the correct barrel:

Code:

barrel_trig = getentarray("barrel_trig", "targetname");
for( i = 0 ; i < barrel_trig.size ; i++ ) {
  // Find the correct barrel for current trigger
  barrel = getent(barrel_trig[i].target, "targetname");
  barrel thread barrelThink(barrel_trig[i]);
 }


Alternatively even better you could spawn in script the trigger_damage and position it around the barrel. That would really simplify the COD2Radiant work since all your would need to do is create the barrel with targetname something like "barrelautotrigger" and write the code to create a trigger_damage on the fly.
Share |
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 10:38 pm
sentchy writes...
Quote:
Alternatively even better you could spawn in script the trigger_damage and position it around the barrel. That would really simplify the COD2Radiant work since all your would need to do is create the barrel with targetname something like "barrelautotrigger" and write the code to create a trigger_damage on the fly.
yes that's exactly what I would want to do ... but can't get it to work. you know the correct line that would spawn the trigger_damage with, lets say, a radius of 50, no_melee damage ?

up to now I was able to simulate auto-damage through fire, until it blows up. I am working on a work-around for the "barrel blows another barrel" issue. (a question on that following). you are right, spawn the trigger would greatly simply the radiant work, and a little bit of the code too. could you help me on that ? I simply need the

trig = spawn(????);

line

so here's the new question:
when a barrel enters the "blows up" thread, it checks for close range barrel and increase their damage value if close enough. but barrels that get their damage increased by another barrel are waiting at the waittill("damage", amount) line in another thread, waiting for the damage trigger. thus they're stock, it's a deadlock until a player shoots it even tho their damage value were well high enough to catch fire or blow up before he shoots. is there a way for a thread that has access to a trigger to "signal it" at the attention of another thread ? (i'm thinking in semaphores here - java).

I'm thinking
signal(some_barrel.trig);

???

edited on Jul. 5, 2006 06:40 pm by FlesyM
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 10:59 pm
signal is called notify in COD2. The syntax is different. Lets assume triggerpointer is a pointer to the trigger entity you retrieved with getentarray or created yourself. Then the syntax is:

triggerpointer notify("trigger", 100);

The first parameter is the name of the event to signal and the second are parameters.




Share |
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Wednesday, Jul. 5, 2006 11:13 pm
excellent !! I knew I saw that elsewhere. thx a lot. for the parameters, I'm guessing that in my case it's the "amount" of damage ? is the parameter mandatory ? anyway thx i'll try this out.

as for the trigger spawn ... i'll try again ... but were you able to spawn one that works ? I'm feeling I'm missing something real basic here.

------
edit : ho yeah the notify worked great ! sweet ! it's getting close to completion.

edited on Jul. 5, 2006 07:19 pm by FlesyM
Share |
Restricted Access Topic is Locked
Page
Next Page
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

»