2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "PointMovementGenerator.h"
22 #include "CreatureAI.h"
23 #include "TemporarySummon.h"
24 #include "DestinationHolderImp.h"
27 //----- Point Movement Generator
29 void PointMovementGenerator
<T
>::Initialize(T
&unit
)
32 unit
.addUnitState(UNIT_STAT_ROAMING
|UNIT_STAT_ROAMING_MOVE
);
33 Traveller
<T
> traveller(unit
);
34 i_destinationHolder
.SetDestination(traveller
, i_x
, i_y
, i_z
);
36 if (unit
.GetTypeId() == TYPEID_UNIT
&& ((Creature
*)&unit
)->canFly())
37 ((Creature
&)unit
).AddSplineFlag(SPLINEFLAG_UNKNOWN7
);
41 void PointMovementGenerator
<T
>::Finalize(T
&unit
)
43 unit
.clearUnitState(UNIT_STAT_ROAMING
|UNIT_STAT_ROAMING_MOVE
);
47 void PointMovementGenerator
<T
>::Interrupt(T
&unit
)
49 unit
.clearUnitState(UNIT_STAT_ROAMING
|UNIT_STAT_ROAMING_MOVE
);
53 void PointMovementGenerator
<T
>::Reset(T
&unit
)
56 unit
.addUnitState(UNIT_STAT_ROAMING
|UNIT_STAT_ROAMING_MOVE
);
61 bool PointMovementGenerator
<T
>::Update(T
&unit
, const uint32
&diff
)
66 if(unit
.hasUnitState(UNIT_STAT_CAN_NOT_MOVE
))
68 unit
.clearUnitState(UNIT_STAT_ROAMING_MOVE
);
72 unit
.addUnitState(UNIT_STAT_ROAMING_MOVE
);
73 Traveller
<T
> traveller(unit
);
74 if (i_destinationHolder
.UpdateTraveller(traveller
, diff
, false))
76 if (!IsActive(unit
)) // force stop processing (movement can move out active zone with cleanup movegens list)
77 return true; // not expire now, but already lost
80 if(i_destinationHolder
.HasArrived())
91 void PointMovementGenerator
<Player
>::MovementInform(Player
&)
96 void PointMovementGenerator
<Creature
>::MovementInform(Creature
&unit
)
99 unit
.AI()->MovementInform(POINT_MOTION_TYPE
, id
);
101 if (unit
.isTemporarySummon())
103 TemporarySummon
* pSummon
= (TemporarySummon
*)(&unit
);
104 if (IS_CREATURE_GUID(pSummon
->GetSummonerGUID()))
105 if(Creature
* pSummoner
= unit
.GetMap()->GetCreature(pSummon
->GetSummonerGUID()))
107 pSummoner
->AI()->SummonedMovementInform(&unit
, POINT_MOTION_TYPE
, id
);
111 template void PointMovementGenerator
<Player
>::Initialize(Player
&);
112 template void PointMovementGenerator
<Creature
>::Initialize(Creature
&);
113 template void PointMovementGenerator
<Player
>::Finalize(Player
&);
114 template void PointMovementGenerator
<Creature
>::Finalize(Creature
&);
115 template void PointMovementGenerator
<Player
>::Interrupt(Player
&);
116 template void PointMovementGenerator
<Creature
>::Interrupt(Creature
&);
117 template void PointMovementGenerator
<Player
>::Reset(Player
&);
118 template void PointMovementGenerator
<Creature
>::Reset(Creature
&);
119 template bool PointMovementGenerator
<Player
>::Update(Player
&, const uint32
&diff
);
120 template bool PointMovementGenerator
<Creature
>::Update(Creature
&, const uint32
&diff
);
122 void AssistanceMovementGenerator::Finalize(Unit
&unit
)
124 unit
.clearUnitState(UNIT_STAT_ROAMING
|UNIT_STAT_ROAMING_MOVE
);
126 ((Creature
*)&unit
)->SetNoCallAssistance(false);
127 ((Creature
*)&unit
)->CallAssistance();
129 unit
.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld
.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY
));