Jump to content

Photo

ghost.zh


  • Please log in to reply
645 replies to this topic

#181 Saffith

Saffith

    IPv7 user

  • Members

Posted 09 December 2012 - 09:15 PM

EWeapons are ignored as long as Misc[__EWI_FLAGS] is 0. __EWI_FLAGS is 15 by default. LWeapons are always ignored

#182 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 09 December 2012 - 09:36 PM

...Derp. Somehow didn't realize that ghost does nothing with LWeapons when I posted that. ._.

Anyhow, thanks! icon_smile.gif That made my life easier with a few things I'm writing up. icon_biggrin.gif

#183 Saffith

Saffith

    IPv7 user

  • Members

Posted 10 December 2012 - 01:16 AM

Erm, sorry. Left a bug in one of the FindSpawnPoint functions. Fixed now. icon_redface.gif

#184 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 14 December 2012 - 04:52 PM

Okay, I have been trying to write a function that heals the enemy but it doesn't work. Mind you that this is not the whole script.
Code (Contains spoilers of the final boss of ZLW)

I can confirm that the function is working, but it just won't heal. I ran a Drawprimitive gauge to confirm that it isn't healing but the healing animation works as intended. Also, I wonder why Ghost_HP is somehow undeclared in this function. An error perhaps? Mind you that I am using an older version of Ghost.zh, with the init functions with the flag augments, but I haven't seen anything in the changelog that relates to Ghost_HP.

Edit: I would also like to have certain EWeapons bounce off walls. Hopefully it would be simple to do.

Edited by Orin XD, 14 December 2012 - 05:12 PM.


#185 Saffith

Saffith

    IPv7 user

  • Members

Posted 14 December 2012 - 05:32 PM

You should be using Ghost_HP. I can only guess that you mistyped it before; there's no other reason why it should be undeclared.

There's no movement type in ghost.zh to make eweapons reflect, but it's not too hard.
CODE
float xComp=RadianCos(wpn->Angle);
float yComp=RadianSin(wpn->Angle);
bool reflect=false;

if((xComp<0 && Screen->isSolid(wpn->X+2, wpn->Y+8)) ||
   (xComp>0 && Screen->isSolid(wpn->X+14, wpn->Y+8)))
{
    reflect=true;
    xComp=-xComp;
}

if((yComp<0 && Screen->isSolid(wpn->X+8, wpn->Y+2)) ||
   (yComp>0 && Screen->isSolid(wpn->X+8, wpn->Y+14)))
{
    reflect=true;
    yComp=-yComp;
}

if(reflect)
    wpn->Angle=ArcTan(xComp, yComp);

You might need to fiddle with it a bit, but that's the general idea.

#186 Da Masta Sord

Da Masta Sord

    The Official Masta Sord of ZC.

  • Members
  • Location:In a pedastal in the lost woods.

Posted 20 December 2012 - 08:51 PM

a script for the enemy Twin Amoeba by Saffith

my script

CODE
import "std.zh"
import "string.zh"
import "ghost.zh"


const float TWA_JUMP_SPEED=2; // Speed in pixels per frame when jumping

// npc->Attributes[] indices
const int TWA_ATTR_SLIME_ID=0;
const int TWA_ATTR_JUMP_SOUND=1;
const int TWA_ATTR_LAND_SOUND=2;
const int TWA_ATTR_JUMPY=3;

