Jump to content

Photo

ghost.zh


  • Please log in to reply
645 replies to this topic

#16 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 18 December 2010 - 09:09 PM

I'm not sure if I broke something or what, but when I try to compile a simple boss I made, it doesn't work. Here's the script:

CODE
const int SLM_BALL = 87; //The slime projectile that shoots to create more slimes.
const int SLM_COMBO = 416; //Slime combo
const int SLM_SOUND = 62; //Sound when the slime shoots a smaller slime
const int SLM_ZOL = 178; //ID of the Zol to spawn
const int SLM_BIGSHADOW = 421; //Combo for big shadows.
const int SLM_SHADOW = 420; //Combo for small shadows.
const int SLM_EXPLODE = 63; //Sound when slime explodes.

ffc script slime
{

    
    void run()
    {
        eweapon wpn;
        eweapon wpn2;
        eweapon wpn3;
        
        npc ghost;

        int frame = 0;
    
        //Swap to invisible combo temporarily
        this->Data = 0;
        
        ghost=GhostInitWait(this,1,false,SLM_COMBO);
    
        while(true)
        {
            frame ++;
            if(frame%120 == 0)
            {
                
                wpn = FireAimedEWeapon(EW_SCRIPT1 ,CenterX(this),CenterY(this),0,50,4,false,SLM_BALL,false,SLM_SOUND,2);
                SetEWeaponMovement(wpn,EWM_THROW,Rand2(25,60)/10);
                SetEWeaponDeathEffect(wpn,EWD_VANISH,0);
                
                wpn2 = FireAimedEWeapon(EW_SCRIPT1,CenterX(this),CenterY(this),DegtoRad(45),50,4,false,SLM_BALL,false,0,2);
                SetEWeaponMovement(wpn2,EWM_THROW,Rand2(25,60)/10);
                SetEWeaponDeathEffect(wpn2,EWD_VANISH,0);
                
                wpn3 = FireAimedEWeapon(EW_SCRIPT1,CenterX(this),CenterY(this),DegtoRad(360-45),50,4,false,SLM_BALL,false,0,2);
                SetEWeaponMovement(wpn3,EWM_THROW,Rand2(25,60)/10);
                SetEWeaponDeathEffect(wpn3,EWD_VANISH,0);
            }
            SlimWaitFrame(this,ghost,1);
        }
    }
    
    void SlimWaitFrame(ffc this, npc ghost, int numframes)
    {

        eweapon wpn;
        if(GotHit(this))
        {
            wpn = FireAimedEWeapon(EW_SCRIPT1,CenterX(this),CenterY(this),0,50,4,false,SLM_BALL,false,SLM_SOUND,2);
            SetEWeaponMovement(wpn,EWM_THROW,Rand2(25,60)/10);
            SetEWeaponDeathEffect(wpn,EWD_SPAWN_NPC,SLM_ZOL);
            if(ghost->HP<1000)
            {
                // Randomly placed harmless explosions
                lweapon explosion;
                this->CSet=this->Misc[GHI_BASE_CSET];
                ghost->Y=176;
                this->Vx=0;
                this->Vy=0;
                for(int i=0; i<10; i++)
                {
                    explosion=Screen->CreateLWeapon(LW_BOMBBLAST);
                    explosion->X=Rand2(this->X, this->X+16*this->TileWidth);
                    explosion->Y=Rand2(this->Y, this->Y+32);
                    explosion->CollDetection=false;
                    Waitframes(30);
                    GhostWaitframeF(this,ghost,true,false);
                }
                
                // Kill NPC and clear combos
                Game->PlaySound(SLM_EXPLODE);
                ghost->HP=-1000;
                this->Data=0;
            
                Quit();
            }
        }
        GhostWaitframeN(this,ghost,true,false);
    }    
}


