Jump to content

Photo

ghost.zh


  • Please log in to reply
645 replies to this topic

#121 Moosh

Moosh

    The Mush

  • Moderators

Posted 01 May 2012 - 10:27 AM

It seems as if the enemy is disconnecting from the ffc occasionally and very briefly causing the phantom hitbox. This only started when I replaced the Ghost_Transform() functions with setting Ghost_Data...

#122 Saffith

Saffith

    IPv7 user

  • Members

Posted 01 May 2012 - 12:28 PM

Try this out, see if it tells you anything helpful.

Code


#123 Moosh

Moosh

    The Mush

  • Moderators

Posted 01 May 2012 - 09:20 PM

QUOTE(Saffith @ May 1 2012, 11:28 AM) View Post

Try this out, see if it tells you anything helpful.

Code


The plot thickens...The hitbox never moves but Link still gets hurt by some invisible entity...

Edit: Well this is embarrassing. I've isolated the cause of the hitbox problem. It was a duplicate of the boss enemy that I still had onscreen from a previous version of the script. icon_heh.gif

OK, so I think I've found a bug. I think I killed a boss offscreen and Zelda Classic didn't like that at all and crashed.
The message I got when I checked allegro.log was:
Invalid value (0) passed to 'Screen->LoadItem'
Pasted about a few hundred times.

Not sure if this is a bug with ghost.zh, my script, or RC3 in general.

Edited by Moosh, 01 May 2012 - 01:52 PM.


#124 Saffith

Saffith

    IPv7 user

  • Members

Posted 01 May 2012 - 09:32 PM

A crash is always a bug in the game, even if it's caused by a buggy script. Can you show me what did it?

#125 Moosh

Moosh

    The Mush

  • Moderators

Posted 01 May 2012 - 09:43 PM

Here's the WIP script that I believe caused the crash. It did it consistently when the enemy died on the very edge of the screen and I noticed that when it dies normally, it teleports up about 50 pixels before exploding.
Notchcode warning!

On closer inspection, it seems that the crash has to do with creating a new enemy at the same time as enemies->item is triggered...

Edited by Moosh, 02 May 2012 - 08:59 AM.


#126 Saffith

Saffith

    IPv7 user

  • Members

Posted 02 May 2012 - 11:20 AM

All right, I'll see if I can find anything.

QUOTE
I noticed that when it dies normally, it teleports up about 50 pixels before exploding.

Replacing while(n->isValid()==true) with while(Ghost_HP>0) should fix that.

#127 Saffith

Saffith

    IPv7 user

  • Members

Posted 03 May 2012 - 02:17 PM

In the interest of reducing boilerplate code and alleviating the difficulty of treating an npc and an ffc as a single conceptual entity, I've written a utility: ghost_zh_converter.zip

This will allow you to treat this as a pointer of type ghost, whose variables and functions are a mix of those defined in ghost.zh and those of ffcs and npcs. The converter will modify the code as necessary to compile and run in ZC.

For example:

CODE
ghost script GhostScriptDemo
{
    void run(int enemyID)
    {
        this->InitAutoGhost(enemyID);
        
        while(true)
        {
            this->MoveTowardLink(this->Step/100, 2);
            DemoWaitframe(this);
        }
    }
    
    void DemoWaitframe(ghost this)
    {
        if(this->Attributes[0]>0)
        {
            if(Link->InputA)
                this->CollDetection=false;
            else
                this->CollDetection=true;
        }
        
        this->Waitframe(true, true);
    }
}


The converter is written in JavaScript and should work in any modern browser. Paste your script, click "Convert," copy the output.

Bear in mind, this is a hastily thrown together demo, not a finished product. It's certainly usable, but I'm not prepared to guarantee it will work perfectly, even if I didn't make any mistakes in writing it. Also, it has the limitation that your ghost pointer must be named this. Any other name will be ignored.

#128 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 03 May 2012 - 10:29 PM

That converter sounds promising. I'd like to see how it works when finished.

I have a suggestion for autoghost... some scripts don't use combos in place of enemy graphics, and it's kind of a pain to go find GH_INVISIBLE_COMBO to put in the enemy's attribute 11. What if we could just put -1 there, and the autoghost global script set it to the invisible combo for us? That would be pretty easy, wouldn't it?

#129 Saffith

Saffith

    IPv7 user

  • Members

Posted 10 May 2012 - 03:14 PM

I'll do that, yeah.


