dantedevil
Well-known member
I try to create Combined Obstacles like in Cime Buster mod.
I study how works the system with the bigfence, but something is wrong.
The obstacle seem works, but you can destroy with a few hits when the health is 500. How can change that?.
Here all parts:
And finally, the script (spawner) in obstacle.c
One more thing, I put an item in the fence, but when the fence fall, the item never comes.
spawn FenceW
alias Fence
item bosser
health 50
coords 590 215
at 1900
I study how works the system with the bigfence, but something is wrong.
The obstacle seem works, but you can destroy with a few hits when the health is 500. How can change that?.
Here all parts:
Code:
name FenceW
type none
shadow 0
nolife 1
nomove 1
noquake 1
cantgrab 1
falldie 1
animationscript data/scripts/obstacle.c
load FenceW1 data/chars/misc/fencew1.txt
load FenceW2 data/chars/misc/fencew2.txt
load FenceW3 data/chars/misc/fencew3.txt
load FenceW4 data/chars/misc/fencew4.txt
anim spawn
delay 1
offset 1 1
frame data/chars/misc/empty.png
anim idle
delay 1
offset 1 1
frame data/chars/misc/empty.png
@cmd spawner "FenceW1" 0 0 0
frame data/chars/misc/empty.png
@cmd spawner "FenceW2" -10 0 20
frame data/chars/misc/empty.png
@cmd spawner "FenceW3" -20 0 40
frame data/chars/misc/empty.png
@cmd spawner "FenceW4" -30 0 60
frame data/chars/misc/empty.png
delay 10
frame data/chars/misc/empty.png
anim fall
delay 13
offset 1 1
frame data/chars/misc/empty.png
anim death
delay 13
offset 1 1
frame data/chars/misc/empty.png
Code:
name FenceW1
health 500
type obstacle
shadow 0
diesound data/sounds/klunk.wav
setlayer -1
anim spawn
@script
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
setglobalvar("1"+parent, self);
@end_script
delay 1
offset 134 233
frame data/chars/misc/fencelec01.png
frame data/chars/misc/fencelec01.png
anim idle
@script
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
//Get all walls
void Obst1 = getglobalvar("1"+parent);
void Obst2 = getglobalvar("2"+parent);
void Obst3 = getglobalvar("3"+parent);
void Obst4 = getglobalvar("4"+parent);
//Get walls' health
int Health1 = getentityproperty(Obst1,"health");
int Health2 = getentityproperty(Obst2,"health");
int Health3 = getentityproperty(Obst3,"health");
int Health4 = getentityproperty(Obst4,"health");
int Health;
if (Health1 > Health2){
Health = Health2;
} else { Health = Health1;}
if (Health > Health3){
Health = Health3;
} else { Health = Health;}
if (Health > Health4){
Health = Health4;
} else { Health = Health;}
// if (Health > 0){
//Make all walls' health the same
changeentityproperty(Obst1, "health", Health);
changeentityproperty(Obst2, "health", Health);
changeentityproperty(Obst3, "health", Health);
changeentityproperty(Obst4, "health", Health);
// }
@end_script
loop 1
delay 5
offset 134 233
bbox 78 21 97 276
platform 78 298 -35 60 120 150 100 500
frame data/chars/misc/fencelec01.png
anim death
@script
if(frame == 1){
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
//Get all walls
void Obst2 = getglobalvar("2"+parent);
void Obst3 = getglobalvar("3"+parent);
void Obst4 = getglobalvar("4"+parent);
setglobalvar("1"+parent, NULL());
// Kill other walls!!
killentity(Obst2);
killentity(Obst3);
killentity(Obst4);
}
@end_script
loop 0
delay 25
offset 134 233
frame data/chars/misc/fencelec02.png
frame data/chars/misc/fencelec02.png
frame data/chars/misc/fencelec03.png
Code:
name FenceW2
health 500
type obstacle
shadow 0
#diesound data/sounds/klunk.wav
setlayer -1
anim idle
@script
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
setglobalvar("2"+parent, self);
@end_script
delay 1
offset 45 137
bbox 0 37 40 100
platform 1 1 1 1 1 1 1 500
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
anim death
@script
if(frame == 1){
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
//Get all walls
void Obst1 = getglobalvar("1"+parent);
void Obst3 = getglobalvar("3"+parent);
void Obst4 = getglobalvar("4"+parent);
setglobalvar("2"+parent, NULL());
// Kill other walls!!
damageentity(Obst1, Obst1, 10000, 1, openborconstant("ATK_NORMAL"));
killentity(Obst3);
killentity(Obst4);
killentity(self);
}
@end_script
delay 3
offset 1 1
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
Code:
name FenceW3
health 500
type obstacle
shadow 0
#diesound data/sounds/klunk.wav
setlayer -1
anim idle
@script
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
setglobalvar("3"+parent, self);
@end_script
delay 1
offset 45 127
bbox 0 27 40 100
platform 1 1 1 1 1 1 1 500
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
anim death
@script
if(frame == 1){
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
//Get all walls
void Obst1 = getglobalvar("1"+parent);
void Obst2 = getglobalvar("2"+parent);
void Obst4 = getglobalvar("4"+parent);
setglobalvar("3"+parent, NULL());
// Kill other walls!!
damageentity(Obst1, Obst1, 10000, 1, openborconstant("ATK_NORMAL"));
killentity(Obst2);
killentity(Obst4);
killentity(self);
}
@end_script
delay 3
offset 45 127
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
Code:
name FenceW4
health 500
type obstacle
shadow 0
#diesound data/sounds/klunk.wav
setlayer -1
anim idle
@script
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
setglobalvar("4"+parent, self);
@end_script
delay 1
offset 5 87
bbox -40 -13 40 100
platform 1 1 1 1 1 1 1 500
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
anim death
@script
if(frame==1){
void self = getlocalvar("self");
void parent = getentityproperty(self,"parent");
//Get all walls
void Obst1 = getglobalvar("1"+parent);
void Obst2 = getglobalvar("2"+parent);
void Obst3 = getglobalvar("3"+parent);
setglobalvar("4"+parent, NULL());
// Kill other walls!!
damageentity(Obst1, Obst1, 500, 1, openborconstant("ATK_NORMAL"));
killentity(Obst2);
killentity(Obst3);
killentity(self);
}
@end_script
delay 50
offset 5 87
frame data/chars/misc/empty.png
frame data/chars/misc/empty.png
And finally, the script (spawner) in obstacle.c
Code:
void spawner(void vName, float fX, float fY, float fZ)
{
//spawner
//Damon Vaughn Caskey
//07/06/2007
//
//Spawns entity next to caller.
//
//vName: Model name of entity to be spawned in.
//fX: X location adjustment.
//fZ: Y location adjustment.
//fY: Z location adjustment.
void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int vAlias = getentityproperty(self, "name");
int iHealth = getentityproperty(self, "health");
int iDirection = getentityproperty(self, "direction");
clearspawnentry(); //Clear current spawn entry.
setspawnentry("name", vName); //Acquire spawn entity by name.
if (iDirection == 0){ //Is entity facing left?
fX = -fX; //Reverse X direction to match facing.
}
fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
vSpawn = spawn(); //Spawn in entity.
changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
changeentityproperty(vSpawn, "name", vAlias); //Set name.
changeentityproperty(vSpawn, "health", iHealth); //Set health.
changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
return vSpawn; //Return spawn.
}
One more thing, I put an item in the fence, but when the fence fall, the item never comes.
spawn FenceW
alias Fence
item bosser
health 50
coords 590 215
at 1900