I get a whole whack of errors, saying that various functions aren't declared. (IsWater, IsPit, Round, CenterX, CenterY as a few examples) Now, if memory serves, there's something in here that's absolute in my script. I did add the flags bit to the fire EWeapon thing, though I don't think I did it right. Anyways, any help is greatly appreciated. With the added shadows, I decided to fix it up and once that's done, I'll release it for public use. icon_smile.gif

#17 Saffith

Saffith

    IPv7 user

  • Members

Posted 18 December 2010 - 09:13 PM

You need a newer version of std.zh.

#18 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 20 December 2010 - 12:38 PM

Aha. Thank you. I'm getting problems again with other things, but it's because I wrote things wrong, so I'll be able to figure it out. icon_wink.gif

#19 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 29 December 2010 - 10:42 PM

I'm trying to make a boss, using Iflyte's code as a base. It complies alright, but it dissapears as soon at appears. I feel that there is something missing from here...

CODE


//Red Dragon Boss

const int RdD_ENEMY_ID=201;



const int RdD_STAND_COMBO=34660;

const int RdD_FIRING_COMBO=34648;

const int RdD_FLYING_COMBO=34636;

const int RdD_SHADOW_COMBO=34684;



const int RdD_FIRE_SPRITE=12;

const int RdD_FIREBALL_SPRITE=17;



ffc script RdD {

void run() {

npc ghost;

while(true) {

Flying(this, ghost);

Firing(this, ghost);

Pausing(this, ghost);

}

}



// Fly around the top of the screen, has a chance of landing at any point. Can only be hurt while on the ground.

void Flying(ffc this, npc ghost) {

int time;



//Make sure that he is in his flying sprites.

Transform(this, ghost, RdD_FLYING_COMBO, 0, 0, 0);



//Makes the dragon unable to be hit while in the air.

SetAllDefenses(ghost, NPCDT_IGNORE);



// Start moving

this->Vy=0;

if(this->X>=104) // X=104 is centered

this->Vx=-1.5;

else

this->Vx=1.5;



time=Rand(180, 480); // 3-8 seconds



for(int i=0; i<time; i++) {

// If at wall, halt and change direction

if(this->X<=32)

this->Vx=0;

time=Rand(25, 35);

this->Vx=1.5;

if(this->X>=172)

this->Vx=0;

time=Rand(25, 35);

this->Vx=-1.5;



//RdDWaitframe(this, ghost);

GhostWaitframeF(this, ghost, true, true);

}

}



//Lands on the ground.

void Pausing(ffc this, npc ghost) {

int time;



// Make him vulnerable.

SetAllDefenses(ghost, NPCDT_BLOCK);

ghost->Defense[NPCD_MAGIC]=NPCDT_NONE;

ghost->Defense[NPCD_REFMAGIC]=NPCDT_NONE;



// Make him change sprites.

Transform(this, ghost, RdD_STAND_COMBO, 0, 0, 0);



// Waits for an amount of time, depending on how much health he has.

if(ghost->HP>24) {

time=Rand(180, 210);

}

else if(ghost->HP>12) {

time=Rand(120, 150);

}

else {

time=Rand(60, 90);

}

//RdDWaitframe(this, ghost);

GhostWaitframeF(this, ghost, true, true);

}

// Is attacking.

void Firing(ffc this, npc ghost) {

eweapon wpn;

int time;



//Make him change sprites once again.

Transform(this, ghost, RdD_FIRING_COMBO, 0, 0, 0);



if(time%60==0 && time>0) {

for(int j=0; j<3; j++) {

wpn=FireEWeapon(EW_SCRIPT1, this->X+24, this->Y+16, j*PI/2, 100, 10, RdD_FIRE_SPRITE, SFX_FIRE, 0);

SetEWeaponLifespan(wpn, EWL_NEAR_LINK, 4);

SetEWeaponDeathEffect(wpn, EWD_8_FIREBALLS, RdD_FIREBALL_SPRITE);

}

}

//RdDWaitframe(this, ghost);

GhostWaitframeF(this, ghost, true, true);

}

}



