예제 #1
0
/*
* This is used to spawn creatures
*/
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::OnUpdate(uint32 const diff)
{
    if(GetEventStatus() < TD_EVENT_STATUS_RUNNING) // if wave is not running
        return;

    Events.Update(diff);

    Player* player = GetPlayer();
    if(!player)
        return;
    while (uint32 eventId = Events.ExecuteEvent())
    {
        switch (eventId)
        {

        case TD_EVENT_DATA_START_MUSIC_TIMER: // this is just some event music to make it feel alive.
            {
                Events.RescheduleEvent(TD_EVENT_DATA_START_MUSIC_TIMER, 240000); // repeat every 4 min, length of track
            }
            break;
        case TD_EVENT_DATA_START_WAVE_TIMER:
            {
                switch(CountDown)
                {
                case 0:
                    player->PlayDirectSound(TD_STARTWAVE_MUSIC,player);
                    SendMessageToPlayer(TD_SYSTEM_MSG_WAVE_STARTING_IN,3);
                    Events.RescheduleEvent(TD_EVENT_DATA_START_WAVE_TIMER, 1000);
                    ++CountDown;
                    break;

                case 1:
                    SendMessageToPlayer(TD_SYSTEM_MSG_WAVE_STARTING,2);
                    Events.RescheduleEvent(TD_EVENT_DATA_START_WAVE_TIMER, 1000);
                    ++CountDown;
                    break;

                case 2:
                    player->PlayDirectSound(TD_STARTWAVE_MUSIC,player);
                    SendMessageToPlayer(TD_SYSTEM_MSG_WAVE_STARTING,1);
                    Events.CancelEvent(TD_EVENT_DATA_START_WAVE_TIMER);
                    Events.ScheduleEvent(TD_EVENT_DATA_START_WAVE_MODE, 1000);
                    ++CountDown;
                    break;
                }
            }
            break;
        case TD_EVENT_DATA_START_WAVE_MODE:
            {
                CountDown = 0;
                SetEventStatus(TD_EVENT_STATUS_LOADING); // set wave status to running so the boss npc can start spawning
                SendMessageToPlayer(TD_SYSTEM_MSG_WAVE_STARTING_GO);
                Events.CancelEvent(TD_EVENT_DATA_START_WAVE_MODE);
                RecordLog("TowerDefense: Wave Id: [%u] is now running.", GetCurrentWaveId());
            }
            break;
        }
    }
}
예제 #2
0
void DlgInitiation::Init(Transient &ref)
{
	m_nEventType = ref.TranType().GetnValue();
	m_page1.Init(ref.TranTriger1());
	m_page2.Init(ref.TranTriger2());

	SetEventStatus();
	UpdateData(FALSE);
}
예제 #3
0
/*
* This occurs when the player clicks on TD_ITEM(); TD_ITEM_MENU_START_WAVE OnGossipSelect, it starts counting.
* wave starting in 3... 2... 1... Wave Started.
* Timer that sends a message to the player every second, decreasing the time till wave is spawned, once it reaches zero. then it sets wave running to true.
*/
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::StartNextWave(uint32 timer)
{
    uint32 waveId = GetCurrentWaveId();
    SetCurrentWaveId(++waveId);
    SetEventStatus(TD_EVENT_STATUS_RUNNING);
    Events.ScheduleEvent(TD_EVENT_DATA_START_MUSIC_TIMER, 200000); // some music 
    Events.ScheduleEvent(TD_EVENT_DATA_START_WAVE_TIMER, timer); // wave countdown
    RecordLog("TowerDefense: Wave Id: [%u] has been scheduled to run in %u milliseconds.", GetCurrentWaveId(), timer);
}
예제 #4
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::SetupEventData()
{
    Player *player = GetPlayer();
    if(!player)
        return;

    SetEventId(GenerateEventId()); // set the event id
    SetPlayerGUID(player->GetGUIDLow()); // set the player guid 
    SetCurrentWaveId(0); // set the current wave id to zero
    SetBaseHealth(100); // set the base health to 100
    SetResources(GetStartResources()); // set the resources that the player has to starter resources
    SetUnits(0); // set the number of spawned attackers to zero
    SetFinished(false); // set the event to unfinished
    SetEventStatus(TD_EVENT_STATUS_TELEPORT); // Set the event status to started and not running a wave
    Events.Reset();
}
예제 #5
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::DeleteEventData()
{
    Player *player = GetPlayer();
    if(!player)
        return;

    SetEventId(0);
    SetPlayerGUID(0);
    SetCurrentWaveId(0);
    SetBaseHealth(0);
    SetResources(0);
    SetUnits(0);
    SetFinished(false);
    SetEventStatus(TD_EVENT_STATUS_NONE);
    CountDown = 0;
    Events.Reset();
    RecordLog("TowerDefense: the tower defense event for player %s was deleted", player->GetName());
    _player = NULL;
}
예제 #6
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::StartEvent(Player* player, uint32 Action)
{
    if (!player || player->isInCombat() || player->GetSession()->isLogingOut() || player->GetGroup()){
        ChatHandler(player).SendSysMessage(TD_SYSTEM_MSG_CANNOT_START_DUE);
        return;
    }
    if(GetPlayer() && player->GetGUIDLow() != GetPlayer()->GetGUIDLow()){
        ChatHandler(player).SendSysMessage(TD_SYSTEM_MSG_CANNOT_START_ALREADY);
        return;
    }else{
        SetPlayer(player);
    }

    if(!player)
        return;

    player->PlayDirectSound(TD_STARTEVENT_MUSIC,player);
    SetupEventData();
    player->AddItem(34131, 1); // add the spawning item to the player
    player->SaveToDB(); // save the player to the db in case of crash
    player->TeleportTo(GetMapId(), GetPSpawnX(), GetPSpawnY(), GetPSpawnZ(), GetPSpawnO()); // teleport to starting location
    SetEventStatus(TD_EVENT_STATUS_TELEPORT);
    switch(Action)
    {
    case 1051: // Easy
        SetEventMode(TD_EVENT_MODE_EASY);
        SendMessageToPlayer(TD_SYSTEM_MSG_STARTED_EVENT_EASY); 
        // wait for user input to start wave
        break;
    case 1052: // Hard
        SetEventMode(TD_EVENT_MODE_HARD);
        SendMessageToPlayer(TD_SYSTEM_MSG_STARTED_EVENT_HARD);
        StartNextWave(30000); // start wave from the start within 30 seconds
        break;
    case 1053: // Extreme
        SetEventMode(TD_EVENT_MODE_EXTREME);
        SendMessageToPlayer(TD_SYSTEM_MSG_STARTED_EVENT_EXTREME);
        StartNextWave(1000); // start waves right away
        break;
    }
    RecordLog("TowerDefense: Player Name: [%s] has started the tower defense event. With Event Id: [%u]",player->GetName(), GetEventId());
}
예제 #7
0
void DlgInitiation::OnRadioDualDeguen() 
{
	// TODO: Add your control notification handler code here
	m_nEventType = 3;
	SetEventStatus();
}
예제 #8
0
void DlgInitiation::OnRadioSingle() 
{
	// TODO: Add your control notification handler code here
	m_nEventType = 1;
	SetEventStatus();
}