Home   Help Search Login Register  

Author Topic: Limit Actions to unit assigned  (Read 2579 times)

0 Members and 1 Guest are viewing this topic.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Limit Actions to unit assigned
« on: 04 Jun 2007, 20:49:28 »
Is there a way to restrict Actions assigned to a unit to appear only in ONE particular unit's Action list?

I took the First Aid script that Shark Attack uses (original author unknown), and modified it so that it is available to all members of the player's squad.  When a unit has dammage > .2, the "First Aid" action is added to the unit.  This way, the player can heal himself, and also order (via Action menu) his squad mates to heal themselves.

My problem is, that when Unit A is hit, his First Aid action appears not only in his Action menu, but in all the squad units action menus.  When three units are hit, I will see 3 "First Aid" actions in all the units' action menus.

If I run the "First Aid" script assigned to Unit A, he heals himself (which is what I want).  If I pick the wrong "First Aid" action, he will run to another injured unit's position, then that other injured unit heals himself (and Unit A is still not healed).  This is bad because, I can't tell which first aid script belongs to which unit, and I don't want units abandoning their positions when I pick the wrong one.

I know I can change the displayed Action text to be unit specific "First Aid unit 1", "First Aid unit 2", etc.  But then its up to the player to be sure that when unit 2 is injured, he orders Unit 2 to run the correct First Aid action ("First Aid unit 2").  I would rather not confuse the player with this choice.

Another workaround would be for me to add code to First Aid script that says:  If Action belongs to a unit other than unit executing the action, then unit says "I'm busy boss, Two will have to bandage himself."

So back to my question: Is there a way to restrict Actions assigned to a unit to appear only in ONE particular unit's Action list?

« Last Edit: 04 Jun 2007, 21:59:34 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Limit Actions to unit assigned
« Reply #1 on: 04 Jun 2007, 21:31:35 »
Quote
Can an admin please move it there???
Here you go :)
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Limit Actions to unit assigned
« Reply #2 on: 04 Jun 2007, 21:33:04 »
Is that there are many action lists per unit??  :blink:

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Limit Actions to unit assigned
« Reply #3 on: 04 Jun 2007, 21:54:53 »
@h: thx for the move, m8.

@Mando:

If only one unit is hit, one First Aid action will appear in that unit's action list.  But this new First Aid action will also appear in all other units action list.

If you order the injured unit to execute the First Aid action, he heals himself, and the Action disappears from everyone's list. 

Alternatively, if you order the First Aid action on a unit other than the injured unit, the ordered unit will run to the injured unit, then the injured unit heals himself, and the Action disappears from all units' action list.  But I don't want the non-injured unit to have this Action available.  I want only the injured unit to have the Action

Its more complicated (i.e., more confusing for player) if 2 or more units are hit.  A First Aid action then appears for each unit that is hit, in all units' action lists.  So if there are six units (named unit1, unit2, ... unit6), and unit1 and unit2 are both injured, ALL units will see TWO First Aid actions (one for unit1, and one for unit2). 

If I order a non-injured unit (Unit3) to perform one of these two First Aid actions, he runs to the injured unit and stands there, and the injured unit heals himself.  Note that Unit3 running to the injured unit is NOT part of the First Aid script, it is engine code that when a player orders a unit to perform an action, the unit first moves to the object that Action is assigned to.  Similar to "Get In" order: unit first runs to the vehicle.

Sorry for so many words...hope I explained this coherently.
« Last Edit: 04 Jun 2007, 22:02:16 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Limit Actions to unit assigned
« Reply #4 on: 04 Jun 2007, 22:08:38 »
No idea what you are using to add or remove these actions, but certainly it is buggy.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Limit Actions to unit assigned
« Reply #5 on: 04 Jun 2007, 23:19:47 »
Quote
No idea what you are using to add or remove these actions, but certainly it is buggy.

Your reply made me double check the add and remove.  I was using only one global variable for all First Aid actions added, so the removeAction command only removed the last Action added, not the correct action.  I fixed this problem, so we no longer get more than one First Aid action in any unit's action menu.  Thanks Mando.

But the Engine still has a limitation.  When you add an action to an object (any object, including soldiers), that action will be listed in the Player's action list (if he is close enough to the object), and will ALSO be listed in ALL commanded unit's action lists. 

