Home   Help Search Login Register  

Author Topic: Scripted actions....  (Read 5952 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:addaction and parameters
« Reply #15 on: 30 Sep 2003, 14:57:36 »
Kyle, i think it's time now that you first explain "exactly"
what you want to do.

There are a lot of suggestions in this thread, which should
(could) have been help for you, but then again it looks
like you want to do something really different to what
everybody else is thinking here.

The suggestion by unnamed (using global arrays in combination
with subarrays), looks very good in case if i understand
your problem right (not sure about that though  ;D).

Also as unnamed said: _currGuy = this select 1
he's refering to the "caller" of the action, what i mentioned
above too.

I'll give you a summary now of what unnamed tried to tell ya:

step 1: initialize an array in init.sqs - AmmoList = []

step 2: put everything you want into this array, using it's
init field: AmmoList = AmmoList + [[this,"M16"]]

Now you have created even an array with it's subarray.

e.g: [[guy1,"m16"],[guy2,"G36"],[guy3,"ak74"]]

Now this array can be accessed that way:

AmmoList stands for the whole array with it's subarray
AmmoList select 0 stands for: [guy1,"m16"]
and so on.

step3 - _param1 addaction ["ReArm","variable.sqs"]

Will start the script: variable.sqs

step4 - do whatever you want by using the if statement

In case of unnamed's suggestion there's one little error,
as AmmoList select 0 is not only the unit he wants to refer to,
rather than a whole array itself [guy1,"m16"]

{If ((_x Select 0)==_CurrGuy) Then {_CurrGuy AddMagazine (_x Select 1}} ForEach AmmoList

One way around here would be to create two seperate
arrays, and another way around could be to divide the
array AmmoList temporarly into two seperate ones, once
rearm.sqs gets started.

I have to go to work now, so i can't get more into detail
at the mo, but i'll be back later to see if i can help ya further
(or just to see that you've clicked the solve button   :D)

I know it may look quite complicated now, but as i said;
post a more detailed explanation about what you wanna
do, and maybe there's an easier way at all, depending on
your prob.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #16 on: 30 Sep 2003, 21:08:05 »
If you must know. Im making an ejection seat script and the parameters are [vehicle,"classnameofseat","classnameofcanopy"]. I have one script that when executed ejects the pilot, called ejection.sqs. I have another script witch adds the action "Eject" to the plane and locks it (so there is only one Eject action) when the engine is on and removes the action when its off. The parameters are the same. So in the addaction script i have:

Code: [Select]
_obj = _this select 0
_seatt = _this select 1
_canopy = _this select 2

#ObjDead
?!(alive _obj) : goto "exit"
goto "ObjDead"

#EngOff
_obj removeaction _ejectaction
?isengineon _obj : goto "action"
goto "EngOff"

#EngOn
?!(isengineon _obj) : goto "EngOff"
goto "EngOn"

#action
_ejectaction = _obj addaction ["Eject","HELP!"]
goto "EngOn"

#exit
exit

_seatt and _canopyt are the second and third parameters for ejection.sqs. _obj is the first. I wonder if _this would work in the addaction activated script to determine _obj.
It must work sepretly on each plane that is using the script. Using the global variable thing does the oppisite. When someone ejects all the other planes using the script eject as well.
« Last Edit: 30 Sep 2003, 21:10:41 by KyleSarnik »

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:addaction and parameters
« Reply #17 on: 30 Sep 2003, 23:31:30 »
Quote
I wonder if _this would work in the addaction activated script to determine _obj.

Kyle, that's one thing i already tried to tell ya all the while - _this in the action-launched script returns
these 3 params automatically:

_this select 0 - owner of the action - this means the unit/object,
owning the action - in your case the plane.

_this select 1 - caller of the action - the guy who touched
of the action (may it be in multiplayer, or may you have ordered
one of your ai guys to do it), else it's the player.

_this select 2 - action-id = the id-number, the action has
:note - you will notice that the action-id is counting upwards
everytime you add an action.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #18 on: 30 Sep 2003, 23:37:42 »
Hmmm..... so what is it like:

Code: [Select]
[_this select 0,_seatt,_canopyt] exec "ejection.sqs"
ok but then how do I get _seatt and _canopyt? Ill try that tho and see if I can figure it out.

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #19 on: 30 Sep 2003, 23:50:25 »
Ok is there any way to make the addaction activate something in the same script, like ["Eject","eject"] then have #eject? Probably not like that but is there any way to do it?

Offline KTottE

  • Former Staff
  • ****
Re:addaction and parameters
« Reply #20 on: 01 Oct 2003, 09:35:51 »
Code: [Select]
_ejectaction = _obj addaction ["Eject","HELP!"]

^ that does absolutely nothing.
The correct syntax is:

addAction ["Eject","scriptname.sqs"]

I suggest doing something tricky :)

Now, the canopy and the ejection seat should have the same classname for all the planes, shouldn't they?
I mean, there are no official addons with openable canopies or ejection seats.
Anyhow, I don't see anywhere in your script that you use _seatt or _canopyt, so why do you need to pass those variables to the script?
Also,  your script with all the goto's won't work. I mean, it will get stuck on the first check to see if it's alive; if it's alive it will loop again until it's dead, and then it will exit the script.
Now, with the eject action you call a script that then calls another script.
Something like so:

ejectInit.sqs
Code: [Select]
;
; Catch the params that are automatically sent to a script called by an action.
; _object = What the action is attached to (the plane)
; _man = whomever calls the action
; _index = index of the action (first added action is 0, second is 1 etc.)
;

_object = _this select 0
_man = _this select 1
_index = _this select 2

; First to make sure that only people inside the current plane can use the action:
?!(_man in _object): exit

; Checks the damage of the plane (object) and only if it's more than 70% will the player be
; able to eject. Useful to prevent stupid behaviour like borrowing a plane just to get a ride to
; somewhere (often seen in BF1942)
; If the plane is dead it exits the script

_damage = getDammage _object
?(_damage > 0.7): goto "eject"
?!(alive _object): exit
exit

; Now for the fun stuff. Here we call the script which will do the actual ejecting,
; And as it's not an added action script, we can pass parameters to it.
#eject
[_object,_man, "seatClass","canopyClass"] exec "ejectScript.sqs"
_object removeAction ejectAction
exit

ejectScript.sqs
Code: [Select]
;
; Catch the parameters passed to the script.
; _object = still the same, the plane
; _man = also the same, the guy who fired the action (pilot)
; _seat = the classname of the seat
; _canopy = the classname of the canopy
;

_object = _this select 0
_man = _this select 1
_seat = _this select 2
_canopy = _this select 3

_man action["Eject",_object]
unAssignVehicle _man

; Now, I don't know what you want to do with the classname of the seat and the canopy
; But just add in that stuff past this point and you'll be fine.


edit
Oops, forgot to add some stuff.

You should do this in the mission editor.
In the init-field of your airplane:

this addAction ["Eject!","ejectInit.sqs"]

Repeat for all aircrafts you want to use this for.
« Last Edit: 01 Oct 2003, 09:38:35 by KTottE »
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #21 on: 01 Oct 2003, 13:16:43 »
Yes KTottE I know that doesnt work, I was asking for help. And yes that script is not what the real one looks like. The real one works but I wasn't looking at it when I wrote the one here. The reason for the classnames is for ejection.sqs. My goal is to create a universal ejection seat usable on any plane. So I plan to have different seats and canopys for different planes. This part all works fine and I'm proud that I was able to do it, but this part is really tricky. Well I must go now. Ill post back later.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:addaction and parameters
« Reply #22 on: 01 Oct 2003, 13:45:39 »
Kyle, for the _seatt and _canopy you could still use
subarrays, as mentioned by unnamed and me before.

your_array = [[plane1,seat1,canopy1],[plane2,seat2,canopy2]]

Now when your action-script is launched, you can do it that
way:

_object = _this select 0

{If (_x Select 0) == _object) Then {_seatt = _x select 1; _canopy = _x select 2}} ForEach your_array

:note - i haven't really checked wether the syntax is correct,
but that way it should work.

Then you need to initialize your_array by using the init.sqs;

your_array = []

And your_array you would fill by using their planes init fields;

your_array = your_array + [this,seattype,canopytype]

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #23 on: 01 Oct 2003, 20:38:41 »
Im still confused, how does that work for more than one unit?? This problem is really starting to piss me off, so Im attaching my scripts here so you can see what they look like. Oh and I trust it you wont steal my scripts or ideas, but maybe if you see them you can understand better what I wish to acheive.

Unnamed

  • Guest
Re:addaction and parameters
« Reply #24 on: 02 Oct 2003, 00:24:28 »
I'm not sure what you are trying to do in your scripts. The following lines in ejection.sqs have me confused:

Code: [Select]
_soldpresent = crew _obj
Then you have:

Code: [Select]
_pilot moveindriver _obj
Is the plane already flying when you call the ejection.sqs script? Or did you want the above code to move him into the seat you camcreated?

A couple more questions:

Am I right in thinking you want to camcreate the seat and canopy objects when the guy decides to eject from the aircraft, rather than at the begining of the mission?

Do you have different canopies and seats for different types of aircraft?

Do you want to support more than one ejection seat per aircraft?
« Last Edit: 02 Oct 2003, 00:27:11 by Unnamed »

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #25 on: 02 Oct 2003, 02:04:30 »
Ok to explain the _soldpresent = crew _obj, that gets the crew of the plane, and next i have _pilot = _soldpresent select 0, witch gets the pilot from the crew. I have _pilot moveindriver because AI use the script and sometimes they tend to exit the vehicle before the seat ejects, so it just puts him back in when it does (sometimes, but not very often).

For the rest of the Q's:

1. Yes
2. Yes
3. Maybe in a later version

You see when he ejects the seat is creatvehicled at [0,0,0] then is setpos to the pilots position, same thing w/ he canopy.

I would like to make it as universal as possible and we all know that different planes have different seats and canopys.

Having more than one seat per plane might be difficult but I'm not worried about doing that yet.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:addaction and parameters
« Reply #26 on: 02 Oct 2003, 02:41:38 »
Nobody should steal your scripts or ideas.   I'm very sad to say it has occasionally happened in the OFP community, but it is very, very rare.    OFPEC unreservedly condemns plagiarism and it is not tolerated on this website.    

The vast majority of OFP editors are decent, honest people who who would not dream of passing off somebody else's idea or work as their own.   It is normal practice on OFPEC for folk who are having trouble with scripts, addons, missions, etc to post the whole thing and hope somebody can help them out.    There are many, many more kind and helpful editors out there than there are thieves of intellectual property.     Hundreds (thousands?) of people have posted their whole script here and the only consequence has been that their problem has been solved.   ;)

(If you ever want to use somebody else's work then then the correct thing to do is ask their permission by IM or email:  as long as you give proper credit it is almost always given.)
Plenty of reviewed ArmA missions for you to play

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #27 on: 02 Oct 2003, 20:43:04 »
I still can't get it to work, can someone please explain the arrays, it doesnt make any sense to me, and I don't think it would even work for what I'm trying to do. What I'm saying is that _seatt and _canopyt have to accept ANY classname, so it could be used with any seat or canopy. _obj, _seatt, and _canopyt must be transfered from ejectactive.sqs to ejection.sqs. It must work with ANY number of planes (if not then at least a reasonable amount) and must be activated on each plane seperatly. And I would like to do this w/ out changing ejection.sqs

KyleSarnik

  • Guest
Re:addaction and parameters
« Reply #28 on: 03 Oct 2003, 01:48:32 »
Ok this one seems to be more difficult then I expected, perhaps one of the moderators can move this thread to Editing/Scripting: Advanced...? I think it might get more replys there....

Unnamed

  • Guest
Re:addaction and parameters
« Reply #29 on: 03 Oct 2003, 14:01:56 »
If you have the following code in init.sqs:

Code: [Select]
AircraftList=[]
Then for a F16 pilot for example, you could add this to his init field:

Code: [Select]
AircraftList=AircraftList+[[_This,"F16"]]
The ejecttrue.sqs script you assigned to your action would contain:

Code: [Select]
_Aircraft = _this select 0
_Pilot = _this select 1

{If ((_x Select 0) == _Pilot) Then {_AirType=_x select 0}} ForEach AircraftList

[_Aircraft,_AirType] Exec "ejection.sqs"

Then in ejection.sqs you would have:

Code: [Select]
_obj = _this select 0
_Type = _this select 1

If (_Type=="F16") Then {_objcanopy = "canopytF16" createVehicle [0,0,0] ; _ejectseat = "seattF16" createVehicle [0,0,0]}

As your problem boils down to "what aircraft am I flying?" You could dispense with arrays all together if you used the TypeOf command in ejection.sqs, to detect the type of aircraft although it's in V1.91 only.

If your making your own addons you dont need to even worry about that, as you can embed the code for say just an F16 within the F16 addon.

I asked about when you create seats because there could be a slight delay using camcreate on a object created for the first time in a mission. This may explain why you sometimes have to force your guy back into the aircraft before ejecting him?

To All:

BTW I've noticed once a player enters a vehicle, he assumes the identity of that vehicle? To reference the actual unit you use driver,crew e.t.c Or have I got it wrong?

I know param 0 of an action referes to the object the action is attached to. But If I'm correct with the above statement, what is passed via param 1 when a player activates an action from within a vehicle, is it the player or the vehicle he is driving?

« Last Edit: 03 Oct 2003, 16:57:04 by Unnamed »