So, I haven't accounted for the no ground/jumping/flying enemy combo and flags yet, and I'm trying to decide how to do that. I'm thinking of adding GHF_FLYING_ENEMY, which will make the enemy be blocked by the flying enemy blocker; otherwise, it would be blocked by the ground or jumping enemy blockers depending on whether Ghost_Z>0. Of course, that won't affect any existing flying enemy scripts, but that's not too awful. Does anyone have a better idea?

Relatedly, does anyone see a problem with making Ghost_CanMove over pits and water true whenever Ghost_Z>0?

#130 Moosh

Moosh

    The Mush

  • Moderators

Posted 16 May 2012 - 11:24 AM

So this probably sounds stupid, but how do I set Ghost_Data in a custom void function? I tried reinitializing the ghosted enemy, but that caused some pretty severe problems...

#131 Saffith

Saffith

    IPv7 user

  • Members

Posted 16 May 2012 - 11:35 AM

Nothing special, just Ghost_Data=whatever;. The Ghost_Init and Ghost_Waitframe functions deal with all the special handling of the Ghost_ variables, so you can treat them like any other.

#132 Saffith

Saffith

    IPv7 user

  • Members

Posted 20 May 2012 - 03:29 PM

Another update.
  • There's now built-in support for multi-FFC enemies like Iflyte.
  • It's now possible to use Screen->DrawCombo rather than making the FFC itself visible. There are three advantages to this:
    • Enemies will correctly be drawn above layers 2 and 4 rather than 1 and 3 (currently, FFCs do appear above layers 2 and 4, but that's a bug).
    • Enemies disappear when the screen is scrolling.
    • Multi-FFC enemies don't actually require multiple FFCs.
  • Enemy blocking combos and flags are now respected.
    • Added GHF_FLYING_ENEMY, which controls whether ground/jumping or flying enemy blockers are checked.
    • Ghost_CanMove and Ghost_CanMovePixel now take an optional argument indicating whether the enemy is in the air; this defaults to Ghost_Z>0.
  • Added flags to restrict an enemies movement to water, including or excluding shallow water.
  • Added a setting to make all Z-axis movement actually use the Y axis.
  • Added a setting to make enemies flicker instead of flash.
  • You can now use an alternate number (-1 by default) instead of GH_INVISIBLE_COMBO to make enemies use the invisible combo.
  • GHF_ flags can no longer be ORed together; they must be set individually. Unfortunate, but it can't be helped; I ran out of bits.
  • Ghost_SetFlags and the init functions with a flags argument are deprecated.
  • Ghost_WaitframeLight now takes ffc and npc arguments. The old version is deprecated and may not work correctly with existing scripts if DrawCombo is enabled.


#133 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 20 May 2012 - 06:06 PM

I took a look at the ghostdemo. What's the deal with these variables: Ghost_X, Vx, etc. Surely those are not declared somewhere?


edit: I see what you did there now, in ghost_waitframe. ..That makes me sad. icon_frown.gif

I would also like to replace the global script with a ffc version, like "ffc script manual_ghost", or "this_screen_has_ghosted_enemies". Is this doable, or is there clean-up logic that needs to execute that would prevent this? (The main reason is I need to control which scripts on which screens will have control over object properties.)

edit2: ninja edit fail.

#134 Saffith

Saffith

    IPv7 user

  • Members

Posted 20 May 2012 - 07:47 PM

QUOTE(Gleeok @ May 20 2012, 07:06 PM) View Post
edit: I see what you did there now, in ghost_waitframe. ..That makes me sad. icon_frown.gif

Hey, I'm the one who has to keep track of it all. icon_razz.gif The alternative is what I used to do instead: store everything in npc->Misc. Not really any better.

QUOTE
I would also like to replace the global script with a ffc version, like "ffc script manual_ghost", or "this_screen_has_ghosted_enemies". Is this doable, or is there clean-up logic that needs to execute that would prevent this?

Sure. This should be all you need:
CODE
ffc script AutoGhoster
{
    void run()
    {
        while(true)
        {
            AutoGhost();
            Waitframe();
        }
    }
}


The only downside is that that'll be before Waitdraw, which means you'll see the first frame of the built-in enemy's spawn animation.

#135 Saffith

Saffith

    IPv7 user

  • Members

Posted 22 May 2012 - 10:18 AM

Quick update, because I made a mistake and potentially broke some scripts (none that I know of, though).
You can easily fix it yourself rather than download it again: add a Waitframe on line 4354.


2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users