diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 037a63f88..50a810e4d 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -119,6 +119,7 @@ SET(zone_headers lua_mob.h lua_npc.h lua_parser.h + lua_trade.h map.h masterentity.h maxskill.h diff --git a/zone/client.cpp b/zone/client.cpp index 1f96a2122..c2cbad7ed 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1073,7 +1073,11 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s if (DistNoRootNoZ(*GetTarget()) <= 200) { if(GetTarget()->CastToNPC()->IsMoving() && !GetTarget()->CastToNPC()->IsOnHatelist(GetTarget())) GetTarget()->CastToNPC()->PauseWandering(RuleI(NPC, SayPauseTimeInSec)); - parse->EventNPC(EVENT_SAY, GetTarget()->CastToNPC(), this, message, language); + + Mob *targ = GetTarget(); + if(targ->GetAppearance() != eaDead) + targ->FaceTarget(targ); + parse->EventNPC(EVENT_SAY, targ->CastToNPC(), this, message, language); } } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ec26fa736..f9323376c 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3264,6 +3264,9 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) { if(silentsaylink) { + Mob *targ = GetTarget(); + if(targ->GetAppearance() != eaDead) + targ->FaceTarget(targ); parse->EventNPC(EVENT_SAY, GetTarget()->CastToNPC(), this, response.c_str(), 0); parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0); } diff --git a/zone/embparser.cpp b/zone/embparser.cpp index b64e06338..eddf2d6ac 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -1064,8 +1064,6 @@ void PerlembParser::ExportEventVariables(std::string &package_name, QuestEventID { switch (event) { case EVENT_SAY: { - if (npcmob && npcmob->GetAppearance() != eaDead) - npcmob->FaceTarget(mob); ExportVar(package_name.c_str(), "data", objid); ExportVar(package_name.c_str(), "text", data); ExportVar(package_name.c_str(), "langid", extradata); diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index 8d0bee738..70123f137 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -2,6 +2,7 @@ #include "masterentity.h" #include "lua_mob.h" +#include "lua_client.h" const char *Lua_Mob::GetName() { Lua_Safe_Call_String(); @@ -18,11 +19,6 @@ void Lua_Mob::Depop(bool start_spawn_timer) { return self->Depop(start_spawn_timer); } -void Lua_Mob::RogueAssassinate(Lua_Mob other) { - Lua_Safe_Call_Void(); - self->RogueAssassinate(other); -} - bool Lua_Mob::BehindMob() { Lua_Safe_Call_Bool(); return self->BehindMob(); @@ -58,26 +54,6 @@ void Lua_Mob::SendWearChange(int material_slot) { self->SendWearChange(material_slot); } -uint32 Lua_Mob::GetEquipment(int material_slot) { - Lua_Safe_Call_Int(); - return self->GetEquipment(material_slot); -} - -int32 Lua_Mob::GetEquipmentMaterial(int material_slot) { - Lua_Safe_Call_Int(); - return self->GetEquipmentMaterial(material_slot); -} - -uint32 Lua_Mob::GetEquipmentColor(int material_slot) { - Lua_Safe_Call_Int(); - return self->GetEquipmentColor(material_slot); -} - -uint32 Lua_Mob::GetArmorTint(int i) { - Lua_Safe_Call_Int(); - return self->GetArmorTint(i); -} - bool Lua_Mob::IsMoving() { Lua_Safe_Call_Bool(); return self->IsMoving(); @@ -223,21 +199,6 @@ void Lua_Mob::GMMove(double x, double y, double z, double heading, bool send_upd self->GMMove(x, y, z, heading, send_update); } -void Lua_Mob::SendPosUpdate() { - Lua_Safe_Call_Void(); - self->SendPosUpdate(); -} - -void Lua_Mob::SendPosUpdate(bool send_to_self) { - Lua_Safe_Call_Void(); - self->SendPosUpdate(send_to_self ? 1 : 0); -} - -void Lua_Mob::SendPosition() { - Lua_Safe_Call_Void(); - self->SendPosition(); -} - bool Lua_Mob::HasProcs() { Lua_Safe_Call_Bool(); return self->HasProcs(); @@ -283,26 +244,6 @@ int Lua_Mob::GetBuffSlotFromType(int slot) { return self->GetBuffSlotFromType(slot); } -void Lua_Mob::MakePet(int spell_id, const char* pet_type) { - Lua_Safe_Call_Void(); - self->MakePet(spell_id, pet_type); -} - -void Lua_Mob::MakePet(int spell_id, const char* pet_type, const char *pet_name) { - Lua_Safe_Call_Void(); - self->MakePet(spell_id, pet_type, pet_name); -} - -void Lua_Mob::MakePoweredPet(int spell_id, const char* pet_type, int pet_power) { - Lua_Safe_Call_Void(); - self->MakePoweredPet(spell_id, pet_type, pet_power); -} - -void Lua_Mob::MakePoweredPet(int spell_id, const char* pet_type, int pet_power, const char *pet_name) { - Lua_Safe_Call_Void(); - self->MakePoweredPet(spell_id, pet_type, pet_power, pet_name); -} - int Lua_Mob::GetBaseRace() { Lua_Safe_Call_Int(); return self->GetBaseRace(); @@ -588,41 +529,6 @@ int Lua_Mob::GetMaxCHA() { return self->GetMaxCHA(); } -double Lua_Mob::GetActSpellRange(int spell_id, double range) { - Lua_Safe_Call_Real(); - return self->GetActSpellRange(spell_id, range); -} - -double Lua_Mob::GetActSpellRange(int spell_id, double range, bool is_bard) { - Lua_Safe_Call_Real(); - return self->GetActSpellRange(spell_id, range, is_bard); -} - -int Lua_Mob::GetActSpellDamage(int spell_id, int value) { - Lua_Safe_Call_Int(); - return self->GetActSpellDamage(spell_id, value); -} - -int Lua_Mob::GetActSpellHealing(int spell_id, int value) { - Lua_Safe_Call_Int(); - return self->GetActSpellHealing(spell_id, value); -} - -int Lua_Mob::GetActSpellCost(int spell_id, int cost) { - Lua_Safe_Call_Int(); - return self->GetActSpellCost(spell_id, cost); -} - -int Lua_Mob::GetActSpellDuration(int spell_id, int duration) { - Lua_Safe_Call_Int(); - return self->GetActSpellDuration(spell_id, duration); -} - -int Lua_Mob::GetActSpellCasttime(int spell_id, int cast_time) { - Lua_Safe_Call_Int(); - return self->GetActSpellCasttime(spell_id, cast_time); -} - double Lua_Mob::ResistSpell(int resist_type, int spell_id, Lua_Mob caster) { Lua_Safe_Call_Real(); return self->ResistSpell(resist_type, spell_id, caster); @@ -719,16 +625,6 @@ double Lua_Mob::GetSize() { return self->GetSize(); } -void Lua_Mob::SetFollowID(int id) { - Lua_Safe_Call_Void(); - self->SetFollowID(id); -} - -int Lua_Mob::GetFollowID() { - Lua_Safe_Call_Int(); - return self->GetFollowID(); -} - void Lua_Mob::Message(int type, const char *message) { Lua_Safe_Call_Void(); self->Message(type, message); @@ -744,6 +640,11 @@ void Lua_Mob::Say(const char *message) { self->Say(message); } +void Lua_Mob::QuestSay(Lua_Client client, const char *message) { + Lua_Safe_Call_Void(); + self->QuestJournalledSay(client, message); +} + void Lua_Mob::Shout(const char *message) { Lua_Safe_Call_Void(); self->Shout(message); @@ -764,689 +665,91 @@ void Lua_Mob::InterruptSpell(int spell_id) { self->InterruptSpell(spell_id); } -//bool Lua_Mob::CastSpell(int spell_id, int target_id) { -// Lua_Safe_Call_Void(); -// return self->CastSpell(spell_id, target_id); -//} -// -//bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot) { -// Lua_Safe_Call_Void(); -// return self->CastSpell(spell_id, target_id, slot); -//} -// -//bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time) { -// Lua_Safe_Call_Void(); -// return self->CastSpell(spell_id, target_id, slot, cast_time); -//} -// -//bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost) { -// Lua_Safe_Call_Void(); -// return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost); -//} -// -//bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot) { -// Lua_Safe_Call_Void(); -// return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot)); -//} -// -//bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, -// int timer_duration) { -// Lua_Safe_Call_Void(); -// return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), -// static_cast(timer), static_cast(timer_duration)); -//} -// -//bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, -// int timer_duration, int resist_adjust) { -// Lua_Safe_Call_Void(); -// int16 res = resist_adjust; -// -// return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), -// static_cast(timer), static_cast(timer_duration), 0, &res); -//} -// -//bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target) { -// return SpellFinished(spell_id, target, 10, 0, 0xFFFFFFFF, 0, false); -//} -// -//bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot) { -// return SpellFinished(spell_id, target, slot, 0, 0xFFFFFFFF, 0, false); -//} -// -//bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used) { -// return SpellFinished(spell_id, target, slot, mana_used, 0xFFFFFFFF, 0, false); -//} -// -//bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot) { -// return SpellFinished(spell_id, target, slot, mana_used, inventory_slot, 0, false); -//} -// -//bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust) { -// return SpellFinished(spell_id, target, slot, mana_used, inventory_slot, resist_adjust, false); -//} -// -//bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust, bool proc) { -// Lua_Safe_Call_Void(); -// Lua_Safe_Cast(Mob, t, target); -// return self->SpellFinished(spell_id, t, slot, mana_used, inventory_slot, resist_adjust, proc); -//} -// -//void Lua_Mob::SpellEffect(Lua_Mob caster, int spell_id, double partial) { -// Lua_Safe_Call_Void(); -// Lua_Safe_Cast(Mob, c, caster); -// -// self->SpellEffect(c, spell_id, partial); -// Lua_Safe_Cast(Mob, c, caster); -//} -// -//bool Lua_Mob::IsImmuneToSpell(int spell_id, Lua_Mob caster) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffFadeBySpellID(int spell_id) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffFadeByEffect(int effect_id, int skip_slot) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffFadeAll() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffFadeDetrimental() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffFadeBySlot(int slot, bool recalc_bonuses) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffFadeDetrimentalByCaster(Lua_Mob caster) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffFadeBySitModifier() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::BuffModifyDurationBySpellID(int spell_id, int new_duration) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::CanBuffStack(int spell_id, int caster_level, bool fail_if_overwrite) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsCasting() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::CastingSpellID() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetAppearance(int app) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetAppearance(int app, bool ignore_self) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetAppearance() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetPetID() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetOwnerID() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetPetType(int type) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetPetType() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetBodyType() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetBodyType(int type) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::Stun(int duration) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::UnStun() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::Spin() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::Kill() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetInvul(bool invul) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::GetInvul() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetExtraHaste(int haste) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetHaste() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetMonkHandToHandDamage() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetMonkHandToHandDelay() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CanThisClassDoubleAttack() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CanThisClassDualWield() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CanThisClassRiposte() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CanThisClassDodge() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CanThisClassParry() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CanThisClassBlock() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetClassLevelFactor() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::Mesmerize() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsMezzed() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsStunned() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::StartEnrage() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsEnraged() { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetReverseFactionCon(Lua_Mob other) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsAIControlled() { -// Lua_Safe_Call_Void(); -//} -// -//double Lua_Mob::GetAggroRange() { -// Lua_Safe_Call_Void(); -//} -// -//double Lua_Mob::GetAssistRange() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetPetOrder(int order) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetPetOrder() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsRoamer() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsRooted() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::AddToHateList(Lua_Mob other) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::AddToHateList(Lua_Mob other, int hate) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::AddToHateList(Lua_Mob other, int hate, int damage) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help, bool frenzy) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help, bool frenzy, bool buff_tic) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::RemoveFromHateList(Lua_Mob mob) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetHate(Lua_Mob other) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetHate(Lua_Mob other, int hate) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetHate(Lua_Mob other, int hate, int damage) { -// Lua_Safe_Call_Void(); -//} -// -//uint32 Lua_Mob::GetHateAmount(Lua_Mob tmob) { -// Lua_Safe_Call_Void(); -//} -// -//uint32 Lua_Mob::GetHateAmount(Lua_Mob tmob, bool is_damage) { -// Lua_Safe_Call_Void(); -//} -// -//uint32 Lua_Mob::GetDamageAmount(Lua_Mob tmob) { -// Lua_Safe_Call_Void(); -//} -// -//Lua_Mob Lua_Mob::GetHateTop() { -// Lua_Safe_Call_Void(); -//} -// -//Lua_Mob Lua_Mob::GetHateDamageTop(Lua_Mob other) { -// Lua_Safe_Call_Void(); -//} -// -//Lua_Mob Lua_Mob::GetHateRandom() { -// Lua_Safe_Call_Void(); -//} -// -//Lua_Mob Lua_Mob::GetHateMost() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsEngaged() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::HateSummon() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::FaceTarget() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::FaceTarget(Lua_Mob mob_to_face) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetHeading(double new_h) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::WipeHateList() { -// Lua_Safe_Call_Void(); -//} -// -//double Lua_Mob::CalculateHeadingToTarget(double x, double y) { -// Lua_Safe_Call_Void(); -//} -// -//double Lua_Mob::CalculateDistance(double x, double y, double z) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SendTo(double new_x, double new_y, double new_z) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SendToFixZ(double new_x, double new_y, double new_z) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::NPCSpecialAttacks(const char* parse, int permtag) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::NPCSpecialAttacks(const char* parse, int permtag, bool reset) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::NPCSpecialAttacks(const char* parse, int permtag, bool reset, bool remove) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetResist(int type) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::Charmed() { -// Lua_Safe_Call_Void(); -//} -// -//uint32 Lua_Mob::GetLevelHP(int level) { -// Lua_Safe_Call_Void(); -//} -// -//uint32 Lua_Mob::GetAA(int level) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::CheckAggroAmount(int spell_id) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::CheckAggroAmount(int spell_id, bool is_proc) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::CheckHealAggroAmount(int spell_id) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::CheckHealAggroAmount(int spell_id, uint32 heal_possible) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::DivineAura() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetOOCRegen(int new_regen) { -// Lua_Safe_Call_Void(); -//} -// -//const Lua_Mob::char* GetEntityVariable(const char *id) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetEntityVariable(const char *id, const char *m_var) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::EntityVariableExists(const char *id) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CombatRange(Lua_Mob other) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override, int reuse_time) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override, int reuse_time, bool hit_chance) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod, int focus) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod, int focus, bool can_riposte) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CheckLoS(Lua_Mob other) { -// Lua_Safe_Call_Void(); -//} -// // make sure this is CheckLoSFN -//bool Lua_Mob::CheckLoSToLoc(double x, double y, double z) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::CheckLoSToLoc(double x, double y, double z, double mob_size) { -// Lua_Safe_Call_Void(); -//} -// -//double Lua_Mob::FindGroundZ(double new_x, double new_y) { -// Lua_Safe_Call_Void(); -//} -// -//double Lua_Mob::FindGroundZ(double new_x, double new_y, double z_offset) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle, double tilt) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle, double tilt, double arc) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::HasNPCSpecialAtk(const char* parse) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SendAppearanceEffect(uint32 parm1, uint32 parm2, uint32 parm3, uint32 parm4, uint32 parm5) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SendAppearanceEffect(uint32 parm1, uint32 parm2, uint32 parm3, uint32 parm4, uint32 parm5, Lua_Client client) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetFlyMode(int value) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetTexture(int value) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetRace(int value) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetGender(int value) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SendIllusionPacket(int in_race, int in_gender, int in_texture, int in_helmtexture, int in_haircolor, int in_beardcolor, int in_eyecolor1, int in_eyecolor2, int in_hairstyle, int in_luclinface, int in_beard, int in_aa_title, uint32 in_drakkin_heritage, uint32 in_drakkin_tattoo, uint32 in_drakkin_details, double in_size) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::QuestReward(Lua_Client c) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::QuestReward(Lua_Client c, uint32 silver) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::QuestReward(Lua_Client c, uint32 silver, uint32 gold) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::QuestReward(Lua_Client c, uint32 silver, uint32 gold, uint32 platinum) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::CameraEffect(uint32 duration, uint32 intensity) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SendSpellEffect(uint32 effect, uint32 duration, uint32 finish_delay, bool zone_wide, uint32 unk20, bool perm_effect, Lua_Client client) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::TempName(const char *new_name) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetGlobal(const char *var_name, const char *new_value, int options, const char *duration) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetGlobal(const char *var_name, const char *new_value, int options, const char *duration, Lua_Mob other) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::TarGlobal(const char *var_name, const char *value, const char *duration, int npc_id, int char_id, int zone_id) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DelGlobal(const char *var_name) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetSlotTint(int slot, int red, int green, int blue) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::WearChange(int material_slot, int texture, uint32 color) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::DoKnockback(Lua_Mob caster, uint32 pushback, uint32 pushup) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::RemoveNimbusEffect(int effect_id) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsRunning() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetRunning(bool v) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetTargetable(bool v) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ModSkillDmgTaken(int skill_num, int value) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetModSkillDmgTaken(int skill_num) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetSkillDmgTaken(int skill_num) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetAllowBeneficial(bool v) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::GetAllowBeneficial() { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsBeneficialAllowed(Lua_Mob target) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::ModVulnerability(int resist, int value) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetModVulnerability(int resist) { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetDisableMelee(bool v) { -// Lua_Safe_Call_Void(); -//} -// -//bool Lua_Mob::IsMeleeDisabled() { -// Lua_Safe_Call_Void(); -//} -// -//void Lua_Mob::SetFlurryChance(int v) { -// Lua_Safe_Call_Void(); -//} -// -//int Lua_Mob::GetFlurryChance() { -// Lua_Safe_Call_Void(); -//} +bool Lua_Mob::CastSpell(int spell_id, int target_id) { + Lua_Safe_Call_Bool(); + return self->CastSpell(spell_id, target_id); +} +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot) { + Lua_Safe_Call_Bool(); + return self->CastSpell(spell_id, target_id, slot); +} + +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time) { + Lua_Safe_Call_Bool(); + return self->CastSpell(spell_id, target_id, slot, cast_time); +} + +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost) { + Lua_Safe_Call_Bool(); + return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost); +} + +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot) { + Lua_Safe_Call_Bool(); + return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot)); +} + +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, + int timer_duration) { + Lua_Safe_Call_Bool(); + return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), + static_cast(timer), static_cast(timer_duration)); +} + +bool Lua_Mob::CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, + int timer_duration, int resist_adjust) { + Lua_Safe_Call_Bool(); + int16 res = resist_adjust; + + return self->CastSpell(spell_id, target_id, slot, cast_time, mana_cost, nullptr, static_cast(item_slot), + static_cast(timer), static_cast(timer_duration), 0, &res); +} + +bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target) { + Lua_Safe_Call_Bool(); + return self->SpellFinished(spell_id, target); +} + +bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot) { + Lua_Safe_Call_Bool(); + return self->SpellFinished(spell_id, target, slot); +} + +bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used) { + Lua_Safe_Call_Bool(); + return self->SpellFinished(spell_id, target, slot, mana_used); +} + +bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot) { + Lua_Safe_Call_Bool(); + return self->SpellFinished(spell_id, target, slot, mana_used, inventory_slot); +} + +bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust) { + Lua_Safe_Call_Bool(); + return self->SpellFinished(spell_id, target, slot, mana_used, inventory_slot, resist_adjust); +} + +bool Lua_Mob::SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust, bool proc) { + Lua_Safe_Call_Bool(); + return self->SpellFinished(spell_id, target, slot, mana_used, inventory_slot, resist_adjust, proc); +} + +void Lua_Mob::SpellEffect(Lua_Mob caster, int spell_id, double partial) { + Lua_Safe_Call_Void(); + self->SpellEffect(caster, spell_id, partial); +} + +Lua_Mob Lua_Mob::GetPet() { + Lua_Safe_Call_Mob(); + return Lua_Mob(self->GetPet()); +} + +Lua_Mob Lua_Mob::GetOwner() { + Lua_Safe_Call_Mob(); + return Lua_Mob(self->GetOwner()); +} #endif diff --git a/zone/lua_mob.h b/zone/lua_mob.h index 7dabeeb8e..9752620a3 100644 --- a/zone/lua_mob.h +++ b/zone/lua_mob.h @@ -25,7 +25,6 @@ public: const char *GetName(); void Depop(); void Depop(bool start_spawn_timer); - void RogueAssassinate(Lua_Mob other); bool BehindMob(); bool BehindMob(Lua_Mob other); bool BehindMob(Lua_Mob other, float x); @@ -33,10 +32,6 @@ public: void SetLevel(int level); void SetLevel(int level, bool command); void SendWearChange(int material_slot); - uint32 GetEquipment(int material_slot); - int32 GetEquipmentMaterial(int material_slot); - uint32 GetEquipmentColor(int material_slot); - uint32 GetArmorTint(int i); bool IsMoving(); void GotoBind(); void Gate(); @@ -66,9 +61,6 @@ public: void GMMove(double x, double y, double z); void GMMove(double x, double y, double z, double heading); void GMMove(double x, double y, double z, double heading, bool send_update); - void SendPosUpdate(); - void SendPosUpdate(bool send_to_self); - void SendPosition(); bool HasProcs(); bool IsInvisible(); bool IsInvisible(Lua_Mob other); @@ -78,10 +70,6 @@ public: bool FindType(int type, bool offensive); bool FindType(int type, bool offensive, int threshold); int GetBuffSlotFromType(int slot); - void MakePet(int spell_id, const char* pet_type); - void MakePet(int spell_id, const char* pet_type, const char *pet_name); - void MakePoweredPet(int spell_id, const char* pet_type, int pet_power); - void MakePoweredPet(int spell_id, const char* pet_type, int pet_power, const char *pet_name); int GetBaseRace(); int GetBaseGender(); int GetDeity(); @@ -139,13 +127,6 @@ public: int GetMaxINT(); int GetMaxWIS(); int GetMaxCHA(); - double GetActSpellRange(int spell_id, double range); - double GetActSpellRange(int spell_id, double range, bool is_bard); - int GetActSpellDamage(int spell_id, int value); - int GetActSpellHealing(int spell_id, int value); - int GetActSpellCost(int spell_id, int cost); - int GetActSpellDuration(int spell_id, int duration); - int GetActSpellCasttime(int spell_id, int cast_time); double ResistSpell(int resist_type, int spell_id, Lua_Mob caster); double ResistSpell(int resist_type, int spell_id, Lua_Mob caster, bool use_resist_override); double ResistSpell(int resist_type, int spell_id, Lua_Mob caster, bool use_resist_override, int resist_override); @@ -165,17 +146,15 @@ public: int GetWaypointID(); void SetCurrentWP(int wp); double GetSize(); - void SetFollowID(int id); - int GetFollowID(); void Message(int type, const char *message); void Message_StringID(int type, int string_id, uint32 distance); void Say(const char *message); + void QuestSay(Lua_Client client, const char *message); void Shout(const char *message); void Emote(const char *message); void InterruptSpell(); void InterruptSpell(int spell_id); - - /*bool CastSpell(int spell_id, int target_id); + bool CastSpell(int spell_id, int target_id); bool CastSpell(int spell_id, int target_id, int slot); bool CastSpell(int spell_id, int target_id, int slot, int cast_time); bool CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost); @@ -190,167 +169,8 @@ public: bool SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust); bool SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust, bool proc); void SpellEffect(Lua_Mob caster, int spell_id, double partial); - bool IsImmuneToSpell(int spell_id, Lua_Mob caster); - void BuffFadeBySpellID(int spell_id); - void BuffFadeByEffect(int effect_id, int skip_slot); - void BuffFadeAll(); - void BuffFadeDetrimental(); - void BuffFadeBySlot(int slot, bool recalc_bonuses); - void BuffFadeDetrimentalByCaster(Lua_Mob caster); - void BuffFadeBySitModifier(); - void BuffModifyDurationBySpellID(int spell_id, int new_duration); - int CanBuffStack(int spell_id, int caster_level, bool fail_if_overwrite); - bool IsCasting(); - int CastingSpellID(); - void SetAppearance(int app); - void SetAppearance(int app, bool ignore_self); - int GetAppearance(); - int GetPetID(); - int GetOwnerID(); - void SetPetType(int type); - int GetPetType(); - int GetBodyType(); - void SetBodyType(int type); - void Stun(int duration); - void UnStun(); - void Spin(); - void Kill(); - void SetInvul(bool invul); - bool GetInvul(); - void SetExtraHaste(int haste); - int GetHaste(); - int GetMonkHandToHandDamage(); - int GetMonkHandToHandDelay(); - bool CanThisClassDoubleAttack(); - bool CanThisClassDualWield(); - bool CanThisClassRiposte(); - bool CanThisClassDodge(); - bool CanThisClassParry(); - bool CanThisClassBlock(); - int GetClassLevelFactor(); - void Mesmerize(); - bool IsMezzed(); - bool IsStunned(); - void StartEnrage(); - bool IsEnraged(); - int GetReverseFactionCon(Lua_Mob other); - bool IsAIControlled(); - double GetAggroRange(); - double GetAssistRange(); - void SetPetOrder(int order); - int GetPetOrder(); - bool IsRoamer(); - bool IsRooted(); - void AddToHateList(Lua_Mob other); - void AddToHateList(Lua_Mob other, int hate); - void AddToHateList(Lua_Mob other, int hate, int damage); - void AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help); - void AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help, bool frenzy); - void AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help, bool frenzy, bool buff_tic); - bool RemoveFromHateList(Lua_Mob mob); - void SetHate(Lua_Mob other); - void SetHate(Lua_Mob other, int hate); - void SetHate(Lua_Mob other, int hate, int damage); - uint32 GetHateAmount(Lua_Mob tmob); - uint32 GetHateAmount(Lua_Mob tmob, bool is_damage); - uint32 GetDamageAmount(Lua_Mob tmob); - Lua_Mob GetHateTop(); - Lua_Mob GetHateDamageTop(Lua_Mob other); - Lua_Mob GetHateRandom(); - Lua_Mob GetHateMost(); - bool IsEngaged(); - bool HateSummon(); - void FaceTarget(); - void FaceTarget(Lua_Mob mob_to_face); - void SetHeading(double new_h); - void WipeHateList(); - double CalculateHeadingToTarget(double x, double y); - double CalculateDistance(double x, double y, double z); - void SendTo(double new_x, double new_y, double new_z); - void SendToFixZ(double new_x, double new_y, double new_z); - void NPCSpecialAttacks(const char* parse, int permtag); - void NPCSpecialAttacks(const char* parse, int permtag, bool reset); - void NPCSpecialAttacks(const char* parse, int permtag, bool reset, bool remove); - int GetResist(int type); - bool Charmed(); - uint32 GetLevelHP(int level); - uint32 GetAA(int level); - int CheckAggroAmount(int spell_id); - int CheckAggroAmount(int spell_id, bool is_proc); - int CheckHealAggroAmount(int spell_id); - int CheckHealAggroAmount(int spell_id, uint32 heal_possible); - bool DivineAura(); - void SetOOCRegen(int new_regen); - const char* GetEntityVariable(const char *id); - void SetEntityVariable(const char *id, const char *m_var); - bool EntityVariableExists(const char *id); - bool CombatRange(Lua_Mob other); - void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage); - void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override); - void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override, int reuse_time); - void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override, int reuse_time, bool hit_chance); - void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse); - void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod); - void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod, int focus); - void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod, int focus, bool can_riposte); - bool CheckLoS(Lua_Mob other); // make sure this is CheckLoSFN - bool CheckLoSToLoc(double x, double y, double z); - bool CheckLoSToLoc(double x, double y, double z, double mob_size); - double FindGroundZ(double new_x, double new_y); - double FindGroundZ(double new_x, double new_y, double z_offset); - void ProjectileAnimation(Lua_Mob to, int item_id); - void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow); - void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed); - void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle); - void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle, double tilt); - void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle, double tilt, double arc); - bool HasNPCSpecialAtk(const char* parse); - void SendAppearanceEffect(uint32 parm1, uint32 parm2, uint32 parm3, uint32 parm4, uint32 parm5); - void SendAppearanceEffect(uint32 parm1, uint32 parm2, uint32 parm3, uint32 parm4, uint32 parm5, Lua_Client client); - void SetFlyMode(int value); - void SetTexture(int value); - void SetRace(int value); - void SetGender(int value); - void SendIllusionPacket(int in_race, int in_gender, int in_texture, int in_helmtexture, int in_haircolor, int in_beardcolor, - int in_eyecolor1, int in_eyecolor2, int in_hairstyle, int in_luclinface, int in_beard, int in_aa_title, - uint32 in_drakkin_heritage, uint32 in_drakkin_tattoo, uint32 in_drakkin_details, double in_size); - void QuestReward(Lua_Client c); - void QuestReward(Lua_Client c, uint32 silver); - void QuestReward(Lua_Client c, uint32 silver, uint32 gold); - void QuestReward(Lua_Client c, uint32 silver, uint32 gold, uint32 platinum); - void CameraEffect(uint32 duration, uint32 intensity); - void SendSpellEffect(uint32 effect, uint32 duration, uint32 finish_delay, bool zone_wide, uint32 unk20, bool perm_effect, - Lua_Client client); - void TempName(const char *new_name); - void SetGlobal(const char *var_name, const char *new_value, int options, const char *duration); - void SetGlobal(const char *var_name, const char *new_value, int options, const char *duration, Lua_Mob other); - void TarGlobal(const char *var_name, const char *value, const char *duration, int npc_id, int char_id, int zone_id); - void DelGlobal(const char *var_name); - void SetSlotTint(int slot, int red, int green, int blue); - void WearChange(int material_slot, int texture, uint32 color); - void DoKnockback(Lua_Mob caster, uint32 pushback, uint32 pushup); - void RemoveNimbusEffect(int effect_id); - bool IsRunning(); - void SetRunning(bool v); - void SetTargetable(bool v); - void ModSkillDmgTaken(int skill_num, int value); - int GetModSkillDmgTaken(int skill_num); - int GetSkillDmgTaken(int skill_num); - void SetAllowBeneficial(bool v); - bool GetAllowBeneficial(); - bool IsBeneficialAllowed(Lua_Mob target); - void ModVulnerability(int resist, int value); - int GetModVulnerability(int resist); - void SetDisableMelee(bool v); - bool IsMeleeDisabled(); - void SetFlurryChance(int v); - int GetFlurryChance(); - */ - - //GetHateList - Requires classes not yet exported - //SignalClient - Gonna do this differently - //DoArcheryAttackDmg - Requires classes not yet exported - //DoThrowingAttackDmg - Requires classes not yet exported + Lua_Mob GetPet(); + Lua_Mob GetOwner(); }; #endif diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index c817c185f..40701cdc2 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -13,6 +13,7 @@ #include "lua_mob.h" #include "lua_client.h" #include "lua_npc.h" +#include "lua_trade.h" const char *LuaEvents[_LargestEventID] = { "event_say", @@ -92,21 +93,37 @@ int LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, return 0; } - if(evt != EVENT_SPAWN && evt != EVENT_SAY) { - return 0; - } - - - const char *sub_name = LuaEvents[evt]; - if(!HasQuestSub(npc->GetNPCTypeID(), sub_name)) { + if(!HasQuestSub(npc->GetNPCTypeID(), LuaEvents[evt])) { return 0; } std::stringstream package_name; package_name << "npc_" << npc->GetNPCTypeID(); + return _EventNPC(package_name.str(), evt, npc, init, data, extra_data); +} + +int LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { + if(evt >= _LargestEventID) { + return 0; + } + + if(!npc) { + return 0; + } + + if(!HasGlobalQuestSub(LuaEvents[evt])) { + return 0; + } + + return _EventNPC("global_npc", evt, npc, init, data, extra_data); +} + +int LuaParser::_EventNPC(std::string package_name, QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { + const char *sub_name = LuaEvents[evt]; + lua_State *L = nullptr; - auto iter = states_.find(package_name.str()); + auto iter = states_.find(package_name); if(iter == states_.end()) { return 0; } @@ -115,23 +132,101 @@ int LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, try { lua_getfield(L, LUA_GLOBALSINDEX, sub_name); + //push self Lua_NPC l_npc(npc); - Lua_Client l_client; luabind::object l_npc_o = luabind::object(L, l_npc); l_npc_o.push(L); int arg_count = 1; int ret_count = 1; - if(evt == EVENT_SAY) { - l_client.d_ = init; - luabind::object l_client_o = luabind::object(L, l_client); - l_client_o.push(L); + if(init) { + Lua_Mob l_mob(init); + luabind::object l_mob_o = luabind::object(L, l_mob); + l_mob_o.push(L); + ++arg_count; + } + switch(evt) { + case EVENT_SAY: + case EVENT_AGGRO_SAY: + case EVENT_PROXIMITY_SAY: { + //text lua_pushstring(L, data.c_str()); + + //language lua_pushinteger(L, extra_data); - arg_count += 3; + arg_count += 2; + break; + } + + case EVENT_ITEM: { + Lua_Trade trade; + std::stringstream ident; + ident << npc->GetNPCTypeID(); + //std::string identifier = std::string(itoa(npc->GetNPCTypeID())); + trade.item1_ = std::stoul(GetVar("item1." + ident.str())); + trade.item2_ = std::stoul(GetVar("item2." + ident.str())); + trade.item3_ = std::stoul(GetVar("item3." + ident.str())); + trade.item4_ = std::stoul(GetVar("item4." + ident.str())); + trade.item1_charges_ = std::stoul(GetVar("item1.charges." + ident.str())); + trade.item1_charges_ = std::stoul(GetVar("item2.charges." + ident.str())); + trade.item1_charges_ = std::stoul(GetVar("item3.charges." + ident.str())); + trade.item1_charges_ = std::stoul(GetVar("item4.charges." + ident.str())); + trade.item1_attuned_ = std::stoi(GetVar("item1.attuned." + ident.str())) != 0 ? true : false; + trade.item2_attuned_ = std::stoi(GetVar("item2.attuned." + ident.str())) != 0 ? true : false; + trade.item3_attuned_ = std::stoi(GetVar("item3.attuned." + ident.str())) != 0 ? true : false; + trade.item4_attuned_ = std::stoi(GetVar("item4.attuned." + ident.str())) != 0 ? true : false; + trade.platinum_ = std::stoul(GetVar("platinum." + ident.str())); + trade.gold_ = std::stoul(GetVar("gold." + ident.str())); + trade.silver_ = std::stoul(GetVar("silver." + ident.str())); + trade.copper_ = std::stoul(GetVar("copper." + ident.str())); + + luabind::object l_trade_o = luabind::object(L, trade); + l_trade_o.push(L); + + arg_count += 1; + break; + } + + case EVENT_HP: { + if(extra_data == 1) { + lua_pushstring(L, "-1"); + lua_pushstring(L, data.c_str()); + } + else + { + lua_pushstring(L, data.c_str()); + lua_pushstring(L, "-1"); + } + + arg_count += 2; + break; + } + + case EVENT_WAYPOINT_ARRIVE: + case EVENT_WAYPOINT_DEPART: + case EVENT_TIMER: + case EVENT_SIGNAL: + case EVENT_COMBAT: + case EVENT_CAST_ON: + case EVENT_TASKACCEPTED: + case EVENT_POPUP_RESPONSE: + case EVENT_HATE_LIST: { + lua_pushstring(L, data.c_str()); + + arg_count += 1; + break; + } + + case EVENT_NPC_SLAY: { + lua_pushinteger(L, init->GetNPCTypeID()); + + arg_count += 1; + break; + } + } if(lua_pcall(L, arg_count, ret_count, 0)) { @@ -152,10 +247,6 @@ int LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, return 0; } -int LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { - return 0; -} - int LuaParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { return 0; } @@ -366,17 +457,12 @@ void LuaParser::MapFunctions(lua_State *L) { .def("GetName", &Lua_Mob::GetName) .def("Depop", (void(Lua_Mob::*)(void))&Lua_Mob::Depop) .def("Depop", (void(Lua_Mob::*)(bool))&Lua_Mob::Depop) - .def("RogueAssassinate", &Lua_Mob::RogueAssassinate) .def("BehindMob", (bool(Lua_Mob::*)(void))&Lua_Mob::BehindMob) .def("BehindMob", (bool(Lua_Mob::*)(Lua_Mob))&Lua_Mob::BehindMob) .def("BehindMob", (bool(Lua_Mob::*)(Lua_Mob,float))&Lua_Mob::BehindMob) .def("BehindMob", (bool(Lua_Mob::*)(Lua_Mob,float,float))&Lua_Mob::BehindMob) .def("SetLevel", (void(Lua_Mob::*)(int))&Lua_Mob::SetLevel) .def("SetLevel", (void(Lua_Mob::*)(int,bool))&Lua_Mob::SetLevel) - .def("GetEquipment", &Lua_Mob::GetEquipment) - .def("GetEquipmentMaterial", &Lua_Mob::GetEquipmentMaterial) - .def("GetEquipmentColor", &Lua_Mob::GetEquipmentColor) - .def("GetArmorTint", &Lua_Mob::GetArmorTint) .def("IsMoving", &Lua_Mob::IsMoving) .def("GotoBind", &Lua_Mob::GotoBind) .def("Attack", (bool(Lua_Mob::*)(Lua_Mob))&Lua_Mob::Attack) @@ -405,9 +491,6 @@ void LuaParser::MapFunctions(lua_State *L) { .def("GMMove", (void(Lua_Mob::*)(double,double,double))&Lua_Mob::GMMove) .def("GMMove", (void(Lua_Mob::*)(double,double,double,double))&Lua_Mob::GMMove) .def("GMMove", (void(Lua_Mob::*)(double,double,double,double,bool))&Lua_Mob::GMMove) - .def("SendPosUpdate", (void(Lua_Mob::*)(void))&Lua_Mob::SendPosUpdate) - .def("SendPosUpdate", (void(Lua_Mob::*)(bool))&Lua_Mob::SendPosUpdate) - .def("SendPosition", &Lua_Mob::SendPosition) .def("HasProcs", &Lua_Mob::HasProcs) .def("IsInvisible", (bool(Lua_Mob::*)(void))&Lua_Mob::IsInvisible) .def("IsInvisible", (bool(Lua_Mob::*)(Lua_Mob))&Lua_Mob::IsInvisible) @@ -417,10 +500,6 @@ void LuaParser::MapFunctions(lua_State *L) { .def("FindType", (bool(Lua_Mob::*)(int,bool))&Lua_Mob::FindType) .def("FindType", (bool(Lua_Mob::*)(int,bool,int))&Lua_Mob::FindType) .def("GetBuffSlotFromType", &Lua_Mob::GetBuffSlotFromType) - .def("MakePet", (void(Lua_Mob::*)(int,const char*))&Lua_Mob::MakePet) - .def("MakePet", (void(Lua_Mob::*)(int,const char*,const char*))&Lua_Mob::MakePet) - .def("MakePoweredPet", (void(Lua_Mob::*)(int,const char*,int))&Lua_Mob::MakePoweredPet) - .def("MakePoweredPet", (void(Lua_Mob::*)(int,const char*,int,const char*))&Lua_Mob::MakePoweredPet) .def("GetBaseRace", &Lua_Mob::GetBaseRace) .def("GetBaseGender", &Lua_Mob::GetBaseGender) .def("GetDeity", &Lua_Mob::GetDeity) @@ -478,13 +557,6 @@ void LuaParser::MapFunctions(lua_State *L) { .def("GetMaxINT", &Lua_Mob::GetMaxINT) .def("GetMaxWIS", &Lua_Mob::GetMaxWIS) .def("GetMaxCHA", &Lua_Mob::GetMaxCHA) - .def("GetActSpellRange", (double(Lua_Mob::*)(int,double))&Lua_Mob::GetActSpellRange) - .def("GetActSpellRange", (double(Lua_Mob::*)(int,double,bool))&Lua_Mob::GetActSpellRange) - .def("GetActSpellDamage", &Lua_Mob::GetActSpellDamage) - .def("GetActSpellHealing", &Lua_Mob::GetActSpellHealing) - .def("GetActSpellCost", &Lua_Mob::GetActSpellCost) - .def("GetActSpellDuration", &Lua_Mob::GetActSpellDuration) - .def("GetActSpellCasttime", &Lua_Mob::GetActSpellCasttime) .def("ResistSpell", (double(Lua_Mob::*)(int,int,Lua_Mob))&Lua_Mob::ResistSpell) .def("ResistSpell", (double(Lua_Mob::*)(int,int,Lua_Mob,bool))&Lua_Mob::ResistSpell) .def("ResistSpell", (double(Lua_Mob::*)(int,int,Lua_Mob,bool,int))&Lua_Mob::ResistSpell) @@ -504,8 +576,6 @@ void LuaParser::MapFunctions(lua_State *L) { .def("GetWaypointID", &Lua_Mob::GetWaypointID) .def("SetCurrentWP", &Lua_Mob::SetCurrentWP) .def("GetSize", &Lua_Mob::GetSize) - .def("SetFollowID", &Lua_Mob::SetFollowID) - .def("GetFollowID", &Lua_Mob::GetFollowID) .def("Message", &Lua_Mob::Message) .def("Message_StringID", &Lua_Mob::Message_StringID) .def("Say", &Lua_Mob::Say) @@ -513,13 +583,46 @@ void LuaParser::MapFunctions(lua_State *L) { .def("Emote", &Lua_Mob::Emote) .def("InterruptSpell", (void(Lua_Mob::*)(void))&Lua_Mob::InterruptSpell) .def("InterruptSpell", (void(Lua_Mob::*)(int))&Lua_Mob::InterruptSpell) + .def("CastSpell", (bool(Lua_Mob::*)(int,int))&Lua_Mob::CastSpell) + .def("CastSpell", (bool(Lua_Mob::*)(int,int,int))&Lua_Mob::CastSpell) + .def("CastSpell", (bool(Lua_Mob::*)(int,int,int,int))&Lua_Mob::CastSpell) + .def("CastSpell", (bool(Lua_Mob::*)(int,int,int,int,int))&Lua_Mob::CastSpell) + .def("CastSpell", (bool(Lua_Mob::*)(int,int,int,int,int,int))&Lua_Mob::CastSpell) + .def("CastSpell", (bool(Lua_Mob::*)(int,int,int,int,int,int,int,int))&Lua_Mob::CastSpell) + .def("CastSpell", (bool(Lua_Mob::*)(int,int,int,int,int,int,int,int,int))&Lua_Mob::CastSpell) + .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob))&Lua_Mob::SpellFinished) + .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int))&Lua_Mob::SpellFinished) + .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int))&Lua_Mob::SpellFinished) + .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int,uint32))&Lua_Mob::SpellFinished) + .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int,uint32,int))&Lua_Mob::SpellFinished) + .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int,uint32,int,bool))&Lua_Mob::SpellFinished) + .def("SpellEffect", &Lua_Mob::SpellEffect) , luabind::class_("Client") .def(luabind::constructor<>()), luabind::class_("NPC") + .def(luabind::constructor<>()), + + luabind::class_("Trade") .def(luabind::constructor<>()) + .def_readwrite("item1", &Lua_Trade::item1_) + .def_readwrite("item2", &Lua_Trade::item2_) + .def_readwrite("item3", &Lua_Trade::item3_) + .def_readwrite("item4", &Lua_Trade::item4_) + .def_readwrite("item1_charges", &Lua_Trade::item1_charges_) + .def_readwrite("item2_charges", &Lua_Trade::item2_charges_) + .def_readwrite("item3_charges", &Lua_Trade::item3_charges_) + .def_readwrite("item4_charges", &Lua_Trade::item4_charges_) + .def_readwrite("item1_attuned", &Lua_Trade::item1_attuned_) + .def_readwrite("item2_attuned", &Lua_Trade::item2_attuned_) + .def_readwrite("item3_attuned", &Lua_Trade::item3_attuned_) + .def_readwrite("item4_attuned", &Lua_Trade::item4_attuned_) + .def_readwrite("platinum", &Lua_Trade::platinum_) + .def_readwrite("gold", &Lua_Trade::gold_) + .def_readwrite("silver", &Lua_Trade::silver_) + .def_readwrite("copper", &Lua_Trade::copper_) ]; } catch(std::exception &ex) { diff --git a/zone/lua_parser.h b/zone/lua_parser.h index 74397d432..4d055aa7e 100644 --- a/zone/lua_parser.h +++ b/zone/lua_parser.h @@ -44,6 +44,7 @@ public: virtual uint32 GetIdentifier() { return 0xb0712acc; } private: + int _EventNPC(std::string package_name, QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data); void LoadScript(std::string filename, std::string package_name); bool HasFunction(std::string function, std::string package_name); void ClearStates(); diff --git a/zone/lua_trade.h b/zone/lua_trade.h new file mode 100644 index 000000000..7ce05027f --- /dev/null +++ b/zone/lua_trade.h @@ -0,0 +1,26 @@ +#ifndef EQEMU_LUA_TRADE_H +#define EQEMU_LUA_TRADE_H +#ifdef LUA_EQEMU + +struct Lua_Trade +{ + uint32 item1_; + uint32 item2_; + uint32 item3_; + uint32 item4_; + uint32 item1_charges_; + uint32 item2_charges_; + uint32 item3_charges_; + uint32 item4_charges_; + uint32 item1_attuned_; + uint32 item2_attuned_; + uint32 item3_attuned_; + uint32 item4_attuned_; + uint32 platinum_; + uint32 gold_; + uint32 silver_; + uint32 copper_; +}; + +#endif +#endif \ No newline at end of file diff --git a/zone/trading.cpp b/zone/trading.cpp index 363faff69..62047ea8c 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -639,39 +639,25 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) snprintf(temp1, 100, "item%d.%d", z+1,tradingWith->GetNPCTypeID()); snprintf(temp2, 100, "%d",items[z]); parse->AddVar(temp1,temp2); - // memset(temp1,0x0,100); - // memset(temp2,0x0,100); snprintf(temp1, 100, "item%d.charges.%d", z+1,tradingWith->GetNPCTypeID()); snprintf(temp2, 100, "%d",charges[z]); parse->AddVar(temp1,temp2); - // memset(temp1,0x0,100); - // memset(temp2,0x0,100); snprintf(temp1, 100, "item%d.attuned.%d", z+1,tradingWith->GetNPCTypeID()); snprintf(temp2, 100, "%d",attuned[z]); parse->AddVar(temp1,temp2); - // memset(temp1,0x0,100); - // memset(temp2,0x0,100); } snprintf(temp1, 100, "copper.%d",tradingWith->GetNPCTypeID()); snprintf(temp2, 100, "%i",trade->cp); parse->AddVar(temp1,temp2); - // memset(temp1,0x0,100); - // memset(temp2,0x0,100); snprintf(temp1, 100, "silver.%d",tradingWith->GetNPCTypeID()); snprintf(temp2, 100, "%i",trade->sp); parse->AddVar(temp1,temp2); - // memset(temp1,0x0,100); - // memset(temp2,0x0,100); - snprintf(temp1, 100, "gold.%d",tradingWith->GetNPCTypeID()); + snprintf(temp1, 100, "gold.%d", tradingWith->GetNPCTypeID()); snprintf(temp2, 100, "%i",trade->gp); - parse->AddVar(temp1,temp2); - // memset(temp1,0x0,100); - // memset(temp2,0x0,100); - snprintf(temp1, 100, "platinum.%d",tradingWith->GetNPCTypeID()); + parse->AddVar(temp1, temp2); + snprintf(temp1, 100, "platinum.%d", tradingWith->GetNPCTypeID()); snprintf(temp2, 100, "%i",trade->pp); parse->AddVar(temp1,temp2); - // memset(temp1,0x0,100); - // memset(temp2,0x0,100); parse->EventNPC(EVENT_ITEM, tradingWith->CastToNPC(), this, "", 0); } }