Toranks
Active member
Is there a simple piece of code to make an entity shake a second when it takes a hit, independent of the entity's animations? I can't use the offset method within the pain animation. It is a car that takes damage and changes appearance as it loses HP, so it does not use a pain animation.
Takedamagescript:
Code:
name Car
type obstacle
score 10000
health 1000
nolife 1
noatflash 1
flash cardam
falldie 1
gfxshadow 1
nodieblink 3
nodrop 2
offscreenkill 10000
animationscript data/scripts/escript.c
takedamagescript data/scripts/tdamage/car.c
load cardam
load cardam2
load steamer
alternatepal data/chars/MISC/car/smap1.gif
anim death
platform -35 105 30 30 245 245 35 40
loop 1 3 6
delay 200
offset 105 95
bbox 0 0 0 0
jumpframe 0 3 0
@cmd spawn01 "cardam2" -20 40 5
@cmd spawnGun "steamer" 0 40 5 1
@cmd spawn01 "cardam2" 20 40 5
frame data/chars/MISC/car/sta5.GIF
frame data/chars/MISC/car/sta5.GIF
@cmd killgun 1 0
frame data/chars/MISC/car/sta5.GIF
frame data/chars/MISC/car/sta5.GIF
frame data/chars/MISC/car/sta5.GIF
frame data/chars/MISC/car/sta5.GIF
frame data/chars/MISC/car/sta5.GIF
frame data/chars/MISC/car/sta5.GIF
anim follow1
platform -35 105 30 30 245 245 35 40
loop 1 1 3
delay 6
offset 105 95
bbox 0 9 190 75 25
@cmd spawn01 "cardam2" 1 50 5
frame data/chars/MISC/car/sta2.GIF
frame data/chars/MISC/car/sta2.GIF
@cmd damage 60 "ANI_FOLLOW2"
frame data/chars/MISC/car/sta2.GIF
anim follow2
platform -35 105 30 30 245 245 35 40
loop 1 1 3
delay 6
offset 105 95
bbox 0 9 190 75 25
@cmd spawn01 "cardam2" 1 60 5
frame data/chars/MISC/car/sta3.GIF
frame data/chars/MISC/car/sta3.GIF
@cmd damage 40 "ANI_FOLLOW3"
frame data/chars/MISC/car/sta3.GIF
anim follow3
platform -35 105 30 30 245 245 35 40
loop 1 1 3
delay 6
offset 105 95
bbox 0 9 190 75 25
@cmd spawn01 "cardam2" 1 60 5
frame data/chars/MISC/car/sta4.GIF
frame data/chars/MISC/car/sta4.GIF
frame data/chars/MISC/car/sta4.GIF
anim idle
platform -35 105 30 30 245 245 35 40
loop 1
delay 6
offset 105 95
bbox 0 9 190 75 25
@cmd damage 80 "ANI_FOLLOW1"
frame data/chars/MISC/car/sta1.GIF
frame data/chars/MISC/car/sta1.GIF
anim spawn
loop 0
delay 5
offset 105 95
bbox 0 0 0 0
frame data/chars/MISC/car/sta1.GIF
frame data/chars/MISC/car/sta1.GIF
Takedamagescript:
Code:
void main()
{
int dmg= getlocalvar("damage");
void target=getlocalvar("attacker");
void vSpawn;
clearspawnentry();
setspawnentry("name","turn");
vSpawn = spawn();
changeentityproperty(vSpawn, "parent",getlocalvar("self"));
changeentityproperty(vSpawn, "speed",getentityproperty(target,"direction"));
if (dmg>7){
changeentityproperty(vSpawn,"animation",openborconstant("ANI_FOLLOW1"));
/// HERE I WAN TO ADD A SHAKE FOR A SECOND
}
}