Home   Help Search Login Register  

Author Topic: Crew out from a tank with an smokie?  (Read 1139 times)

0 Members and 1 Guest are viewing this topic.

Offline Elzo

  • Members
  • *
Crew out from a tank with an smokie?
« on: 02 Oct 2008, 17:02:24 »
Hello!

I need to know how can I make tank crew get out from a tank when I throw smokegrenade near to it and that grenade have smoked for a while (10 seconds for example).

Yes I know this sounds pretty interesting, but I hope some ones got an idea!  ;)

Walter_E_Kurtz

  • Guest
Re: Crew out from a tank with an smokie?
« Reply #1 on: 02 Oct 2008, 20:21:30 »
I can give you a start, working for an ordinary Smoke grenade:

write the following in the init for the player's unit:
[this] exec "WaitSmoke.sqs"

Then you need two scripts, WaitSmoke.sqs:
Code: [Select]
_man = _this select 0

_man addEventHandler ["Fired", {if ((_this select 4) == "SmokeShell") then {_grenade = nearestObject [_this select 0, _this select 4]; [_grenade] exec "SmokeThrown.sqs"}}]

exit

which, once a smoke shell is thrown, launches SmokeThrown.sqs:

Edit: improved the following
Code: [Select]
_grenade = _this select 0

~6

_where = getPos _grenade
_GrenadeLongitude = _where select 0
_GrenadeLatitude = _where select 1

_armour = getPos tanky
_TankLongitude = _armour select 0
_TankLatitude = _armour select 1

_eastwest = (_TankLongitude - _GrenadeLongitude)
_northsouth = (_TankLatitude - _GrenadeLatitude)

_gap = sqrt ( (_eastwest)^2 + (_northsouth)^2)

Hint format ["%1", _gap]

? (_gap > 5): exit

~4

UnassignVehicle tankC
UnassignVehicle tankD
UnassignVehicle tankG

exit

The empty enemy tank is to be named "tanky".
Create a group of three enemy crew, the leader is to be named "tankC" with "this moveInCommander tanky" in his init line.
The other two should be  "tankD" with "this moveInDriver tanky" in his init line
and  "tankG" with "this moveInGunner tanky" in his init line.


Hope you appreciate Pythagoras. Getting the smoke grenade within 5 metres requires some serious throwing accuracy, so you may want to increase the necessary radius for _gap.
« Last Edit: 02 Oct 2008, 23:37:05 by Walter_E_Kurtz »

Offline Elzo

  • Members
  • *
Re: Crew out from a tank with an smokie?
« Reply #2 on: 03 Oct 2008, 16:09:39 »
WOW!

Thank you very much sir!  :)