Author Topic: Questions for 3 different functions...  (Read 1726 times)

I didn't want to make 3 different topics for each question so I hope it's OK to bundle them into one like this 乁(ツ)ㄏ

Question 1: I'd like to make a melee weapon with multiple "swing" animations that work like a combo, since having just one hit/swing animation is a bit boring. For example, having three animations (clicking attack button in 3 rapid-succession clicks): swing left, swing right, swing up, then back to the root stance of holding the weapon or continuing with the combo starting at swing left until you stop attacking. If you click once, it will play swing left but then go back to the root stance. If you click twice, it will play swing left and swing right then go back to the root stance. Each click will result in an attack/hit. I'm sure this can be done but I don't know how I would go about this.

Question 2:
This is a much simpler task (pretty sure), I just don't know the code for it. Essentially, I'd like to make a timer for a light. Example: Player clicks left-click, light comes on and/or model changes and a timer starts for say 1 minute, after timer expires the light goes off and the model back to the "off" state and not be able to turn back on (they'd have to pick up another item).    P.S. I'd also like the timer to carry over if the player switches weapons/closes the inventory, and for the light to stay on when they go back but if the timer expires and they go back, the light should be off; however I don't know if this is possible, worth a shot.

Question 3:
I'm also sure this is a relatively simple one but, alas, I know not of how to do. I am wondering how to play random animations and/or sounds, when the player clicks left-click. Or, for example, if a projectile hits the ground, how would I play a random sound from one of the 4 that I have loaded?

Any and all help is much appreciated. I might be able to figure this out (after a long time) with the help of bldocs or whatever but it's not working at all for me.

1 and 3 can only be controlled through states. you can create as many animations as you want and then access them via statesequence[n], so you can essentially chain different animations to different states. however, you can't randomize animations

Question 2:[/b] This is a much simpler task (pretty sure), I just don't know the code for it. Essentially, I'd like to make a timer for a light. Example: Player clicks left-click, light comes on and/or model changes and a timer starts for say 1 minute, after timer expires the light goes off and the model back to the "off" state and not be able to turn back on (they'd have to pick up another item).    P.S. I'd also like the timer to carry over if the player switches weapons/closes the inventory, and for the light to stay on when they go back but if the timer expires and they go back, the light should be off; however I don't know if this is possible, worth a shot.
this is possible as an item or as part of the player
I do remember a few addons (flashlights/lanterns or something) doing something similar to what you're describing, just without the timer
it shouldn't be too difficult to add a timer

1 and 3 can only be controlled through states. you can create as many animations as you want and then access them via statesequence[n], so you can essentially chain different animations to different states. however, you can't randomize animations

Good to know, thanks. Do you by any chance know how to animate with empties? I'm (always) having issues with animating but I simply cannot get it to work with empties. I'm using Portify's new dts exporter so that's why.

it shouldn't be too difficult to add a timer

Don't happen to know how do ya? ;)

Don't happen to know how do ya? ;)
function <itemdataorwhatever>::turnOn(%this)
{
   %this.schedule(<delay>, 0, turnOff);
   //also turn on the light
}

function <itemdataorwhatever>::turnOff(%this)
{
   //turn the light off
}

there's many other things you can do with it, like change the light over time or whatever you want

function <itemdataorwhatever>::turnOn(%this)
{
   %this.schedule(<delay>, 0, turnOff);
   //also turn on the light
}

function <itemdataorwhatever>::turnOff(%this)
{
   //turn the light off
}

there's many other things you can do with it, like change the light over time or whatever you want

Awesome! Thanks. Does this only apply to fxLight's then?

you can put whatever code to turn on/off the light in those functions
so it can change the player light, lights on objects, models mounted to the player

you can put whatever code to turn on/off the light in those functions
so it can change the player light, lights on objects, models mounted to the player

Oh nice. I still have lots to learn lol. While it's on my mind, you wouldn't know how exactly to move/mount an fxLight to, say, the top of the players head? (Or anywhere doesn't matter)

function <itemdataorwhatever>::turnOn(%this)
{
   %this.schedule(<delay>, 0, turnOff);
   //also turn on the light
}

function <itemdataorwhatever>::turnOff(%this)
{
   //turn the light off
}

How do you use this^  with this: serverPlay3D(aSound,%pl.getPosition()); ? I've spent over an hour just trying to get this to work and it doesn't play no matter what variables I change or add or take out or what. I have it working on this:
Code: [Select]
function ImageOn::onFire(%this, %obj, %slot, %pl)
{
%obj.playthread(2, spearThrow);
Parent::onFire(%this, %obj, %slot);
%obj.unMountImage(0);
%obj.mountImage(ImageOff, 0);
serverPlay3D(aSound,%pl.getPosition());
}

There's pretty much no difference I can see (how I have it set up) how it wouldn't work. Grr. I can't figure out a way to play a delayed sound with the above method. Or any other method I found -.-

The engine only passes 3 arguments, making pl blank. Use %obj.