OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Jimboob on 09 Aug 2006, 02:05:44
-
Basicly, ive got this,
?((getdammage unit)>0.4): setCombatMode "BLUE"
But it doesnt seem to work.
What I want is when an enemy gets hit, (An AI) I want him to hold fire. Thought this would work but to no avail, continues to fire at me.
-
GetDammage is quite buggy from my experience. That code should work, although try to debug it with a hint-format check to see how much damage is actually caused. If that doesn't work, go with EventHandlers or something instead, if you can spare the CPU/Memory it takes.
EDIT: Typo.
-
er, actually the syntax is incorrect.
?((getdammage unit)>=0.4) : unit setCombatMode "BLUE"
setcombatmode (http://www.ofpec.com/COMREF/index.php?action=list&letter=s#setCombatMode) needs to be told the unit (or group) whose combatmode it's setting.
always read the COMREF folks.
-
I like this idea...and suggest a modification. When hit, have the soldier not fire for a few seconds (say a random range of .5 to 3), then setcombatmode back to "RED". This would simulate impact and fear stunning the soldier.
May burn too much cpu to put this script or eventhandler on all ai though...
-
Of course he will hold fire for few secs only...
Getdammage is indeed buggy, I have a trigger where in condition I set this:
Getdammage easttroop >=0.7
And on activation:
Hint "Mortal Wound"
But It takes two headshots to display the hint.
-
Getdammage is indeed buggy
The damage caused to a unit depends on where it was hit and with what...
Also, triggers are 'executed' at about 0.5 second intervals so there may be a delay between the shot and the hint..
Although it wouldn't surprise me if the function was indeed buggy as so many others are..
@dmakatra
How exactly is an interrupt (eventHandler) more CPU/memory consuming than a function?
The game itself uses eventhandlers for almost everything...
I'm not a real coder but I don't really see how that would be true.. :P
-
@dmakatra
How exactly is an interrupt (eventHandler) more CPU/memory consuming than a function?
The game itself uses eventhandlers for almost everything...
I'm not a real coder but I don't really see how that would be true.. :P
AFAIK, that is how I remember it and how I learnt it. Anything I say these days should be taken with caution though, as I haven't done any scripting for over a year. :P
-
Event handlers are definitely the way to go everywhere you can use them, but common sense is naturally needed.
It depends on how you use (or more precisely, what you start from the event handlers) event handlers if they take too much processing power or not. Putting a fired event handler into many units and then starting a long-ish script from those event handlers, is well... plain stupidity. Imagine two 12-man groups firing automatic weapons simultaneously, and count how many instances of the script you will have started per minute in an intense firefight... So there you get strain on the CPU via an event handler but that is not the event handler's fault anymore, really.