167 | | |
| 167 | /*##### |
| 168 | ## npc_twiggy_flathead |
| 169 | #####*/ |
| 170 | |
| 171 | #define BIG_WILL 6238 |
| 172 | #define AFFRAY_CHALLENGER 6240 |
| 173 | #define SAY_BIG_WILL_READY "Ready when you are, warrior" |
| 174 | #define SAY_TWIGGY_FLATHEAD_BEGIN "The Affray has begun, get ready to fight!" |
| 175 | #define SAY_TWIGGY_FLATHEAD_FRAY "You! Enter the fray!" |
| 176 | #define SAY_TWIGGY_FLATHEAD_DOWN "Challenger is down!" |
| 177 | #define SAY_TWIGGY_FLATHEAD_OVER "The Affray is over" |
| 178 | |
| 179 | float AffrayChallengerLoc[6][4]= |
| 180 | { |
| 181 | {-1683, -4326, 2.79, 0}, |
| 182 | {-1682, -4329, 2.79, 0}, |
| 183 | {-1683, -4330, 2.79, 0}, |
| 184 | {-1680, -4334, 2.79, 1.49}, |
| 185 | {-1674, -4326, 2.79, 3.49}, |
| 186 | {-1677, -4334, 2.79, 1.66} |
| 187 | }; |
| 188 | |
| 189 | struct TRINITY_DLL_DECL npc_twiggy_flatheadAI : public ScriptedAI |
| 190 | { |
| 191 | npc_twiggy_flatheadAI(Creature *c) : ScriptedAI(c) {Reset();} |
| 192 | |
| 193 | bool EventInProgress; |
| 194 | bool EventGrate; |
| 195 | bool EventBigWill; |
| 196 | bool Challenger_down[6]; |
| 197 | uint32 Wave; |
| 198 | uint32 Wave_Timer; |
| 199 | uint32 Challenger_checker; |
| 200 | uint64 PlayerGUID; |
| 201 | uint64 AffrayChallenger[6]; |
| 202 | uint64 BigWill; |
| 203 | |
| 204 | void Reset() |
| 205 | { |
| 206 | EventInProgress = false; |
| 207 | EventGrate = false; |
| 208 | EventBigWill = false; |
| 209 | Wave_Timer = 600000; |
| 210 | Challenger_checker = 0; |
| 211 | Wave = 0; |
| 212 | PlayerGUID = 0; |
| 213 | |
| 214 | for(uint8 i = 0; i < 6; i++) { |
| 215 | AffrayChallenger[i] = 0; |
| 216 | Challenger_down[i] = false; |
| 217 | } |
| 218 | BigWill = 0; |
| 219 | } |
| 220 | |
| 221 | void Aggro(Unit *who) { } |
| 222 | |
| 223 | void MoveInLineOfSight(Unit *who) |
| 224 | { |
| 225 | if(!who || (!who->isAlive())) return; |
| 226 | |
| 227 | if (m_creature->IsWithinDistInMap(who, 10.0f) && (who->GetTypeId() == TYPEID_PLAYER) && ((Player*)who)->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE && !EventInProgress) |
| 228 | { |
| 229 | PlayerGUID = who->GetGUID(); |
| 230 | EventInProgress = true; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | void KilledUnit(Unit *victim) { } |
| 235 | |
| 236 | void UpdateAI(const uint32 diff) |
| 237 | { |
| 238 | if (EventInProgress) { |
| 239 | Player* pWarrior = NULL; |
| 240 | |
| 241 | if(PlayerGUID) |
| 242 | pWarrior = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); |
| 243 | |
| 244 | if(!pWarrior) |
| 245 | return; |
| 246 | |
| 247 | if(!pWarrior->isAlive() && pWarrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) { |
| 248 | EventInProgress = false; |
| 249 | DoYell(SAY_TWIGGY_FLATHEAD_DOWN,LANG_UNIVERSAL,NULL); |
| 250 | pWarrior->FailQuest(1719); |
| 251 | |
| 252 | for(uint8 i = 0; i < 6; i++) { |
| 253 | if (AffrayChallenger[i]) { |
| 254 | Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), AffrayChallenger[i]); |
| 255 | if(pCreature) { |
| 256 | if(pCreature->isAlive()) { |
| 257 | pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); |
| 258 | pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); |
| 259 | pCreature->setDeathState(JUST_DIED); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | AffrayChallenger[i] = 0; |
| 264 | Challenger_down[i] = false; |
| 265 | } |
| 266 | |
| 267 | if (BigWill) { |
| 268 | Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), BigWill); |
| 269 | if(pCreature) { |
| 270 | if(pCreature->isAlive()) { |
| 271 | pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); |
| 272 | pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); |
| 273 | pCreature->setDeathState(JUST_DIED); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | BigWill = 0; |
| 278 | } |
| 279 | |
| 280 | if (!EventGrate && EventInProgress) { |
| 281 | float x,y,z; |
| 282 | pWarrior->GetPosition(x, y, z); |
| 283 | |
| 284 | if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324) { |
| 285 | pWarrior->AreaExploredOrEventHappens(1719); |
| 286 | DoYell(SAY_TWIGGY_FLATHEAD_BEGIN,LANG_UNIVERSAL,NULL); |
| 287 | |
| 288 | for(uint8 i = 0; i < 6; i++) { |
| 289 | Creature* pCreature = m_creature->SummonCreature(AFFRAY_CHALLENGER, AffrayChallengerLoc[i][0], AffrayChallengerLoc[i][1], AffrayChallengerLoc[i][2], AffrayChallengerLoc[i][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000); |
| 290 | pCreature->setFaction(35); |
| 291 | pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); |
| 292 | pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); |
| 293 | pCreature->HandleEmoteCommand(15); |
| 294 | AffrayChallenger[i] = pCreature->GetGUID(); |
| 295 | } |
| 296 | Wave_Timer = 5000; |
| 297 | Challenger_checker = 1000; |
| 298 | EventGrate = true; |
| 299 | } |
| 300 | } |
| 301 | else if (EventInProgress) { |
| 302 | if (Challenger_checker < diff) { |
| 303 | for(uint8 i = 0; i < 6; i++) { |
| 304 | if (AffrayChallenger[i]) { |
| 305 | Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), AffrayChallenger[i]); |
| 306 | if((!pCreature || (!pCreature->isAlive())) && !Challenger_down[i]) { |
| 307 | DoYell(SAY_TWIGGY_FLATHEAD_DOWN,LANG_UNIVERSAL,NULL); |
| 308 | Challenger_down[i] = true; |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | Challenger_checker = 1000; |
| 313 | } else Challenger_checker -= diff; |
| 314 | |
| 315 | if(Wave_Timer < diff) { |
| 316 | if (AffrayChallenger[Wave] && Wave < 6 && !EventBigWill) { |
| 317 | DoYell(SAY_TWIGGY_FLATHEAD_FRAY,LANG_UNIVERSAL,NULL); |
| 318 | Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), AffrayChallenger[Wave]); |
| 319 | if(pCreature || (pCreature->isAlive())) { |
| 320 | pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); |
| 321 | pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); |
| 322 | pCreature->HandleEmoteCommand(15); |
| 323 | pCreature->setFaction(14); |
| 324 | ((CreatureAI*)pCreature->AI())->AttackStart(pWarrior); |
| 325 | Wave++; |
| 326 | Wave_Timer = 20000; |
| 327 | } |
| 328 | } |
| 329 | else if (Wave >= 6 && !EventBigWill) { |
| 330 | Creature* pCreature = m_creature->SummonCreature(BIG_WILL, -1722, -4341, 6.12, 6.26, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 480000); |
| 331 | BigWill = pCreature->GetGUID(); |
| 332 | //pCreature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32); |
| 333 | //pCreature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78); |
| 334 | pCreature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79); |
| 335 | //pCreature->HandleEmoteCommand(15); |
| 336 | pCreature->HandleEmoteCommand(27); |
| 337 | EventBigWill = true; |
| 338 | Wave_Timer = 1000; |
| 339 | } |
| 340 | else if (Wave >= 6 && EventBigWill && BigWill) { |
| 341 | Creature* pCreature = (Creature*)Unit::GetUnit((*m_creature), BigWill); |
| 342 | if (!pCreature->isAlive()) { |
| 343 | DoYell(SAY_TWIGGY_FLATHEAD_OVER,LANG_UNIVERSAL,NULL); |
| 344 | EventInProgress = false; |
| 345 | EventBigWill = false; |
| 346 | EventGrate = false; |
| 347 | PlayerGUID = 0; |
| 348 | Wave = 0; |
| 349 | } |
| 350 | } |
| 351 | } else Wave_Timer -= diff; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | }; |
| 356 | CreatureAI* GetAI_npc_twiggy_flathead(Creature *_Creature) |
| 357 | { |
| 358 | return new npc_twiggy_flatheadAI (_Creature); |
| 359 | } |