Skip to content

Commit

Permalink
Added trapper AI and fixed necrotic ai secondary strike.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchyDev committed Nov 15, 2023
1 parent 6653b78 commit 13b22d9
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
4 changes: 2 additions & 2 deletions data/sql/db-world/base/tos_world_base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ INSERT INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entr
DELETE FROM `creature_template` WHERE `entry`=441505;
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 (441505, 0, 0, 0, 0, 0, 2338, 2339, 0, 0, 'Defias Pillager', '', NULL, 0, 80, 80, 0, 17, 0, 1, 1.14286, 1, 1, 18, 1, 0, 0, 1, 2000, 2000, 1, 1, 8, 32768, 2048, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'SmartAI', 1, 1, 2, 1, 1, 1, 0, 0, 1, 0, 0, 0, 'ToSAISpellElemental', -1);
DELETE FROM `creature_template` WHERE `entry`=441504;
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 (441504, 0, 0, 0, 0, 0, 4418, 4419, 0, 0, 'Defias Smuggler', '', NULL, 0, 80, 80, 0, 17, 0, 1, 1.14286, 1, 1, 18, 1, 0, 0, 1, 2000, 2000, 1, 1, 1, 32768, 2048, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'SmartAI', 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, '', -1);
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 (441504, 0, 0, 0, 0, 0, 4418, 4419, 0, 0, 'Defias Smuggler', '', NULL, 0, 80, 80, 0, 17, 0, 1, 1.14286, 1, 1, 18, 1, 0, 0, 1, 2000, 2000, 1, 1, 1, 32768, 2048, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'SmartAI', 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 'ToSAIMeleeAngry', -1);
DELETE FROM `creature_template` WHERE `entry`=441503;
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 (441503, 0, 0, 0, 0, 0, 2331, 2332, 0, 0, 'Defias Trapper', '', NULL, 0, 80, 80, 0, 17, 0, 1, 1.14286, 1, 1, 18, 1, 0, 0, 1, 2000, 2000, 1, 1, 1, 32768, 2048, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'SmartAI', 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, '', -1);
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 (441503, 0, 0, 0, 0, 0, 2331, 2332, 0, 0, 'Defias Trapper', '', NULL, 0, 80, 80, 0, 17, 0, 1, 1.14286, 1, 1, 18, 1, 0, 0, 1, 2000, 2000, 1, 1, 1, 32768, 2048, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'SmartAI', 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 'ToSAIMeleeTrapper', -1);

-- Wave 1
DELETE FROM `creature_template` WHERE `entry`=441502;
Expand Down
2 changes: 2 additions & 0 deletions src/TrialOfStrength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "scripts/AI/ToSAIMeleeAngry.h"
#include "scripts/AI/ToSAISpellElemental.h"
#include "scripts/AI/ToSAIMeleeNecrotic.h"
#include "scripts/AI/ToSAIMeleeTrapper.h"

#include "scripts/ToSArenaMasterScript.h"

Expand Down Expand Up @@ -185,6 +186,7 @@ void SC_AddTrialOfStrengthScripts()
new ToSAIMeleeAngry();
new ToSAISpellElemental();
new ToSAIMeleeNecrotic();
new ToSAIMeleeTrapper();
}

new ToSInstanceMapScript();
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/AI/ToSAIMeleeNecrotic.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ToSAIMeleeNecrotic : public CreatureScript
break;

case 1:
me->CastSpell(creature, 1);
me->CastSpell(creature, TOS_EVENT_COMBATANT_SPELL_ID_STRIKE_2);
break;
}
events.ScheduleEvent(TOS_EVENT_COMBATANT_SPELL_RANDOM, 3s);
Expand Down
71 changes: 71 additions & 0 deletions src/scripts/AI/ToSAIMeleeTrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef MODULE_TRIAL_OF_STRENGTH_AI_MELEE_TRAPPER_H
#define MODULE_TRIAL_OF_STRENGTH_AI_MELEE_TRAPPER_H

#include "ScriptMgr.h"

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

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

struct ToSAIMeleeTrapperAI : public CombatAI
{
enum CombatantEvents
{
TOS_EVENT_COMBATANT_SPELL_ID_NET = 50762, // Net

TOS_EVENT_COMBATANT_SPELL_RANDOM = 1,
};

EventMap events;

ToSAIMeleeTrapperAI(Creature* creature) : CombatAI(creature)
{
Reset();
}

void Reset() override
{
events.Reset();

events.ScheduleEvent(TOS_EVENT_COMBATANT_SPELL_RANDOM, 3s);
}

void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;

events.Update(diff);

switch (events.ExecuteEvent())
{
case TOS_EVENT_COMBATANT_SPELL_RANDOM:
RandomAttack();
break;
}

DoMeleeAttackIfReady();
}

void RandomAttack()
{
auto creature = me->GetVictim();
if (!creature)
{
return;
}

me->CastSpell(creature, TOS_EVENT_COMBATANT_SPELL_ID_NET);

events.ScheduleEvent(TOS_EVENT_COMBATANT_SPELL_RANDOM, 15s);
}
};
};

#endif // MODULE_TRIAL_OF_STRENGTH_AI_MELEE_TRAPPER_H

0 comments on commit 13b22d9

Please sign in to comment.