random walking speed, random risetime

ABK

Well-known member
I wanted to add some variations to enemies ingame, i dont like they way they all fall in groups and fly the same path then rise in the same time, i would like to add some randomness, i gave enemies running animation and its working kinda ok, not what i wanted but fine.
Is property "risetime" controlled by script ? I would like to make it random lets say from 10 to 1000 after each fall so every enemy would have random risetime and would rise sooner or later than others.
Also is there some quick way to control enemies walking speed and keep it random at all times so enemies walk faster/slower whenever they want ? Now running is activated only when enemies are far.
Or do i have to give enemies risetime 1000 and then use script in their rise animation to adjust how long they wait until rise from the floor?
---
OK so far i have this in rise animation and it adds a lot IMO to overall feel, game feels more "real" and not so automatic and robotic cause each character gets up a bit sooner/later :) Also my risetime is 1000 cause more = faster
Code:
anim	rise
	loop	0
	offset	164 196
	bbox	0 0 0 0 0
	delay	25
      @script
    void self = getlocalvar("self");
    if( frame == 0){
      int r = rand()%30;
      if( r > 11){
        changeentityproperty(self, "animpos", 1);
      } else if( r < -10){
        changeentityproperty(self, "animpos", 2);
      } else if( r < 0){
        changeentityproperty(self, "animpos", 0);
      } else if( r > 0){
        changeentityproperty(self, "animpos", 3);
      }
    }
	@end_script
	frame	data/chars/zboj/fall6.gif
	frame	data/chars/zboj/fall6.gif
	frame	data/chars/zboj/fall6.gif
	frame	data/chars/zboj/fall6.gif
	offset	164 200
	delay	8
	frame	data/chars/zboj/rise1.gif
 
O Ilusionista said:

+1

This is precisely what you should do, and why we removed support for multiple script files on a level spawn; the engine code that facilitated it was unbelievably inefficient and slowed down modules even if they didn't use it. Aside from that, the feature itself was completely superfluous when you can use @script tags to run as many functions as you like.

DC
 
can someone please provide an example of how to impliment random walking speeds.

I make it like next:

This script check entitys speed and add to it a little coefficient, so in group of several same enemies they will have a little bit different speed, so they would not walk as 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);
}

use it like this
anim spawn
loop 0
offset 10 10
delay  5
@cmd rspeed
        frame data/chars/misc/empty.gif
        frame data/chars/misc/empty.gif

But if this is not what you looking for, i think you can modify that script for your need.
 
you can also clone run animation and name it attack3 then give it speedup velocity and range 300 400 so enemy will run towards player when hes too far.
 
I also recommend this script in walking animation:

    @script
    void self = getlocalvar("self");
    if( frame == 1){
      int r = rand()%30;
      if( r > 11){
        changeentityproperty(getlocalvar("self"), "speed", 3.0);
      } else if( r < -10){
  changeentityproperty(getlocalvar("self"), "speed", 3.5);
      } else if( r < 0){
      changeentityproperty(getlocalvar("self"), "speed", 2.5);
      } else if( r > 0){
        changeentityproperty(getlocalvar("self"), "speed", 3.7);
      }
    }
@end_script


walkin speed wil be different each time enemy will walk and i think thats what we want really, it also wont be some hilarious high values and this can be controlled better this way.If default speed is 28 then in script its 2.8.
And this running animation:



anim attack3
loop 0
@script
                void self = getlocalvar("self");
if ((getentityproperty(self, "direction")==1)&&(frame >= 0)){
changeentityproperty(self, "velocity", 8, 0, 0);
}
if ((getentityproperty(self, "direction")==0)&&(frame >= 0)){
changeentityproperty(self, "velocity", -8, 0, 0);
}
@end_script
range 600 800
offset 121 223
bbox 88 31 70 205
delay 4
frame data/chars/horde/run01.gif
frame data/chars/horde/run02.gif
attack 75 6 67 198 10 1 1 0 20 30
dropv 4 4
frame data/chars/horde/run03.gif
frame data/chars/horde/run04.gif
frame data/chars/horde/run05.gif
frame data/chars/horde/run06.gif
frame data/chars/horde/run07.gif
frame data/chars/horde/run08.gif
frame data/chars/horde/run09.gif
frame data/chars/horde/run10.gif
frame data/chars/horde/run11.gif
frame data/chars/horde/run12.gif
frame data/chars/horde/run13.gif
frame data/chars/horde/run14.gif
frame data/chars/horde/run01.gif
frame data/chars/horde/run02.gif
frame data/chars/horde/run03.gif
frame data/chars/horde/run04.gif
frame data/chars/horde/run05.gif
frame data/chars/horde/run06.gif
frame data/chars/horde/run07.gif
frame data/chars/horde/run08.gif
frame data/chars/horde/run09.gif
frame data/chars/horde/run10.gif
frame data/chars/horde/run11.gif
frame data/chars/horde/run12.gif
frame data/chars/horde/run13.gif
frame data/chars/horde/run14.gif

IT works nice and looks like enemies are alive and run when you are too far, it isnt that good when there are holes on stage becauise they keep running into them.

 
I use all 3 methods now, the one posted here and my 2 other ones.

anim walk
      @script
    void self = getlocalvar("self");
    if( frame == 1){
      int r = rand()%30;
      if( r > 11){
        changeentityproperty(getlocalvar("self"), "speed", 3.0);
      } else if( r < -10){
  changeentityproperty(getlocalvar("self"), "speed", 2.3);
      } else if( r < 0){
      changeentityproperty(getlocalvar("self"), "speed", 2.5);
      } else if( r > 0){
        changeentityproperty(getlocalvar("self"), "speed", 2.7);
      }
    }
@end_script
loop 1
offset 77 232
bbox 42 31 70 205
delay 7
frame data/chars/horde/walk1.gif
frame data/chars/horde/walk2.gif
frame data/chars/horde/walk3.gif
frame data/chars/horde/walk4.gif
frame data/chars/horde/walk5.gif
frame data/chars/horde/walk6.gif
frame data/chars/horde/walk7.gif
frame data/chars/horde/walk8.gif
frame data/chars/horde/walk9.gif
frame data/chars/horde/walk10.gif
frame data/chars/horde/walk11.gif
frame data/chars/horde/walk12.gif
frame data/chars/horde/walk1.gif
frame data/chars/horde/walk2.gif
frame data/chars/horde/walk3.gif
frame data/chars/horde/walk4.gif
frame data/chars/horde/walk5.gif
frame data/chars/horde/walk6.gif
frame data/chars/horde/walk7.gif
frame data/chars/horde/walk8.gif
frame data/chars/horde/walk9.gif
frame data/chars/horde/walk10.gif
frame data/chars/horde/walk11.gif
frame data/chars/horde/walk12.gif

This works really nice because you can see characters speedup in the middle of walking like in capcom games, it would be perfect if also delay in walking would change when they speed up
 
Back
Top Bottom