Skip to content

Commit

Permalink
Added a spectator script and crowd upon completion of a wave.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchyDev committed Oct 18, 2023
1 parent 010f1a5 commit b9c7394
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data/sql/db-world/base/tos_world_base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ INSERT INTO `creature_equip_template` (`CreatureID`, `ID`, `ItemID1`, `ItemID2`,
DELETE FROM `creature_template` WHERE `entry`=441250;
INSERT INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `speed_walk`, `speed_run`, `speed_swim`, `speed_flight`, `detection_range`, `scale`, `rank`, `dmgschool`, `DamageModifier`, `BaseAttackTime`, `RangeAttackTime`, `BaseVariance`, `RangeVariance`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `HoverHeight`, `HealthModifier`, `ManaModifier`, `ArmorModifier`, `ExperienceModifier`, `RacialLeader`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `spell_school_immune_mask`, `flags_extra`, `ScriptName`, `VerifiedBuild`) VALUES (441250, 0, 0, 0, 0, 0, 18039, 0, 0, 0, 'Fortichad Ironfist', 'Arena Master', NULL, 0, 80, 80, 0, 35, 3, 1, 1.14286, 1, 1, 20, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 'ToSArenaMasterScript', 1);

-- Trial of Strength / Arena Spectator
DELETE FROM `creature_template` WHERE `entry`=441253;
INSERT INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `speed_walk`, `speed_run`, `speed_swim`, `speed_flight`, `detection_range`, `scale`, `rank`, `dmgschool`, `DamageModifier`, `BaseAttackTime`, `RangeAttackTime`, `BaseVariance`, `RangeVariance`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `HoverHeight`, `HealthModifier`, `ManaModifier`, `ArmorModifier`, `ExperienceModifier`, `RacialLeader`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `spell_school_immune_mask`, `flags_extra`, `ScriptName`, `VerifiedBuild`) VALUES (441253, 0, 0, 0, 0, 0, 1485, 3606, 4123, 2224, 'Arena Spectator', NULL, NULL, 0, 78, 80, 0, 35, 0, 1, 1.14286, 1, 1, 20, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'NullCreatureAI', 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 'ToSArenaSpectatorScript', 1);


