• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Fighting Animations!

Finally.
Looking up the possibility of slowing a character's run speed for Alan, I was thankfully forced to `re-examine` void SetDefaultFight(ref character) in CharCharacters.c

It lists all the fight animations of a character.
Now the awesome thing, as I just tested, is that a character will choose (for a specific action) only from the animations assigned. What this means is that finally we can have control over which attack animation our character (or an NPC!) uses.

Want to try this out?
Open your console.c file and add the following text at the bottom (above the LogIt() line). Then run a game, draw your sword, and hit F12. You will now only execute attack anim 1. Press F12 again, and you'll do #2. There are eight, and pressing F12 a ninth time will loop back to 1.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    BeginChangeCharacterActions(GetMainCharacter());

    SetDefaultNormWalk(GetMainCharacter());

    SetDefaultFight(GetMainCharacter());

    DeleteAttribute(GetMainCharacter(),"actions.attack");

    if(!CheckAttribute(pchar,"cur_attack")) pchar.cur_attack = 0;

    if(sti(pchar.cur_attack) >= 8) pchar.cur_attack = 0;

    pchar.cur_attack = sti(pchar.cur_attack) + 1;

    string tmpattr = "a" + sti(pchar.cur_attack);

    

    pchar.actions.attack.(tmpattr) = "attack_" + sti(pchar.cur_attack);

    EndChangeCharacterActions(GetMainCharacter());<!--c2--></div><!--ec2-->

Where to go from here?
Should different blade types do better with different attacks?
 
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" /> OMG!!! This is really cool, Nathan!!! WTG! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />

Have a nice cold and frosty mug of ...LEMONADE! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="icon_wink.gif" /> (only because I know you prefer it!) <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/beer2.gif" style="vertical-align:middle" emoid=":beer" border="0" alt="beer2.gif" />
 
So we can CHOOSE which move we make in fighting? That's really OMG. I don't dare go anywhere from here or I will get lost <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="icon_wink.gif" />
 
Oh, BTW:
The walking speed is controllable in the ani file:
Look at the [swim] entry for an example: speed = 1.1
You can set that for the [walk] entry also.
This controls the *animation* speed.
The speed of the actual movement over ground is set as in the existing [walk] entry:
data = "walk speed", "1.6"
 
See ani file for other animation like capture, hand up and more

But to set different keys to attack we must study how to make press comand buttion in code
How to event ChrAction, ChrBlock
Only them start animation and fight in game engine
 
Alexus, are you talking about the events in the ani files ?
Is it an event from the engine that triggers the animation or is it a certain frame in the animation that triggers an event ? (I thought the latter).
 
Cat: Eh, I just finally noticed what was in front of my face. This is my week for feeling stupid, I think, what with this and knocking out guns. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/oops3.gif" style="vertical-align:middle" emoid=":eek:ops2" border="0" alt="oops3.gif" />
But thank you, and most especially for the lemonade. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

Inez: Thanks for the correction re: speeds. Guess I assumed (incorrectly) one more time. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/oops3.gif" style="vertical-align:middle" emoid=":eek:ops2" border="0" alt="oops3.gif" />

Regarding keys. Here's how I would do it.
Evidently we can bind more than one control to a key (see how many times Tab or Space is bound).
My hope is we can do the reverse: make multiple copies of a control and assign them/it to different keys.

If so, we can then simply bind two actions to a control: 1, set the new animations, and 2, attack.

However, this relies on 1 executing before 2, which is probably doubtful given that 1 will have to run via scripts and 2 is a direct `engine-level` event.

Ah, well. At the least we can divide the attacks into groups (thrust, slash, chop) and allow only one group at a time (and thereby allow the functions in FightParams to tell what kind of attack was made).

