Walk and Backwalk question

mtrain

New member
I have some questions:
- Is there possible to set different speed for walk and backwalk animations?
- Is it possible to force entity play walk or backwalk animation complete. For example: a regular walking animation of the enemy consist of walk frames and when he attacks or making another animation, so the walk animation brakes in the middle for that. So if enemy have, saying, 8 frames of walk animation, is it possible to make him not interrupt it or make something else before this 8 frames played?
 
I don't know about #1, unless you are willing to try script which changes walking speed in WALK and BACKWALK animation.

As for #2, the best solution I have in mind is to disable ranges in entity's attack animations and use script based attack instead to perform those animations.

What I mean by disabling ranges in by setting impossible range like

range 0 -100

That's a simple trick if you want to disable enemy's attack animation but you don't want setting # in each line :)

Back to topic, you'll be using a function such as this to attack instead, like in this example:

loop  1
offset ...
bbox ...
delay  12
@cmd attack1 0 100 20 "ANI_ATTACK1"
frame data/chars/enemy/walk1
frame data/chars/enemy/walk2
frame data/chars/enemy/walk3
frame data/chars/enemy/walk4
frame data/chars/enemy/walk5
frame data/chars/enemy/walk6
frame data/chars/enemy/walk7
frame data/chars/enemy/walk8

This function is only declared in 1st frame like this to ensure that all walk frames are played before deciding to attack.

If you're using scripts from Crime Busterv2.5, you can find this function in escript.c
 
I don't know about #1, unless you are willing to try script which changes walking speed in WALK and BACKWALK animation.

If there are scripts for this i`ll try. I guess i need to put this script in the start of the animation to change speed of backwalk and need to put another script that will reset speed to amount which set in header of entity to the start of the walk or idle animation? If there a mods with examples?

As for #2

Interesting method i will try it. Thank you, BB!
 
Here's the script I'm referring:

anim WALK
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "speed", 10);
@end_script
...

10 means walk speed is 10

anim BACKWALK
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "speed", 8 );
@end_script
...

8 means walk speed 8 during this animation

You can give this a try :)

EDIT: Should've realized that 8 and ) = smiley
 
Would this work to set speed as ZERO for the first few frames to create a walk delay ? 
For entities where the first few frames of walking the should still be motionless.

(added to helpful links - scripts index)
http://www.chronocrash.com/forum/index.php?topic=13.msg57
 
Here's the script I'm referring:

anim WALK
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "speed", 10);
@end_script
...

10 means walk speed is 10

anim BACKWALK
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "speed", 8 );
@end_script
...

8 means walk speed 8 during this animation

Setting speed this way makes enemies walk like the current speed was multiplied by assigned variable.
For example: a regular enemy speed in his header is 20, but if i set the speed with changeentityproperty(self, "speed", 20 ); with the same variable 20, enemy will walk like his speed is 120 :o
I`m trying to make a random walkspeed onspawnscript for enemy but this is weird.
 
mtrain said:

There is a reason for this. The model's Speed setting is not the actual value used by OpenBOR; it is divided by 10 when read in and THAT is the value used. Don't ask me why, that goes all the way back to the original BOR. Maybe it was an attempt to make model sheets more human readable?

Anyway, when you set the speed value through script, you are working with the real thing and that's why it seems to act so odd. If you want to avoid confusion (and also have more precise control of the model's default speed), use "Speedf" in your model header. It does not mess with the value at all before sending it on to the engine, and so you can be consistent across the board with model header vs. script.

DC
 
Oh, i see now. I just tried it and what i have:

set SpeedF 2 in enemy header (in fact it will 20, yes?)

and put a script in spawn anim

@script
{
void spd = getentityproperty(getlocalvar("self"),"speed");
void ri = rand()%50;
int sp = spd + ri / 70;
changeentityproperty(getlocalvar("self"), "speed", sp);
}
@end_script

so it will check actual speed of enemy that was set in header, then calculate a random value from -50 to 50 and divide by 70 and add result to speed. So if ri will be 34 sp will be: 2 + 34 / 70 = 2 + 0.48 = 2.48 (actual speed will be ~ 25). Is it correct?
 
Help me figure out what is the problem with random walk speed. I think randomness working strange. I make a next script:

void rspeed(int s)
{
// void spd = getentityproperty(getlocalvar("self"),"speed");
void ri = rand()%1000+1000;
void ra = rand()%1000+1000;
int sp = s + ( ri / 1000 + ra / 1000 ) / 2;
changeentityproperty(getlocalvar("self"), "speed", sp);
}

S is the default speed of the enemy which you define. In my case i take 2 (speed 20).

Call it next way:

anim spawn
#----NAME
@script
changeentityproperty(getlocalvar("self"), "name", "Galsia");
@end_script
#----NAME
@cmd rspeed 2
loop 0
offset 290 275
        bbox 264 53 53 224
delay  1
              frame data/chars/galsia/103.gif

What i have in result: i spawn 10 galsia`s at one time in same coordinate to look with wich speed they will walk to me and will it be different. But in fact always 1-2 galsias have the same speed a little bit faster than the others and 8-9 galsias have same default speed (20). Random number is not really random, it seems like it it is always only 2 values: very low and very high.
 
I've made couple tests and figured out the problem here.

For some reason, ri / 1000 gives truncated integer result, you either get 0, 1 or 2.
I changed this to ri*0.001 and it works.
So you should change
Code:
int sp = s + ( ri / 1000 + ra / 1000 ) / 2;

to this:
Code:
float sp = s + ( ri*0.001 + ra*0.001 )*0.5;

HTH
 
Yes, now it is works fine! Thank you, BB! ;)

I`m trying to add randomness to enemies actions, and for now every enemy have random walking speed script, that now works fine and saves us when the same enemies walk like one.

void rspeed()
{
void spd = getentityproperty(getlocalvar("self"),"speed");
void ri = rand()%1000+1000;
void ra = rand()%1000+1000;
float sp = spd + ( ri*0.001 + ra*0.001 )*0.4;
changeentityproperty(getlocalvar("self"), "speed", sp);
}

using
anim spawn
@cmd rspeed
loop 0
offset 290 275
        bbox 264 53 53 224
delay  1
        frame data/chars/galsia/103.gif

Also i use bWWb`s random rise script for rise and fall animation, again works great for moments when group of same enemies falls and rises in same time. Now it is randomness and looks good enough ;)

void rrise()
{   
void self = getlocalvar("self");
      int r = rand()%30;
      if( r > 15){
        changeentityproperty(self, "animpos", 1);
      } else if( r < -15){
        changeentityproperty(self, "animpos", 2);
      } else if( r < 0){
        changeentityproperty(self, "animpos", 0);
      } else if( r > 0){
        changeentityproperty(self, "animpos", 3);
      }
}

using for rise
anim rise
offset  290  275
delay  25
@cmd rrise()
frame  data/chars/galsia/109.gif
frame  data/chars/galsia/109.gif
frame  data/chars/galsia/109.gif
frame  data/chars/galsia/109.gif

        frame data/chars/galsia/110.gif
delay  2
        frame data/chars/galsia/103.gif

same using for fall
anim fall
landframe 6
delay 8
offset 290 275
attack1  234  80  57  91  0  1  1  0  0
@cmd rrise()
frame data/chars/galsia/131.gif
frame data/chars/galsia/131.gif
frame data/chars/galsia/131.gif
frame data/chars/galsia/131.gif

delay 10
frame data/chars/galsia/132.gif
delay 200
frame data/chars/galsia/133.gif
delay 7
Attack1  0
frame data/chars/galsia/107.gif

Maybe this will be useful for someone.
 
Back
Top Bottom