14 #include <format/format.h> 15 #include "../bscript/eprog.h" 16 #include "../clib/cfgelem.h" 17 #include "../clib/cfgfile.h" 18 #include "../clib/fileutil.h" 19 #include "../clib/logfacility.h" 20 #include "../clib/refptr.h" 21 #include "../plib/pkg.h" 22 #include "../plib/systemstate.h" 73 if ( cont !=
nullptr )
96 if ( item !=
nullptr )
99 if (
id.blocks_casting_if_in_hand )
104 if ( item !=
nullptr )
107 if (
id.blocks_casting_if_in_hand )
117 :
manacost( elem.remove_ushort(
"MANA" ) ),
118 difficulty( elem.remove_ushort(
"DIFFICULTY" ) ),
119 pointvalue( elem.remove_ushort(
"POINTVALUE" ) ),
120 delay( elem.remove_ushort(
"DELAY" ) )
129 spellid_( elem.remove_ushort(
"SPELLID" ) ),
130 name_( elem.remove_string(
"NAME" ) ),
131 power_words_( elem.remove_string(
"POWERWORDS" ) ),
132 scriptdef_( elem.remove_string(
"SCRIPT",
"" ), pkg,
"scripts/" )
134 unsigned short action;
151 unsigned short circle;
158 <<
" is not defined.\n";
159 throw std::runtime_error(
"Config file error" );
169 std::string reagent_name;
170 while ( elem.
remove_prop(
"Reagent", &reagent_name ) )
181 +
sizeof(
unsigned short )
183 + 3 *
sizeof(
unsigned int* ) +
reglist_.capacity() *
sizeof(
unsigned int ) +
193 if ( chr->
client !=
nullptr )
203 if ( prog.
get() != nullptr )
210 if ( chr->
client !=
nullptr )
220 for ( RegList::iterator itr =
reglist_.begin(), end =
reglist_.end(); itr != end; ++itr )
223 if ( item ==
nullptr )
253 else if ( !chr->
hidden() )
261 :
OneShotTask( handle, run_when_clock ), caster_( caster ), spell_( spell )
291 if ( spell ==
nullptr )
293 ERROR_PRINT <<
"Spell " << spellid <<
" is not implemented.\n";
344 spell->
cast( client );
351 u16 spellnum =
static_cast<u16>( strtoul( (
char*)msg->
data,
nullptr, 10 ) );
373 if ( spellbook ==
nullptr )
376 if ( backpack !=
nullptr )
384 if ( spellbook !=
nullptr )
389 if ( spellbook !=
nullptr )
406 tmp <<
"Spell ID " << spellid <<
" (" << origspell->
name() <<
") multiply defined\n";
407 if ( origspell->
pkg_ !=
nullptr )
409 tmp <<
" Spell originally defined in package '" << origspell->
pkg_->
name() <<
"' (" 410 << origspell->
pkg_->
dir() <<
")\n";
414 tmp <<
" Spell originally defined in main\n";
416 if ( spell->
pkg_ !=
nullptr )
418 tmp <<
" Spell redefined in package '" << spell->
pkg_->
name() <<
"' (" << spell->
pkg_->
dir()
423 tmp <<
" Spell redefined in main\n";
426 throw std::runtime_error(
"Spell ID multiply defined" );
438 INFO_PRINT <<
"File config/circles not found, skipping.\n";
445 while ( cf.
read( elem ) )
447 int index = strtoul( elem.
rest(),
nullptr, 0 ) - 1;
448 if ( index < 0 || index >= 100 )
450 ERROR_PRINT <<
"Error in CIRCLES.CFG: Circle must fall between 1 and 100\n";
451 throw std::runtime_error(
"Config file error" );
458 ERROR_PRINT <<
"Error in CIRCLES.CFG: Circle " << index + 1 <<
" is multiply defined.\n";
459 throw std::runtime_error(
"Config file error" );
471 while ( cf.
read( elem ) )
473 std::unique_ptr<USpell> spell(
new USpell( elem, pkg ) );
475 unsigned short spellid = spell->spell_id();
488 INFO_PRINT <<
"File config/spells.cfg not found, skipping\n";
bool start_spell_script(Bscript::EScriptProgram *prog, Core::USpell *spell)
Contents::const_iterator const_iterator
ref_ptr< Bscript::EScriptProgram > find_script2(const ScriptDef &script, bool complain_if_not_found, bool cache_script)
size_t estimateSize() const
bool skill_ex_active() const
bool hands_are_free(Mobile::Character *chr)
bool call(Bscript::BObjectImp *p0)
ExportedFunction * open_spellbook_hook
void register_spell(USpell *spell, unsigned short spellid)
void handle_open_spellbook(Network::Client *client, PKTIN_12 *msg)
void speak_power_words(Mobile::Character *chr, unsigned short font, unsigned short color)
size_t estimatedSize() const
virtual void on_run() POL_OVERRIDE
#define THREAD_CHECKPOINT(thread, check)
static bool nocast_here(Mobile::Character *chr)
bool casting_spell() const
unsigned short manacost() const
SpellTask(OneShotTask **handle, polclock_t run_when, Mobile::Character *caster, USpell *spell, bool dummy)
const std::string & name() const
virtual T * getregion(xcoord x, ycoord y, Realms::Realm *realm)
ExportedFunction * on_cast_hook
const std::string & name() const
virtual bool script_isa(unsigned isatype) const POL_OVERRIDE
bool private_say_above(Character *chr, const UObject *obj, const char *text, unsigned short font, unsigned short color, unsigned int journal_print)
bool consume(const Core::Vital *pVital, VitalValue &vv, unsigned int amt)
void do_cast(Network::Client *client, u16 spellid)
const char * rest() const
bool has_spellid(unsigned int spellid) const
unsigned short pointvalue
POL_NORETURN void throw_error(const std::string &errmsg) const
unsigned int get_objtype_from_string(const std::string &str)
unsigned short difficulty
void consume_mana(Mobile::Character *chr)
void handle_cast_spell(Network::Client *client, PKTIN_12 *msg)
bool consume_reagents(Mobile::Character *chr)
bool check_mana(Mobile::Character *chr)
virtual void double_click(Network::Client *client)
SpellCircle(Clib::ConfigElem &elem)
#define GET_ITEM_PTR(itr)
void cast(Mobile::Character *caster)
std::vector< USpell * > spells
const unsigned POLCLASS_SPELLBOOK
Items::Item * find_objtype_noninuse(u32 objtype) const
bool remove_prop(const char *propname, std::string *value)
void subtract_amount_from_item(Item *item, unsigned short amount)
Core::UContainer * backpack() const
void schedule_spell(Core::USpell *)
const VitalValue & vital(unsigned vitalid) const
std::string GetPackageCfgPath(const Package *pkg, const std::string &filename)
Items::Item * wornitem(int layer) const
bool knows_spell(Mobile::Character *chr, u16 spellid)
Items::Item * find_toplevel_polclass(unsigned int polclass) const
void load_spells_cfg(const char *path, Plib::Package *pkg)
bool FileExists(const char *filename)
const ItemDesc & itemdesc() const
bool read(ConfigElem &elem)
Bscript::BObjectImp * make_mobileref(Mobile::Character *chr)
USpell(Clib::ConfigElem &elem, Plib::Package *pkg)
bool UACTION_IS_VALID(unsigned short action)
bool check_skill(Core::USKILLID skillid, int difficulty, unsigned short pointvalue)
std::vector< SpellCircle * > spellcircles
bool say_above(const UObject *obj, const char *text, unsigned short font, unsigned short color, unsigned int journal_print)
bool check_skill(Mobile::Character *chr)
void send_sysmessage(Network::Client *client, const char *text, unsigned short font, unsigned short color)
void send_put_in_container(Client *client, const Item *item)
const std::string & dir() const