Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Monster::getNextStep(Direction& dir, uint32_t& flags)
- {
- if(isIdle || getHealth() <= 0){
- //we dont have anyone watching might aswell stop walking
- eventWalk = 0;
- return false;
- }
- bool result = false;
- if((!followCreature || !hasFollowPath) && !isSummon()){
- if(followCreature){
- result = getRandomStep(getPosition(), dir);
- }else{
- if(getTimeSinceLastMove() > 1000){
- //choose a random direction
- result = getRandomStep(getPosition(), dir);
- }
- }
- }
- else if(isSummon() || followCreature){
- result = Creature::getNextStep(dir, flags);
- if(result){
- flags |= FLAG_PATHFINDING;
- }
- else{
- //target dancing
- if(attackedCreature && attackedCreature == followCreature){
- if(isFleeing()){
- result = getDanceStep(getPosition(), dir, false, false);
- }
- else if(mType->staticAttackChance < (uint32_t)random_range(1, 100)){
- result = getDanceStep(getPosition(), dir);
- }
- }
- }
- }
- if(result && (canPushItems() || canPushCreatures()) ){
- const Position& pos = Spells::getCasterPosition(this, dir);
- Tile* tile = g_game.getTile(pos.x, pos.y, pos.z);
- if(tile){
- if(canPushItems()){
- pushItems(tile);
- }
- if(canPushCreatures()){
- pushCreatures(tile);
- }
- }
- #ifdef __DEBUG__
- else{
- std::cout << "getNextStep - no tile." << std::endl;
- }
- #endif
- }
- if (result) {
- const Position& pos = Spells::getCasterPosition(this, dir);
- Tile* tile = g_game.getTile(pos.x, pos.y, pos.z);
- if (tile) {
- Creature* c = tile->getTopVisibleCreature(this);
- if (c) {
- selectTarget(c);
- }
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment