17 #include "../../bscript/berror.h" 18 #include "../../bscript/eprog.h" 19 #include "../../clib/cfgelem.h" 20 #include "../../clib/passert.h" 21 #include "../../clib/refptr.h" 22 #include "../../clib/streamsaver.h" 23 #include "../../plib/mapcell.h" 24 #include "../../plib/systemstate.h" 25 #include "../clidata.h" 26 #include "../containr.h" 27 #include "../gameclck.h" 28 #include "../globals/uvars.h" 29 #include "../mobile/charactr.h" 30 #include "../network/client.h" 31 #include "../objtype.h" 32 #include "../polcfg.h" 33 #include "../proplist.h" 34 #include "../resource.h" 35 #include "../scrdef.h" 36 #include "../scrsched.h" 37 #include "../scrstore.h" 38 #include "../tooltips.h" 40 #include "../uoscrobj.h" 70 item->sellprice_( sellprice_() );
71 item->buyprice_( buyprice_() );
91 item->fire_resist( fire_resist() );
92 item->cold_resist( cold_resist() );
93 item->energy_resist( energy_resist() );
94 item->poison_resist( poison_resist() );
95 item->physical_resist( physical_resist() );
97 item->fire_damage( fire_damage() );
98 item->cold_damage( cold_damage() );
99 item->energy_damage( energy_damage() );
100 item->poison_damage( poison_damage() );
101 item->physical_damage( physical_damage() );
103 item->maxhp_mod( maxhp_mod() );
104 item->name_suffix( name_suffix() );
112 if ( !
name_.get().empty() )
120 if (
id.desc.get().empty() )
152 std::string suffix = name_suffix();
160 if (
id.desc.get().empty() )
179 std::string suffix = name_suffix();
187 if (
id.desc.get().empty() )
200 u32 price = sellprice_();
216 u32 price = buyprice_();
263 const Item* item =
this;
331 else if ( maxhp <= USHRT_MAX )
343 short maxhp_mod_ = maxhp_mod();
344 std::string suffix = name_suffix();
350 sw() <<
"\tLayer\t" << (int)
layer << pf_endl;
358 s16 value = fire_resist().mod;
360 sw() <<
"\tFireResistMod\t" <<
static_cast<int>( value ) << pf_endl;
361 value = cold_resist().mod;
363 sw() <<
"\tColdResistMod\t" <<
static_cast<int>( value ) << pf_endl;
364 value = energy_resist().mod;
366 sw() <<
"\tEnergyResistMod\t" <<
static_cast<int>( value ) << pf_endl;
367 value = poison_resist().mod;
369 sw() <<
"\tPoisonResistMod\t" <<
static_cast<int>( value ) << pf_endl;
370 value = physical_resist().mod;
372 sw() <<
"\tPhysicalResistMod\t" <<
static_cast<int>( value ) << pf_endl;
374 value = fire_damage().mod;
376 sw() <<
"\tFireDamageMod\t" <<
static_cast<int>( value ) << pf_endl;
377 value = cold_damage().mod;
379 sw() <<
"\tColdDamageMod\t" <<
static_cast<int>( value ) << pf_endl;
380 value = energy_damage().mod;
382 sw() <<
"\tEnergyDamageMod\t" <<
static_cast<int>( value ) << pf_endl;
383 value = poison_damage().mod;
385 sw() <<
"\tPoisonDamageMod\t" <<
static_cast<int>( value ) << pf_endl;
386 value = physical_damage().mod;
388 sw() <<
"\tPhysicalDamageMod\t" <<
static_cast<int>( value ) << pf_endl;
405 if ( has_sellprice_() )
406 sw() <<
"\tSellPrice\t" << sellprice_() <<
pf_endl;
407 if ( has_buyprice_() )
408 sw() <<
"\tBuyPrice\t" << buyprice_() <<
pf_endl;
417 sw() <<
"\tMaxHp_mod\t" << maxhp_mod_ <<
pf_endl;
422 sw() <<
"\tQuality\t" << quali <<
pf_endl;
423 if ( !suffix.empty() )
424 sw() <<
"\tNameSuffix\t" << suffix <<
pf_endl;
460 if ( buyprice_() == 2147483647 )
468 if ( mod_value != 0 )
469 fire_resist( fire_resist().setAsMod( mod_value ) );
470 mod_value =
static_cast<s16>( elem.
remove_int(
"COLDRESISTMOD", 0 ) );
471 if ( mod_value != 0 )
472 cold_resist( cold_resist().setAsMod( mod_value ) );
473 mod_value =
static_cast<s16>( elem.
remove_int(
"ENERGYRESISTMOD", 0 ) );
474 if ( mod_value != 0 )
475 energy_resist( energy_resist().setAsMod( mod_value ) );
476 mod_value =
static_cast<s16>( elem.
remove_int(
"POISONRESISTMOD", 0 ) );
477 if ( mod_value != 0 )
478 poison_resist( poison_resist().setAsMod( mod_value ) );
479 mod_value =
static_cast<s16>( elem.
remove_int(
"PHYSICALRESISTMOD", 0 ) );
480 if ( mod_value != 0 )
481 physical_resist( physical_resist().setAsMod( mod_value ) );
483 mod_value =
static_cast<s16>( elem.
remove_int(
"FIREDAMAGEMOD", 0 ) );
484 if ( mod_value != 0 )
485 fire_damage( fire_damage().setAsMod( mod_value ) );
486 mod_value =
static_cast<s16>( elem.
remove_int(
"COLDDAMAGEMOD", 0 ) );
487 if ( mod_value != 0 )
488 cold_damage( cold_damage().setAsMod( mod_value ) );
489 mod_value =
static_cast<s16>( elem.
remove_int(
"ENERGYDAMAGEMOD", 0 ) );
490 if ( mod_value != 0 )
491 energy_damage( energy_damage().setAsMod( mod_value ) );
492 mod_value =
static_cast<s16>( elem.
remove_int(
"POISONDAMAGEMOD", 0 ) );
493 if ( mod_value != 0 )
494 poison_damage( poison_damage().setAsMod( mod_value ) );
495 mod_value =
static_cast<s16>( elem.
remove_int(
"PHYSICALDAMAGEMOD", 0 ) );
496 if ( mod_value != 0 )
497 physical_damage( physical_damage().setAsMod( mod_value ) );
500 maxhp_mod( static_cast<s16>( elem.
remove_int(
"MAXHP_MOD", 0 ) ) );
539 if ( prog.
get() != nullptr )
603 ct_merge_stacks_pergon(
621 void Item::ct_merge_stacks_pergon(
Item*& item_sub )
623 int time_self, time_sub, time;
624 std::string value_self, value_sub;
627 if (
getprop(
"ct", value_self ) )
631 time_self = static_cast<Bscript::BLong*>( imp.
impptr() )->value();
639 if ( item_sub->
getprop(
"ct", value_sub ) )
643 time_sub = static_cast<Bscript::BLong*>( imp.
impptr() )->value();
651 if ( time_self < time_sub )
654 time = int( ( time_sub - time_self ) * factor + time_self );
656 else if ( time_self > time_sub )
659 time = int( ( time_self - time_sub ) * factor + time_sub );
669 void Item::ct_merge_stacks_pergon(
u16 amount_sub )
671 int time_self, time_sub, time;
672 std::string value_self;
675 if (
getprop(
"ct", value_self ) )
679 time_self = static_cast<Bscript::BLong*>( imp.
impptr() )->value();
690 if ( time_self != time_sub )
692 double factor = ( amount_sub * 1.0 ) / (
amount_ + amount_sub );
693 time = int( ( time_sub - time_self ) * factor + time_self );
708 unsigned int amount1 = (
unsigned int)
amount_;
709 unsigned int amount2 = (
unsigned int)amount;
717 if ( more_weight > USHRT_MAX )
729 ( ( item.objtype_ ==
objtype_ ) && ( item.newbie() ==
newbie() ) &&
730 ( item.insured() ==
insured() ) && ( item.graphic ==
graphic ) && ( item.color ==
color ) &&
741 yourprops -= item.itemdesc().ignore_cprops;
744 res = ( myprops == yourprops );
754 if ( compare ==
nullptr )
765 return ( myprops == yourprops );
770 return ( ( this_item_new_amount <
amount_ ) &&
772 ( this_item_new_amount > 0 ) );
793 if ( new_item !=
nullptr )
804 if ( new_item !=
nullptr )
858 if ( ( newcolor & ( ~theMask ) ) != 0 )
862 newcolor &= ( theMask );
864 if (
color != newcolor )
891 if ( newfacing > 127 )
894 if (
facing != newfacing )
931 unsigned int amt = amount;
932 amt *=
id.weightmult;
933 if (
id.weightdiv != 1 &&
id.weightdiv != 0 )
935 amt = ( amt +
id.weightdiv - 1 ) /
id.weightdiv;
1009 catch ( std::exception& ex )
1011 return new Bscript::BError( std::string(
"Script descriptor error" ) + ex.what() );
1020 catch ( std::exception& ex )
1022 return new Bscript::BError( std::string(
"Script execution error" ) + ex.what() );
1034 catch ( std::exception& ex )
1036 return new Bscript::BError( std::string(
"Script descriptor error: " ) + ex.what() );
1044 catch ( std::exception& ex )
1046 return new Bscript::BError( std::string(
"Script execution error:" ) + ex.what() );
1074 return obj.isTrue();
1109 this->
inuse(
true );
1115 this->
inuse(
false );
1127 this->
inuse(
false );
1133 this->
inuse(
false );
1175 if ( chr_owner !=
nullptr )
bool script_loaded(ScriptDef &sd)
std::string format_description(unsigned int polflags, const std::string &descdef, unsigned short amount, const std::string suffix)
virtual void on_facing_changed() POL_OVERRIDE
static Item * create(u32 objtype, u32 serial=0)
unsigned int tile_flags(unsigned short tilenum)
virtual std::string description() const POL_OVERRIDE
unsigned short stack_limit
bool check_unequiptest_scripts()
void subamount(u16 amount_subtract)
PropSet Global_Ignore_CProps
virtual bool setcolor(u16 newcolor) POL_OVERRIDE
ref_ptr< Bscript::EScriptProgram > find_script2(const ScriptDef &script, bool complain_if_not_found, bool cache_script)
void quickconfig(const Plib::Package *pkg, const std::string &name_ecl)
bool should_decay(unsigned int gameclock) const
bool can_add_to_self(unsigned short amount, bool force_stacking) const
Character * chr_from_wornitems(UContainer *wornitems)
std::string remove_string(const char *propname)
virtual UObject * owner() POL_OVERRIDE
virtual bool can_add(const Items::Item &item) const
void return_resources(u32 objtype, u16)
bool skill_ex_active() const
bool check_unequip_script()
bool isa(BObjectType type) const
void setprop(const std::string &propname, const std::string &propvalue)
virtual void add_bulk(int item_count_delta, int weight_delta)
virtual UObject * toplevel_owner() POL_OVERRIDE
static const u32 SELLPRICE_DEFAULT
unsigned char tilelayer(unsigned short tilenum)
bool getbuyprice(u32 &buyprice) const
virtual std::string name() const POL_OVERRIDE
bool specific_name() const
std::set< std::string > ignore_cprops
std::string decint(unsigned short v)
void preload_test_scripts(const std::string &script_ecl)
unsigned int remove_ulong(const char *propname)
std::string merchant_description() const
virtual void printProperties(Clib::StreamWriter &sw) const POL_OVERRIDE
boost_utils::script_name_flystring on_use_script_
bool get(ENUM flag) const
int remove_int(const char *propname)
bool has_equip_script() const
unsigned int vendor_sells_for
bool casting_spell() const
bool use_insurance()
Returns current insurance value and resets it to false.
virtual void on_color_changed() POL_OVERRIDE
boost_utils::script_name_flystring unequip_script_
virtual void setQuality(double value)
virtual Item * clone() const
static const u32 BUYPRICE_DEFAULT
const ItemDesc & find_itemdesc(unsigned int objtype)
void add_to_self(Item *&item)
virtual void builtin_on_use(Network::Client *client)
std::string tile_desc(unsigned short tilenum)
virtual Items::Item * remove(u32 serial, UContainer **found_in=nullptr)
virtual u16 get_senditem_amount() const
static gameclock_t gameclock
unsigned short maxhp() const
virtual const char * classname() const POL_OVERRIDE
Core::ScriptDef on_use_script
double remove_double(const char *propname, double dflt)
virtual void readProperties(Clib::ConfigElem &elem) POL_OVERRIDE
bool setlayer(unsigned char layer)
bool getprop(const std::string &propname, std::string &propvalue) const
void setamount(u16 amount)
bool call_script(const ScriptDef &script, Bscript::BObjectImp *param0)
bool start_itemuse_script(Bscript::EScriptProgram *prog, Items::Item *item, bool start_attached)
bool check_test_scripts(Mobile::Character *chr, const std::string &script_ecl, bool startup)
AttributeFlags< OBJ_FLAGS > flags_
void unequip(Items::Item *item)
void config(const std::string &name, const Plib::Package *pkg, const char *mainpfx, bool warn_if_not_found=true)
virtual UObject * self_as_owner()
void set_use_script(const std::string &scriptname)
bool check_equip_script(Mobile::Character *chr, bool startup)
void set_decay_after(unsigned int seconds)
virtual void spill_contents(Multi::UMulti *supporting_multi)
virtual void double_click(Network::Client *client)
char tileheight(unsigned short tilenum)
virtual void setfacing(u8 newfacing) POL_OVERRIDE
bool has_only_default_cprops(const ItemDesc *compare=nullptr) const
void on_movable_changed()
const PropertyList & getprops() const
static BObjectImp * unpack(const char *pstr)
unsigned int decayat_gameclock_
virtual const char * target_tag() const POL_OVERRIDE
virtual unsigned int item_count() const
Core::UContainer * container
gameclock_t read_gameclock()
Reads the current value of the game clock.
Item * remove_part_of_stack(u16 amount_to_remove)
void remove_resources(u32 objtype, u16)
bool cache_interactive_scripts
SettingsManager settingsManager
bool default_no_drop() const
bool IsCharacter(u32 serial)
bool default_insured() const
virtual void printDebugProperties(Clib::StreamWriter &sw) const
void restart_decay_timer()
bool is_equipped(const Items::Item *item) const
virtual void readProperties(Clib::ConfigElem &elem)
bool default_invisible() const
std::string get_use_script_name() const
bool default_movable() const
unsigned short remove_ushort(const char *propname)
virtual double getQuality() const
bool run_script_to_completion(const char *filename, Bscript::BObjectImp *parameter)
bool default_newbie() const
bool isa(UOBJ_CLASS uobj_class) const
void change(ENUM flag, bool value)
bool check_equiptest_scripts(Mobile::Character *chr, bool startup=false)
bool amount_to_remove_is_partial(u16 amount_to_remove) const
virtual bool setgraphic(u16 newobjtype) POL_OVERRIDE
void on_invisible_changed()
Item * slice_stacked_item(u16 this_item_new_amount)
virtual void printDebugProperties(Clib::StreamWriter &sw) const POL_OVERRIDE
virtual void printProperties(Clib::StreamWriter &sw) const
Bscript::BObjectImp * run_equip_script(Mobile::Character *chr, bool startup)
const ItemDesc & itemdesc() const
double getItemdescQuality() const
unsigned short item_color_mask
unsigned int vendor_buys_for
virtual unsigned int weight() const POL_OVERRIDE
#define passert_always(exp)
void send_object_cache_to_inrange(const UObject *obj)
enum Pol::Items::ItemDesc::Movable movable
Mobile::Character * GetCharacterOwner()
const ItemDesc * _itemdesc
boost_utils::object_name_flystring name_
Bscript::BObjectImp * run_unequip_script(Mobile::Character *who)
bool remove_bool(const char *propname)
void copyprops(const UObject &obj)
void send_sysmessage(Network::Client *client, const char *text, unsigned short font, unsigned short color)
unsigned int weight_of(unsigned short amount) const
void update_item_to_inrange(const Item *item)
boost_utils::script_name_flystring equip_script_