atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRDY; atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO|ATAPI_INTREASON_COMMAND; } else { // indicate data ready: set DRQ and DMA ready, and IO in INTREASON if (atapi_regs[ATAPI_REG_FEATURES] & 0x01) // DMA feature { atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_BSY | ATAPI_STAT_DRDY | ATAPI_STAT_SERVDSC; } else { atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC | ATAPI_STAT_DRQ; } atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO; } switch( phase ) { case SCSI_PHASE_DATAOUT: atapi_cdata_wait = atapi_xferlen; break; } // perform special ATAPI processing of certain commands switch (atapi_data[0]&0xff) { case 0x00: // BUS RESET / TEST UNIT READY case 0xbb: // SET CDROM SPEED atapi_regs[ATAPI_REG_CMDSTATUS] = 0; break;
int Creature::flee(bool magicTerror, bool wimpyFlee) { Monster* mThis = getAsMonster(); Player* pThis = getAsPlayer(); if(!magicTerror && !canFlee(true, false)) return(0); if(mThis || magicTerror || wimpyFlee) { if(wimpyFlee && pThis) pThis->setFleeing(true); doFlee(magicTerror); } else { *this << "You frantically look around for someplace to flee to!\n"; pThis->setFleeing(true); } return(1); }
void Creature::removeStatEffects() { Player* pThis = getAsPlayer(); if(pThis) { pThis->loseRage(); pThis->loseFrenzy(); pThis->losePray(); } removeEffect("strength"); removeEffect("enfeeblement"); removeEffect("haste"); removeEffect("slow"); removeEffect("fortitude"); removeEffect("weakness"); removeEffect("insight"); removeEffect("feeblemind"); removeEffect("prayer"); removeEffect("damnation"); }
bool Creature::hasCharm(bstring charmed) { etag *cp=0; if(charmed == "") return(false); Player* player = getAsPlayer(); if(!player) return(false); cp = player->first_charm; while(cp) { if(!strcmp(cp->enemy, charmed.c_str())) return(true); cp = cp->next_tag; } return(false); }
void Creature::attackDelay(long delay) { if(delay < 1) return; getAsPlayer()->updateAttackTimer(true, delay*10); }
bool Creature::doFlee(bool magicTerror) { Monster* mThis = getAsMonster(); Player* pThis = getAsPlayer(); BaseRoom* oldRoom = getRoomParent(), *newRoom=0; UniqueRoom* uRoom=0; Exit* exit=0; unsigned int n=0; if(isEffected("fear")) magicTerror = true; exit = getFleeableExit(); if(!exit) { printColor("You couldn't find any place to run to!\n"); if(pThis) pThis->setFleeing(false); return(0); } newRoom = getFleeableRoom(exit); if(!newRoom) { printColor("You failed to escape!\n"); return(0); } switch(mrand(1,10)) { case 1: print("You run like a chicken.\n"); break; case 2: print("You flee in terror.\n"); break; case 3: print("You run screaming in horror.\n"); break; case 4: print("You flee aimlessly in any direction you can.\n"); break; case 5: print("You run screaming for your mommy.\n"); break; case 6: print("You run as your life flashes before your eyes.\n"); break; case 7: print("Your heart throbs as you attempt to escape death.\n"); break; case 8: print("Colors and sounds mingle as you frantically flee.\n"); break; case 9: print("Fear of death grips you as you flee in panic.\n"); break; case 10: print("You run like a coward.\n"); break; default: print("You run like a chicken.\n"); break; } broadcast(getSock(), oldRoom, "%M flees to the %s^x.", this, exit->getCName()); if(mThis) { mThis->diePermCrt(); if(exit->doEffectDamage(this)) return(2); mThis->deleteFromRoom(); mThis->addToRoom(newRoom); } else if(pThis) { pThis->dropWeapons(); pThis->checkDarkness(); unhide(); if(magicTerror) printColor("^rYou flee from unnatural fear!\n"); Move::track(getUniqueRoomParent(), ¤tLocation.mapmarker, exit, pThis, false); if(pThis->flagIsSet(P_ALIASING)) { pThis->getAlias()->deleteFromRoom(); pThis->getAlias()->addToRoom(newRoom); } Move::update(pThis); pThis->statistics.flee(); if(cClass == CreatureClass::PALADIN && deity != GRADIUS && !magicTerror && level >= 10) { n = level * 8; n = MIN<long>(experience, n); print("You lose %d experience for your cowardly retreat.\n", n); experience -= n; } if(exit->doEffectDamage(this)) return(2); pThis->deleteFromRoom(); pThis->addToRoom(newRoom); for(Monster* pet : pThis->pets) { if(pet && inSameRoom(pThis)) broadcast(getSock(), oldRoom, "%M flees to the %s^x with its master.", pet, exit->getCName()); } } exit->checkReLock(this, false); broadcast(getSock(), newRoom, "%M just fled rapidly into the room.", this); if(pThis) { pThis->doPetFollow(); uRoom = newRoom->getAsUniqueRoom(); if(uRoom) pThis->checkTraps(uRoom); if(Move::usePortal(pThis, oldRoom, exit)) Move::deletePortal(oldRoom, exit); } return(1); }
bool Creature::canFleeToExit(const Exit *exit, bool skipScary, bool blinking) { Player *pThis = getAsPlayer(); // flags both players and mobs have to obey if(!canEnter(exit, false, blinking) || exit->flagIsSet(X_SECRET) || exit->isConcealed(this) || exit->flagIsSet(X_DESCRIPTION_ONLY) || exit->flagIsSet(X_NO_FLEE) || exit->flagIsSet(X_TO_STORAGE_ROOM) || exit->flagIsSet(X_TO_BOUND_ROOM) || exit->flagIsSet(X_TOLL_TO_PASS) || exit->flagIsSet(X_WATCHER_UNLOCK) ) return(false); if(pThis) { if( (( getRoomParent()->flagIsSet(R_NO_FLEE) || getRoomParent()->flagIsSet(R_LIMBO) ) && inCombat()) || (exit->flagIsSet(X_DIFFICULT_CLIMB) && !isEffected("levitate")) || ( ( exit->flagIsSet(X_NEEDS_CLIMBING_GEAR) || exit->flagIsSet(X_CLIMBING_GEAR_TO_REPEL) || exit->flagIsSet(X_DIFFICULT_CLIMB) ) && !isEffected("levitate") ) ) return(false); int chance=0, *scary; // should we skip checking for scary exits? skipScary = skipScary || fd == -1 || exit->target.mapmarker.getArea() || isEffected("fear"); // are they scared of going in that direction if(!skipScary && pThis->scared_of) { scary = pThis->scared_of; while(*scary) { if(exit->target.room.id && *scary == exit->target.room.id) { // oldPrint(fd, "Scared of going %s^x!\n", exit->getCName()); // there is a chance we will flee to this exit anyway chance = 65 + bonus((int) dexterity.getCur()) * 5; if(getRoomParent()->flagIsSet(R_DIFFICULT_TO_MOVE) || getRoomParent()->flagIsSet(R_DIFFICULT_FLEE)) chance /=2; if(mrand(1,100) < chance) return(false); // success; means that the player is now scared of this room if(inUniqueRoom() && fd > -1) { scary = pThis->scared_of; { int roomNum = getUniqueRoomParent()->info.id; if(scary) { int size = 0; while(*scary) { size++; if(*scary == roomNum) break; scary++; } if(!*scary) { // LEAK: Next line reported to be leaky: 10 count pThis->scared_of = (int *) realloc(pThis->scared_of, (size + 2) * sizeof(int)); (pThis->scared_of)[size] = roomNum; (pThis->scared_of)[size + 1] = 0; } } else { // LEAK: Next line reported to be leaky: 10 count pThis->scared_of = (int *) malloc(sizeof(int) * 2); (pThis->scared_of)[0] = roomNum; (pThis->scared_of)[1] = 0; } } } return(true); } scary++; } } } return(true); }
bool Creature::canFlee(bool displayFail, bool checkTimer) { bool crtInRoom=false; long t=0; int i=0; if(isMonster()) { if(!flagIsSet(M_WILL_FLEE) || flagIsSet(M_DM_FOLLOW)) return(false); if(hp.getCur() > hp.getMax()/5) return(false); if(flagIsSet(M_PERMENANT_MONSTER)) return(false); } else { //Player* pThis = getPlayer(); if(!ableToDoCommand()) return(false); if(flagIsSet(P_SITTING)) { if(displayFail) print("You have to stand up first.\n"); return(false); } if(isEffected("hold-person")) { if(displayFail) print("You are unable to move right now.\n"); return(false); } // blah blah re-submit if( (cClass == CreatureClass::BERSERKER || cClass == CreatureClass::CLERIC) && isEffected("berserk") ) { if(displayFail) printColor("^rYour lust for battle prevents you from fleeing!\n"); return(false); } if(checkTimer && !isEffected("fear") && !isStaff()) { t = time(0); i = MAX(getLTAttack(), MAX(lasttime[LT_SPELL].ltime,lasttime[LT_READ_SCROLL].ltime)) + 3L; if(t < i) { if(displayFail) pleaseWait(i-t); return(false); } } // confusion and drunkenness overrides following checks if(isEffected("confusion") || isEffected("drunkenness")) return(true); // players can only flee if someone/something else is in the room for(Monster* mons : getConstRoomParent()->monsters) { if(!mons->isPet()) { crtInRoom = true; break; } } if(!crtInRoom) { for(Player* ply : getConstRoomParent()->players) { if(ply == this) continue; if(!ply->isStaff()) { crtInRoom = true; break; } } } if( !crtInRoom && !checkStaff("There's nothing to flee from!\n") ) { getAsPlayer()->setFleeing(false); return(false); } } return(true); }