void MonsterAI::update(Actor *owner) { if (owner->destructible && owner->destructible->isDead()) { return; } moveOrAttack(owner, engine.player->x,engine.player->y); }
void PlayerAi::update(Actor *owner) { if(owner->destructible && owner->destructible->isDead()) { return; } int dx = 0, dy = 0; switch(engine.lastKey.vk) { case TCODK_UP : dy = -1; break; case TCODK_DOWN : dy = 1; break; case TCODK_LEFT : dx = -1; break; case TCODK_RIGHT : dx = 1; break; case TCODK_CHAR : handleActionKey(owner, engine.lastKey.c); break; default: break; } if(dx != 0 || dy != 0) { engine.gameStatus = Engine::NEW_TURN; if(moveOrAttack(owner, owner->x + dx, owner->y + dy)) { engine.map->computeFov(); } } }
void PlayerAi::update(Actor *owner) { if (owner->destructible && owner->destructible->isDead()) { return; } int dx = 0, dy = 0; if (engine.lastKey.vk == TCODK_UP || engine.lastKey.c == 'k') dy = -1; else if (engine.lastKey.vk == TCODK_DOWN || engine.lastKey.c == 'j') dy = 1; else if (engine.lastKey.vk == TCODK_LEFT || engine.lastKey.c == 'h') dx = -1; else if (engine.lastKey.vk == TCODK_RIGHT || engine.lastKey.c == 'l') dx = 1; if (dx != 0 || dy != 0) { if (moveOrAttack(owner, owner->x + dx, owner->y + dy)) engine.computeFov = true; } if ((int)TCODSystem::getElapsedMilli() < engine.player->blinded) { // compute empty Fov while blinded engine.computeFov = false; engine.map->emptyFov(); } else if (engine.player->blinded > 0) { // Force computeFov once when blind ends engine.computeFov = true; engine.player->blinded = 0; } }
void Player::update() { if ( isDead() ) { return; } int dx = 0; int dy = 0; switch(engine.lastKey.vk) { case TCODK_CHAR: switch (engine.lastKey.c) { case 'w': dy--; break; case 'e': dy--; dx++; break; case 'd': dx++; break; case 'c': dy++; dx++; break; case 'x': dy++; break; case 'z': dy++; dx--; break; case 'a': dx--; break; case 'q': dy--; dx--; break; default: handleActionKey(engine.lastKey.c); break; } break; default: break; } if (dx != 0 || dy != 0) { engine.gameStatus = Engine::NEW_TURN; if ( moveOrAttack(x + dx, y + dy) ) { engine.updateFOV = true; } } }
void MonsterAi::update(Actor *owner) { if (owner->destructible && owner->destructible->isDead()){ return; } if (engine.map->isInFov(owner->x,owner->y)){ //we can see the player and move towards him moveCount = TRACKING_TURNS; } else { moveCount--; } if (moveCount > 0) { moveOrAttack(owner,engine.player->x,engine.player->y); } }
void Monster::update() { if (canDie && isDead()) { return; } engine.map->computeFOV(*this); if (canSee(engine.player->x, engine.player->y)) { moveCount = TRACKING_TURNS; } else { --moveCount; } if (moveCount > 0) { moveOrAttack(engine.player->x, engine.player->y); } }
void PlayerAI::update(Actor *owner) { if (owner->destructible && owner->destructible->isDead()) { return; } int dx=0,dy=0; switch(engine.lastKey.vk) { case TCODK_UP : dy=-1; break; case TCODK_DOWN : dy=1; break; case TCODK_LEFT : dx=-1; break; case TCODK_RIGHT : dx=1; break; default:break; } if (dx != 0 || dy != 0) { engine.gameStatus=Engine::NEW_TURN; if (moveOrAttack(owner, owner->x + dx, owner->y + dy)) { // if moved successfully } } }
void PlayerAi::update(Actor *owner){ if (owner->destructible &&owner->destructible->isDead() ) { return; } int levelUpXp = getNextLevelXp(owner); if (owner->destructible->xp >= levelUpXp) { owner->xpLevel++; owner->destructible->xp -= levelUpXp; engine.gui->message(TCODColor::yellow,"You feel a strange rush as the enemy falls to the floor!"); engine.gui->render(); TCODConsole::root->flush(); engine.gui->menu.clear(); engine.gui->menu.addItem(Menu::CONSTITUTION,"+20 HP"); engine.gui->menu.addItem(Menu::STRENGTH,"+1 Attack"); engine.gui->menu.addItem(Menu::AGILITY,"+1 Defense"); Menu::MenuItemCode menuItem = Menu::RESUME; while (menuItem == Menu::RESUME) { menuItem = engine.gui->menu.pick(Menu::PAUSE); } switch (menuItem) { case Menu::CONSTITUTION : owner->destructible->maxHp+= 20; owner->destructible->hp += 20; break; case Menu::STRENGTH : owner->attacker->basePower += 1; owner->attacker->totalPower += 1; break; case Menu::AGILITY : owner->destructible->baseDR += 1; owner->destructible->totalDR += 1; break; default: break; } } int dx = 0, dy = 0; switch (engine.lastKey.vk) { case TCODK_KP5: engine.gameStatus = Engine::NEW_TURN; break; case TCODK_UP: case TCODK_KP8: dy = -1; break; case TCODK_KP7: dy = -1; dx = -1; break; case TCODK_KP9: dy = -1; dx = 1; break; case TCODK_KP1: dy = 1; dx = -1; break; case TCODK_KP3: dy = 1; dx = 1; break; case TCODK_DOWN: case TCODK_KP2: dy = 1; break; case TCODK_LEFT: case TCODK_KP4: dx =-1; break; case TCODK_RIGHT: case TCODK_KP6: dx = 1; break; case TCODK_CHAR: handleActionKey(owner, engine.lastKey.c, (engine.lastKey.rctrl || engine.lastKey.lctrl), (engine.lastKey.ralt || engine.lastKey.lalt)); break; default: break; } // std::cout << "got here"<< std::endl; if ( dx != 0 || dy != 0){ engine.gameStatus = Engine::NEW_TURN; if (moveOrAttack(owner,owner->x+dx,owner->y+dy)){ engine.map->computeFov(); } } }