Forcing spawn animation when changing to weapon model

oldyz

Well-known member
i have these zombies that are laying down, normally  you can hit them before they get up.
when they are "randomized" you can't hit them for about 1 centisecond, using the old method - but they pretty much behave the same

now with the new "weapon model" method , i can't figure out how to make them do their spawn animation - the plan is to have a total of 3 frames do the "weapon" change, but i cant make the script work - they go from laying down to walking right away -
here is the script:

Code:
name zombieA-M
health 204
nolife 1
type enemy
#lifespan 3
shadow 3
gfxshadow 1
noquake 1
falldie 1
nodieblink 3
animationscript data/scripts/zombie.c
weapons zombiea zombiea-3 zombiea-6 zombiea-8 zombiea-12 zombiea-13 zombieA-M
weaploss 3
modelflag 3
palette data/chars/zombie/00a
alternatepal data/chars/zombie/alt1a
alternatepal data/chars/zombie/alt2a
alternatepal data/chars/zombie/alt3a
alternatepal data/chars/zombie/alt4a
alternatepal data/chars/zombie/alt2a
load zombiea
load zombiea-3
load zombiea-6
load zombiea-8
load zombiea-12
load zombiea-13

anim spawn
delay	1
offset  124 124
        bbox 0 0 0 0
weaponframe 1 6
	frame data/chars/zombie/24

        @script
	void self = getlocalvar("self");
	if(frame == 1){
	changeentityproperty(self, "aiflag", "attacking", 1);
	changeentityproperty(self, "aiflag", "idling", 0);
	changeentityproperty(self, "takeaction", "common_attack_proc");
	}
	@end_script
frame	data/chars/zombie/24

i tried with this change, but all it does is make the zombie model stand & not do anything until you hit it

        @script
void self = getlocalvar("self");
if(frame == 1){
changeentityproperty(self, "aiflag", "attacking", 1);
changeentityproperty(self, "aiflag", "idling", 0);
changeentityproperty(self, "takeaction", "common_spawn");
}
@end_script

i also tried using this script on the anifollow & the same thing happens:

anim follow1
@script
void self = getlocalvar("self");
if(frame == 0){
changeentityproperty(self, "takeaction", "common_spawn");

}
@end_script
delay 1
offset  124 124
        bbox 0 0 0 0
weaponframe 0 1
        frame data/chars/zombie/24
 
Update:

it seems that changing weapons  was not the best  thing - changing models allowed for spawn animation:

Code:
name zombieA-M
health 204
nolife 1
type enemy
#lifespan 3
shadow 3
gfxshadow 1
noquake 1
falldie 1
nodieblink 3
animationscript data/scripts/zombie.c
weapons zombiea-X zombiea-3 zombiea-6 zombiea-8 zombiea-12 zombiea-13 zombieA-M
weaploss 3
modelflag 3
palette data/chars/zombie/00a
alternatepal data/chars/zombie/alt1a
alternatepal data/chars/zombie/alt2a
alternatepal data/chars/zombie/alt3a
alternatepal data/chars/zombie/alt4a
alternatepal data/chars/zombie/alt2a
load zombiea-X
load zombiea-3
load zombiea-6
load zombiea-8
load zombiea-12
load zombiea-13

anim spawn
delay	1
offset  124 124
        bbox 0 0 0 0
@script
	if(frame == 0){
	void self = getlocalvar("self");
	int map = rand()%5;
	if(map < 0)
	{
	-map == map;
	}
	changeentityproperty(self, "map", map);
	}
	@end_script
        
@script
	void self = getlocalvar("self");
	if(frame == 1){
changeentityproperty(self, "model", "zombiea-X", 0);

} else if(frame == 3){
changeentityproperty(self, "model", "zombiea-3", 0);

} else if(frame == 5){
changeentityproperty(self, "model", "zombiea-6", 0);

} else if(frame == 7){
changeentityproperty(self, "model", "zombiea-8", 0);

} else if(frame == 9){
changeentityproperty(self, "model", "zombiea-12", 0);

} else if(frame == 11){
changeentityproperty(self, "model", "zombiea-13", 0);
}
@end_script

@script
    void self = getlocalvar("self");
    if( frame == 0){
      int iR = rand()%50+50;
      if (iR >= 0 && iR < 16){
        changeentityproperty(self, "animpos", 6);
      }else if (iR >= 17 && iR < 33){
        changeentityproperty(self, "animpos", 8);
      }else if (iR >= 34 && iR < 50){ 
        changeentityproperty(self, "animpos", 10);
      }else if (iR >= 51 && iR < 67){ 
        changeentityproperty(self, "animpos", 2);
      }else if (iR >= 68 && iR < 84){ 
        changeentityproperty(self, "animpos", 4);
      }else if (iR >= 85 && iR < 100){
        changeentityproperty(self, "animpos", 1);
      }
    }
	@end_script

	frame data/chars/zombie/24 #0



        frame data/chars/zombie/24 #1

        frame data/chars/zombie/24 #2


        frame data/chars/zombie/24 


	frame data/chars/zombie/24  #4



	frame data/chars/zombie/24



	frame data/chars/zombie/24 #6



        frame data/chars/zombie/24


        frame data/chars/zombie/24 #8


        frame data/chars/zombie/24


        frame data/chars/zombie/24 #10


        frame data/chars/zombie/24

The only thing that is not clear is why zombiea-X  is so scarce - i tried all variations of the "random" switch that i know:
this was the worst:
int r = rand()%45;
      if( r > 30){
        changeentityproperty(self, "animpos", 6);
      } else if( r < -30){
        changeentityproperty(self, "animpos", 8);
      } else if( r > 15){
    .... etc

then this one:
int r = rand()%50+50;
      if (r >= 0 && r < 17){
      ... etc


 
oldyz  something I am trying to understand: why you are using this code on the spawn animation? 

Code:
      @script
	void self = getlocalvar("self");
	if(frame == 1){
	changeentityproperty(self, "aiflag", "attacking", 1);
	changeentityproperty(self, "aiflag", "idling", 0);
	changeentityproperty(self, "takeaction", "common_attack_proc");
	}
	@end_script

It's an SPAWN animation, you don't need to set the attack flag, neither the idling flag - the engine will set it when you revert to IDLE.
I suggest you to not change aiflags unless you know what you are doing, because the result could be a mess.

About your random code, take a look into I replied I made on one of your topics https://www.chronocrash.com/forum/index.php?topic=5706.msg76290#msg76290
I find that method way more reliable and easier to understand. Plus, you don't need to take care about negative numbers.
 
Back
Top Bottom