Author Topic: Alternate Swing Animations  (Read 863 times)

Now I know that the game automatically has a way to put a model together with the sword script and you can have your little Blocklander swing his hand up and down to get a nice generic sword motion.

How would I achieve other ranges of motions?  Like horizontal swing, or a curved swing.

My guess is that it would be a part of the models animation, but I have no clue how to script (due to my utter lack of intelligence obviously) so I ask for help on the forums.

Animation or Code related? and how to achieve?

The state system. I'm not really good with it, your best bet is to talk to Space Guy about it.

oh, thank you :)

Then, can I (with permission) ask a stupid question?

I'm new with modeling, so I want to know what the animation feature of it actually does.  I was looking into some addons that were previously made and it seems none use animations.  Or if they do, they are unexplained (For example: at the bottom of the .cs files of all the addons they have start-up states like Activate, Fire, Wait, etc... yet I don't see how these work.  Are they built into the game to know that they are meant to use the item or what)

To create new animations for the player model?
Impossible.

To fiddle with combination of already existent animations in the player model?
Possible.

As destiny said, the state system.
But if you want a horizontal swing, you might want to think about modeling a hand on your weapon, and then animate it in your dts. Like heed's midevil pack or w/e

To create new animations for the player model?
Impossible.
It's been discussed and seems like it'd be possible but I've never seen it done

An add-on could easily make their own player type with extra animations and set their datablock to it when you use weapons.

The states can be named anything and are ran in order, starting from "0" when you use the weapon.

datablock ShapeBaseImageData(swordImage)
{
   ...
   
   stateName[0]                     = "Activate";
   stateTimeoutValue[0]             = 0.5; //This state ends after half a second
   stateTransitionOnTimeout[0]      = "Ready"; //This changes to the "Ready" state
   stateSound[0]                    = swordDrawSound; //Play the "draw" sound

   stateName[1]                     = "Ready";
   stateTransitionOnTriggerDown[1]  = "PreFire"; //If the Fire key is pressed, go to "PreFire"
   stateAllowImageChange[1]         = true; //You can change tools while in this state

   stateName[2]         = "PreFire";
   stateScript[2]                  = "onPreFire"; //Call swordImage::onPreFire() (see below)
   stateAllowImageChange[2]        = false; //You can't change tools while in this state
   stateTimeoutValue[2]            = 0.1; //There is a delay of 0.1 seconds
   stateTransitionOnTimeout[2]     = "Fire"; //Switch to the "Fire" state after the time out

   stateName[3]                    = "Fire";
   stateTransitionOnTimeout[3]     = "CheckFire";
   stateTimeoutValue[3]            = 0.2;
   stateFire[3]                    = true; //Used in some scripts reading weapon images to tell if it's firing in that state
   stateAllowImageChange[3]        = false;
   stateSequence[3]                = "Fire"; //Play the model's "Fire" animation (makes it swing in first person)
   stateScript[3]                  = "onFire"; //onFire is a default function defined to make the weapon fire its projectile type
   stateWaitForTimeout[3]      = true; //Can't change to other states until the timeout is done

   stateName[4]         = "CheckFire";
   stateTransitionOnTriggerUp[4]   = "StopFire"; //If you have released the Fire key, go to "StopFire"
   stateTransitionOnTriggerDown[4]   = "Fire"; //If you are still holding the Fire key, go to "Fire" again

   stateName[5]                    = "StopFire";
   stateTransitionOnTimeout[5]     = "Ready";
   stateTimeoutValue[5]            = 0.2;
   stateAllowImageChange[5]        = false;
   stateWaitForTimeout[5]      = true;
   stateSequence[5]                = "StopFire"; //Play the model's "StopFire" animation
   stateScript[5]                  = "onStopFire"; //Call swordImage::onStopFire() (See below)

};

function swordImage::onPreFire(%this, %obj, %slot)
{
   %obj.playthread(2, armattack); //Play a looping "Swing" animation blended with others (e.g. walking, sitting)
}

function swordImage::onStopFire(%this, %obj, %slot)
{   
   %obj.playthread(2, root); //Stop the animation in that slot
}

^
This should be stickied.

It's been discussed and seems like it'd be possible but I've never seen it done

That's because it's rather difficult and quite hacky.

I have done it, but never achieved anything that could be put to any use.

^
This should be stickied.

But isn't that an example from any melee weapon .cs file?  He's just (very helpfully I might add) explained it nicely.

I guess the real question which is rather hard to comprehend having just started on learning this stuff is how to use the .dts files animation.  I'm slowly figuring it out, thank you for the information!

(and also, a Player Type seems the way to go for any complicated mechanics eh?  I'll look into that)

But isn't that an example from any melee weapon .cs file?  He's just (very helpfully I might add) explained it nicely.
The idea is that if you can read that and understand it then looking at any other weapon's structure will be very similar. The only extra things I can think of are adding particle emitters (looking at the Rocket Launcher) or weapons with special "ammo" states which are triggered in script by Player.setImageAmmo(slot,on/off) for "stateTransitionOnAmmo" and "stateTransitionOnNoAmmo".