Home   Help Search Login Register  

Author Topic: Vehicle animations  (Read 1267 times)

0 Members and 2 Guests are viewing this topic.

DeLiltMon

  • Guest
Vehicle animations
« on: 30 Jul 2003, 14:43:14 »
Could someone tell me if it's possible to turn a script on and off using the action menu?
I want to create a reciprocating animation (vehicle windscreen wipers being a good example), I know how to set up a script so that, using the example, the wipers will sweep and return and also to do this in a loop so that when activated it will repeat a set number of times, but I was wondering if there's a way to be able to activate and start this script on demand?
Cheers
DLM

Offline KTottE

  • Former Staff
  • ****
Re:Vehicle animations
« Reply #1 on: 30 Jul 2003, 15:01:18 »
Code: [Select]
class UserActions
{
   class TEST
   {
      displayName="bla";
      position="???";
      radius=18100;
      condition="player hasWeapon ""blablabla""";
      statement="this exec ""myscript.sqs""";
   };
}

Should work, try adding that to the vehicle's config. Position can be any named section in the model, suggest you add it to the steering wheel and make the radius so small that only the driver can use the action. I think the radius is in meter format, I.E 1 = 1 meter etc.
"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!'"

DeLiltMon

  • Guest
Re:Vehicle animations
« Reply #2 on: 30 Jul 2003, 22:12:00 »
Thanks KT but it's not quite what I was after, what I was wondering is if there is a way to stop a script from running using a user action.
Using the windscreen wiper example, I'd have the script which will animate the wipers so they sweep and return and will execute this loop continously, so the player starts the wipers with a "Wiper On" action which starts the script which will keep the wipers going for ever unless the user selects the "Wipers Off" action which will then stop the script.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Vehicle animations
« Reply #3 on: 30 Jul 2003, 22:14:24 »
welll from my scripting knowledge couldn't the wipers off be a seperate script which when activated sends a global variable to true and tgis variable is a condition the wipers script searches for in the loop and when it is true the script ends...

well, that works for normal scripts... not sure about ones inside an addon.
Proud Member of the Volunteer Commando Battalion

DeLiltMon

  • Guest
Re:Vehicle animations
« Reply #4 on: 30 Jul 2003, 22:43:38 »
Pass, what I know about scripting I could probably fit inside my avatar.
I got the idea when I a forklift went past the window with a flashing light on.
It reminded me of Klink's tutorial on adding beacon lights to planes and helis and I thought if the script could be started and stopped on demand then there was the possibility of creating all kinds of repetitive anims, rotating lights such as those on top of a police car, fire engine, works van, etc and windscreen wipers are what I've thought of so far.

Offline KTottE

  • Former Staff
  • ****
Re:Vehicle animations
« Reply #5 on: 30 Jul 2003, 23:06:33 »
Hm, do it like messiah says.
Should work.
"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!'"

Offline Colonel_Klink

  • Members
  • *
  • Independent Addon Creator
    • DC3D Game Modelling Zone
Re:Vehicle animations
« Reply #6 on: 04 Aug 2003, 02:43:18 »
I've implemented wiper animations in the next version of the Lincolns: (change the animations, classes to suit). Its probably messy but you'll get the idea. The wiper useractions are only on while the engine is running.

wiperson.sqs
Code: [Select]
_car = _this select 0

_player = player

?(_player in _car):goto "start"



#start

_car removeaction WipersTurnedOff
_car removeaction WipersAreOn
; reset the wipers when engine is off

_car animate ["AniWipersL",0]
_car animate ["AniWipersR",0]

wiperson=false;


#AI
~0.001
?(_player in _car):goto "stateloop"
?(not alive _car):goto "end"
goto "AI"



#stateLoop
_direction1 =  getpos _car select 2
?(isengineon _car and _player in _car) : goto "wipersAreOff"
~0.001
?(not alive _car):goto "end"
goto "stateLoop"







#wipersAreOff

WipersAreOn = _car addAction ["Turn Wipers On","\cwkLdip\wipers.sqs"];

#waitForWipers
direction1 =  getpos _car select 2
~0.001
?!(isengineon _car): goto "Start"
?!(_player in _car): goto "Start"
;?(speed _car <20):goto "Start"
?(not alive _car):goto "end"
?!(wiperson):goto "waitForWipers";

WipersTurnedOff = _car addAction ["Turn Wipers Off","\cwkLdip\wipers.sqs"];

_car removeaction WipersAreOn

#Loop
?!(isengineon _car): goto "Start"
?!(_player in _car): goto "Start"
_car say "DIPLincolnWiper1"

_car animate ["AniWipersL",1]
_car animate ["AniWipersR",1]


~1
_car say "DIPLincolnWiper2"
_car animate ["AniWipersL",0]
_car animate ["AniWipersR",0]
?!(wiperson):goto "reset"
~1
goto "loop"



#reset
_car say "DIPLincolnWiper2"
_car animate ["AniWipersL",0]
_car animate ["AniWipersR",0]
_car removeaction WipersTurnedOff
goto "wipersAreOff"
#End
EXIT

Wipers.sqs
Code: [Select]
?(wiperson):wiperson=false;exit;
?!(wiperson):wiperson=true;exit;

Animations in config.cpp
Code: [Select]
         
class AniWipersL
{
animperiod = 1;
type = "rotation";
axis = "osa_LeftWiper";
selection = "LeftWiper"
angle0=0;
angle1=-1.623150;
};
class AniWipersR
{
animperiod = 1;
type = "rotation";
axis = "osa_RightWiper";
selection = "RightWiper"
angle0=0;
angle1=-1.623150;
};

All.sqs run from the init eventhandler
Code: [Select]
_car = _this select 0

wiperson = false

[_car] exec "\cwkLDIP\wiperson.sqs"


In the eventhandler all the all.sqs
Code: [Select]
init = [_this select 0] exec "\CWKLDIP\all.sqs";
« Last Edit: 04 Aug 2003, 02:45:16 by Colonel_Klink »
Rebel without a pause...D.I.L.L.I.G.A.F.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Vehicle animations
« Reply #7 on: 04 Aug 2003, 02:57:05 »
 :o

cheers klinkers - from the PUKF team :thumbsup:
Proud Member of the Volunteer Commando Battalion

DeLiltMon

  • Guest
Re:Vehicle animations
« Reply #8 on: 04 Aug 2003, 10:46:21 »
Yeah thanks Klink, should make perfect sense one I get the chance to look into it in detail (roll on 4 o'clock when I can go home)
:cheers:
« Last Edit: 04 Aug 2003, 10:48:06 by DeLiltMon »