Inez: We can test that (whether it's the animation that triggers the fight functions) by binding PlayAnimation(attackX) to a key and trying it out, and seeing if someone standing in front of us is damaged thereby.
 
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Thanks for the correction re: speeds<!--QuoteEnd--></div><!--QuoteEEnd-->
??? Correct ? Nothing wrong with what you said, I just added to it.
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->We can test that (whether it's the animation that triggers the fight functions) by binding PlayAnimation(attackX) to a key<!--QuoteEnd--></div><!--QuoteEEnd-->
I' love to find that out, but my knowldge of POTC script is by far not as good as I'd like - took me a million years to set up a key for the console. So I'm afraid this is above me.
 
I mean in terms of the speed being changed parametrically (though yes not from scripts). So I'm right that I'm half wrong. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
At any rate thank you for the addition. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

The command we should use is I believe
CharacterPlayAction(chr, actionName);
Which is a wrapper for a `low-level` sendmessage that directly plays the animation.
Rather than one of the PlayAnimation commands which have `AI-level` things like `set-stay`-type before play anim, etc.

So above the logit() line in console.c, say:
CharacterPlayAction(pchar, "attack1");
or whatever the animation name you want is.

And quite frankly I'm amazed at the work you, do deciphering data formats and writing _actual_ programs rather than just script modding; but if you ever have need of the latter, but ask. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
Ah, but this is hilarious! It only works when your sword is _not_ drawn.

But on the bright side you are quite right, Inez: it's the animation that triggers the collision detection and thus the events.
 
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->it's the animation that triggers the collision detection and thus the events.<!--QuoteEnd--></div><!--QuoteEEnd-->
that's coool - now probably it wouldn't be possible to have your own code be triggered by such an event ?
(I'm thinking of the low_men: if the engine moves them could we at least react to their movements?)
 
If we could but find a way to play animations when in fight mode, we'd be set!

Further gleanings:
1. File ActionsAttributes.txt in Characters. Has listing of a number of animations, including the fighting ones; interestingly it has them separated into four blocks (attack/block/hit 1, 2, 3, and 4). So maybe originally you _could_ choose a height or style? And there were matching blocks and hits?
{Haven't played them yet, will check}
2. Also, I find apparently unused (back in SetDefaultFight() ) attack_left_1 and attack_right_1, swipes to the left and right. We should add those. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

Back on triggering...
Actually....
Can you change what animation is used for drawing and sheathing your sword?
Because if so, what if we did this.
You start in fight mode.
When you press a `non-standard` attack key the following happens.
1. Anim to sheath sword is set to 1 frame, as is the one to draw sword
2. Sword is sheathed (SetFightMode(false))
3. Desired attack anim triggered
4. Sword is drawn again (setfightmode(true))
5. Anims to sheath/draw sword are reset.

That would still leave the problem of there being no sword in your hand when you strike.

Hmm. I wonder what happens if you try to attack and there are no attack animations? If so, we could use my last method (in the previous post) and simply not assign _any_ attack anim until the keypress (which assigns it), deleting the attribute once the attack has completed.
 
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Can you change what animation is used for drawing and sheathing your sword?  <!--QuoteEnd--></div><!--QuoteEEnd-->
Only thing I can think of would be to change the whole ani file. But I doubt that would immediately take effect.
 
And the sword would still be invisible (that is to say, visible but sheathed) when attacking.
We can make that take effect immediately by reloading the model, I should think.
 
Argh. Earlier I grep'd man.an, but didn't think to open man.ani (which is plaintext...)...and where all the anims are named, no work necessary. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/oops3.gif" style="vertical-align:middle" emoid=":eek:ops2" border="0" alt="oops3.gif" />

So scratch the above about `block1-4`, that must have been an earlier version of the anim file (or at least the ani file--who knows, those may still exist in the an file).
 
Lots of neat stuff for the disarm mod--"drop saber", "hands up".
So yeah we can set speed to 999999 for "fight to normal" and "normal to fight" and resave file as man_quickdraw.ani, then force a reload of the model with _that_ animation instead of the other (and reload original and redraw sword at the end).

But again, the saber will not move with hand if we trigger the anim manually...must be forgetting something (or maybe only the DLL can do it?)
 
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->the saber will not move with hand if we trigger the anim manually<!--QuoteEnd--></div><!--QuoteEEnd-->
You tried that or you know theoretically ? When the NPCs do `LAI_actor-animations`, they have sword, do they not ? Or am I missing the point here?
 
Yes, tried. Put the line in the console ( CharacterPlayAction(pchar, "attack1"); ) and ran game and executed. The animation will only play when not in fight mode; in fact, it will _keep_ playing indefintely (and while it stops when you enter fight mode, it will start up again when you exit fight mode).

In fact I just now remember that at least in the case of the Redcoat who strikes you in the Redmond tavern (on meeting Danielle) he too does not have sword in hand when attacking (via play_animation).

The other difference being that when you use a play_animation command it makes the character an actor (I believe), sets the actor to Stay (definitely) and only then executes the CharacterPlayAction() call that actually plays the animation.
 
Gene Fowler, a great journalist and biographer, said once that "...Writing is easy. All you do is stare at a blank sheet of paper until drops of blood form on your forehead..."

The same is VERY true of modding... Heh... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />
 
Back
Top