void UpdateAI(const uint32 diff) { if (!UpdateVictim()) return; if (TidalShieldTimer <= diff) { if (TryDoCast(me, SPELL_TIDAL_SHIELD, true)) { ResetTimer(45000); TidalShieldTimer = 60000; } } else TidalShieldTimer -= diff; if (!me->HasAura(SPELL_BERSERK,0)) { if (EnrageTimer <= diff) { DoScriptText(SAY_ENRAGE2, me); DoCast(me, SPELL_BERSERK, true); } else EnrageTimer -= diff; } if (SpecialYellTimer <= diff) { switch(rand()%2) { case 0: DoScriptText(SAY_SPECIAL1, me); break; case 1: DoScriptText(SAY_SPECIAL2, me); break; } SpecialYellTimer = 25000 + (rand()%76)*1000; } else SpecialYellTimer -= diff; if (ImpalingSpineTimer <= diff) { if (!me->IsNonMeleeSpellCasted(false)) { Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 80,true); if (!pTarget) pTarget = me->getVictim(); if (pTarget) { DoCast(pTarget, SPELL_IMPALING_SPINE); SpineTargetGUID = pTarget->GetGUID(); //must let target summon, otherwise you cannot click the spine pTarget->SummonGameObject(GOBJECT_SPINE, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), me->GetOrientation(), 0, 0, 0, 0, 0); switch(rand()%2) { case 0: DoScriptText(SAY_NEEDLE1, me); break; case 1: DoScriptText(SAY_NEEDLE2, me); break; } ImpalingSpineTimer = 21000; } } } else ImpalingSpineTimer -= diff; if (NeedleSpineTimer <= diff) { if (TryDoCast(me, SPELL_NEEDLE_SPINE, true)) { //std::list<Unit*> target; //SelectUnitList(target, 3, SELECT_TARGET_RANDOM, 100, true); //for (std::list<Unit*>::iterator i = target.begin(); i != target.end(); ++i) // me->CastSpell(*i, 39835, true); NeedleSpineTimer = 3000; } } else NeedleSpineTimer -= diff; DoMeleeAttackIfReady(); }
static LRESULT CALLBACK TalkPrjWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_CREATE: ClearKeyBuffer(); PostMessage(hWnd, WM_SETTIMER, 2000, 0); break; case WM_SETTIMER: SetTimer(hWnd, TIMER_PRJ, wParam, NULL); break; case WM_PAINT: if (GetFocus() == hWnd) { if (ST_UK_DELAY == g_TalkInfo.unlock.dwUnLockState) { TalkUlkWndPaint(hWnd, Msg, wParam, lParam); } else { // TalkWndPaint(hWnd, Msg, wParam, lParam); TalkPrjWndPaint(hWnd, Msg, wParam, lParam); } } break; case WM_CHAR: if (GetFocus() != hWnd) { SendMessage(GetFocus(), WM_CHAR, wParam, 0l); return; } wParam = KeyBoardMap(wParam); if (wParam == KEY_RETURN) { if(ST_CO_TALKING == g_TalkInfo.talking.dwTalkState || ST_CO_WAIT_PICKUP == g_TalkInfo.talking.dwTalkState || ST_CI_TALKING == g_TalkInfo.talking.dwTalkState) { SendGMHangupCmd2Talking(); } else if(ST_ORIGINAL == g_TalkInfo.talking.dwTalkState) { memset(g_KeyInputBuffer, 0, KEY_BUF_LEN); g_KeyInputBufferLen = 0; PostMessage(hWnd, WM_CLOSE, 0, 0); } } else if ((wParam >= KEY_NUM_0) && (wParam <= KEY_NUM_9)) { ResetTimer(hWnd, TIMER_PRJ, 2000, NULL); if (g_KeyInputBufferLen < KEY_BUF_LEN) { g_KeyInputBuffer[g_KeyInputBufferLen++] = (UCHAR)wParam; } else { g_KeyInputBufferLen = 0; g_KeyInputBuffer[g_KeyInputBufferLen++] = (UCHAR)wParam; } } PostMessage(hWnd, WM_PAINT, 0, 0); break; case WM_TIMER: TalkPrjTimerProc(hWnd, Msg, wParam, lParam); break; case WM_REFRESHPARENT_WND: SetFocus(hWnd); PostMessage(hWnd, WM_PAINT, 0, 0); break; case WM_DESTROY: KillTimer(hWnd, TIMER_PRJ); // PostMessage(GetParent(hWnd), WM_REFRESHPARENT_WND, 0, 0); g_hWNDTalk = NULL; // SendMessage(GetFocus(), WM_REFRESHPARENT_WND, 0, 0); break; default: // if (WM_CLOSE == Msg) // { // RemoveOneWnd(hWnd); // } // return DefWindowProc(hWnd, Msg, wParam, lParam); DefWindowProc(hWnd, Msg, wParam, lParam); if (WM_CLOSE == Msg) { RemoveOneWnd(hWnd); } } return 0; }
//Main program loop - Run gets called until it returns false bool Run() { //Main loop - get keypresses and interpret them keystate=GetRemoteKeys(); if(keystate & KEY_HOME) { return false; } switch(mode) { case 0: { //Splash screen if (keystate & KEY_INPUT2) { //Button B //Start game InitialiseGame(); PlaySound(SOUND_BEEP); } if (keystate & KEY_INPUT1) { //Button A //show help ShowHelp(); PlaySound(SOUND_BEEP); } } break; case 2: { //Help - wait for 'OK' press if (keystate & KEY_INPUT2) { //Button B //Reset back to splash screen ResetTimer(); mode=0; Splash(); PlaySound(SOUND_BEEP); } } break; case 1: { //Game if (keystate & KEY_INPUT1) { //Button A //Reset back to splash screen ResetTimer(); mode=0; Splash(); } if (keystate & KEY_RUN) { //Go button //Fire! PlaySound(SOUND_SHOOT); refreshCount = 0; int hit; hit = LineHitsObject(cameraPos, cameraAngle); if (hit == tankObjectIndex) { //we hit the tank! score += 100; CloseGraphics(); OpenGraphics(); DrawWorld(&world, cameraPos, cameraAngle); DrawHUD(); DrawExplosion(); DrawArrow(cameraAngle.y); DrawRadarDots(true); DrawRadarArm(sweepAngle * sweepStepCount++); DrawRadarDots(false); SetTextColor(CYAN); DrawText(6,100,"Quit"); Show(); PlaySound(SOUND_EXPLOSION); PlaceTank(cameraPos, cameraAngle); } } //Have the movement sticks changed? This bit doesn't care about buttons if((keystate & (KEY_RIGHT_BACK+KEY_RIGHT_FORWARD+KEY_LEFT_BACK+KEY_LEFT_FORWARD)) != (oldKeystate & (KEY_RIGHT_BACK+KEY_RIGHT_FORWARD+KEY_LEFT_BACK+KEY_LEFT_FORWARD))) { MoveCamera(&cameraPos, &cameraAngle, baselinePos, arrowRefAngle, ReadTimer(), oldKeystate); arrowRefAngle=cameraAngle.y; baselinePos=cameraPos; ResetTimer(); oldKeystate = keystate; if (keystate==0) //we've just stopped moving refreshCount=0; } if (mode==1) { if (sweepStepCount == SWEEPSTEPS) sweepStepCount=0; if (--behaviourCount<0) ChooseBehaviour(); MoveTank(); MoveCamera(&cameraPos, &cameraAngle, baselinePos, arrowRefAngle, ReadTimer(), oldKeystate); //is it time to reset the tank model? Otherwise it gradually gets distorted if (--resetCount<0) { //Refresh the tank model which is prone to getting distorted //due to cumulative inaccuracies of sin/cos approximations Point3d angle=world.objects[tankObjectIndex].heading; Point3d tankPos=world.objects[tankObjectIndex].centre; world.objects[tankObjectIndex]=tank; MoveObject(&(world.objects[tankObjectIndex]), tankPos); RotateObjectYAxis(&(world.objects[tankObjectIndex]), angle.y); resetCount=50; } //Is it time to redraw the world? if (--refreshCount<0) { //Seems a bit brutal to have to close graphics but it's //the only way to clear the screen that'll let us draw //on it properly again - ClearScreen or ClearRectangle mess up CloseGraphics(); OpenGraphics(); DrawWorld(&world, cameraPos, cameraAngle); DrawHUD(); refreshCount=2; } DrawArrow(cameraAngle.y); DrawRadarDots(true); DrawRadarArm(sweepAngle * sweepStepCount++); DrawRadarDots(false); SetTextColor(CYAN); DrawText(6,100,"Quit"); Show(); //just in case we changed mode... if (mode==0) Splash(); } } } Sleep(50); return true; }
Timer::Timer() { ResetTimer(); }
void AIUpdate() { if(IsTimerFinished(mJovaanTimer)) { switch(mJovaanPhase) { case 0: { MoonScriptCreatureAI* pRazuunAI = SpawnCreature(21502, -3300.47f, 2927.22f, 173.870f, 2.42924f, false); // Spawn Razuun if(pRazuunAI != NULL) { pRazuunAI->GetUnit()->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); pRazuunAI->SetCanEnterCombat(false); pRazuunAI->SetMoveType(Move_DontMoveWP); pRazuunAI->SetCanMove(false); } _unit->SetStandState(STANDSTATE_KNEEL); _unit->Emote(EMOTE_ONESHOT_TALK); _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Everything is in readiness, warbringer."); mJovaanPhase = 1; ResetTimer(mJovaanTimer, 6000); } break; case 1: { _unit->Emote(EMOTE_ONESHOT_TALK); _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Warbringer, that will require the use of all the hold's infernals. It may leave us vulnerable to a counterattack."); mJovaanPhase = 2; ResetTimer(mJovaanTimer, 11000); } break; case 2: { _unit->SetStandState(STANDSTATE_STAND); mJovaanPhase = 3; ResetTimer(mJovaanTimer, 1000); } break; case 3: { _unit->Emote(EMOTE_ONESHOT_SALUTE); _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "It shall be as you say, warbringer. One last question, if I may..."); mJovaanPhase = 4; ResetTimer(mJovaanTimer, 10000); } break; case 4: { _unit->Emote(EMOTE_ONESHOT_QUESTION); _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "What's in the crate?"); mJovaanPhase = 5; ResetTimer(mJovaanTimer, 10000); } break; case 5: { _unit->Emote(EMOTE_ONESHOT_SALUTE); mJovaanPhase = -1; RemoveTimer(mJovaanTimer); } break; } } ParentClass::AIUpdate(); }
TimerP newTimer() { TimerP t = (TimerP) allocate(sizeof(Timer)); ResetTimer(t); return t; }
void UFOController::SmallUFODistroyed(void) { pSmallUFO->GotDistroyed(); ResetTimer(); }
void UFOController::LargeUFODistroyed(void) { pLargeUFO->GotDistroyed(); ResetTimer(); }
void TTmProfiler::ResetAll() { int TimerId = GetTimerIdFFirst(); while (GetTimerIdFNext(TimerId)) { ResetTimer(TimerId); } }
void AIUpdate() { SetCanEnterCombat(false); SetCanMove(false); SetAllowMelee(false); SetAllowSpell(false); // ORB ONE if (IsTimerFinished(Phase_Timer) && GetPhase() == 0) { if (Phasepart == 0) { Spawncounter = 0; orb1 = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(482.929f, -151.114f, 43.654f, 183961); if (orb1) orb1->SetState(GAMEOBJECT_STATE_OPEN); switch (RandomUInt(1)) { NPC_ID_Spawn = 0; case 0: NPC_ID_Spawn = CN_BLAZING_TRICKSTER; break; case 1: NPC_ID_Spawn = CN_WARP_STALKER; break; } ResetTimer(Phase_Timer, 8000); Phasepart = 1; return; } else if (Phasepart == 1) { if (!NPC_orb1 && NPC_ID_Spawn != 0 && Spawncounter == 0) { ++Spawncounter; NPC_orb1 = SpawnCreature(NPC_ID_Spawn, 475.672f, -147.086f, 42.567f, 3.184015f); return; } else if (NPC_orb1 && !NPC_orb1->IsAlive()) { _unit->SendScriptTextChatMessage(SAY_MELLICHAR_03); SetPhase(1); Phasepart = 0; ResetTimer(Phase_Timer, 6000); return; } else { return; } return; } //return; } // ORB TWO else if (IsTimerFinished(Phase_Timer) && GetPhase() == 1) { if (Phasepart == 0) { Spawncounter = 0; orb2 = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(409.062f, -152.161f, 43.653f, 183963); if (orb2) orb2->SetState(GAMEOBJECT_STATE_OPEN); ResetTimer(Phase_Timer, 8000); Phasepart = 1; return; } else if (Phasepart == 1) { if (!NPC_orb2 && Spawncounter == 0) { ++Spawncounter; NPC_orb2 = SpawnCreature(CN_MILLHOUSE_MANASTORM, 413.192f, -148.586f, 42.569f, 0.024347f); return; } else if (NPC_orb2 && NPC_orb2->IsAlive()) { Creature* millhouse = TO_CREATURE(ForceCreatureFind(CN_MILLHOUSE_MANASTORM)); if (millhouse) { millhouse->SendTimedScriptTextChatMessage(SAY_MILLHOUS_01, 2000); _unit->SendTimedScriptTextChatMessage(SAY_MELLICHAR_04, 13000); millhouse->SendTimedScriptTextChatMessage(SAY_MILLHOUS_02, 22000); } SetPhase(2); Phasepart = 0; ResetTimer(Phase_Timer, 25000); return; } else { return; } return; } //return; } // ORB THREE else if (IsTimerFinished(Phase_Timer) && GetPhase() == 2) { if (Phasepart == 0) { Spawncounter = 0; orb3 = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(415.167f, -174.338f, 43.654f, 183964); if (orb3) orb3->SetState(GAMEOBJECT_STATE_OPEN); switch (RandomUInt(1)) { NPC_ID_Spawn = 0; case 0: NPC_ID_Spawn = CN_SULFURON_MAGMA_THROWER; break; case 1: NPC_ID_Spawn = CN_AKKIRIS_LIGHTNING_WAKER; break; } ResetTimer(Phase_Timer, 8000); Phasepart = 1; return; } else if (Phasepart == 1) { if (!NPC_orb3 && NPC_ID_Spawn != 0 && Spawncounter == 0) { /// \todo investigate.... saying "1"... really? _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "1"); ++Spawncounter; NPC_orb3 = SpawnCreature(NPC_ID_Spawn, 420.050f, -173.500f, 42.580f, 6.110f); return; } else if (!NPC_orb3) { /// \todo investigate.... saying "2"... really? _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "2"); NPC_orb3 = GetNearestCreature(NPC_ID_Spawn); } else if (NPC_orb3 && !NPC_orb3->IsAlive()) { _unit->SendScriptTextChatMessage(SAY_MELLICHAR_05); SetPhase(3); Phasepart = 0; ResetTimer(Phase_Timer, 8000); return; } else { return; } return; } //return; } // ORB FOUR else if (IsTimerFinished(Phase_Timer) && GetPhase() == 3) { if (Phasepart == 0) { Spawncounter = 0; orb4 = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(476.422f, -174.517f, 42.748f, 183962); if (orb4) orb4->SetState(GAMEOBJECT_STATE_OPEN); switch (RandomUInt(1)) { NPC_ID_Spawn = 0; case 0: NPC_ID_Spawn = CN_TWILIGHT_DRAKONAAR; break; case 1: NPC_ID_Spawn = CN_BLACKWING_DRAKONAAR; break; } ResetTimer(Phase_Timer, 8000); Phasepart = 1; return; } else if (Phasepart == 1) { if (!NPC_orb4 && NPC_ID_Spawn != 0 && Spawncounter == 0) { ++Spawncounter; NPC_orb4 = SpawnCreature(NPC_ID_Spawn, 471.153f, -174.715f, 42.589f, 3.097f); return; } else if (!NPC_orb4) { NPC_orb4 = GetNearestCreature(NPC_ID_Spawn); } else if (NPC_orb4 && !NPC_orb4->IsAlive()) { _unit->SendScriptTextChatMessage(SAY_MELLICHAR_06); SetPhase(4); Phasepart = 0; ResetTimer(Phase_Timer, 6000); return; } else { return; } return; } //return; } else if (IsTimerFinished(Phase_Timer) && GetPhase() == 4) {} ParentClass::AIUpdate(); SetCanMove(false); SetAllowMelee(false); SetAllowSpell(false); }