Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //NPC.ZH
- //An attempt to port guys.cpp functions to ZScript
- //for use by npc scripts
- bool isjumper(npc n)
- {
- switch(n->family)
- {
- case NPCT_ROCK:
- case NPCT_TEKTITE:
- return true;
- case NPCT_WALK:
- if(n->Attributes[8] == NPCA_WALK_WS_VIRE ) return true;
- else if(n->Attributes[8] == NPCA_WALK_WS_POLSVOICE ) return true;
- return false;
- default: return false;
- }
- }
- bool isfixedtogrid(npc n)
- {
- switch(n->family)
- {
- case NPCT_WALK:
- case NPCT_LEEVER:
- case NPCT_ZORA:
- case NPCT_DODONGO:
- case NPCT_GANON:
- case NPCT_ROCK:
- case NPCT_GLEEOK:
- case NPCT_AQUAMENTUS:
- case NPCT_LANMOLA:
- return true;
- default: return false;
- }
- }
- // Can't fall, can have Z value.
- bool isflier(npc n)
- {
- switch(n->family) //id&0x0FFF)
- {
- case NPCT_PEAHAT:
- case eeKEESE:
- case eePATRA:
- case eeFAIRY:
- case eeGHINI:
- // Could theoretically have their Z set by a script
- //case eeFIRE: //this is 'NPCT_OTHER'
- return true;
- default: return false;
- }
- }
- bool never_in_air(npc n)
- {
- switch(n->family)
- {
- case NPCT_MANHANDLA:
- case NPCT_MOLDORM:
- case NPCT_LANMOLA:
- case NPCT_GLEEOK:
- case NPCT_ZORA:
- case NPCT_LEEVER:
- case NPCT_AQUAMENTUS:
- case NPCT_ROCK:
- case NPCT_GANON:
- case NPCT_TRAP:
- case NPCT_PROJECTILE:
- case NPCT_SPINTILE:
- return true;
- default: return false;
- }
- }
- bool canfall(npc n)
- {
- /*
- switch(n->amily)
- {
- case eeGUY:
- {
- if(id < eOCTO1S)
- return false;
- switch(guysbuf[id&0xFFF].misc10)
- {
- case 1:
- case 2:
- return true;
- case 0:
- case 3:
- default:
- return false;
- }
- case eeGHOMA:
- case eeDIG:
- return false;
- }
- }
- */
- if ( never_in_air(n) ) return false;
- if ( isflier(n) ) return false;
- if ( isjumper(n) ) return false;
- return true;
- }
- // returns true if next step is ok, false if there is something there
- bool canmove(npc n, int ndir, float step,int special,int dx1,int dy1,int dx2,int dy2)
- {
- bool ok;
- int dx = 0, dy = 0;
- int sv = 8;
- step += 0.5; // Make the ints round; doesn't seem to cause any problems.
- switch(ndir)
- {
- case 8:
- case DIR_UP:
- if(canfall(id) && tmpscr->flags7&fSIDEVIEW)
- return false;
- dy = dy1-step;
- special = (special==spw_clipbottomright)?spw_none:special;
- ok = !m_walkflag(n->X,n->Y+dy,special, n->X, n->Y) && !flyerblocked(n->X,n->Y+dy, special);
- break;
- case 12:
- case DIR_DOWN:
- if(canfall(id) && tmpscr->flags7&fSIDEVIEW)
- return false;
- dy = dy2+step;
- ok = !m_walkflag(n->X,n->Y+dy,special, n->X, n->Y) && !flyerblocked(n->X,n->Y+dy, special);
- break;
- case 14:
- case DIR_LEFT:
- dx = dx1-step;
- sv = ((tmpscr->flags7&fSIDEVIEW)?7:8);
- special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
- ok = !m_walkflag(n->X+dx,n->Y+sv,special, n->X, n->Y) && !flyerblocked(n->X+dx,n->Y+8, special);
- break;
- case 10:
- case DIR_RIGHT:
- dx = dx2+step;
- sv = ((tmpscr->flags7&fSIDEVIEW)?7:8);
- ok = !m_walkflag(n->X+dx,n->Y+sv,special, n->X, n->Y) && !flyerblocked(n->X+dx,n->Y+8, special);
- break;
- case 9:
- case DIR_RIGHTUP:
- dx = dx2+step;
- dy = dy1-step;
- ok = !m_walkflag(n->X,n->Y+dy,special, n->X, n->Y) && !m_walkflag(n->X+dx,n->Y+sv,special, n->X, n->Y) &&
- !flyerblocked(n->X,n->Y+dy, special) && !flyerblocked(n->X+dx,n->Y+8, special);
- break;
- case 11:
- case r_down:
- dx = dx2+step;
- dx = dy2+step;
- ok = !m_walkflag(n->X,n->Y+dy,special, n->X, n->Y) && !m_walkflag(n->X+dx,n->Y+sv,special, n->X, n->Y) &&
- !flyerblocked(n->X,n->Y+dy, special) && !flyerblocked(n->X+dx,n->Y+8, special);
- break;
- case 13:
- case DIR_LEFTDOWN:
- dx = dx1-step;
- dy = dy2+step;
- ok = !m_walkflag(n->X,n->Y+dy,special, n->X, n->Y) && !m_walkflag(n->X+dx,n->Y+sv,special, n->X, n->Y) &&
- !flyerblocked(n->X,n->Y+dy, special) && !flyerblocked(n->X+dx,n->Y+8, special);
- break;
- case 15:
- case DIR_LEFTUP:
- dx = dx1-step;
- dy = dy1-step;
- ok = !m_walkflag(n->X,n->Y+dy,special, n->X, n->Y) && !m_walkflag(n->X+dx,n->Y+sv,special, n->X, n->Y) &&
- !flyerblocked(n->X,n->Y+dy, special) && !flyerblocked(n->X+dx,n->Y+8, special);
- break;
- default:
- db=99;
- return true;
- }
- return ok;
- }
Add Comment
Please, Sign In to add comment