OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: TC on 14 Nov 2005, 15:54:19
-
hello
I am making a set of units which are complete individuals, with thier own names, voices, faces etc.
I have cannabalised the ECP mod to make a few scripts that mean that the units will talk when firing, or hit, or idle.
However, can anybody help me to make a couple of scipts that will make the unit speak as soon as it has detected a new enemy, or has detected a grenade being thrown?
-
talk to the ECP and ask for permission of course, but there is a scrpit that does this in ECP v1.085. When a grenade is near, Americans yell "Grenade!" and Russians yell "Grenadia!" Also, when the enemy is detected by a unit, Russians yell "Americana!", etc, etc...
-
you can try:
_myGrenade = nearestObject [_unit,"GrenadeHand"]
or it could be
_myGrenade = nearestObject [_unit,"HandGrenade"]
I'm never sure. :P You will have to test those but that should do it.
That will detect the nearest grenade. Then use the _unit distance _myGrenade to detect how far away it is. If it is close to _unit, make him shout something. Put that in a slow looping script, and initiate it for every unit on the map. I would assume that's how the ECP does it.
-
but what about friendly thrown grenades, if the player throws a grenade its a bit obnoxious to hear every member of the squad shout "grenade!" posible to see who it is that has thrown it?
-
Wouldn't a "fired" eventhandler be a lot more efficient for this purpose? Especially since it returns the unit who threw the grenade (from which you can extrapolate the side), as well as muzzle and ammo.
From there you can get the nearest object of type "grenadehand" (or whatever the class is if you're using custom grenades), and get a check on nearby units and run the appropriate scripts.