bool Creature::dropCorpse() { if (!lootDrop && getMonster() && !(master && master->getPlayer())) { if (master) { //scripting event - onDeath CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH); for (CreatureEventList::const_iterator it = deathEvents.begin(); it != deathEvents.end(); ++it) { (*it)->executeOnDeath(this, NULL, _lastHitCreature, _mostDamageCreature, lastHitUnjustified, mostDamageUnjustified); } } g_game.addMagicEffect(getPosition(), NM_ME_POFF); } else { Item* splash = NULL; switch (getRace()) { case RACE_VENOM: splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_GREEN); break; case RACE_BLOOD: splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD); break; default: break; } Tile* tile = getTile(); if (splash) { g_game.internalAddItem(tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT); g_game.startDecay(splash); } Item* corpse = getCorpse(); if (corpse) { g_game.internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT); g_game.startDecay(corpse); } //scripting event - onDeath CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH); for (CreatureEventList::const_iterator it = deathEvents.begin(); it != deathEvents.end(); ++it) { (*it)->executeOnDeath(this, corpse, _lastHitCreature, _mostDamageCreature, lastHitUnjustified, mostDamageUnjustified); } if (corpse) { dropLoot(corpse->getContainer()); } } return true; }
bool Creature::dropCorpse(Creature* lastHitCreature, Creature* mostDamageCreature, bool lastHitUnjustified, bool mostDamageUnjustified) { if (!lootDrop && getMonster()) { if (master) { //scripting event - onDeath const CreatureEventList& deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH); for (CreatureEvent* deathEvent : deathEvents) { deathEvent->executeOnDeath(this, nullptr, lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified); } } g_game.addMagicEffect(getPosition(), CONST_ME_POFF); } else { Item* splash; switch (getRace()) { case RACE_VENOM: splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_GREEN); break; case RACE_BLOOD: splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD); break; default: splash = nullptr; break; } Tile* tile = getTile(); if (splash) { g_game.internalAddItem(tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT); g_game.startDecay(splash); } Item* corpse = getCorpse(lastHitCreature, mostDamageCreature); if (corpse) { g_game.internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT); g_game.startDecay(corpse); } //scripting event - onDeath for (CreatureEvent* deathEvent : getCreatureEvents(CREATURE_EVENT_DEATH)) { deathEvent->executeOnDeath(this, corpse, lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified); } if (corpse) { dropLoot(corpse->getContainer(), lastHitCreature); } } return true; }
void MyGame::update() { getMonster().update(*this); helicopters.update(); missiles.update(); getHUD().update(*this); // me->get<MyEntity>().update(); // shuttle->get<Shuttle>().update(*this); #ifndef WEB updateDesktopShortcuts_(); #endif //updateCameraMotion_(); }
void Creature::goToFollowCreature() { if (followCreature) { FindPathParams fpp; getPathSearchParams(followCreature, fpp); Monster* monster = getMonster(); if (monster && !monster->getMaster() && (monster->isFleeing() || fpp.maxTargetDist > 1)) { Direction dir = DIRECTION_NONE; if (monster->isFleeing()) { monster->getDistanceStep(followCreature->getPosition(), dir, true); } else { //maxTargetDist > 1 if (!monster->getDistanceStep(followCreature->getPosition(), dir)) { // if we can't get anything then let the A* calculate listWalkDir.clear(); if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) { hasFollowPath = true; startAutoWalk(listWalkDir); } else { hasFollowPath = false; } return; } } if (dir != DIRECTION_NONE) { listWalkDir.clear(); listWalkDir.push_front(dir); hasFollowPath = true; startAutoWalk(listWalkDir); } } else { listWalkDir.clear(); if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) { hasFollowPath = true; startAutoWalk(listWalkDir); } else { hasFollowPath = false; } } } onFollowCreatureComplete(followCreature); }
int32_t Creature::getStepDuration() const { if (isRemoved()) { return 0; } uint32_t calculatedStepSpeed; uint32_t groundSpeed; int32_t stepSpeed = getStepSpeed(); if (stepSpeed > -Creature::speedB) { calculatedStepSpeed = floor((Creature::speedA * log((stepSpeed / 2) + Creature::speedB) + Creature::speedC) + 0.5); if (calculatedStepSpeed <= 0) { calculatedStepSpeed = 1; } } else { calculatedStepSpeed = 1; } const Tile* tile = getTile(); if (tile && tile->ground) { uint32_t groundId = tile->ground->getID(); groundSpeed = Item::items[groundId].speed; if (groundSpeed == 0) { groundSpeed = 150; } } else { groundSpeed = 150; } double duration = std::floor(1000 * groundSpeed / calculatedStepSpeed); int32_t stepDuration = std::ceil(duration / 50) * 50; const Monster* monster = getMonster(); if (monster && monster->isTargetNearby() && !monster->isFleeing() && !monster->getMaster()) { stepDuration <<= 1; } return stepDuration; }
void Floor::updateMonsterPosition(){ for (int i = 0; i < getTotalGhosts(); i++){ getMonster()[i].UpdatePosition(); } }