Home   Help Search Login Register  

Author Topic: Detecting enemies and grenades  (Read 964 times)

0 Members and 1 Guest are viewing this topic.

TC

  • Guest
Detecting enemies and grenades
« 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?

Offline Morglor9

  • Members
  • *
Re:Detecting enemies and grenades
« Reply #1 on: 14 Nov 2005, 20:16:08 »
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...
Cymbaline

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:Detecting enemies and grenades
« Reply #2 on: 15 Nov 2005, 01:27:02 »
you can try:
Code: [Select]
_myGrenade = nearestObject [_unit,"GrenadeHand"]

or it could be
Code: [Select]
_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.
« Last Edit: 15 Nov 2005, 01:29:20 by Tyger »
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:Detecting enemies and grenades
« Reply #3 on: 06 Dec 2005, 04:08:45 »
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?

LoTekK

  • Guest
Re:Detecting enemies and grenades
« Reply #4 on: 06 Dec 2005, 06:27:12 »
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.