Using build 1343 and using the minium global script. I'm a novice scripter and the questionable use of whitespace is due to being copypasted from ZSPad.

Edit: and one more thing: this script is only built for functionality (No shadows, no dragon actually overhead, no death animation, ect).

Edited by Orin XD, 30 December 2010 - 05:49 PM.


#20 Saffith

Saffith

    IPv7 user

  • Members

Posted 08 January 2011 - 11:57 PM

It disappears because the npc pointer is invalid. You never actually initialized it; you've got to use one of the GhostInit methods to set up the enemy first.

#21 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 09 January 2011 - 06:25 AM

I was wondering when you would get back to me.

I did what you said, I used the same init that Iflyte uses; ghost=GhostInitWait (ffc this, int enemyIndex, bool useEnemyPos), and it solved the problem of it dissappearing, but it dies instantly (I know that it did because it doesn't return, unlike the previous problem).

The updated script, now including a death animation.

CODE
ffc script RdD {

void run() {

npc ghost;



SetHP(this, ghost, ghost->HP+1000);

ghost=GhostInitWait(this, 1, false);

Trace(ghost->HP);

while(true) {

Flying(this, ghost);

Firing(this, ghost);

Pausing(this, ghost);

}

}



// Fly around the top of the screen, has a chance of landing at any point. Can only be hurt while on the ground.

void Flying(ffc this, npc ghost) {

int time;



//Make sure that he is in his flying sprites.

Transform(this, ghost, RdD_FLYING_COMBO, 0, 0, 0);



//Makes the dragon unable to be hit while in the air.

SetAllDefenses(ghost, NPCDT_IGNORE);



// Start moving

this->Vy=0;

if(this->X>=104) // X=104 is centered

this->Vx=-1.5;

else

this->Vx=1.5;



time=Rand(180, 480); // 3-8 seconds



for(int i=0; i<time; i++) {

// If at wall, halt and change direction

if(this->X<=32)

this->Vx=0;

time=Rand(25, 35);

this->Vx=1.5;

if(this->X>=172)

this->Vx=0;

time=Rand(25, 35);

this->Vx=-1.5;



RdDWaitframe(this, ghost);

}

}



//Lands on the ground.

void Pausing(ffc this, npc ghost) {

int time;



// Make him vulnerable.

SetAllDefenses(ghost, NPCDT_BLOCK);

ghost->Defense[NPCD_MAGIC]=NPCDT_NONE;

ghost->Defense[NPCD_REFMAGIC]=NPCDT_NONE;



// Make him change sprites.

Transform(this, ghost, RdD_STAND_COMBO, 0, 0, 0);



// Waits for an amount of time, depending on how much health he has.

if(ghost->HP>1024) {

time=Rand(180, 210);

}

else if(ghost->HP>1012) {

time=Rand(120, 150);

}

else {

time=Rand(60, 90);

}

RdDWaitframe(this, ghost);

}

// Is attacking.

void Firing(ffc this, npc ghost) {

eweapon wpn;

int time;



//Make him change sprites once again.

Transform(this, ghost, RdD_FIRING_COMBO, 0, 0, 0);



if(time%60==0 && time>0) {

for(int j=0; j<3; j++) {

wpn=FireEWeapon(EW_SCRIPT1, this->X+24, this->Y+16, j*PI/2, 100, 10, RdD_FIRE_SPRITE, SFX_FIRE, 0);

SetEWeaponLifespan(wpn, EWL_NEAR_LINK, 4);

SetEWeaponDeathEffect(wpn, EWD_8_FIREBALLS, RdD_FIREBALL_SPRITE);

}

}

}



void RdDWaitframe(ffc this, npc ghost) {

int time;



GhostWaitframeF(this, ghost, false, false);



if(ghost->HP<=1000) {

Die(this, ghost);

Quit();

}

else {

time=Rand(10, 15);

}

}



// Show a death animation, then remove the enemy.

void Die(ffc this, npc ghost) {

lweapon explosion;



// Stop moving, stop flashing, turn off collision detection

ghost->CollDetection=false;

this->CSet=this->Misc[GHI_BASE_CSET];

this->Vx=0;

this->Vy=0;



// Randomly placed harmless explosions - one every 1/4 second for 4 seconds

for(int i=0; i<16; i++) {

explosion=Screen->CreateLWeapon(LW_BOMBBLAST);

explosion->X=Rand(this->X, this->X+16*this->TileWidth);

explosion->Y=Rand(this->Y, this->Y+16*this->TileHeight);

explosion->CollDetection=false;

Waitframes(15);

}



// Kill NPC and clear combos

ghost->HP=-1000;

this->Data=0;

}

}


I looked through Allergo.log and it gives me this:

CODE
Invalid NPC with UID 0 passed to npc->HP
NPCs on screen have UIDs
Invalid NPC with UID 0 passed to npc->HP
NPCs on screen have UIDs
36.0000[/size][size="1"]


Is there something am I still missing?



#22 Saffith

Saffith

    IPv7 user

  • Members

Posted 09 January 2011 - 09:38 AM

Switch GhostInitWait() and SetHP(). The initialization has to come before anything else that uses the ghost.
You also need to change the arguments to Transform(); if you don't want to change its size, use -1, not 0.

#23 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 09 January 2011 - 07:34 PM

Thanks! That removed one big hurdle, I can now actually kill it by attacking, but I have another problem:

It can now fly left and right across the screen and it can land, but only for a single frame and won't attack (read the comments I put in for more depth). Any global varables that would go undeclared here are declared outside the script.

CODE
ffc script RdD {

void run() {

npc ghost;



ghost=GhostInitWait(this, 1, false);

SetHP(this, ghost, ghost->HP+1000);

while(true) {

Flying(this, ghost);

Firing(this, ghost);

Pausing(this, ghost);

}

}



// Fly around the top of the screen, has a chance of landing at any point. Can only be hurt while on the ground.

void Flying(ffc this, npc ghost) {

int time;



//Make sure that he is in his flying sprites.

Transform(this, ghost, RdD_FLYING_COMBO, 8, -1, -1);



//Makes the dragon unable to be hit while in the air.

SetAllDefenses(ghost, NPCDT_IGNORE);



// Start moving

this->Vy=0;

if(this->X>=104) // X=104 is centered

this->Vx=-1.5;

else

this->Vx=1.5;



time=Rand(180, 480); // 3-8 seconds



for(int i=0; i<time; i++) {

// If at wall, change direction

if(this->X<=32)

this->Vx=1.5;

else if(this->X>=172)

this->Vx=-1.5;



RdDWaitframe(this, ghost);

}

}



//Lands on the ground.

void Pausing(ffc this, npc ghost) {

int time;



// Make him vulnerable.

SetAllDefenses(ghost, NPCDT_BLOCK);

ghost->Defense[NPCD_MAGIC]=NPCDT_NONE;

ghost->Defense[NPCD_REFMAGIC]=NPCDT_NONE;



// Freezes his position.

this->Vx=0;



// Make him change sprites.

Transform(this, ghost, RdD_STAND_COMBO, 8, -1, -1);



// Waits for an amount of time, depending on how much health he has.

if(ghost->HP>1024) {

time=Rand(180, 210);

}

else if(ghost->HP>1012) {

time=Rand(120, 150);

}

else {

time=Rand(60, 90);

}

RdDWaitframe(this, ghost);

}

// Is attacking.

void Firing(ffc this, npc ghost) {

eweapon wpn;

int time;



//Make him change sprites once again.

Transform(this, ghost, RdD_FIRING_COMBO, 8, -1, -1);



if(time%60==0 && time>0) {

for(int j=0; j<3; j++) {

wpn=FireEWeapon(EW_SCRIPT1, this->X+24, this->Y+16, j*PI/2, 100, 10, RdD_FIRE_SPRITE, SFX_FIRE, 0);

SetEWeaponLifespan(wpn, EWL_NEAR_LINK, 4);

SetEWeaponDeathEffect(wpn, EWD_8_FIREBALLS, RdD_FIREBALL_SPRITE);

}

}

}



void RdDWaitframe(ffc this, npc ghost) {

int time;



GhostWaitframeF(this, ghost, false, false);



if(ghost->HP<=1000) {

Die(this, ghost);

Quit();

}

else {

time=Rand(10, 15);

}

}



// Show a death animation, then remove the enemy.

void Die(ffc this, npc ghost) {

lweapon explosion;



// Stop moving, stop flashing, turn off collision detection

ghost->CollDetection=false;

this->CSet=this->Misc[GHI_BASE_CSET];

this->Vx=0;

this->Vy=0;

SetAllDefenses(ghost, NPCDT_IGNORE);



// Randomly placed harmless explosions - one every 1/4 second for 4 seconds

for(int i=0; i<16; i++) {

explosion=Screen->CreateLWeapon(LW_BOMBBLAST);

explosion->X=Rand(this->X, this->X+16*this->TileWidth);

explosion->Y=Rand(this->Y, this->Y+16*this->TileHeight);

explosion->CollDetection=false;

Waitframes(15);

}



// Kill NPC and clear combos

ghost->HP=-1000;

this->Data=0;

}

}





#24 Saffith

Saffith

    IPv7 user

  • Members

Posted 10 January 2011 - 09:49 AM

You've got time variables, but you're never actually doing anything with them. You probably want to use it as an argument to RdDWaitframe() to tell it to wait that many frames.

#25 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 11 January 2011 - 07:49 PM

Thanks! Now that I argumented the RdD Waitframe, the standing part now works correctly, but It still won't fire.

The updated script, now with overhead flying:

CODE
ffc script RdD {

void run() {

npc ghost;



ghost=GhostInitWait(this, 1, false);

SetHP(this, ghost, ghost->HP+1000);

while(true) {

Flying(this, ghost);

Firing(this, ghost);

Pausing(this, ghost);

}

}



// Fly around the top of the screen, has a chance of landing at any point. Can only be hurt while on the ground.

void Flying(ffc this, npc ghost) {

int time;



//Make sure that he is in his flying sprites.

Transform(this, ghost, RdD_FLYING_COMBO, 8, -1, -1);



//Makes the dragon unable to be hit while in the air, and make weapons pass underneath.

SetAllDefenses(ghost, NPCDT_IGNORE);

this->Flags[FFCF_OVERLAY]=true;



// Start moving

this->Vy=0;

if(this->X>=104) // X=104 is centered

this->Vx=-1.5;

else

this->Vx=1.5;



time=Rand(180, 480); // 3-8 seconds



for(int i=0; i<time; i++) {

// If at wall, change direction

if(this->X<=32)

this->Vx=1.5;

else if(this->X>=172)

this->Vx=-1.5;



RdDWaitframe(this, ghost, 1);

}

}



//Lands on the ground.

void Pausing(ffc this, npc ghost) {



// Make him vulnerable.

SetAllDefenses(ghost, NPCDT_BLOCK);

ghost->Defense[NPCD_MAGIC]=NPCDT_NONE;

ghost->Defense[NPCD_REFMAGIC]=NPCDT_NONE;

this->Flags[FFCF_OVERLAY]=false;



// Freezes his position.

this->Vx=0;



// Make him change sprites.

Transform(this, ghost, RdD_STAND_COMBO, 8, -1, -1);





// Waits for an amount of time, depending on how much health he has.

//if(ghost->HP>1024) {

//Waitframes(180);

//}

//else if(ghost->HP>1012) {

//Waitframes(120);

//}

//else {

//Waitframes(60);

//}

RdDWaitframe(this, ghost, 180);

}

// Is attacking.

void Firing(ffc this, npc ghost) {

eweapon wpn;

int time;

//Make him change sprites once again.

Transform(this, ghost, RdD_FIRING_COMBO, 8, -1, -1);



if(time%60==0 && time>0) {

for(int j=0; j<3; j++) {

wpn=FireEWeapon(EW_SCRIPT1, this->X+24, this->Y+16, j*PI/2, 100, 10, RdD_FIRE_SPRITE, SFX_FIRE, 0);

SetEWeaponLifespan(wpn, EWL_NEAR_LINK, 4);

SetEWeaponDeathEffect(wpn, EWD_8_FIREBALLS, RdD_FIREBALL_SPRITE);

}

}

RdDWaitframe(this,ghost, 1);

}



void RdDWaitframe(ffc this, npc ghost, int time) {



GhostWaitframesF(this, ghost, false, false, time);



if(ghost->HP<=1000) {

Die(this, ghost);

Quit();

}

else {

Waitframe();

}

}



// Show a death animation, then remove the enemy.

void Die(ffc this, npc ghost) {

lweapon explosion;



// Stop moving, stop flashing, turn off collision detection

ghost->CollDetection=false;

this->CSet=this->Misc[GHI_BASE_CSET];

this->Vx=0;

this->Vy=0;

SetAllDefenses(ghost, NPCDT_IGNORE);



// Randomly placed harmless explosions - one every 1/4 second for 4 seconds

for(int i=0; i<16; i++) {

explosion=Screen->CreateLWeapon(LW_BOMBBLAST);

explosion->X=Rand(this->X, this->X+16*this->TileWidth);

explosion->Y=Rand(this->Y, this->Y+16*this->TileHeight);

explosion->CollDetection=false;

Waitframes(15);

}



// Kill NPC and clear combos

ghost->HP=-1000;

this->Data=0;

}

}



What do I need now?



#26 Saffith

Saffith

    IPv7 user

  • Members

Posted 12 January 2011 - 10:12 AM

You either need an outer for loop in Firing() where you can initialize and increment time, or you need to remove the conditional. Time is never changed from 0, so the condition is always false.

Edited by Saffith, 12 January 2011 - 10:12 AM.


#27 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 13 January 2011 - 04:54 AM

Thanks, I removed the timed conditional and it worked perfectly

#28 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 19 April 2011 - 11:32 AM

Messing around with this again to make a boss. Damn I love this thing. XD

Anyway, I'm using the weapon death effect that shoots more weapons from it. It works all fine and dandy in other scripts using it, but for some reason in my boss script, when it splits, the sprites are of swords. There doesn't seem to be any arguments for me to tweak in the setting of the death effect to change the sprite, so I'm not sure what I'm doing wrong.

Here's the boss code thus far. It's not commented well right now and a little disorganized, but hopefully you'll be able to see what I did wrong.

Spoiler


The section I'm talking about specifically is in the 3rd state of the boss, or within the if(state==2) area.

EDIT: Also, disregard the comment about what state 2 actually does; I decided to change it and use my original plan for something else.


EDIT: I derped. Badly. Forget this post. After rereading the documentation I see what I was doing wrong. Wow. DX

#29 Saffith

Saffith

    IPv7 user

  • Members

Posted 26 April 2011 - 11:08 PM

Say, would it be a big deal if I switched all the ffc->Misc[] stuff to npc->Misc[]? I want to add a flag that has to go on the npc anyway, and I think it makes more sense to leave this->Misc[] free for the script to use. It shouldn't require any changes to most scripts, and trivial ones for the rest, but I hate to go and break stuff without at least asking.

#30 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 26 April 2011 - 11:19 PM

Doesn't sound like anything too major to fix anyway. Just a simple find and replace if I'm getting this right. :3

I say, if it makes it easier for the user to create with it and makes it more flexible, go for it. icon_smile.gif


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users