Jump to content

Photo

ghost.zh


  • Please log in to reply
645 replies to this topic

#91 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 24 September 2011 - 12:26 AM

Okay, I tried using two of the autoghost enemies; Homing Fireball Shooter and WallBouncer. I'm using the Classic set. WallBouncer works alright, but Homing Fireball Shooter appears to do nothing. I've traced it and I discovered that the script doesn't reach the While Loop. I'll show the code here because I made a few alterations, namley the arrangement of the braces.

CODE
ffc script HomingFireballShooter{
    void run(int enemyID){
        npc ghost;
        eweapon fireball;
        int damage;
        int step;
        float turnSpeed;
        int homingTime;
        int sprite;
        int sound;
        int flags=0;
        
        // Initialize
        ghost=Ghost_InitAutoGhost(this, enemyID);
        
        // Get enemy settings
        damage=ghost->WeaponDamage;
        
        step=ghost->Attributes[HFS_ATTR_FIREBALL_STEP];
        if(step<=0){
            step=HFS_DEFAULT_FIREBALL_STEP;
        }
        turnSpeed=ghost->Attributes[HFS_ATTR_FIREBALL_TURN_SPEED]/1000;
        if(turnSpeed<=0){
            turnSpeed=HFS_DEFAULT_FIREBALL_TURN_SPEED/1000;
        }
        homingTime=ghost->Attributes[HFS_ATTR_FIREBALL_HOMING_TIME];
        if(homingTime<=0){
            homingTime=HFS_DEFAULT_FIREBALL_HOMING_TIME;
        }
        sprite=ghost->Attributes[HFS_ATTR_FIREBALL_SPRITE];
        if(sprite<=0){
            sprite=HFS_DEFAULT_FIREBALL_SPRITE;
        }
        sound=ghost->Attributes[HFS_ATTR_FIRE_SOUND];
        
        if(ghost->Attributes[HFS_ATTR_SHIELD_LEVEL]<0){
            flags|=EWF_UNBLOCKABLE;
        }
        else if(GetCurrentShieldLevel()<ghost->Attributes[HFS_ATTR_SHIELD_LEVEL]){
            flags|=EWF_UNBLOCKABLE;
        }
        if(ghost->Attributes[HFS_ATTR_FIREBALL_ROTATE]>0){
            flags|=EWF_ROTATE;
        }
        
        while(true){ //The script does not appear to be running through this loop - I've applied Trace to it and found nothing.
            Ghost_Waitframes(this, ghost, true, true, Rand(HFS_MIN_FIRE_TIME, HFS_MAX_FIRE_TIME));
            
            if(Distance(Ghost_X, Ghost_Y, Link->X, Link->Y)>=HFS_MIN_DISTANCE){
                fireball=FireAimedEWeapon(EW_FIREBALL, Ghost_X, Ghost_Y, 0, step, damage, sprite, sound, flags);
                SetEWeaponMovement(fireball, EWM_HOMING, turnSpeed);
                SetEWeaponLifespan(fireball, EWL_TIMER, homingTime);
            }
        }
    }
    
    int GetCurrentShieldLevel(){
     itemdata id;
     int ret = -1;
     int curlevel = -1;
    
     // Check each item
     for(int i = 0; i < 256; i++){
         // Does Link have this item?
      if(!Link->Item[i]){
          continue;
         }
         // Is it a shield?
      id = Game->LoadItemData(i);
      if(id->Family != IC_SHIELD){
       continue;
      }
      // Check its level
      if(id->Level > curlevel){
          curlevel = id->Level;
      }
     }
    
     return curlevel;
    }
}


Edit: I figgured that I should put my enemy attributes here:

CODE
Enemy Type - other
HP - 2
Wpn Dmg - 2
Misc. attr.1 - 0
Misc. attr.2 - 0
Misc. attr.3 - 0
Misc. attr.4 - -1
Misc. attr.5 - 0
Misc. attr.6 - 1
Misc. attr.7 - 40
Misc. attr.11 - 8 (Transparent combo)
Misc. attr.12 - 1 (My script slot for the Homing Fireball Shooter)




Is there any problems with Ghost ZH itself or is there any mistake on my part?


Edited by Orin XD, 24 September 2011 - 12:35 AM.


#92 Imzogelmo

Imzogelmo

    Experienced Forumer

  • Members
  • Real Name:Joseph

Posted 25 September 2011 - 02:56 AM

I'm not sure what the difference is, as mine works fine. Are you standing far enough away from the shooter? Not that it would stop it from creating, but it won't fire if you're too close. Also, try putting an Enemys always return screen flag on the screen you're testing with, just to make sure it's not counting it as killed when you test.


Aside from that, I'm not sure what would cause it.

I made a couple of tweaks to the script and I thought it may be interesting enough to share. The changes are to turn collision detection off for the shooter enemy (as the original Zelda had no collision there) and to make the safe distance an attribute value so you can vary it and have different values if desired.

It's long so I'll hide it


#93 Moosh

Moosh

    The Mush

  • Moderators

Posted 05 November 2011 - 08:18 PM

I'm trying to import ghost.zh and having issues. I keep getting the message "GHOST.ZH, LINE 335: ERROR S10: FUNCTION PRINTF IS UNDECLARED.". What am I doing wrong? icon_frown.gif

#94 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 05 November 2011 - 08:26 PM

You also need to import string.zh.

