OFPEC Forum

Addons & Mods Depot => OFP - Addons & Mods General => Topic started by: Ding on 14 Jul 2005, 16:42:59

Title: I guess this belongs here, Animation.
Post by: Ding on 14 Jul 2005, 16:42:59
I have animated a Lever in o2 and have given it hte animation to move forwards and backwards, when they are used through the action menu, what i want to do though is i want a script to be activated when the lever is pressed, how do i do this?     :D
Title: Re:I guess this belongs here, Animation.
Post by: remcen on 14 Jul 2005, 21:15:23
no problemo actually. the clue is the init eventhandler and the animationphase query.

insert into the cfgvehicles section of the config of your object/car/whatever

class eventhandlers
{
Init="[_this select 0] exec ""\pboname\init_object.sqs"";";
};


your init_object.sqs:

#start
@ (_this select 0) animationphase "lever" == 1

insert script code here, loop maybe

@ (_this select 0) animationphase "lever" == 0
goto "start"


NB. this will not work for any stuff that you place on an island in an island editor. the class eventhandlers only work for vehicles/objects/etc which are placed in the mission editor.
hope that helps ;)
Title: Re:I guess this belongs here, Animation.
Post by: Planck on 14 Jul 2005, 22:25:16
Quote
class eventhandlers only work for vehicles/objects/etc which are placed in the mission editor.

Actually the "init" eventhandler can be used on .wrp placed objects.......static objects like buildings and such anyway.

I think the model has to be in ODOL format though.....i.e. Binarized.


Planck
Title: Re:I guess this belongs here, Animation.
Post by: Ding on 15 Jul 2005, 11:00:34
what i realy wanted is a Global variable which says that when the lever is pressed a gate opens, i have an opening script for the gate, i just dont know how to get it to be activated by pressing the lever
Title: Re:I guess this belongs here, Animation.
Post by: UNN on 22 Jul 2005, 08:59:05
Quote
Actually the "init" eventhandler can be used on .wrp placed objects.......static objects like buildings and such anyway.

I think the model has to be in ODOL format though.....i.e. Binarized.

Do you know of any released addons, that implement this?

Quote
what i realy wanted is a Global variable which says that when the lever is pressed a gate opens, i have an opening script for the gate, i just dont know how to get it to be activated by pressing the lever

Use class Useractions, I guess you have one already setup to animate the lever? Just use the AnimationPhase command remcen posted, to decied if the gate should open or close.

Code: [Select]
class UserActions
   {
   class PullLeverDown
      {  
           displayName="Pull Lever Down";
           position="zbran";
           radius=0.5;
           condition="This animationphase "lever"==1";
           statement="[Object <Map Object ID>,True] Exec ""OperateGate.sqs""";
            };

   class PushLeverUp
      {  
           displayName="Puch Lever Up";
           position="zbran";
           radius=0.5;
           condition="This animationphase "lever"==0";
           statement="[Object <Map Object ID>,False] Exec ""OperateGate.sqs""";
            };
   };

The Object (http://www.ofpec.com/editors/comref.php?letter=O#object) command needs the ID you get in the mission editor, thats assigned to the gate object, you want to operate.
Title: Re:I guess this belongs here, Animation.
Post by: Planck on 22 Jul 2005, 20:46:28
Quote
Do you know of any released addons, that implement this?

Yes......for example try looking at the config for AGS_inds.pbo from Agent Smith.

Basically it looks similar to:

class EventHandlers
    {
        init = "(_this select 0) exec {\pboname\scriptname}";
    };


Planck
Title: Re:I guess this belongs here, Animation.
Post by: UNN on 22 Jul 2005, 23:20:57
Quote
Yes......for example try looking at the config for AGS_inds.pbo from Agent Smith.

I don't think they work from .wrp placed objects though :( They will launch there config init from the Mission editor, but not straight from loading an island. I hope this is added for Armed Assault.

Cheers
Title: Re:I guess this belongs here, Animation.
Post by: Planck on 23 Jul 2005, 00:17:57
Hmmm......I think you may be right there.

He actually uses effects scripts that need to be manually started.

Ah well, as you say, maybe in AA.

 ::) ::)


Planck