ffc script TwinAmoeba
{
    void run(int enemyID)
    {
        npc ghost;
        npc slime[2];
        int currentSlime;
        bool jumpy;
        lweapon wpn;
        int i;
        
        // Initialize
        ghost=Ghost_InitAutoGhost(this, enemyID);
        Ghost_SetFlag(GHF_NO_FALL);
        Ghost_SetFlag(GHF_CLOCK);
        Ghost_SetFlag(GHF_SET_OVERLAY);
        Ghost_SpawnAnimationPuff(this, ghost);
        currentSlime=0;
        jumpy=ghost->Attributes[TWA_ATTR_JUMPY]!=0;
        
        // Create the first slime at the core's position; the second is randomly placed
        slime[0]=Screen->CreateNPC(ghost->Attributes[TWA_ATTR_SLIME_ID]);
        slime[0]->X=Ghost_X;
        slime[0]->Y=Ghost_Y;
        slime[1]=SpawnNPC(ghost->Attributes[TWA_ATTR_SLIME_ID]);
        
        Ghost_SetAllDefenses(slime[0], NPCDT_IGNORE);
        Ghost_SetAllDefenses(slime[1], NPCDT_IGNORE);
        
        while(true)
        {
            // If the core just got hit, jump to the other slime
            if(Ghost_GotHit())
            {
                SlimeJump(this, ghost, slime[currentSlime], slime[currentSlime^1], true);
                currentSlime^=1; // Switch index between 0 and 1
            }
            // If Link is too close and the other slime is farther, jump over
            else if(Distance(Ghost_X, Ghost_Y, Link->X, Link->Y)<32)
            {
                if(SlimeJump(this, ghost, slime[currentSlime], slime[currentSlime^1], false))
                    currentSlime^=1;
            }
            else if(jumpy)
            {
                // Jumpy ones jump whenever a weapon is too close
                for(i=Screen->NumLWeapons(); i>0; i--)
                {
                    wpn=Screen->LoadLWeapon(i);
                    
                    // This could be a lot of checks, so just look at X and Y difference
                    if(Abs(wpn->X-Ghost_X)<32 && Abs(wpn->Y-Ghost_Y)<32)
                    {
                        SlimeJump(this, ghost, slime[currentSlime], slime[currentSlime^1], true);
                        currentSlime^=1;
                        break;
                    }
                }
            }
            
            Ghost_X=slime[currentSlime]->X;
            Ghost_Y=slime[currentSlime]->Y;
            
            TwAWaitframe(this, ghost, slime[0], slime[1]);
        }
    }
    
    
    // Jump from one slime to the other. If not forced, it won't jump if the other slime is
    // closer to Link. Returns true if it jumps, false if not.
    bool SlimeJump(ffc this, npc ghost, npc startSlime, npc destSlime, bool force)
    {
        // If not forced, see if the destination slime is closer to Link than the starting slime;
        // if so, don't do anything
        if(!force)
        {
            if(Distance(startSlime->X, startSlime->Y, Link->X, Link->Y)>=Distance(destSlime->X, destSlime->Y, Link->X, Link->Y))
                return false;
        }
    
        int startX;
        int startY;
        int targetX;
        int targetY;
        float angle;
        float totalDist;
        float currentDist;
        
        // Ignore clocks while jumping so the core doesn't get stuck in midair
        Ghost_UnsetFlag(GHF_CLOCK);
        Game->PlaySound(ghost->Attributes[TWA_ATTR_JUMP_SOUND]);
        
        // Jump
        do
        {
            // Get the current position of the two slimes
            startX=startSlime->X;
            startY=startSlime->Y;
            targetX=destSlime->X;
            targetY=destSlime->Y;
            
            // Move toward one from the other
            angle=Angle(Ghost_X, Ghost_Y, targetX, targetY);
            Ghost_X+=VectorX(TWA_JUMP_SPEED, angle);
            Ghost_Y+=VectorY(TWA_JUMP_SPEED, angle);
            
            // Set height based on how much of the total distance has been covered
            totalDist=Distance(startX, startY, targetX, targetY);
            currentDist=Distance(Ghost_X, Ghost_Y, targetX, targetY);
            Ghost_Z=totalDist/2*Sin(currentDist/totalDist*180);
            
            TwAWaitframe(this, ghost, startSlime, destSlime);
        } while(currentDist>1);
        
        Ghost_Z=0;
        Ghost_SetFlag(GHF_CLOCK);
        Game->PlaySound(ghost->Attributes[TWA_ATTR_LAND_SOUND]);
        return true;
    }
    
    
    void TwAWaitframe(ffc this, npc ghost, npc slime1, npc slime2)
    {
        // The slimes should be invincible, but if one becomes invalid, kill everything
        if(!slime1->isValid())
        {
            ghost->HP=0;
            if(slime2->isValid())
                slime2->HP=0;
            this->Data=0;
            Quit();
        }
        else if(!slime2->isValid())
        {
            ghost->HP=0;
            slime1->HP=0;
            this->Data=0;
            Quit();
        }
        
        // Still valid - try to keep them alive, no matter what
        else
        {
            if(slime1->HP<32768)
                slime1->HP=32768;
            if(slime2->HP<32768)
                slime2->HP=32768;
        }
        
        // If the core is dead, kill the slimes as well
        if(!Ghost_Waitframe(this, ghost, true, false))
        {
            slime1->HP=0;
            slime2->HP=0;
            Quit();
        }
    }
}