It took me awhile to figure that one out. DX

#95 Moosh

Moosh

    The Mush

  • Moderators

Posted 05 November 2011 - 09:41 PM

QUOTE(SpacemanDan @ Nov 5 2011, 07:26 PM) View Post

You also need to import string.zh.

It took me awhile to figure that one out. DX

That is just eeeevil! So I guess now I'm back to getting normal errors due to my somewhat unresponsive R key like "HOLY COW MAN WHAT KIND OF A POINTER IS Sceen!?" icon_razz.gif

How do I change an aimed eweapon's weapon movement? This is giving me a lot of trouble.

Edited by Pokemonmaster64, 05 November 2011 - 09:40 PM.


#96 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 05 November 2011 - 09:57 PM

You'll probably want to use this:

SetEWeaponMovement(eweapon wpn, int type, int arg)

What the type and args are can be found in Ghost.txt.

I hope that's what you were asking for and I didn't misinterpret or something. icon_xd.gif

#97 Moosh

Moosh

    The Mush

  • Moderators

Posted 05 November 2011 - 10:22 PM

QUOTE(SpacemanDan @ Nov 5 2011, 08:57 PM) View Post

You'll probably want to use this:

SetEWeaponMovement(eweapon wpn, int type, int arg)

What the type and args are can be found in Ghost.txt.

I hope that's what you were asking for and I didn't misinterpret or something. icon_xd.gif

Well I've tried eweapon e=FireAimedEWeapon(various crap goes here) followed by SetEWeaponMovement(e, type goes here, argument goes here) for pretty much every movement type and it hasn't worked...icon_frown.gif

#98 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 05 November 2011 - 11:15 PM

Do you have the global script imported that comes with ghost.zh? I believe without it things won't quite work. (Or if you use the UpdateEWeapon() in your global script each frame, but I find it easier to just use the global script that comes with it already. :3)

#99 Moosh

Moosh

    The Mush

  • Moderators

Posted 05 November 2011 - 11:27 PM

QUOTE(SpacemanDan @ Nov 5 2011, 10:15 PM) View Post

Do you have the global script imported that comes with ghost.zh? I believe without it things won't quite work. (Or if you use the UpdateEWeapon() in your global script each frame, but I find it easier to just use the global script that comes with it already. :3)

OK, so now I have the problem of it not doing anything solved, but I'd like some help on the sine wave and sine wave fast movement styles which (I assume) you used on that one boss that you broke in that one video. They seem to be behaving a bit strange. To they require some sort of additional setup? I'm trying to make a goriya's boomerang travel in a sine wave pattern.

#100 Moosh

Moosh

    The Mush

  • Moderators

Posted 07 November 2011 - 12:36 PM

So the problem with the sine wave function has been fixed by not using the boomerang eweapon. Bummer it couldn't work with it...Now I have the problem that shadows aren't showing up even if I use DrawEWeaponShadow() every frame.

#101 Mero

Mero

    Touch Fluffy Tail

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

Posted 07 November 2011 - 12:39 PM

Do you have the shadow tile set correctly in ghost.zh?

#102 Saffith

Saffith

    IPv7 user

  • Members

Posted 07 November 2011 - 01:49 PM

Sorry I've been gone so long. I'll get around to updating this at some point. icon_razz.gif

QUOTE(Pokemonmaster64 @ Nov 7 2011, 01:36 PM) View Post

So the problem with the sine wave function has been fixed by not using the boomerang eweapon. Bummer it couldn't work with it...Now I have the problem that shadows aren't showing up even if I use DrawEWeaponShadow() every frame.

Is wpn->Z greater than 0? Shadows aren't drawn for weapons on the ground.

#103 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 15 January 2012 - 09:49 PM

Here's a question I'm going to ask only because I'm a little afraid to look into the inner working of this thing. icon_heh.gif

Does it heavily use the NPC Misc array? I only ask because I'm thinking of using a slot in there for something else, but if it messed with Ghost.zh too much, I'm certain I can find a work around. :3 I'm kinda doubtful that it would use all 16, but I figure I should ask. icon_wink.gif If it does, which slots are free?

#104 Saffith

Saffith

    IPv7 user

  • Members

Posted 15 January 2012 - 09:52 PM

It uses one slot, 15 by default. You can set which it uses by changing __GHI_IN_USE.


... I should really get around to updating this thing. icon_razz.gif

#105 Saffith

Saffith

    IPv7 user

  • Members

Posted 28 February 2012 - 08:26 PM

A long overdue update.

- Finally added handling for sideview screens
- Improved movement functions a bit (in particular, 4-way walking should work much better now)
- Added GHF_FULL_TILE_MOVEMENT, which makes the enemy consider a combo completely solid if any quadrant of it is
- Various bug fixes


I'm still only so happy with the movement functions. I was thinking about rewriting them completely, but that's proven rather tricky, so it'll have to wait for the next version.
There's no handling yet for the No Ground Enemies combo and flag. I might just have GHF_NO_FALL control that, or maybe it could depend on the enemy type being Other (Floating). Any other ideas?

Another question (don't make me triple post, now icon_razz.gif). I was thinking I could add a debug mode, but I'm not entirely sure what it would do. Any ideas there? And since it would make scripts larger and (marginally) slower, is it even worth doing? I could also make a separate ghost_debug.zh. That'd be more work to maintain, but I don't think that's too big a concern.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users