DELETE FROM `npc_text` WHERE `ID`=441250;
INSERT INTO `npc_text` (`ID`, `text0_0`, `text0_1`, `BroadcastTextID0`, `lang0`, `Probability0`, `em0_0`, `em0_1`, `em0_2`, `em0_3`, `em0_4`, `em0_5`, `text1_0`, `text1_1`, `BroadcastTextID1`, `lang1`, `Probability1`, `em1_0`, `em1_1`, `em1_2`, `em1_3`, `em1_4`, `em1_5`, `text2_0`, `text2_1`, `BroadcastTextID2`, `lang2`, `Probability2`, `em2_0`, `em2_1`, `em2_2`, `em2_3`, `em2_4`, `em2_5`, `text3_0`, `text3_1`, `BroadcastTextID3`, `lang3`, `Probability3`, `em3_0`, `em3_1`, `em3_2`, `em3_3`, `em3_4`, `em3_5`, `text4_0`, `text4_1`, `BroadcastTextID4`, `lang4`, `Probability4`, `em4_0`, `em4_1`, `em4_2`, `em4_3`, `em4_4`, `em4_5`, `text5_0`, `text5_1`, `BroadcastTextID5`, `lang5`, `Probability5`, `em5_0`, `em5_1`, `em5_2`, `em5_3`, `em5_4`, `em5_5`, `text6_0`, `text6_1`, `BroadcastTextID6`, `lang6`, `Probability6`, `em6_0`, `em6_1`, `em6_2`, `em6_3`, `em6_4`, `em6_5`, `text7_0`, `text7_1`, `BroadcastTextID7`, `lang7`, `Probability7`, `em7_0`, `em7_1`, `em7_2`, `em7_3`, `em7_4`, `em7_5`, `VerifiedBuild`) VALUES (441250, 'Greetings, $n.|n|nI am the Arena Master for the Trial of Strength.|n|nIf you seek to test your abilities, then I can transport you to the arena.|n|nAre you ready to face the challenges that lie ahead?', NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
DELETE FROM `npc_text` WHERE `ID`=441251;
Expand Down
3 changes: 3 additions & 0 deletions src/TrialOfStrength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "scripts/ToSEnemyCombatantBossScript.h"

#include "scripts/ToSArenaMasterScript.h"
#include "scripts/ToSArenaSpectatorScript.h"

#include "scripts/ToSInstanceScript.h"
#include "scripts/ToSInstanceMapScript.h"
Expand Down Expand Up @@ -168,7 +169,9 @@ void ToSWorldScript::OnAfterConfigLoad(bool reload)
void SC_AddTrialOfStrengthScripts()
{
new ToSWorldScript();

new ToSArenaMasterScript();
new ToSArenaSpectatorScript();

new ToSEnemyCombatantScript();
new ToSEnemyCombatantBossScript();
Expand Down
1 change: 1 addition & 0 deletions src/TrialOfStrength.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum ToSConstants {
TOS_DATA_ENCOUNTER_TRIAL_COMPLETED = 13,
TOS_DATA_ENCOUNTER_CHECK_ARENA_MASTER_RELOCATE = 14,
TOS_DATA_ENCOUNTER_WAVE_IN_PROGRESS = 15,
TOS_DATA_ENCOUNTER_CROWD = 16,

TOS_CURSE_TYPE_ENEMY = 0,
TOS_CURSE_TYPE_PLAYER = 1,
Expand Down
85 changes: 85 additions & 0 deletions src/scripts/ToSArenaSpectatorScript.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef MODULE_TRIAL_OF_STRENGTH_ARENA_SPECTATOR_H
#define MODULE_TRIAL_OF_STRENGTH_ARENA_SPECTATOR_H

#include "ScriptedCreature.h"

class ToSArenaSpectatorScript : public CreatureScript
{
public:
ToSArenaSpectatorScript() : CreatureScript("ToSArenaSpectatorScript") { }

CreatureAI* GetAI(Creature* creature) const override
{
return new ToSArenaSpectatorAIScript(creature);
}

class ToSArenaSpectatorAIScript : public ScriptedAI
{
enum ToSSpectatorConstants
{
TOS_ARENA_SPEC_DO_EMOTE = 1
};

public:
ToSArenaSpectatorAIScript(Creature* creature) : ScriptedAI(creature)
{
events.Reset();
events.ScheduleEvent(TOS_ARENA_SPEC_DO_EMOTE, randtime(3s, 10s));

crowdCheerAlternate = false;
}

void UpdateAI(uint32 diff) override
{
events.Update(diff);

switch (events.ExecuteEvent())
{
case TOS_ARENA_SPEC_DO_EMOTE:
DoEmote();
events.RescheduleEvent(TOS_ARENA_SPEC_DO_EMOTE, randtime(3s, 10s));
break;
}
}

void DoEmote()
{
auto iScript = me->GetInstanceScript();
if (!iScript)
{
events.Reset();
LOG_WARN("module", "Failed to find instance script for Arena Spectator.");
return;
}

if (!iScript->IsEncounterInProgress())
{
return;
}

switch (urand(0, 2))
{
case 0:
me->HandleEmoteCommand(EMOTE_ONESHOT_CHEER);
break;

case 1:
me->HandleEmoteCommand(EMOTE_ONESHOT_DANCE);
break;

case 2:
me->HandleEmoteCommand(EMOTE_ONESHOT_APPLAUD);
break;
}
}

private:
EventMap events;
bool crowdCheerAlternate;
};

private:
EventMap events;
};

#endif // MODULE_TRIAL_OF_STRENGTH_ARENA_SPECTATOR_H
17 changes: 17 additions & 0 deletions src/scripts/ToSInstanceScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,20 @@ void ToSInstanceScript::Update(uint32 diff)
CheckArenaMasterRelocate();
events.RescheduleEvent(TOS_DATA_ENCOUNTER_CHECK_ARENA_MASTER_RELOCATE, 3s);
break;

case TOS_DATA_ENCOUNTER_CROWD:
PlayCrowd();
events.RescheduleEvent(TOS_DATA_ENCOUNTER_CROWD, 1s);
break;
}
}

void ToSInstanceScript::PlayCrowd()
{
if (IsEncounterInProgress() && IsWaveCleared() && !cheerPlayed)
{
instance->PlayDirectSoundToMap(13904);
cheerPlayed = true;
}
}

Expand Down Expand Up @@ -361,6 +375,7 @@ void ToSInstanceScript::SetupEncounter()
}

events.ScheduleEvent(TOS_DATA_ENCOUNTER_START_NEXT_WAVE, 5s);
events.ScheduleEvent(TOS_DATA_ENCOUNTER_CROWD, 1s);
}

void ToSInstanceScript::CheckWaveCompletion()
Expand Down Expand Up @@ -388,6 +403,7 @@ void ToSInstanceScript::CheckWaveCompletion()

waveInProgress = false;
waveCleared = true;
cheerPlayed = false;

if (currentWave == totalWaves)
{
Expand Down Expand Up @@ -606,6 +622,7 @@ void ToSInstanceScript::ResetEncounter()
{
encounterInProgress = false;
waveInProgress = false;
cheerPlayed = false;

currentWave = 1;
totalWaves = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/ToSInstanceScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class ToSInstanceScript : public InstanceScript
void PopulateRewardChest();
void AnnounceCompletion();

void PlayCrowd();

void SetData(uint32 dataId, uint32 value) override;
uint32 GetData(uint32 dataId) const override;

Expand All @@ -81,6 +83,7 @@ class ToSInstanceScript : public InstanceScript

bool waveCleared;
bool trialCompleted;
bool cheerPlayed;

std::vector<Creature*> waveCreatures;
std::vector<ToSCurseTemplate*> curses;
Expand Down

0 comments on commit b9c7394

Please sign in to comment.