Help error noooooooo!

Pass 1: Parsing
Pass 2: Preprocessing
Can't open input file
ghost.zh, line 89: Error P01 : Failure to parse imported file ghost_zh/update.zh.

I'm using Autoghost script version 2.5 RC5 latest version

by Saffith

You probably didn't extract the ghost_zh directory, which needs to go into the ZC directory along with ghost.zh

I didn't see a ghost_zh directory in the ghost.zh download 2.5 RC5 version file
do you extract the files with a zip program first because I did that.Is there is a ghost_zh directory somwhere?
I did see the ghost_legacy.zh

Edited by Da Masta Sord, 20 December 2012 - 08:54 PM.


#187 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 21 December 2012 - 12:18 AM

You need to download the most recent copy of the ghost.zh package (linked on the first post), and extract ghost.zh and the ghost_zh folder into your ZC folder.

#188 Da Masta Sord

Da Masta Sord

    The Official Masta Sord of ZC.

  • Members
  • Location:In a pedastal in the lost woods.

Posted 21 December 2012 - 01:46 AM

THANK YOU YOU DON'T KNOW HOW LONG IV'E WAITED FOR A RESPONSE!

#189 Saffith

Saffith

    IPv7 user

  • Members

Posted 21 December 2012 - 09:15 AM

Five hours, fifty-eight minutes. icon_razz.gif


Anyway, another small update, requiring 2.50. I added another way to set up AutoGhost enemies. Set misc. attribute 12 to -1 and put the script name in the enemy's name after @, for instance:
Goriya (LttP, green) @Goriya_LttP

Also, I added constants to control flashing and knockback, so now you can fling enemies clear across the screen if you like.

#190 Da Masta Sord

Da Masta Sord

    The Official Masta Sord of ZC.

  • Members
  • Location:In a pedastal in the lost woods.

Posted 21 December 2012 - 02:24 PM

I just upgraded to ghost.zh version 2.5.1 and it gave me this when I tried to compile the Amoeba Twin script Pass 1: Parsing
Pass 2: Preprocessing
Pass 3: Building symbol tables
Pass 4: Type-checking/Completing function symbol tables/Constant folding
ghost_zh/global.zh, line 319: Error T28: That pointer type does not have a function GetFFCScript.



#191 Saffith

Saffith

    IPv7 user

  • Members

Posted 21 December 2012 - 02:33 PM

You're still using RC5. It needs 2.50 now. http://www.zeldaclas...m/downloads.php

#192 Mero

Mero

    Touch Fluffy Tail

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

Posted 21 December 2012 - 05:32 PM

About the name @ script name format.
If we use this format is it okay to use Misc Attribute 11 for whatever we want?

#193 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 21 December 2012 - 07:21 PM

QUOTE(Saffith @ Dec 21 2012, 09:15 AM) View Post

I added another way to set up AutoGhost enemies. Set misc. attribute 12 to -1 and put the script name in the enemy's name after @, for instance:
Goriya (LttP, green) @Goriya_LttP


This is beautiful. Thank you for that! icon_biggrin.gif

I will also have fun messing with the knockback bit. Is this something that can be set on a per-enemy basis or is it a global number?


#194 Mero

Mero

    Touch Fluffy Tail

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

Posted 21 December 2012 - 07:34 PM

QUOTE(SpacemanDan @ Dec 21 2012, 05:21 PM) View Post

I will also have fun messing with the knockback bit. Is this something that can be set on a per-enemy basis or is it a global number?


Unfortunately no, it's a constant. It's in ghost.zh if you feel like changing it.

#195 Saffith

Saffith

    IPv7 user

  • Members

Posted 21 December 2012 - 07:41 PM

QUOTE(blackbishop89 @ Dec 21 2012, 05:32 PM) View Post
About the name @ script name format.
If we use this format is it okay to use Misc Attribute 11 for whatever we want?

No, you still need that for the combo. This doesn't allow you to do anything new, it's just meant to simplify setup a bit.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users