int joinRoom(int curClient, int prevRoom, int prevSpot) { if(strcmp(buf, "0") == 0) { addToRoom(curClient, 0, prevRoom, prevSpot); return 1; } else if(strcmp(buf, "1") == 0) { addToRoom(curClient, 1, prevRoom, prevSpot); return 1; } else if(strcmp(buf, "2") == 0) { addToRoom(curClient, 2, prevRoom, prevSpot); return 1; } else if(strcmp(buf, "3") == 0) { addToRoom(curClient, 3, prevRoom, prevSpot); return 1; } else if(strcmp(buf, "4") == 0) { addToRoom(curClient, 4, prevRoom, prevSpot); return 1; } else if(strcmp(buf, "5") == 0) { addToRoom(curClient, 5, prevRoom, prevSpot); return 1; } return 0; }
int Monster::mobileCrt() { BaseRoom *newRoom=0; AreaRoom *caRoom = getAreaRoomParent(); int i=0, num=0, ret=0; bool mem=false; if( !flagIsSet(M_MOBILE_MONSTER) || flagIsSet(M_PERMENANT_MONSTER) || flagIsSet(M_PASSIVE_EXIT_GUARD) ) return(0); if(nearEnemy()) return(0); for(Exit* exit : getRoomParent()->exits) { // count up exits if(mobileEnter(exit)) i += 1; } if(!i) return(0); num = mrand(1, i); i = 0; for(Exit* exit : getRoomParent()->exits) { if(mobileEnter(exit)) i += 1; if(i == num) { // get us out of this room if(!Move::getRoom(this, exit, &newRoom)) return(0); if(newRoom->isAreaRoom()) { mem = newRoom->getAsAreaRoom()->getStayInMemory(); newRoom->getAsAreaRoom()->setStayInMemory(true); } // make sure there are no problems with the new room if(!newRoom) return(0); if(newRoom->countCrt() >= newRoom->getMaxMobs()) return(0); // no wandering between live/construction areas if(newRoom->isConstruction() != getRoomParent()->isConstruction()) return(0); if(exit->flagIsSet(X_CLOSED) && !exit->flagIsSet(X_LOCKED)) { broadcast(nullptr, getRoomParent(), "%M just opened the %s.", this, exit->getCName()); exit->clearFlag(X_CLOSED); } if(flagIsSet(M_WILL_SNEAK) && flagIsSet(M_HIDDEN)) setFlag(M_SNEAKING); if( flagIsSet(M_SNEAKING) && mrand (1,100) <= (3+dexterity.getCur())*3) { broadcast(::isStaff, getSock(), getRoomParent(), "*DM* %M just snuck to the %s.", this,exit->getCName()); } else { Creature* lookingFor = nullptr; if(flagIsSet(M_CHASING_SOMEONE) && hasEnemy() && ((lookingFor = getTarget(false)) != nullptr) ) { broadcast(nullptr, getRoomParent(), "%M %s to the %s^x, looking for %s.", this, Move::getString(this).c_str(), exit->getCName(), lookingFor->getCName()); } else broadcast(nullptr, getRoomParent(), "%M just %s to the %s^x.", this, Move::getString(this).c_str(), exit->getCName()); clearFlag(M_SNEAKING); } // see if we can recycle this room deleteFromRoom(); if(caRoom && newRoom == caRoom && newRoom->isAreaRoom()) { newRoom = Move::recycle(newRoom->getAsAreaRoom(), exit); } addToRoom(newRoom); // reset stayInMemory if(newRoom->isAreaRoom()) newRoom->getAsAreaRoom()->setStayInMemory(mem); lasttime[LT_MON_WANDER].ltime = time(0); lasttime[LT_MON_WANDER].interval = mrand(5,60); ret = 1; break; } } if(mrand(1,100) > 80) clearFlag(M_MOBILE_MONSTER); return(ret); }