OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Noobinator on 31 Jul 2009, 23:10:54
-
Hello everyone, ok well i have some script, i can show you, this will gib the npc, but i have no other code, im stuck, i need the conditions, for first, finding out if the npc is dead, and second. is npc moving at a high volocity due to explosion.
Here is the script
_unit = _this select 0;
_VelocityX = random 10;
_VelocityY = random 7;
_VelocityZ = random 10;
_direc = getDir _unit
~0.0000002
_gib001 = "HEAD_GIB" createVehicle getpos _unit; _gib001 setVelocity [_VelocityX,_VelocityY,_VelocityZ]
_gib001 setpos [ getPos _unit select 0, getPos _unit select 1]
_gib001 setDir _direc
_gib002 = "TORSO_GIB" createVehicle getpos _unit; _gib002 setVelocity [_VelocityZ,_VelocityX,_VelocityZ]
_gib002 setpos [ getPos _unit select 0, getPos _unit select 1]
_gib002 setDir _direc
_gib003 = "LEFT_ARM_GIB" createVehicle getpos _unit; _gib003 setVelocity [_VelocityZ,_VelocityX,_VelocityZ]
_gib003 setpos [ getPos _unit select 0, getPos _unit select 1]
_gib003 setDir _direc
(And so on for the other body parts)
deleteVehicle _unit
Any help, would be nice :)
Noobinator
-
Use the the killed eventHandler, that way your code only gets executed when the npc dies.
As for the velocity, you might get by just by checking if the z velocity (upwards) has changed dramatically :dunno:
if ((vehicle _unit) == _unit && (velocity _unit select 2)>0)
then {..gib stuff here...};
-
Thanks buddy for your reply! :D
ok so should the code now look like this;
_unit = _this select 0;
if ((vehicle _unit) == _unit && (velocity _unit select 2)>0)
then {_VelocityX = random 10;
_VelocityY = random 7;
_VelocityZ = random 10;
_direc = getDir _unit
~0.0000002
_gib001 = "HEAD_GIB" createVehicle getpos _unit; _gib001 setVelocity [_VelocityX,_VelocityY,_VelocityZ]
_gib001 setpos [ getPos _unit select 0, getPos _unit select 1]
_gib001 setDir _direc
_gib002 = "TORSO_GIB" createVehicle getpos _unit; _gib002 setVelocity [_VelocityZ,_VelocityX,_VelocityZ]
_gib002 setpos [ getPos _unit select 0, getPos _unit select 1]
_gib002 setDir _direc
_gib003 = "LEFT_ARM_GIB" createVehicle getpos _unit; _gib003 setVelocity [_VelocityZ,_VelocityX,_VelocityZ]
_gib003 setpos [ getPos _unit select 0, getPos _unit select 1]
_gib003 setDir _direc
(And so on for the other body parts)
deleteVehicle _unit};
-
You should be able to get some sort of results with that yes (hopefully :P).
But, you have to change it to sqf because sqs (which that script seems to be) does not support formatting like that, everything within the then {}; would need to be on one line if you keep using sqs.
Just remember that the sqf script is executed by execVM and the ~ has to be replaced with sleep (http://www.ofpec.com/COMREF/index.php?action=details&id=776&game=All), and each line has to end with ;
And btw, that pause is kinda useless because it's way too short to have any effect.
-
Thank you so much for this :D
Now for it to run in game, do i need a config? or can i just use the init line in the editor?
-
You can use the init line.
Or a config, it depends on how you want to go about doing this..
-
Thanks :D
Could you also explain to me how i implement the (killed eventhandlers)?
-
For the init field
this addEventHandler ["killed",{_this execVM "yourscriptname.sqf"}]
(should work unless something has changed since A1)
And since this is for Arma2 you have to initialize all the variables you use first, in the beginning of the script.
Also, that velocity part might not be sufficient enough, it may very well be that you have to check the whole velocity and that's where my math skills don't extend to..
-
I'm also new to scripting (my appologies, trying to learn it), but could you please tell me how do I get this working? I'm mainly interested to get this working for the bullets from the Attack Helicopters. Willl that work?
-
You would need to have the addon that provides those gib models that are created by the script (unless A2 provides such and afaik it doesn't).
If the helo bullets can throw the guy into the air when hitting then it should work, otherwise it gets much more complex.
-
Ah, ok, thanks for the reply. I'll let more experienced people play with it for now and hopefully help alter it later. Still it would be nice to see this for say the C-130 gunship and such. Personally, I would like to see some of it in a random fashion for Attack Helicopters.
-
Yeah me too, i would love to have this working for helicopters, still no look with this though, and im sick of people telling me its easy lol
Yeah the concept is simple, if the unit is dead, and is moving at a high volicity, activate script. But i just can't do it :(
Btw the helicopter does throw soldiers into the air when they are shot :)
I have the gib models here
http://www.filefront.com/14168235/slx_wounds.zip
Im just gonna have to see if someone else can do this :)