MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / saveWoundedCreatures

Method saveWoundedCreatures

source/ai/KeeperAI.cpp:603–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603void KeeperAI::saveWoundedCreatures()
604{
605 if(mCooldownSaveWoundedCreatures > 0)
606 {
607 --mCooldownSaveWoundedCreatures;
608 return;
609 }
610 mCooldownSaveWoundedCreatures = Random::Int(mCooldownSaveWoundedCreaturesMin, mCooldownSaveWoundedCreaturesMax);
611
612 Tile* dungeonTempleTile = getDungeonTemple()->getCentralTile();
613 if(dungeonTempleTile == nullptr)
614 {
615 OD_LOG_ERR("keeperAi=" + mPlayer.getNick());
616 return;
617 }
618
619 Seat* seat = mPlayer.getSeat();
620 std::vector<Creature*> creatures = mGameMap.getCreaturesBySeat(seat);
621 for(Creature* creature : creatures)
622 {
623 // We take away fleeing creatures not too near our dungeon heart
624 if(!creature->isActionInList(CreatureActionType::flee))
625 continue;
626 Tile* tile = creature->getPositionTile();
627 if(tile == nullptr)
628 continue;
629
630 if((std::abs(dungeonTempleTile->getX() - tile->getX()) <= 5) &&
631 (std::abs(dungeonTempleTile->getY() - tile->getY()) <= 5))
632 {
633 // We are too close from our dungeon heart to be picked up
634 continue;
635 }
636
637 if(!creature->tryPickup(seat))
638 continue;
639
640 mPlayer.pickUpEntity(creature);
641
642 mPlayer.dropHand(dungeonTempleTile);
643 }
644}
645
646void KeeperAI::handleDefense()
647{

Callers

nothing calls this directly

Calls 11

IntFunction · 0.85
getCentralTileMethod · 0.80
getCreaturesBySeatMethod · 0.80
isActionInListMethod · 0.80
getPositionTileMethod · 0.80
pickUpEntityMethod · 0.80
dropHandMethod · 0.80
getSeatMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
tryPickupMethod · 0.45

Tested by

no test coverage detected