CustomSpell addition, customspell function: Create custom spells within themselves
Spells/Fighter/Crusader/Shadowknight/Painbringer.lua function customspell(Spell, Caster, Target) SetSpellData(Spell,"name","Painbringer 2.0!") end sets name to Painbringer 2.0! instead of 'Painbringer'
This commit is contained in:
parent
1df57c9818
commit
f42e6f08de
3 changed files with 40 additions and 4 deletions
EQ2/source/WorldServer
|
@ -477,7 +477,7 @@ bool LuaInterface::LoadZoneScript(string name) {
|
|||
return LoadZoneScript(name.c_str());
|
||||
}
|
||||
|
||||
void LuaInterface::AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast, const char* function, SpellScriptTimer* timer) {
|
||||
void LuaInterface::AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast, const char* function, SpellScriptTimer* timer, bool passLuaSpell) {
|
||||
if (function)
|
||||
lua_getglobal(spell->state, function);
|
||||
else if (precast)
|
||||
|
@ -487,6 +487,9 @@ void LuaInterface::AddSpawnPointers(LuaSpell* spell, bool first_cast, bool preca
|
|||
else
|
||||
lua_getglobal(spell->state, "tick");
|
||||
|
||||
if(passLuaSpell)
|
||||
SetSpellValue(spell->state, spell);
|
||||
|
||||
Spawn* temp_spawn = 0;
|
||||
if (timer && timer->caster && spell->caster)
|
||||
temp_spawn = spell->caster->GetZone()->GetSpawnByID(timer->caster);
|
||||
|
@ -1717,7 +1720,6 @@ bool LuaInterface::RunItemScript(string script_name, const char* function_name,
|
|||
return false;
|
||||
}
|
||||
lua_getglobal(state, function_name);
|
||||
lua_getglobal(state, function_name);
|
||||
if (!lua_isfunction(state, lua_gettop(state))){
|
||||
lua_pop(state, 1);
|
||||
mutex->releasereadlock(__FUNCTION__);
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
void SetConversationValue(lua_State* state, vector<ConversationOption>* conversation);
|
||||
void SetOptionWindowValue(lua_State* state, vector<OptionWindowOption>* optionWindow);
|
||||
|
||||
void AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast = false, const char* function = 0, SpellScriptTimer* timer = 0);
|
||||
void AddSpawnPointers(LuaSpell* spell, bool first_cast, bool precast = false, const char* function = 0, SpellScriptTimer* timer = 0, bool passLuaSpell=false);
|
||||
LuaSpell* GetCurrentSpell(lua_State* state);
|
||||
bool CallSpellProcess(LuaSpell* spell, int8 num_parameters);
|
||||
LuaSpell* GetSpell(const char* name);
|
||||
|
|
|
@ -475,6 +475,23 @@ bool SpellProcess::CastInstant(Spell* spell, Entity* caster, Entity* target, boo
|
|||
lua_spell->initial_target = target->GetID();
|
||||
GetSpellTargets(lua_spell);
|
||||
|
||||
if (!lua_spell->spell->IsCopiedSpell())
|
||||
{
|
||||
lua_getglobal(lua_spell->state, "customspell");
|
||||
if (lua_isfunction(lua_spell->state, lua_gettop(lua_spell->state))) {
|
||||
lua_pop(lua_spell->state, 1);
|
||||
Spell* tmpSpell = lua_spell->spell;
|
||||
lua_spell->spell = new Spell(lua_spell->spell);
|
||||
lua_interface->AddCustomSpell(lua_spell);
|
||||
lua_interface->AddSpawnPointers(lua_spell, false, false, "customspell",0,true);
|
||||
if (lua_pcall(lua_spell->state, 3, 3, 0) != 0) {
|
||||
lua_interface->RemoveCustomSpell(lua_spell->spell->GetSpellID());
|
||||
safe_delete(lua_spell->spell);
|
||||
lua_spell->spell = tmpSpell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
caster->GetZone()->SendCastSpellPacket(lua_spell, caster);
|
||||
|
||||
if (!remove)
|
||||
|
@ -787,7 +804,6 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
|
|||
{
|
||||
if((customSpell != 0 || spell != 0) && caster)
|
||||
{
|
||||
|
||||
Client* client = 0;
|
||||
//int16 version = 0;
|
||||
|
||||
|
@ -823,6 +839,7 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
|
|||
|
||||
lua_spell->caster = caster;
|
||||
lua_spell->spell = spell;
|
||||
|
||||
int32 target_id = target->GetID();
|
||||
lua_spell->initial_target = target_id;
|
||||
|
||||
|
@ -852,6 +869,23 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
|
|||
//version = client->GetVersion();
|
||||
}
|
||||
|
||||
if (!customSpell)
|
||||
{
|
||||
lua_getglobal(lua_spell->state, "customspell");
|
||||
if (lua_isfunction(lua_spell->state, lua_gettop(lua_spell->state))) {
|
||||
lua_pop(lua_spell->state, 1);
|
||||
Spell* tmpSpell = lua_spell->spell;
|
||||
lua_spell->spell = new Spell(lua_spell->spell);
|
||||
lua_interface->AddCustomSpell(lua_spell);
|
||||
lua_interface->AddSpawnPointers(lua_spell, false, false, "customspell", 0, true);
|
||||
if (lua_pcall(lua_spell->state, 3, 3, 0) != 0) {
|
||||
lua_interface->RemoveCustomSpell(lua_spell->spell->GetSpellID());
|
||||
safe_delete(lua_spell->spell);
|
||||
lua_spell->spell = tmpSpell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If this spell is the toggle cast type and is being toggled off, do this now
|
||||
if (spell->GetSpellData()->cast_type == SPELL_CAST_TYPE_TOGGLE)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue