Home   Help Search Login Register  

Author Topic: DETECTING activated Actions  (Read 573 times)

0 Members and 1 Guest are viewing this topic.

Offline ryankaplan

  • Members
  • *
  • yeah...
DETECTING activated Actions
« on: 07 Sep 2004, 17:24:36 »
ok, i have a simple timebomb script, which makes a guy put a timebomb via the action menu (he plays a bend over move and creates a timebomb on his feet)

BUT there was one thing i didn't know how to do:

Detecting when the action is activated, so i can remove the action for 30 seconds and add it again so the guy and have a little countdown.

So how do i detect the action activation?

thanks alot to anyone who hepls.

and also, i anly want to activate this action 5 times, so af6ter 5 timebombs,there is none left. Is there a way to find out how many times the action has been activated? or shall i just copy and paste the script 5 times rather than putting it in a loop?


« Last Edit: 07 Sep 2004, 17:49:52 by ryankaplan »

Offline C0LDSt33L

  • Members
  • *
  • Member of the SotM Team
Re:DETECTING activated Actions
« Reply #1 on: 07 Sep 2004, 18:16:17 »
If I were you my action script would be something like:

?(bombs>0) goto "BombLay"

BlackOp RemoveAction 0

exit

#BombLay

Make the timebomb
BlackOp PlayMove "Whatever"
bombs = bombs - 1
BlackOp RemoveAction 0
~30
BlackOp addAction ["Set Charges to Blow", "PlaceCharge.sqs"]

exit

And have bombs = 5 in the initialisation field. If it works you need not have to detect the action. I'd still be interested in how to detect actions if anybody knew.
« Last Edit: 07 Sep 2004, 18:21:53 by C0LDSt33L »

Offline ryankaplan

  • Members
  • *
  • yeah...
Re:DETECTING activated Actions
« Reply #2 on: 07 Sep 2004, 18:36:17 »
k thanx alot, this will make my script work fine but does anybody know how to detect activated actions?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:DETECTING activated Actions
« Reply #3 on: 07 Sep 2004, 19:18:12 »
 ???

If the script starts the action must have been activated.   Don't understand what you're asking.
Plenty of reviewed ArmA missions for you to play

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:DETECTING activated Actions
« Reply #4 on: 07 Sep 2004, 21:57:25 »
k thanx alot, this will make my script work fine but does anybody know how to detect activated actions?

Like macguba said, when the action is activated, the script will be run. You can then change a global variable in the script ("actionUsed=true" or whatever you want) if you really need to let other scripts know the action was used.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline ryankaplan

  • Members
  • *
  • yeah...
Re:DETECTING activated Actions
« Reply #5 on: 07 Sep 2004, 22:59:09 »
OK what i'm trying to do is a script where you have 5 timebombs (out of your inventory). the action at the start is "Put Timebomb (5 left)"

and when the guy puts a timebomb, it changes to "put timebomb (4 left)" and so on. but i don't seem to be able to do it, because to do that i need to addaction and remove action. i use 5 diffrent scripts fo reach one.

each of these is a action sqs.

i'll copy and paste them for you.
INIT field of Unit: guy addaction ["put timebomb (5 left)", "timebomb.sqs"]

TIMEBOMB.SQS
explo1 = "timebomb" camcreate [getpos guy select 0, getpos guy select 1, 0.1];
guy playmove "CrouchToBinocCrouch";
guy removeaction 0;
hint "Timebomb Set, 20 seconds until explosion"
~10
hint "10 seconds until explosion"
~5
hint "5 seconds until explosion"
~2
hint "3 seconds until explosion"
~1
hint "2 seconds until explosion"
~1
hint "1 seconds until explosion"
~1
hint "timebomb exploded"
guy addaction ["put timebomb (4 left)", "timebomb2.sqs"]

TIMEBOMB2.SQS
explo1 = "timebomb" camcreate [getpos guy select 0, getpos guy select 1, 0.1];
guy playmove "CrouchToBinocCrouch";
guy removeaction 0
hint "Timebomb Set, 20 seconds until explosion"
~10
hint "10 seconds until explosion"
~5
hint "5 seconds until explosion"
~2
hint "3 seconds until explosion"
~1
hint "2 seconds until explosion"
~1
hint "1 seconds until explosion"
~1
hint "timebomb exploded"
guy addaction ["put timebomb (3 left)", "timebomb3.sqs"]

exit

AND it goes on until;

