User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Attempting to Fix Ghost.zh

  1. #1
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%

    Attempting to Fix Ghost.zh

    First up: random rate is ignored in one of the functions. __Ghost_NewDir4 to be exact.
    CODE: Show
    // Used by walk functions to pick a new direction
    void __Ghost_NewDir4(int rate, int homing, int hunger)
    {
    int newDir=-1;
    // Go for bait?
    if(Rand(4)<hunger)
    {
    // See if any is on the screen
    lweapon bait=LoadLWeaponOf(LW_BAIT);

    if(bait->isValid())
    {
    // Found bait; try to move toward it
    if(Abs(Ghost_Y-bait->Y)>14)
    {
    if(bait->Y<Ghost_Y)

    newDir=DIR_UP;
    else
    newDir=DIR_DOWN;

    if(__Ghost_CanMoveNES(newDir, 1, 0))
    {
    Ghost_Dir=newDir;
    return;
    }
    }

    if(bait->X<Ghost_X)
    newDir=DIR_LEFT;
    else
    newDir=DIR_RIGHT;

    if(__Ghost_CanMoveNES(newDir, 1, 0))
    {
    Ghost_Dir=newDir;
    return;
    }
    }
    } // End hunger check

    // Homing?
    if(Rand(256)<homing)
    {
    newDir=__Ghost_LinedUp(8, false);
    if(newDir>=0 && __Ghost_CanMoveNES(newDir, 1, 0))
    {
    Ghost_Dir=newDir;
    return;
    }
    }

    // Check solidity of surrounding combos
    bool combos[4];
    int numDirs;
    int ndir;

    for(int i=0; i<4; i++)
    {
    if(__Ghost_CanMoveNES(i, 1, 0))
    {
    combos[i]=true;
    // numDirs++;
    }
    }

    int i=0;

    for(; i <32; i++)
    {
    int r=Rand(255);

    if((r&15)<rate)
    ndir=(r>>4)&3;
    else
    ndir=Ghost_Dir;

    if(combos[ndir])
    break;
    }

    if(i==32)
    {
    for(ndir=0; ndir<4; ndir++)
    {
    if(combos[ndir])
    break;
    }

    if(ndir==4) //Trapped
    {
    // if(IsSideView)
    // ndir=Cond(Rand(1,DIR_LEFT,DIR_RIGHT)) //Sideview Enemies bug out if their dir becomes -1
    // else
    ndir=-1;
    }
    }

    Ghost_Dir=ndir;
    }


    Note this hasn't been tested, since it's my second attempt this morning. This is acutely how ZC does it. So yeah a lot of shit is different from the original random direction code. Yeah the enemy code is weird. Oh yeah before I forget. In case you want to help when you got some spare time. Here's a tag. @Saffith

    edit: Works like a charm regardless of rate. Tested it with a normal enemy and a ghost enemy using the walk function.

    Next up is Dummy Weapons... ugh
    Last edited by Tamamo; 09-19-2015 at 01:07 PM.

  2. #2
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    This fix was a colloborative effort and fixes the following.
    1. EWF_ROTATE_360 is no longer drawn while link is dying. "tamamo"
    2. Dummy weapons work now. "lejes"
    3. Big EWeapons can have EWF_ROTATE_360 "saffith"

    http://pastebin.com/9RZFD6VJ

    Let me know if you guys have any problems.

  3. #3
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    CODE: Show
    void Ghost_WaitframeLight(ffc this, npc ghost)
    {
    // Remember all the global variables

    // Initializing the array is faster than setting it up afterward...
    // but the difference is probably negligible, realistically
    float tempGhostData[24] = {
    Ghost_X, // 0
    Ghost_Y, // 1
    Ghost_Z, // 2
    Ghost_Jump, // 3
    Ghost_Vx, // 4
    Ghost_Vy, // 5
    Ghost_Ax, // 6
    Ghost_Ay, // 7
    __Ghost_PrevX, // 8
    __Ghost_PrevY, // 9
    Ghost_CSet, // 10
    Ghost_Dir, // 11
    Ghost_Data, // 12
    Ghost_TileWidth, // 13
    Ghost_TileHeight, // 14
    __Ghost_Flags, // 15
    __Ghost_Flags2, // 16
    __Ghost_InternalFlags, // 17
    __Ghost_FlashCounter, // 18
    __Ghost_KnockbackCounter, // 19
    Ghost_HP, // 20
    __Ghost_XOffsets, // 21
    __Ghost_YOffsets // 22
    // 23 is for either drawingData or tempGhostAdditionalCombos;
    // update DrawGhostFFCs if that changes
    };
    int tempGhostAdditionalCombos[21]; // Same size as __Ghost_AdditionalCombos
    // Change it in the loop below, too
    if(__Ghost_AdditionalCombos[0]>0)
    {
    for(int i=0; i<21; i++)
    tempGhostAdditionalCombos[i]=__Ghost_AdditionalCombos[i];
    }

    // Give ghost an array pointer so its data can be found by other scripts
    if(ghost->isValid())
    ghost->Misc[__GHI_NPC_DATA]=0x10000|tempGhostData;

    // Position additional FFCs, set draw data, make FFCs invisible if flickering.
    do
    {
    if(ghost->isValid())
    {
    // Set up drawing array if needed. The array size depends on what
    // might need drawn. If only ZScript had malloc...
    if(__GH_USE_DRAWCOMBO!=0)
    {
    // DrawCombo and additional combos
    if(__Ghost_AdditionalCombos[__GHI_AC_COUNT]>0)
    {
    // Array size is 4 + (__GH_AC_MAX_ADDITIONAL_COMBOS + 1) * __GHCD_DATA_SIZE
    int drawData[34];
    __SetUpDrawingArray(this, ghost, drawData);
    tempGhostData[23]=drawData;
    __HideFFCAndWait(this);
    }

    // DrawCombo and no additional combos
    else
    {
    // 4 + __GHCD_DATA_SIZE
    int drawData[10];
    __SetUpDrawingArray(this, ghost, drawData);
    tempGhostData[23]=drawData;
    __HideFFCAndWait(this);
    }
    }
    else // __GH_USE_DRAWCOMBO==0
    {
    // Additional combos, no DrawCombo
    if(__Ghost_AdditionalCombos[__GHI_AC_COUNT]>0)
    {
    // 4 + __GH_AC_MAX_ADDITIONAL_COMBOS * __GHCD_DATA_SIZE
    int drawData[28];
    __SetUpDrawingArray(this, ghost, drawData);
    tempGhostData[23]=drawData;

    // Hide the FFC if the enemy is flickering.
    if(__Ghost_IsFlickering(ghost) &&
    (__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_FLICKER)!=0)
    __HideFFCAndWait(this);
    else
    Waitframe();
    }

    // No DrawCombo or additional combos
    else
    {
    if(__Ghost_IsFlickering(ghost) &&
    (__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_FLICKER)==0)
    __HideFFCAndWait(this);
    else
    Waitframe();
    }
    }
    }
    else // ghost is not valid
    __HideFFCAndWait(this);

    // Restore the global variables
    Ghost_X=tempGhostData[0];
    Ghost_Y=tempGhostData[1];
    Ghost_Z=tempGhostData[2];
    Ghost_Jump=tempGhostData[3];
    Ghost_Vx=tempGhostData[4];
    Ghost_Vy=tempGhostData[5];
    Ghost_Ax=tempGhostData[6];
    Ghost_Ay=tempGhostData[7];
    __Ghost_PrevX=tempGhostData[8];
    __Ghost_PrevY=tempGhostData[9];
    Ghost_CSet=tempGhostData[10];
    Ghost_Dir=tempGhostData[11];
    Ghost_Data=tempGhostData[12];
    Ghost_TileWidth=tempGhostData[13];
    Ghost_TileHeight=tempGhostData[14];
    __Ghost_Flags=tempGhostData[15];
    __Ghost_Flags2=tempGhostData[16];
    __Ghost_InternalFlags=tempGhostData[17];
    __Ghost_FlashCounter=tempGhostData[18];
    __Ghost_KnockbackCounter=tempGhostData[19];
    Ghost_HP=tempGhostData[20];
    __Ghost_XOffsets=tempGhostData[21];
    __Ghost_YOffsets=tempGhostData[22];

    if(tempGhostAdditionalCombos[0]>0)
    {
    for(int i=0; i<21; i++)
    __Ghost_AdditionalCombos[i]=tempGhostAdditionalCombos[i];
    }
    else
    __Ghost_AdditionalCombos[0]=0; //this is all I added

    } while((__ghzhData[__GHI_GLOBAL_FLAGS]&__GHGF_SUSPEND)!=0);

    if(ghost->isValid())
    ghost->Misc[__GHI_NPC_DATA]=0x10000;
    }


    Goes in update.zh by the way. Fixes some bugs with Additional combos.

    edit: whoops posted again. My mistake. Here's update 4... Custom pits.

    Put this in ghost.zh
    CODE: Show
    const int __GH_CUSTOM_PITS = 0;

    bool __Ghost_IsPit(int combo)
    {
    if(__GH_CUSTOM_PITS!=0)
    {
    //Insert the check for a custom pit here.
    //Besure you return a true/false statement
    }
    else
    return IsPit(combo);
    }


    And replace line 467 in movement.zh with this.

    if(__Ghost_IsPit(combo)
    Last edited by Tamamo; 09-19-2015 at 07:44 PM.

  4. #4
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,433
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.03%
    I know, I've been lazy. I've pretty much got this stuff done, I just have one or two more things I want to do and haven't gotten around to.

  5. #5
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    @Saffith
    No honey, you haven't been lazy at all. This past week you've been working on ZC Stuff, I keep a eye on beta news my good friend. So it's all good no worries. It's just that when your scripts you write don't work. You need to debug ghost.zh and fix it yourself our wait for you patiently to be able to get around to finishing it. Being a seasoned programmer and scripter like yourself I chose the former only so I could get my Z2 enemies working in prime condition upon zscript release "1000 lines of code right there folks". Also any chance we can have EWF_FAKE_Z to. That was the one thing I couldn't figure out how to do. :/
    Last edited by Tamamo; 10-03-2015 at 09:25 AM.

  6. #6
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    @Saffith
    So I was thinking this morning about the problem with adding EWF_FAKE_Z. And I might have an idea to make it work. Some of the misc indices are always integers and don't go that high, such as __EWI_MOVEMENT which goes to like 30 something. It might be possible to use one of those and some dark binary mathematics in order to fake implement __EWI_ZPOS without using another index. Thoughts?

  7. #7
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,433
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.03%
    I just did it with hit and draw offsets. Amusingly, although it's called fake Z, it's really using eweapon->Z and faking not using it.

  8. #8
    Here lies mero. Died by his own dumbassitude.
    Join Date
    May 2011
    Posts
    929
    Mentioned
    102 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    5,527
    Level
    23
    vBActivity - Bars
    Lv. Percent
    13.96%
    @Saffith
    DOH! That's how GH_FAKE_Z works! Why didn't I think of that.
    So what else is left?

  9. #9
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    41
    Posts
    3,389
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,433
    Level
    24
    vBActivity - Bars
    Lv. Percent
    70.03%
    A bit of testing and documentation.

  10. #10
    Quest Builder Anarchy_Balsac's Avatar
    Join Date
    Nov 2005
    Posts
    751
    Mentioned
    11 Post(s)
    Tagged
    2 Thread(s)
    vBActivity - Stats
    Points
    2,593
    Level
    16
    vBActivity - Bars
    Lv. Percent
    64.18%
    I don't know if this is known or not, but it also has a nasty habit of fucking with your global variables. I tried an autoghost script today from pureZC (The Acid Handla to be Specific), but all my game's global variables reset, and didn't unreset until after I deleted not only the new code, but ghost.zh as well.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social