Home   Help Search Login Register  

Author Topic: unit hasweapon "radio" script...  (Read 1743 times)

0 Members and 1 Guest are viewing this topic.

Offline Kendo J

  • Members
  • *
  • Britain Has more varieties of cheese than France
unit hasweapon "radio" script...
« on: 16 Oct 2008, 12:25:21 »
Hi all I am having problems with a script I wrote for the Laser radio that checks if a unit in the player squad has a radio. If so you get the radio options if not you get only the TACBE (tactical emergency beacon) which allows you only evac calls.

My problem is that the loops in the script cause loads of Lag and I don't know why? is there anyone who has a script that works better than mine?

Kendo

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: unit hasweapon "radio" script...
« Reply #1 on: 16 Oct 2008, 13:18:11 »
Might be it would be a good idea to copy here that script.

Offline Kendo J

  • Members
  • *
  • Britain Has more varieties of cheese than France
Re: unit hasweapon "radio" script...
« Reply #2 on: 16 Oct 2008, 14:15:41 »
will do.... just don't have the script with me right now....

was kinda hoping someone already wrote one ... anyhow, post it tommorow..

Kendo

Walter_E_Kurtz

  • Guest
Re: unit hasweapon "radio" script...
« Reply #3 on: 17 Oct 2008, 02:26:08 »
Here's a basic script, how I'd do it (for what it's worth)
Code: [Select]
#RESTART

~5

_teammates = units player
_teamcount = count _teammates

~2

_i = -1

#LOOP

_i = _i + 1

? ((_teammates select _i) hasWeapon "LSR_prc117new"): hint "Laser Radio in Group"; RadioEquipped=true; goto "RESTART"

? (_i == _teamcount): goto "NORADIO"
goto "LOOP"

#NORADIO
RadioEquipped=false
hint "Radio no longer in group"

goto "RESTART"

exit

Obviously, it changes the value of RadioEquipped depending on the presence of the radio; I don't know if that is useful or if you'd have to merge your Radio Call scripts with this.

A possible flaw might be if the radio operator has been killed, and the player hasn't noticed, that is said "Oh no. Seven is down!". Until his icon has been removed from the command bar, is he still considered part of the players group?



My original idea was, rather than check for the radio's presence, check for its use through an eventHandler. All units in the players group would run the following script:
Code: [Select]
_man = _this select 0

_man addEventHandler ["Fired", {if ((_this select 1) == "LSR_prc117new") then {[_man] exec "RadioCall.sqs"}}]

exit

Unfortunately, Laser's radio doesn't seem to fire - it doesn't trigger the script and it doesn't deplete the batteries. Also, I don't know if team-mates could be ordered to fire it.

Offline Kendo J

  • Members
  • *
  • Britain Has more varieties of cheese than France
Re: unit hasweapon "radio" script...
« Reply #4 on: 17 Oct 2008, 12:07:36 »
Walter your first script is almost exactly like mine, except I think you cracked the problem that I had... with using "_i" I left out a couple of "==" and this bogged the script down... It looks at first glance like it will work better than my script.

Thanks
Kendo

Walter_E_Kurtz

  • Guest
Re: unit hasweapon "radio" script...
« Reply #5 on: 11 Dec 2008, 17:03:59 »
More impressively, General Barron manages to do the same with just a single line that can be used in a trigger or a script (see original post here):

({_x hasweapon "LSR_prc117new"} count units groupname) > 0

Offline zwobot

  • Members
  • *
Re: unit hasweapon "radio" script...
« Reply #6 on: 14 Dec 2008, 21:54:58 »
This may be a bit late to post here but I just came across this thread. Anyway:
Some time ago I made a "light version" of General Barrons Handsignal Command system which basically only includes a scripted version of the HS's radio system. That means you can have a radio operator in a normal Ofp group with the player as the leader and you are only able to use the radio when the player is near the radio operator. The radio operator dies -> radio is not useable anymore.
If you are interested I can post the template mission here, General Barron even gave me the permission to release it back then if I remember correctly.
"Executing tactics in real combat is the hardest thing one can ever do...well I've never given birth but..well whatever."