Home   Help Search Login Register  

Author Topic: HasWeapon checks / AddAction to objects  (Read 649 times)

0 Members and 1 Guest are viewing this topic.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
HasWeapon checks / AddAction to objects
« on: 21 Feb 2004, 03:10:40 »
Ive got my unit carrying a piece of kit.  When the unit carries this item they get a custom AddAction.  When the drop the kit they lose the Action.  If someone else picks up the item, they recieve the action, if they drop it  etc etc.

Whats the besy way of doing this?  So far I have the unit start with the action in its init, thus if he drops the item then he still has the action.  Ive put in a check at the end of the script that runs (the action is taken away while the script runs) and the action is given back to the unit if he still has the item, incase he drops it part way through the script.  But its a very dodgy way of doing it all.  Can I add an action to the object, or must I keep running HasWeapon checks?

gundernak

  • Guest
Re:HasWeapon checks / AddAction to objects
« Reply #1 on: 21 Feb 2004, 10:52:42 »
Off course you can add the action to the object as well. you can add an action to any unit, vehicle, object...

but maybe we should know a little bit more about what your units carry...to help you

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:HasWeapon checks / AddAction to objects
« Reply #2 on: 21 Feb 2004, 14:00:58 »
Oh yes its a satcom radio.  So it starts off as inventory on the unit and I dont know how to then add the custom action to the radio, only the man carrying it.  Of course I could put the radio in a weapon holder on teh ground and let people pick it up.  But then I have a feeling that the weapon holder will carry the action, and not the radio itself.
« Last Edit: 21 Feb 2004, 14:13:08 by [icarus_uk] »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:HasWeapon checks / AddAction to objects
« Reply #3 on: 21 Feb 2004, 14:28:08 »
Is this supposed to be used on AI or only 'human' players?
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:HasWeapon checks / AddAction to objects
« Reply #4 on: 21 Feb 2004, 14:37:09 »
Human.

Ive come up with avery dodgy way of doing it with a looping check through all the possible units;

_group = playergroup
_count = 0

#checkone
_unit = _group select _count

?_unit hasweapon "bas_satcom" : goto "hasweapon"

_count = _count + 1
?_count == 9 : goto "exit"

goto "checkone"

#hasweapon
firerqst = _unit addaction ["Radio Fire Mission", "firemission.sqs"]

#exit
exit


But that seems a bit ugly.  I also need to pass a variable to the firemission.sqs script from the addaction, how do I do that?
« Last Edit: 21 Feb 2004, 14:39:06 by [icarus_uk] »

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:HasWeapon checks / AddAction to objects
« Reply #5 on: 22 Feb 2004, 01:12:16 »
Hey Icarus... been a while mate ;)

As an alternative to having a constantly looping script, you could always use a trigger to check if anyone in an array of units has the weapon...

Trigger

Radius: 0,0
Condition: none (repeatedly)
Condition Field: "_x hasweapon {bas_satcom}" count [ unit1, unit2... etc] > 0
OnActivation field: firerqst = _unit addaction ["Radio Fire Mission", "firemission.sqs"]

As it is, that would save a bit of time compared to your script. If you were to put a small delay in that loop (ie. a second or so), they'd probably use about the same time.

What sort of variable are you looking to pass to your script?
By default the addaction command passes a few (the unit the action is on, the unit that activated the action etc.)??

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:HasWeapon checks / AddAction to objects
« Reply #6 on: 22 Feb 2004, 02:25:59 »
Howdy Sefe, can't keep me a away.  I left, then came back, now just write scripts for people, occasionally come up with an idea that is sufficiently good it warrants making into a mission.  And of course I lurk around alot so I dont get told off. :P

I think I fixed my script, it took alot of trial and error but it seems to be working.  I had to come up with a work-a-round for the variable problem, but you say AddAction already parses the name of the unit?  That would be excellent to know.  What I came up with is;

;***************************************
;* Radio check script                  *
;* By [icarus_uk]                      *
;* http://furryclan.net                *
;***************************************
#start
?artyfire: goto "inprogress"
_group = _this select 0
_count = 0
#checkone
_unit = units _group select _count

?_unit hasweapon "bas_satcom" : goto "hasradio"

?_count == 9 : goto "noradio"
_count = _count + 1

goto "checkone"

#hasradio
"_X RemoveAction firerqst" foreach units playergroup

?!(alive _unit) : goto "noradio"

firerqst = _unit addaction ["Radio Fire Mission", "firemission.sqs"]
RadioUnit = _unit

#noradio
~1.5
goto "start"

#inprogress
~6
goto "start"


I found this first loop checking all the units to see who has a radio goes by so fast that its not noticable, so fast infact there isnt enough time to display a hint as the loop goes around.  I decided that this was acceptable.  After 1.5 seconds, it rechecks, and if the action is used, then it loops every 6 seconds.  It works quite well without any noticable slowing.  The only gripe I did have, is that I had to make the name of the unit into a public variable RadioUnit as I didnt know how to parse _unit to the next script.  I take it from your post that _unit is parsed automaticaly, so the question is, is it select 0, 1 , 2?

This way, the script works great,  If the unit drops the radio, someone else can pick it up and use it (call firemission.sqs).  I have eventhandlers so when the unit carrying the radio dies the radio is destroyed (as though shot to peices) otherwise when the radio unit respawns there would be dozens of working radios around the island, that would be bad :)

While Im on the subject, I noticed a very annoying "bug"/"feature" when you add a action to a unit, another other units close enough, and looking at said first unit, also get the action.  Is there away around this?  Or do I just hape to put up with it?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:HasWeapon checks / AddAction to objects
« Reply #7 on: 22 Feb 2004, 10:56:57 »
I think you just have to put up with that particular "feature" .... I started a thread about this a couple of weeks ago and nobody came up with a solution.
Plenty of reviewed ArmA missions for you to play

gundernak

  • Guest
Re:HasWeapon checks / AddAction to objects
« Reply #8 on: 22 Feb 2004, 12:25:31 »
check this:

http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=15715
 
this is the topic macguba is talking about.

here you can find the values you can pass into the script started by the action...