TIMEBOMB5.SQS
explo1 = "timebomb" camcreate [getpos guy select 0, getpos guy select 1, 0.1];
guy playmove "CrouchToBinocCrouch";
guy removeaction 0
hint "Timebomb Set, 20 seconds until explosion"
~10
hint "10 seconds until explosion"
~5
hint "5 seconds until explosion"
~2
hint "3 seconds until explosion"
~1
hint "2 seconds until explosion"
~1
hint "1 seconds until explosion"
~1
hint "timebomb exploded"

exit.

THE first removeaction works in the first script, because the first addaction was made in the editor, but the rest doesn't work because the other addactions were made in diffrent external scripts. what they are trying to delete is in the script one before them.

NOW, it is 11pm, and i'm sleepy so excuse me of it sounds like some sort of alien language. And yes i am a noob scripter if the script seems very stupid to you, but i do know most of the commands and am quite skilled in the editor but i understand that if you cannot do external scripts then you are missing most of the things you can do.

Basicly, i am trying to get a "Put Satchel Charges (3 left)" with timebombs you don't have in your inventory.

Any help will be greatl;y appreciated.
« Last Edit: 07 Sep 2004, 23:06:23 by ryankaplan »

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:DETECTING activated Actions
« Reply #6 on: 07 Sep 2004, 23:44:39 »
Ok, first off, some basics about addaction. Scripts run from the action will have these three parameters:

_this select 0 = unit/object the action was added to
_this select 1 = unit that activated the action
_this select 2 = index of the action

Even though it is always going to be the player that uses this action, you should get into the habit of making your scripts sorta universal, so they could be used by people other than "guy", if you later wanted to. So it should look more like this:

_man = _this select 1
? _man != _this select 0 : exit
 .......
_man playmove "CrouchToBinocCrouch"
.......

The part in bold will make sure nobody can use the action except the unit the action was added to (try adding an action to an AI unit and you will see that anyone close can use actions that are added).

The last parameter passed to the script (_this select 2) is what you should use with the 'removeaction' command. So instead of "guy removeaction 0", you should put "guy removeaction (_this select 2)".

---------------------------------------------------------------------------

You should be able to understand the stuff I just said above, and it will help you tons in the future. Now time for the more advanced stuff that will help you with this specific script. You could just use  what I told you above, and make 5 different scripts, like you are doing. It will work, but if you want to be more fancy about it, you can do it like this:

INIT.SQS OR THE INIT FIELD OF THE GUY
bombs_left = 5; guy addaction addaction [format ["put timebomb (%1 left)", bombs_left], "timebomb.sqs"]

TIMEBOMB.SQS
Code: [Select]
_man = _this select 1
? _man != _this select 0 : exit
_man removeaction (_this select 2)

"timebomb" camcreate [getpos _man select 0, getpos _man select 1, 0.1]
bombs_left = bombs_left - 1
_man playmove "CrouchToBinocCrouch"
hint "Timebomb Set, 20 seconds until explosion"
~10
hint "10 seconds until explosion"
~5
hint "5 seconds until explosion"
~2
hint "3 seconds until explosion"
~1
hint "2 seconds until explosion"
~1
hint "1 seconds until explosion"
~1
hint "timebomb exploded"
? bombs_left > 0 : _man addaction [format ["put timebomb (%1 left)", bombs_left], "timebomb.sqs"]
exit

  Now, I've incorporated the basic stuff I covered into the top of the script. But the trick is at the bottom of the script. bombs_left is a global variable. In case you don't know, that means all scripts can see and use it; just like all scripts can see the name of a unit. You can tell because it doesn't have an underscore _ in front of it. You'll see that at the top of the script, this variable is lowered each time the script is run. At the bottom, a new action is only added if this variable is above 0. Now for the tricky part, this line:

_man addaction [ format ["put timebomb (%1 left)", bombs_left], "timebomb.sqs"]

  You'll notice that the same script is used each time the action is added again. And you now see why it will only add the action back a limited number of times. But to let the player know how many bombs he has left, the description of the action is changed each time by the script (the part in bold). Click here for info on the format command, and you will understand why this works.
 
« Last Edit: 07 Sep 2004, 23:46:26 by General Barron »
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline ryankaplan

  • Members
  • *
  • yeah...
Re:DETECTING activated Actions
« Reply #7 on: 08 Sep 2004, 16:55:43 »
thanks very much general barron, ofpec community would really be missing something without you. :)