*Add base scripting interfce for spells - thanks to Brian for help in making it compile with GCC.

*Add hook for handling spell effects in new scripting system.

--HG--
branch : trunk
This commit is contained in:
QAston
2010-07-24 22:41:42 +02:00
parent 687cd83bdd
commit 2352fc7cdf
30 changed files with 1253 additions and 14 deletions

View File

@@ -0,0 +1,101 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* An example of a spell script file
* to bind a script to spell you have to add entry for it in `spell_script_names`
* where `spell_id` is id of the spell to bind
* and `ScriptName` is the name of a script assigned on registration
*/
#include "ScriptPCH.h"
class spell_ex_49375SpellScript : public SpellScript
{
public:
std::string localVariable;
char * localVariable2;
private:
// effect handler hook - effIndex - effIndex of handled effect of a spell
void HandleDummy(SpellEffIndex effIndex)
{
// we're handling SPELL_EFFECT_DUMMY in effIndex 0 here
sLog.outError("WE ARE HANDLING DUMMY!");
sLog.outError(localVariable.c_str());
// make caster cast a spell on a unit target of effect
if (Unit * target = GetEffectUnitTarget())
GetCaster()->CastSpell(target, 70522, true);
};
void Register()
{
// we're registering our function here
// function HandleDummy will be called when unit is hit by spell, just before default effect 0 handler
EffectHandlers += EffectHandlerFn(spell_ex_49375SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
// this will prompt an error on startup because effect 0 of spell 49375 is set to SPELL_EFFECT_DUMMY, not SPELL_EFFECT_APPLY_AURA
//EffectHandlers += EffectHandlerFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_APPLY_AURA);
// this will make HandleDummy function to be called on first != 0 effect of spell 49375
//EffectHandlers += EffectHandlerFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_FIRST_FOUND, SPELL_EFFECT_ANY);
// this will make HandleDummy function to be called on all != 0 effect of spell 49375
//EffectHandlers += EffectHandlerFn(spell_gen_49375SpellScript::HandleDummy, EFFECT_ALL, SPELL_EFFECT_ANY);
};
// function called on server startup
// checks if script has data required for it to work
bool Validate(SpellEntry const * spellEntry)
{
// check if spellid 1 exists in dbc
if (!sSpellStore.LookupEntry(70522))
return false;
return true;
};
// function called just after script is added to spell
// we initialize local variables if needed
bool Load()
{
localVariable = "WE'RE USING LOCAL VARIABLE";
localVariable2 = new char;
return true;
// script will be immediately removed from the spell
// for example - we don't want this script to be executed on a creature
// if (GetCaster()->GetTypeID() != TYPEID_PLAYER)
// return false
}
// function called just before script delete
// we free allocated memory
void Unload()
{
delete localVariable2;
}
};
// function which creates SpellScript
SpellScript * GetSpellScript_spell_ex_49375()
{
return new spell_ex_49375SpellScript();
}
// this function has to be added to function set in ScriptLoader.cpp
void AddSC_example_spell_scripts()
{
Script *newscript;
newscript = new Script;
// name to be put in `spell_script_names`
newscript->Name = "spell_ex_49375";
// assign create function to the script
newscript->GetSpellScript = &GetSpellScript_spell_ex_49375;
newscript->RegisterSelf();
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_DEATHKNIGHT and SPELLFAMILY_GENERIC spells used by deathknight players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_dk_".
*/
#include "ScriptPCH.h"
void AddSC_deathknight_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_dk_";
newscript->GetSpellScript = &GetSpellScript_spell_dk_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_DRUID and SPELLFAMILY_GENERIC spells used by druid players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_dru_".
*/
#include "ScriptPCH.h"
void AddSC_druid_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_dru_";
newscript->GetSpellScript = &GetSpellScript_spell_dru_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_GENERIC which cannot be included in AI script file
* of creature using it or can't be bound to any player class.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_gen_"
*/
#include "ScriptPCH.h"
void AddSC_generic_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_gen_";
newscript->GetSpellScript = &GetSpellScript_spell_gen_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_HUNTER, SPELLFAMILY_PET and SPELLFAMILY_GENERIC spells used by hunter players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_hun_".
*/
#include "ScriptPCH.h"
void AddSC_hunter_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_hun_";
newscript->GetSpellScript = &GetSpellScript_spell_hun_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_MAGE and SPELLFAMILY_GENERIC spells used by mage players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_mag_".
*/
#include "ScriptPCH.h"
void AddSC_mage_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_mag_";
newscript->GetSpellScript = &GetSpellScript_spell_mag_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_SHAMAN and SPELLFAMILY_GENERIC spells used by paladin players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_pal_".
*/
#include "ScriptPCH.h"
void AddSC_paladin_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_pal_";
newscript->GetSpellScript = &GetSpellScript_spell_pal_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_PRIEST and SPELLFAMILY_GENERIC spells used by warrior players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_pri_".
*/
void AddSC_mage_spell_scripts()
{
Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_pri_";
newscript->GetSpellScript = &GetSpellScript_spell_pri_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_PRIEST and SPELLFAMILY_GENERIC spells used by priest players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_pri_".
*/
#include "ScriptPCH.h"
void AddSC_priest_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_pri_";
newscript->GetSpellScript = &GetSpellScript_spell_pri_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_ROGUE and SPELLFAMILY_GENERIC spells used by rogue players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_rog_".
*/
#include "ScriptPCH.h"
void AddSC_rogue_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_rog_";
newscript->GetSpellScript = &GetSpellScript_spell_rog_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_SHAMAN and SPELLFAMILY_GENERIC spells used by shaman players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_sha_".
*/
#include "ScriptPCH.h"
void AddSC_shaman_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_sha_";
newscript->GetSpellScript = &GetSpellScript_spell_sha_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_WARLOCK and SPELLFAMILY_GENERIC spells used by warlock players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_warl_".
*/
#include "ScriptPCH.h"
void AddSC_warlock_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_warl_";
newscript->GetSpellScript = &GetSpellScript_spell_warl_;
newscript->RegisterSelf();
*/
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_WARRIOR and SPELLFAMILY_GENERIC spells used by warrior players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_warr_".
*/
#include "ScriptPCH.h"
void AddSC_warrior_spell_scripts()
{
//Script *newscript;
/*
newscript = new Script;
newscript->Name = "spell_warr_";
newscript->GetSpellScript = &GetSpellScript_spell_warr_;
newscript->RegisterSelf();
*/
}