Hi guys, here’s a boss Kelathos and I made,
It has serverside health and revive delay, he spawns mostly bombs, sometimes explosions, sometimes baddies.
It mostly works real fine, but sometimes when I log in this level, the boss spawn all of its bombs at x,y, ignoring the random.
Any idea why this happens?
// NPC made by Kelathos
// Fixed by Fredi
// Alien Bomber with server side health
// V 1.00
// Spawn
if (created) {
// Variables
this.bx = x;
this.by = y;
this.hpmax = 1000;
this.hp = this.hpmax;
this.sleep = 1;
this.bombRange = 12; // The maximum range for planting bombs
this.respawnTime = 120; // Divide by 2 to count as seconds
// Static
hide;
setstring server.AlienBossRespawn,#v(strtofloat(#s(this.respawnTime)));
// Check for Health on Spawn
this.hp = strtofloat(#s(server.AlienBossHealth));
// Activate if it has Health
if (this.hp > 0) {
this.sleep = 0;
show;
}
else
{
this.sleep = 1;
setstring server.AlienBossRespawn,#v(strtofloat(#s(this.respawnTime)));
}
}
// Keep the NPC active, always
if (playerenters) {
timeout = 0.5;
if (strtofloat(#s(server.AlienBossHealth)) <=0 && strtofloat(#s(server.AlienBossRespawn))<=0){
setstring server.AlienBossHealth,#v(this.hpmax);
this.hp = this.hpmax; //strtofloat(#s(server.AlienBossHealth));
this.sleep = 0;
this.bombRange = 12;
show;
}
}
// Main Action Loop
if (timeout) {
// Sleeping
if (this.sleep == 1) {
// Check HP
this.hp = strtofloat(#s(server.AlienBossHealth));
// Activate if has HP
if (strtofloat(#s(server.AlienBossHealth)) > 0) {
this.sleep = 0;
setstring server.AlienBossRespawn,#v(strtofloat(#s(this.respawnTime)));
show;
}
//Respawn if killed
if (strtofloat(#s(server.AlienBossHealth)) <=0){
//Respawn counter decrements
if (strtofloat(#s(server.AlienBossRespawn))>0){
this.sleep = 1;
setstring server.AlienBossRespawn,#v(strtofloat(#s(server.AlienBossRespawn))-1);
}
// Boss Respawns
if (strtofloat(#s(server.AlienBossRespawn))<=0){
setstring server.AlienBossHealth,#v(this.hpmax);
this.hp = this.hpmax; //strtofloat(#s(server.AlienBossHealth));
//setstring server.AlienBossRespawn,#v(strtofloat(#s(this.respawnTime)));
this.sleep = 0;
show;
}
}// End of Respawn
}
// While Awake (sleep == 0)
else {
// If Defeated, put to sleep
if (strtofloat(#s(server.AlienBossHealth)) <= 0) {
this.hp = 0;
this.sleep = 1;
setstring server.AlienBossHealth,0;
setstring server.AlienBossRespawn,#v(this.respawnTime);
play ff7victory2.mid;
hide;
}
// Or Fight!
else {
show;
// Special attack each time boss loses 20 hp
if (strtofloat(#s(server.AlienBossHealth))%20=0){
this.bx = random(x-this.bombRange,x+this.bombRange);
this.by = random(y-this.bombRange,y+this.bombRange);
putexplosion2 3, 3, this.bx,this.by;
}
// Each 27 hp
if(strtofloat(#s(server.AlienBossHealth))%27=0){
shootfireball random(0,4);
}
if(strtofloat(#s(server.AlienBossHealth))%47=0){
putnewcomp lizardon,x+2,y-4,baddyninja.png,8;
putnewcomp lizardon,x-2,y-4,baddyninja.png,8;
}
//this.bx = random(x-this.bombRange,x+this.bombRange);
//this.by = random(y-this.bombRange,y+this.bombRange);
putbomb 1, random(x-this.bombRange,x+this.bombRange),random(y-this.bombRange,y+this.bombRange);
}
}
timeout = 0.5;
}
// How to take damage!
if (washit || wasshot && strtofloat(#s(server.AlienBossHealth))>0) {
setstring server.AlienBossHealth,#v(strtofloat(#s(server.AlienBossHealth))-playerswordpower/2);
this.hp = strtofloat(#s(server.AlienBossHealth));
hearts = strtofloat(#s(server.AlienBossHealth));
putleaps 2,x,y;
}
// Black rocks and vase hurt 1 hp, other throwables 0.5
if (waspelt && strtofloat(#s(server.AlienBossHealth))>0){
if (peltwithblackstone || peltwithvase){
setstring server.AlienBossHealth,#v(strtofloat(#s(server.AlienBossHealth))-1);
}
else {
setstring server.AlienBossHealth,#v(strtofloat(#s(server.AlienBossHealth))-0.5);
this.hp = strtofloat(#s(server.AlienBossHealth));
putleaps 2,x,y;
}
hearts = strtofloat(#s(server.AlienBossHealth));
}
(I can’t figure out the code tag, please help me on that)