| 1 | /* |
|---|
| 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
|---|
| 3 | * |
|---|
| 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #include "OutdoorPvPObjectiveAI.h" |
|---|
| 22 | #include "Creature.h" |
|---|
| 23 | #include "Player.h" |
|---|
| 24 | #include "Unit.h" |
|---|
| 25 | #include "OutdoorPvPMgr.h" |
|---|
| 26 | #include "World.h" |
|---|
| 27 | |
|---|
| 28 | #define MAX_OUTDOOR_PVP_DISTANCE 200 // the max value in capture point type go data0 is 100 currently, so use twice that much to handle leaving as well |
|---|
| 29 | |
|---|
| 30 | OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature &c) : i_creature(c) |
|---|
| 31 | { |
|---|
| 32 | sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", c.GetGUIDLow()); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | void OutdoorPvPObjectiveAI::MoveInLineOfSight(Unit *u) |
|---|
| 36 | { |
|---|
| 37 | // IsVisible only passes for players in range, so no need to check again |
|---|
| 38 | // leaving/entering distance will be checked based on go range data |
|---|
| 39 | sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),&i_creature); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | int OutdoorPvPObjectiveAI::Permissible(const Creature * c) |
|---|
| 43 | { |
|---|
| 44 | // only assigned through AI name, never by permissibility check |
|---|
| 45 | return PERMIT_BASE_NO; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | bool OutdoorPvPObjectiveAI::IsVisible(Unit *pl) const |
|---|
| 49 | { |
|---|
| 50 | return (pl->GetTypeId() == TYPEID_PLAYER) && (i_creature.GetDistance(pl) < MAX_OUTDOOR_PVP_DISTANCE); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | void OutdoorPvPObjectiveAI::AttackStart(Unit *) |
|---|
| 54 | { |
|---|
| 55 | EnterEvadeMode(); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | void OutdoorPvPObjectiveAI::EnterEvadeMode() |
|---|
| 59 | { |
|---|
| 60 | i_creature.DeleteThreatList(); |
|---|
| 61 | i_creature.CombatStop(); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | void OutdoorPvPObjectiveAI::UpdateAI(const uint32 diff) |
|---|
| 65 | { |
|---|
| 66 | } |
|---|