User Tag List

Results 1 to 10 of 13

Thread: Attempting to Fix Ghost.zh

Threaded View

Previous Post Previous Post   Next Post Next Post
  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.

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