PDA

View Full Version : Boss dies?!



lucas92
01-02-2009, 05:39 PM
Anyway, maybe this is a bug, or not, but I can't seem to be able to control the hp of a npc via scripting when it is set to 0 in the enemy editor... It just die...


I could set the value of the hp in the enemy editor at a higher value to 0, and it wouldn't die... But I want to control the HP of the npc via scripting... and I can't seem to be able to. :(

Here's the test file:
http://www.mediafire.com/download.php?v11mhlmykmm

pkmnfrk
01-02-2009, 06:00 PM
Uh. Yeah, things die when their HP goes to 0. And, heck, if they start out at zero, they die immediately!

If you want to control the HP of a monster, give it a non-zero HP to begin with, so it doesn't die.

lucas92
01-02-2009, 06:03 PM
Did you actually see the script?


//Thanks go to pkmnfrk for the moveTowards() function and the advmath.zh file.
//http://www.armageddongames.net/forums/showthread.php?p=1202737#post1202737
//"advmath.zh" can be found here: http://www.armageddongames.net/forums/showthread.php?p=1202755#post1202755
import "std.zh"
import "advmath.zh"

const int CSET_TEAM=10;
const int CSET_DEADSTATE=8;

const int CSET_SOLO=8;
const int CMB_DEADSTATE=24404;
const int CMB_1x1_SHADOW=24398;
const int CMB_ARMOS_TEAM=24396;

const int SFX_JUMPSTOMP=66;
const int SFX_FALLING=65;

// Method to move a FFC angularly based on a target location
// and speed without constant supervision

// Parameters
// ffc combo - The FFC to be moved
// int targetX - The target X location
// int targetY - The target Y location
// int speed - The total FFC movement speed

void angularMove(ffc combo, int targetX, int targetY, int speed)
{

// Calculate the distance to the target location
int xDis = targetX - combo->X;
int yDis = targetY - combo->Y;
int dis = Abs(xDis) + Abs(yDis);

// Calculate the speed coefficient
float d = speed / dis;

// Calculate the speeds for each direction
combo->Vx = d * xDis;
combo->Vy = d * yDis;
} // End of angularMove


//Note: To set it up, you'll have to create 4 npcs and 4 ffcs in order to create 4 armos etc.

ffc script LTTP_ArmosKnight
{
//D0:Choose a number from 1 to 4. Each number represent the npc number in the list. Also represents the ffc number in the list of this armos.
//D1:The time in frames that the Armos Knights have to wait until they get in a row.
//D2:The time in frames that the Armos Knight while he's alone has to wait until he fall from the sky.
//D3:The damage in quarters hearts when Link is hit.
//D4:The initial HP of the Armos.
//D5:The initial HP of the Armos in solo

void run(int n,int dt, int ds,int d,int h,int hf)
{
Waitframes(4);
int x1;int x2;
int y1;int y2;
int LinkCurrentHP=Link->HP;
bool isDead;
bool isNotPlayed;
bool isFalling;bool isReturning;
npc ghosted=Screen->LoadNPC(n);
ghosted->Damage=d;
ghosted->HP=h;
ffc armos=Screen->LoadFFC(n);
ffc shadow=Screen->LoadFFC(n+4);
bool isStill;
bool check;
bool solo=true;bool soloAttack;
bool team;
int delaysolo=ds;
int delaystill=30;
int delayIsDead=300;
int shadowx;
int shadowy;
//INIT//
shadow->X=Link->X;
shadow->Y=Link->Y;
armos->X=Link->X-8;
armos->Y=0;
while(true)
{
if(Screen->NumNPCs()==1)solo=true;
if(Screen->NumNPCs()>1)team=true;
if(Screen->NumNPCs()<=0)
{
isDead=true;
break;
}
if(team)
{
if(Screen->NumNPCs()>1&&ghosted->HP==0)isDead=true;
if(Screen->NumNPCs()==1&&ghosted->HP==0)
{
team=false;
solo=true;
isReturning=true;
}
armos->Data=CMB_ARMOS_TEAM;
armos->CSet=CSET_TEAM;
}
if(solo)
{
if(!check)
{
ghosted->HP=hf;
check=true;
}
if(delaysolo>0)
{
delaysolo-=1;
//Placing armos above Link's head
armos->X=Link->X-8;
armos->Y=0;
//Making the armos invulnerable and untouchable
ghosted->Damage=0;
ghosted->HitHeight=0;
ghosted->HitWidth=0;
armos->Flags[FFCF_OVERLAY]=true;
//Drawing the shadow on Link
shadow->X=Link->X;shadow->Y=Link->Y;
}
if(delaysolo<=0)
{
if(!isNotPlayed)
{
shadowx=shadow->X;
shadowy=shadow->Y;
isFalling=true;
Game->PlaySound(SFX_FALLING);
isNotPlayed=true;
}
if(isFalling)
{
shadow->X=shadowx;shadow->Y=shadowy;
ghosted->Damage=0;
ghosted->HitHeight=0;
ghosted->HitWidth=0;
armos->Flags[FFCF_OVERLAY]=true;
armos->Y+=4;
if(armos->Y>=shadowy-16)
{
Game->PlaySound(SFX_JUMPSTOMP);
armos->Y=shadow->Y-16;
isFalling=false;
isStill=true;
}
}
if(isStill)
{
armos->Flags[FFCF_OVERLAY]=false;
ghosted->HitHeight=32;
ghosted->HitWidth=32;
ghosted->Damage=ds;
delaystill-=1;
if(delaystill<=0)
{
isStill=false;
delaystill=30;
isReturning=true;
}
}
if(isReturning)
{
armos->Flags[FFCF_OVERLAY]=true;
ghosted->HitHeight=0;
ghosted->HitWidth=0;
ghosted->Damage=0;
angularMove(shadow, Link->X, Link->Y, 9);
angularMove(armos, Link->X-8, 0, 9);
shadow->X=armos->X+8;
if(armos->Y<=0)
{
armos->Vx=0;
armos->Vy=0;
shadow->Vx=0;
shadow->Vy=0;
armos->Y=0;
armos->X=Link->X-8;
shadow->X=Link->X;
shadow->Y=Link->Y;
isReturning=false;
isNotPlayed=false;
delaysolo=ds;
}
}
}
armos->Data=CMB_ARMOS_TEAM;
armos->CSet=CSET_SOLO;
armos->TileHeight=2;
armos->TileWidth=2;
ghosted->X=armos->X;
ghosted->Y=armos->Y;
}
ghosted->HP=5;
shadow->Data=CMB_1x1_SHADOW;
shadow->CSet=2;
shadow->Flags[FFCF_OVERLAY]=true;
shadow->Flags[FFCF_TRANS]=true;
if(ghosted->HP<=0)isDead=true;
if(isDead)break;
Waitframe();
}
while(isDead)
{
shadow->Data=0;
armos->Data=0;
delayIsDead-=1;
Screen->DrawCombo(3, armos->X, armos->Y, CMB_DEADSTATE, 1, 2,CSET_DEADSTATE, 1, 0, 0, 0,0, 0, true, 128);
Screen->DrawCombo(3, armos->X+16, armos->Y, CMB_DEADSTATE+1, 1, 2,CSET_DEADSTATE, 1, 0, 0, 0,0, 0, true, 128);
if(delayIsDead<=0)Quit();
Waitframe();
}
}
}

It dies even with that in the while(true) loop ?!

ghosted->HP=5;

pkmnfrk
01-02-2009, 06:10 PM
Set D5 on the FFC to something other than 0.

Also, you seem to have credited me for providing "moveTowards", but you didn't actually include it, or use it anywhere.

lucas92
01-02-2009, 06:54 PM
I did...

Could you download the file before trying to solve the problem? :S


Oh... I tried moveTowards, but it didn't worked fine for me...

pkmnfrk
01-02-2009, 07:09 PM
First things first, I downloaded it, looked at the scripts, and then hit Compile. When I started the game again, the moving tile worked fine.

Second... Remember when I said this?


Uh. Yeah, things die when their HP goes to 0. And, heck, if they start out at zero, they die immediately!

If you want to control the HP of a monster, give it a non-zero HP to begin with, so it doesn't die.

I actually meant it. The armos1 enemy has to have an HP > 0, or else it will die right away.

lucas92
01-02-2009, 07:16 PM
I think I will do a video...

pkmnfrk
01-02-2009, 07:31 PM
There is no need. Edit the armos1 enemy, and give it a single HP. Just one. Then save, and try it.

Joe123
01-02-2009, 07:36 PM
Oh, did you give it 0 HP to start off with?
Why?

lucas92
01-02-2009, 08:04 PM
I've set the HP to 5 via scripting, isn't that allowed? It's kind of strange but anyway... I'll put him a HP of 1 even if I set it to 5 via scripting....

pkmnfrk
01-02-2009, 08:08 PM
No, because the enemy is dead before the script gets to it!

It's not complicated! If you still don't understand, then just take our word for it!

Joe123
01-02-2009, 08:38 PM
Well, think about it.

If an NPC has 0 health, it's dead and so removed from the screen.
The system creates the NPC, realises it has no health, and so removes it before your 'e->HP = h;' line comes into play.

If however, you'd used 'Screen->CreateNPC()' I believe you could have an NPC with 0 health, because the 'e->HP = h;' line is called before the system functions that would remove it.


That's pretty irrelevant though, because there's no need for it to have health 0 if you're going to modify it by the script anyway.

lucas92
01-02-2009, 08:43 PM
No, because the enemy is dead before the script gets to it!



Oh! Didn't know that... Sorry for the confusion...

Gleeok
01-02-2009, 08:44 PM
lol.

What you want is Screen->CreateNPC(); , not load.


edit: Joe beat me to it.
...And loading a dead enemy onto the screen?!...that's just silly.

lucas92
01-02-2009, 08:58 PM
Anyway, now it works perfect. :)

Hides himself...