It appears there is no way to limit an action to only appear in the action list of the unit the action is attached to.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Limit Actions to unit assigned
« Reply #6 on: 05 Jun 2007, 00:02:39 »
Well, the purpose of adding actions to objects, vehicles or AI units is just that player can use them. If you want an AI unit to perform the script attached to its action, just execute it, you dont need to add these actions to AI units.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Limit Actions to unit assigned
« Reply #7 on: 05 Jun 2007, 04:52:17 »
I understand what you are saying, but if I add an action to the player only, it also appears on the other units' action list.  If the player commands another unit to perform the listed action, that other unit will move to the player, and then the player's action is executed.

Maybe this is a new "feaure" in ARMA, that has to do with Switchable/playable units.  In my case, I have been dealing with all switchable units in my squad.  I will now check and see if the Player Action appears in the action list for non-switchable units in the player's group.

Edit:  Non-Playable units also shows the player's actions in their action list.

If anyone is interested, I will build a stripped down sample mission to illustrate the point.  This is an annoyance that everyone who Adds actions to player, and also has the player command a squad, will face.

Allthough in many cases, you would like it work this way I guess.  Like an Action "Open Bargate" assigned to a Bargate.  You could open it yourself when near, or order an AI to go Open it.

I may change my mission to use radio commands instead of actions because of this...
« Last Edit: 05 Jun 2007, 04:59:40 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline CrashDome

  • Members
  • *
Re: Limit Actions to unit assigned
« Reply #8 on: 08 Jun 2007, 19:51:32 »
johnnyboy,

I know exactly what you are trying to accomplish. Unfortunately, you can only add actions like that via a modified config. WGL did great work doing this sort of thing and if you are good config writer, you can make the actions in a seperate PBO and let inheritance distribute the actions to all the units.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Limit Actions to unit assigned
« Reply #9 on: 08 Jun 2007, 20:29:11 »
Thanks for the alternative crash.  For my particular case though, its not worth that effort.

For now, I'm copping out and using radio actions instead.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Limit Actions to unit assigned
« Reply #10 on: 08 Jun 2007, 22:07:56 »
Johnny, despite what's being said in here, you DO NOT need any modified files to make an action available to only one person.  As an additional condition for the addAction command, add:

Code: [Select]
x == player
where "x" is the name of the unit for whom you want the action to be available.  If this is a single player mission where you intend to have the player switch between different people, then you will also need to remove the action for the player's previous avatar each time he switches.  If you would like help with this, feel free to contact me. 
« Last Edit: 08 Jun 2007, 22:11:46 by DucusSumus »

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Limit Actions to unit assigned
« Reply #11 on: 09 Jun 2007, 04:56:32 »
Ducus, where would you put that condition?  My understanding is you add an action to a unit (or object)--which may be player.  But once the action is added (regardless of who or what the action was added to), the action will appear in all units' action lists.

I could put such a condition at the top of the script that is called by the action, so only the player would actually execute the main contents of the script.   But this would not solve 2 other problems:

1)  The action would still show in all units action lists (confusing, when you only want the action attached to a particular unit).
2)  If a non-player unit is ordered to execute the action, he will move to the location of the unit (or object) to whom the action was added (an undesirable behaviour from my point of view).

Any further light you can shed on this is appreciated.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Limit Actions to unit assigned
« Reply #12 on: 09 Jun 2007, 10:19:48 »
The condition would have to go where the action is added.  So if your current condition is something like "damage this < .2," then you would need to change it to "damage this < .2 && this == player."  Now instead of adding the action for everyone, it will only add the action for you.  In other words, this action will only be added for another unit if you switch into that unit.  But this will only work for teamswitching/MP (and for teamswitching, you will also need to remove the old action each time you change characters). 

Giving exclusive actions to the AI is going to be a lot more difficult, since there is no player value for you to use; in fact, it's probably impossible.  You may be able to systematically remove actions that are not attached to the AI in question, but if I were you, I would just have the AI automatically carry out whatever script your "First Aid" action executes whenever their damage level drops below .2.  I don't see the purpose in giving any actions to the AI, to be honest.