Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ReturnValue Combat::canDoCombat(const Creature* attacker, const Creature* target)
- {
- if(attacker){
- if(const Player* targetPlayer = target->getPlayer()){
- if(targetPlayer->hasFlag(PlayerFlag_CannotBeAttacked)){
- return RET_YOUMAYNOTATTACKTHISPERSON;
- }
- if(const Player* attackerPlayer = attacker->getPlayer()){
- if(attackerPlayer->hasFlag(PlayerFlag_CannotAttackPlayer) ||
- attackerPlayer->isLoginAttackLocked(targetPlayer->getID())){
- return RET_YOUMAYNOTATTACKTHISPERSON;
- }
- }
- if(const Player* masterAttackerPlayer = attacker->getPlayerMaster()){
- if(masterAttackerPlayer->hasFlag(PlayerFlag_CannotAttackPlayer)){
- return RET_YOUMAYNOTATTACKTHISPERSON;
- }
- }
- }
- else if(target->getMonster()){
- if(const Player* attackerPlayer = attacker->getPlayer()){
- if(attackerPlayer->hasFlag(PlayerFlag_CannotAttackMonster)){
- return RET_YOUMAYNOTATTACKTHISCREATURE;
- }
- } else if (attacker->getMonster()) {
- const Creature* targetMaster = target->getMaster();
- if (!targetMaster || !targetMaster->getPlayer()) {
- const Creature* attackerMaster = attacker->getMaster();
- if (!attackerMaster || !attackerMaster->getPlayer()) {
- return RET_YOUMAYNOTATTACKTHISCREATURE;
- }
- }
- }
- }
- if(attacker->getPlayer() || attacker->isPlayerSummon()){
- //nopvp-zone
- if(target->getPlayer() && target->getTile()->hasFlag(TILESTATE_NOPVPZONE)){
- return RET_ACTIONNOTPERMITTEDINANONPVPZONE;
- }
- return Combat::checkPVPExtraRestrictions(attacker, target, false);
- }
- }
- return RET_NOERROR;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement