Jump to content

Photo

ghost.zh


  • Please log in to reply
645 replies to this topic

#256 Saffith

Saffith

    IPv7 user

  • Members

Posted 31 March 2013 - 10:24 PM

There's no obvious reason why they would interact. Are you using a new save?

#257 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 01 April 2013 - 04:48 PM

QUOTE(Saffith @ Mar 31 2013, 09:24 PM) View Post

There's no obvious reason why they would interact. Are you using a new save?


I'm using my quest save file from day 1. I still have no idea why the armos would freeze. Since you are the creator of such a useful and stunning file, I thought you could help me Saffith, any reasons why the armos are freezing?

P.S. HAPPY APRIL FOOL'S DAY EVERYONE!!!!! icon_razz.gif

#258 Saffith

Saffith

    IPv7 user

  • Members

Posted 01 April 2013 - 07:09 PM

QUOTE(demonlink14 @ Apr 1 2013, 05:48 PM) View Post
I'm using my quest save file from day 1.

When you add new scripts to a quest, it can invalidate saved games, so you generally need to start a new game. That's the only thing I can think of here. The scripts appear to be combined correctly, and there's no reason they should interfere with each other, so I don't think it's an issue with the scripts themselves.
If that's not the problem, make sure you have the quest rule "Log Script Errors To Allegro.log" enabled and see if anything's logged after the knights try to run.

#259 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 01 April 2013 - 09:16 PM

QUOTE(Saffith @ Apr 1 2013, 06:09 PM) View Post

When you add new scripts to a quest, it can invalidate saved games, so you generally need to start a new game. That's the only thing I can think of here. The scripts appear to be combined correctly, and there's no reason they should interfere with each other, so I don't think it's an issue with the scripts themselves.
If that's not the problem, make sure you have the quest rule "Log Script Errors To Allegro.log" enabled and see if anything's logged after the knights try to run.

Thanks Saffith! I just needed to start a new save file after all... Thanks.

#260 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 02 April 2013 - 02:16 AM

http://www.purezc.co...showtopic=57416

#261 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 April 2013 - 08:55 PM

I'm having a problem compiling when including ghost.zh...

The error I get is:
Pass 3 Building Symbol Tree
Ghost.zh/init.zh, Line 106: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 107: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 108: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 315: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 316: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 317: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 340: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 341: Error S10 Function PrintF is undeclared
Ghost.zh/init.zh, Line 342: Error S10 Function PrintF is undeclared

Am I using an outdated ghost.zh file? (It's the one from the 1st post in this thread...)

The main script ghost.zh is in the same directory as my .qst and other .z and .zh files; the ghost_zh directory is in the same directory as the ghost.zh script, so the files-system looks like this:

/ZeldaClassic/2.50Final/quest.qst
/ZeldaClassic/2.50Final/quest.z
/ZeldaClassic/2.50Final/ghost.zh
/ZeldaClassic/2.50Final/ghost_zh/
/ZeldaClassic/2.50Final/ffcscript.zh
/ZeldaClassic/2.50Final/ZQuest.exe
/ZeldaClassic/2.50Final/ZLaunch.exe
/ZeldaClassic/2.50Final/Zelda-w.exe

Am I supposed to dump the contents of /ZeldaClassic/2.50Final/ghost_zh/ into /ZeldaClassic/2.50Final/ ?
I did not do this, as I presumed they were in their own directory for a reason.

(Obviously, 'quest' is relative to the quest I'm using, so there are several .qst and .z files that share a quest name.)


Here is my main .z script at present, in case it matters. I stripped out other incomplete or broken scripts and commented out one that I am working on right now that I intend to create a counter system for my Timestop Scrolls.

CODE

import "std.zh"
import "ffcscript.zh"
import "ghost.zh"

//const int SFX_ERROR = 0; //In case you want an error SFX

const int SFX_MAGICCHARGE = 53;
const int SFX_LIGHTARROW = 1;
const int lightColor = 134; //Color of the charging ring: CSet# * 16 + color# (from 0 to 15)
const int WPS_NONE = 101; //Weapon sprite with an empty tile (for superlight arrow)

//Item power: Same scale as any other item's damage stat
//D0: Time (in frames) to charge the arrow (Recommended: 25)
//D1: Weap/Misc sprite to use (34 is golden arrow sprite)
//D2: Magic required (expended as you start charging) (8)
//D3: Speed of the arrow (same scale as enemy step speed) (500 for normal; 2500 for super)
//D4: # of the FFC script (check as you assign it to a slot)
item script lightArrow{
    void run(int chargeTime, int arrowSprite, int magicCost, int speed, int ffcScriptNum){
        if ( Game->Counter[CR_MAGIC] < magicCost || !Game->Counter[CR_ARROWS] ){
            Game->PlaySound(SFX_ERROR);     //Comment out to remove error SFX
            return;
        }
        if(CountFFCsRunning(ffcScriptNum) == 0){
            int args[4] = {this->Power*2, chargeTime, arrowSprite, speed};
            Game->Counter[CR_MAGIC] -= magicCost;
            RunFFCScript(ffcScriptNum, args);
        }
    }
}

ffc script lightArrowFFC{
    void run(int power, int chargeTime, int arrowSprite, int speed){
        int startHP = Link->HP;
        lweapon lArrow;
        Game->PlaySound(SFX_MAGICCHARGE);
        for(int i = chargeTime; i > 0; i--){ //Charge duration
            NoAction(); //Freeze Link
            //Display charging animation: gold circle (non-filled) appears and shrinks (radius)
            Screen->Circle ( 7, Link->X+8, Link->Y+8, 20*i/chargeTime, lightColor, 1, 0, 0, 0, false, 64 );
            if ( Link->HP < startHP )
                return; //If Link is hurt, quit
            Waitframe();
        }
        
        //Charging done! Shoot that arrow!
        Link->Action = LA_ATTACKING;
        Game->Counter[CR_ARROWS]--;
        Game->PlaySound(SFX_LIGHTARROW);
        lArrow = NextToLink(LW_ARROW, 8);                        //Create in front of Link
        lArrow->UseSprite(arrowSprite);                            //Graphics
        lArrow->Damage = power;                                    //Damage
        lArrow->Step = speed;                                    //Speed
        if ( Link->Dir == DIR_DOWN ){                            //Sprite selection/rotation
            lArrow->Flip = 3;
        }
        else if ( Link->Dir == DIR_LEFT ){
            lArrow->Tile++;
            lArrow->Flip = 1;
        }
        else if ( Link->Dir == DIR_RIGHT ){
            lArrow->Tile++;
        }
    }
}

ffc script superLightArrowFFC{
    void run(int power, int chargeTime, int arrowSprite, int speed){
        int startX;
        int startY;
        int startHP = Link->HP;
        lweapon lArrow;
        Game->PlaySound(SFX_MAGICCHARGE);
        for(int i = chargeTime; i > 0; i--){ //Charge duration
            NoAction(); //Freeze Link
            //Display charging animation: random lines from Link of random length
            for ( int j = 0; j < 5; j++ ){
                int angle = Rand(360);
                Screen->Arc(7, Link->X+8, Link->Y+8, Rand(50)+1, angle, angle+1, lightColor, 1, 0, 0, 0, true, false, 128);
            }
            if ( Link->HP < startHP )
                return; //If Link is hurt, quit
            Waitframe();
        }
        
        //Charging done! Shoot that arrow!
        startX = Link->X+8;
        startY = Link->Y+8;
        Link->Action = LA_ATTACKING;
        Game->Counter[CR_ARROWS]--;
        Game->PlaySound(SFX_LIGHTARROW);
        lArrow = NextToLink(LW_ARROW, 8);                        //Create in front of Link
        lArrow->UseSprite(WPS_NONE);                            //Graphics (invisible)
        lArrow->Damage = power;                                    //Damage
        lArrow->Step = speed;                                    //Speed
        
        for ( int i = 0; i < 30; i++ ){ //For 30 frames
            Screen->Line(4, startX, startY, lArrow->X+8, lArrow->Y+8, lightColor, 1, 0, 0, 0, 128); //Draw a line from Link to the arrow
            lArrow->DeadState = WDS_ALIVE; //Keep it alive at all times
            Waitframe();
        }
        lArrow->DeadState = WDS_DEAD;
    }
}



//Usable Clock (Or other things??)
//D0 - Item to use for clock.(or whatever) If doing clock, this needs to be a clock item with duration set.
//Note: The default clock item is 4.
//D1 - Amount of time to Jinx link. (0 for no Jinx)
//Note: The Jinx can be used to create a small pause before the item
//can be used again. You can also make it the clock duration, but this
//is only recommended in quests that aren't using the B+A item setting
//configuration.

item script usedclock{

void run(int clockitem, int jinxtime){

item givenclock = Screen->CreateItem(4);
givenclock->X = Link->X;
givenclock->Y = Link->Y;
givenclock->Z = Link->Z;
Link->ItemJinx = 2;


}

}


//Magical Key
//D0 - Item to use for clock.(or whatever) If doing clock, this needs to be a clock item with duration set.
//Note: The default clock item is 4.
//D1 - Amount of time to Jinx link. (0 for no Jinx)
//Note: The Jinx can be used to create a small pause before the item
//can be used again. You can also make it the clock duration, but this
//is only recommended in quests that aren't using the B+A item setting
//configuration.

item script magicalkey{

void run(int keyitem, int jinxtime){

item givenkey = Screen->CreateItem(9);
givenkey->X = Link->X;
givenkey->Y = Link->Y;
givenkey->Z = Link->Z;
Link->ItemJinx = 0;


}


}

int healsfx = 64; //Sound effect to play when Link is healed
int errorsfx = 65; //Sound effect to play when Link's HP is full or MP is empty

item script heal6heart{
  void run(int m, int h){
    if(Link->MP >= m && Link->HP < Link->MaxHP){
        Link->HP += 96;
        Link->MP -= 64;
        Game->PlaySound(healsfx);
    }
    else{
    Game->PlaySound(errorsfx);
    }
    
  }
}


item script heal12heart{
  void run(int m, int h){
    if(Link->MP >= m && Link->HP < Link->MaxHP){
        Link->HP += 196;
        Link->MP -= 200;
        Game->PlaySound(healsfx);
    }
    else{
    Game->PlaySound(errorsfx);
    }
    
  }
}



item script restoremagic{
  void run(int m, int h){
    if(Link->HP >= m && Link->MP < Link->MaxMP){
        Link->HP += 0;
        Link->MP += 200;
        Game->PlaySound(healsfx);
    }
    else{
    Game->PlaySound(errorsfx);
    }
    
  }
}

//D0 = Rupeegain

ffc script GetRupees{
    void run(int rup){
    Game->Counter[CR_RUPEES]+rup;
    }
}


//Rupee Loss - Jinx

ffc script LoseRupees{
    void run(int rup){
    Game->Counter[CR_RUPEES]-rup;
    }
}


//Mirror Teleporter Script


const int SFX_MIRROR = 62; //Sound on successful warp
const int SFX_ERROR = 61; //SFX number of an error sound
const int CMB_AUTOWARPA = 0; //Transparent combo with "Auto Side Warp A" combo type

item script mirror{
    void run (){
        int targetDMap; //DMap to warp to
        int targetMap; //Map (not DMap) to warp to
        if (Game->GetCurDMap() == 1){ //First possible DMap
            targetDMap = 1; //Sample origin/destination DMap change
            targetMap = 2;
        }
        else if (Game->GetCurDMap() == 2){ //Second DMap
            targetDMap = 0; //All other ones start with "else"
            targetMap = 1;
        }
        else{ //Invalid DMap
            Game->PlaySound(SFX_ERROR);
            return;
        }
        if ( Game->GetComboSolid(targetMap, Game->GetCurScreen(), ComboAt(Link->X+8,Link->Y+8)) ){
            Game->PlaySound(SFX_ERROR);
            return;
        }
        Game->PlaySound(SFX_MIRROR);
        Screen->SetSideWarp(0, Game->GetCurDMapScreen(), targetDMap, WT_IWARPWAVE);
        Screen->ComboD[0] = CMB_AUTOWARPA; //Trigger the warp
    }
}

// //Timestop Scroll Item

//const int CR_TSCROLL = 0;

//Game->Counter(CR_TSCROLL) == 0;

//bool CanPickupTScroll
//{
//    return(Game->Counter(CR_TSCROLL) = < 255)
//}

Edited by ZoriaRPG, 02 April 2013 - 09:07 PM.


#262 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 03 April 2013 - 08:46 AM

You forgot this line...
import "string.zh"

#263 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 April 2013 - 05:55 PM

Wow, I don't remember seeing that in any of the script examples that I read that have include "ghost.zh" in the header. Thank you very much; it now compiles and I can start doing even trickier things.

I need ghost.zh for the follower scripts, as an example, and I want to use those in a Doctor Who themed quest. Come on... we all know that darknuts are Daleks in disguise... icon_smile.gif

Edited by ZoriaRPG, 03 April 2013 - 05:57 PM.


#264 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 05 April 2013 - 08:17 AM

Hey Saffith, did my method of incrementing the step of dummy eweapons of type EW_FIRE by one work or no?

#265 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 April 2013 - 06:50 AM

I have a global script and would also like to use GhostZHAcriveScript... Where can I insert the code from my global script so that it becomes part of GhostZHActiveScript?

#266 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 07 April 2013 - 03:50 PM

Basically you need to check where the statements in the other global scripts you have (after run(), after while(true), after Waitdraw(), etc.) and move the statements to the same place in GhostZHActiveScript. If the other script doesn't use Waitdraw() I think you can place the statements anywhere within the while(true) loop (as long as they were inside that loop in the source script).

Unrelated question: how would I go about making an enemy deal no damage/knockback to Link but still take damage itself? One way would be to turn the collision detection off and check for lweapons each frame, but I haven't messed with lweapons. Is there any easy setting for it?

#267 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 07 April 2013 - 04:38 PM

Checking for LWeapons isn't too hard. You'd need a loop like this to get all the lweapons on the screen:

CODE

for(int Instance = Screen->NumLWeapons(); Instance > 0; Instance --){
                lweapon Wpn = Screen->LoadLWeapon(Instance);
                               //Do stuff with Wpn here
}


For seeing if the Lweapon's hitting the enemy, you can check the collision like if(Collision(Wpn, ghost)).

#268 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 07 April 2013 - 05:24 PM

Looks pretty straightforward; I'm guessing that you can use variables like Wpn->ID on that to do things for specific ones.

#269 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 07 April 2013 - 09:11 PM

Can we use Ghost_Waitframe() as the condition for the main loop of our autoghost enemies?

#270 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 10 April 2013 - 08:59 PM

Almost-daily question time!

If I'm using SetEWeaponMovement() with EWM_THROW as the type, does setting arg1 to -1 account for the Z position of the projectile when the function is called? It's slightly off depending on Link's position, and I'm thinking that the starting Z value of 20 might be throwing it off.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users