15 #include "../../bscript/bstruct.h" 16 #include "../../bscript/impstr.h" 17 #include "../../clib/cfgelem.h" 18 #include "../../clib/logfacility.h" 19 #include "../../clib/passert.h" 20 #include "../../clib/streamsaver.h" 21 #include "../../clib/strutil.h" 22 #include "../../plib/systemstate.h" 23 #include "../containr.h" 25 #include "../equipdsc.h" 26 #include "../extobj.h" 27 #include "../globals/settings.h" 28 #include "../globals/uvars.h" 29 #include "../layers.h" 30 #include "../mobile/charactr.h" 31 #include "../realms/realm.h" 33 #include "../umanip.h" 34 #include "../uobject.h" 57 unsigned short tmp = elem.
remove_ushort( name, static_cast<unsigned short>( deflt ) );
64 elem.
throw_error( std::string( name ) +
" is out of range" );
76 elem.
throw_error( std::string( name ) +
" is out of range" );
89 :
EquipDesc( objtype, elem, WEAPONDESC, pkg ),
91 delay( elem.remove_ushort(
"DELAY", 0 ) ),
92 hit_script( elem.remove_string(
"HITSCRIPT",
"" ), pkg,
"scripts/items/" ),
94 projectile( elem.remove_bool(
"PROJECTILE", false ) ),
97 projectile_sound( 0 ),
98 projectile_action( static_cast<Core::
UACTION>( 0 ) ),
101 hit_sound( elem.remove_ushort(
"HITSOUND", 0 ) ),
102 miss_sound( elem.remove_ushort(
"MISSSOUND", 0 ) ),
103 two_handed( elem.remove_bool(
"TWOHANDED", false ) ),
104 minrange( elem.remove_ushort(
"MINRANGE", projectile ? 2 : 0 ) ),
105 maxrange( elem.remove_ushort(
"MAXRANGE", projectile ? 20 : 1 ) )
112 std::string attrname = elem.
remove_string(
"Attribute",
"" );
113 if ( attrname.empty() )
118 if ( attrname.empty() )
121 elem.
warn(
"Element specifies a SkillID instead of an Attribute" );
127 elem.
throw_error(
"Attribute " + attrname +
" not found" );
132 elem.
throw_error(
"Weapon has INTRINSIC property, which is no longer needed" );
137 elem.
throw_error(
"Weapon has illegal Speed value (Speed must be positive)" );
141 elem.
throw_error(
"Weapon has illegal MaxHP value (MaxHP must be positive)" );
147 elem.
throw_error(
"Error parsing DAMAGE string for WeaponTemplate\n" + errmsg );
170 using namespace Bscript;
205 +
sizeof(
unsigned short )
206 +
sizeof(
unsigned short )
210 +
sizeof(
unsigned short )
211 +
sizeof(
unsigned short )
212 +
sizeof(
unsigned short )
216 +
sizeof(
unsigned short )
217 +
sizeof(
unsigned short )
219 +
sizeof(
unsigned short )
220 +
sizeof(
unsigned short )
232 tmpl->is_intrinsic =
true;
233 auto wpn =
new UWeapon( *tmpl, tmpl );
248 throw std::runtime_error(
"Wrestling weapon " +
250 " must specify SaveOnExit 0" );
271 throw std::runtime_error(
"A WeaponTemplate for Wrestling is required in itemdesc.cfg" );
288 wpnelem.
add_prop(
"Objtype",
"0xFFFF" );
297 if ( elem.
has_prop(
"AttackSkillId" ) )
307 wpnelem.
add_prop(
"HitScript", tmp );
309 wpnelem.
add_prop(
"MinRange", tmp );
311 wpnelem.
add_prop(
"MaxRange", tmp );
313 if ( elem.
has_prop(
"AttackProjectile" ) )
315 wpnelem.
add_prop(
"Projectile",
"1" );
349 else if ( speed_ <= USHRT_MAX )
350 return static_cast<u16>( speed_ );
371 else if ( dmg <= USHRT_MAX )
372 return static_cast<unsigned short>( dmg );
437 if ( item !=
nullptr )
452 << fmt::hexu( target->
serial ) <<
"):\n" 453 <<
"dist: " << dist <<
"\n" 456 <<
"has_los: " << wielder->
realm->
has_los( *wielder, *target ) <<
"\n";
457 return ( dist >=
WEAPON_TMPL->minrange && dist <= WEAPON_TMPL->maxrange &&
466 wpn->damage_mod( this->damage_mod() );
467 wpn->speed_mod( this->speed_mod() );
476 short speed_mod_ = speed_mod();
477 short dmg_mod = damage_mod();
480 sw() <<
"\tdmg_mod\t" << dmg_mod <<
pf_endl;
482 sw() <<
"tspeed_mod\t" << speed_mod_ <<
pf_endl;
491 damage_mod( static_cast<s16>( elem.
remove_int(
"DMG_MOD", 0 ) ) );
492 speed_mod( static_cast<s16>( elem.
remove_int(
"SPEED_MOD", 0 ) ) );
501 if ( scriptname.empty() )
UWeapon * create_intrinsic_weapon(const char *name, Clib::ConfigElem &elem, const Plib::Package *pkg)
Creates a new intrinsic weapon and returns it.
virtual Item * clone() const POL_OVERRIDE
Core::UACTION remove_action(Clib::ConfigElem &elem, const char *name, Core::UACTION deflt)
std::string remove_string(const char *propname)
Core::UACTION mounted_anim() const
unsigned short roll(void) const
void register_intrinsic_equipment(const std::string &name, Equipment *equip)
Must be called when a new intrinsic equipment is created.
virtual size_t estimatedSize() const POL_OVERRIDE
bool consume_projectile(Core::UContainer *cont) const
unsigned short min_value(void) const
unsigned short hit_sound() const
bool in_range(const Mobile::Character *wielder, const Mobile::Character *target) const
unsigned short get_random_damage() const
virtual void printProperties(Clib::StreamWriter &sw) const POL_OVERRIDE
size_t estimatedSize() const
int remove_int(const char *propname)
const Core::EquipDesc * tmpl
std::string relativename(const Plib::Package *pkg=nullptr) const
void insert_intrinsic_equipment(const std::string &name, Equipment *equip)
Adds a new intrisinc equipment to the map of known ones.
UWeapon(const WeaponDesc &descriptor, const WeaponDesc *permanent_descriptor)
virtual void readProperties(Clib::ConfigElem &elem) POL_OVERRIDE
virtual void printProperties(Clib::StreamWriter &sw) const POL_OVERRIDE
void addMember(const char *name, BObjectRef val)
virtual size_t estimatedSize() const POL_OVERRIDE
const Mobile::Attribute & attribute() const
const ItemDesc & find_itemdesc(unsigned int objtype)
bool is_projectile() const
unsigned short projectile_type
const WeaponDesc & descriptor() const
unsigned short delay() const
unsigned short maxhp() const
unsigned short projectile_sound() const
unsigned short projectile_sound
void warn(const std::string &errmsg) const
std::string hexint(unsigned short v)
const char * rest() const
void set_hit_script(const std::string &scriptname)
virtual size_t estimatedSize() const POL_OVERRIDE
POL_NORETURN void throw_error(const std::string &errmsg) const
unsigned short miss_sound
const Plib::Package * pkg
unsigned short get_random_damage() const
void config(const std::string &name, const Plib::Package *pkg, const char *mainpfx, bool warn_if_not_found=true)
void add_prop(std::string propname, std::string propval)
bool has_los(const Core::ULWObject &att, const Core::ULWObject &tgt) const
Core::UACTION anim() const
void die_string(std::string &str) const
unsigned short miss_sound() const
Core::ScriptDef hit_script_
Core::UACTION mounted_anim
virtual void PopulateStruct(Bscript::BStruct *descriptor) const POL_OVERRIDE
SettingsManager settingsManager
virtual void readProperties(Clib::ConfigElem &elem) POL_OVERRIDE
Items::Item * find_objtype_noninuse(u32 objtype) const
const Mobile::Attribute * pAttr
bool remove_prop(const char *propname, std::string *value)
unsigned short max_value(void) const
void subtract_amount_from_item(Item *item, unsigned short amount)
#define INFO_PRINT_TRACE(n)
unsigned short pol_distance(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
bool has_prop(const char *propname) const
unsigned short projectile_anim
unsigned short remove_ushort(const char *propname)
void set_source(const ConfigElem &elem)
UWeapon * create_intrinsic_weapon_from_npctemplate(Clib::ConfigElem &elem, const Plib::Package *pkg)
Creates a new intrinic weapon for an NPC template and returns it.
void load_intrinsic_weapons()
Creates the intrinsic wrestling weapon for PCs must be called at startup.
Items::UWeapon * wrestling_weapon
bool load(const char *dice, std::string *errormsg)
virtual size_t estimatedSize() const POL_OVERRIDE
void set_rest(const char *newrest)
bool UACTION_IS_VALID(unsigned short action)
Core::ScriptDef hit_script
Core::UACTION default_anim(bool two_handed)
virtual void PopulateStruct(Bscript::BStruct *descriptor) const POL_OVERRIDE
unsigned short projectile_anim() const
unsigned short speed() const
static Attribute * FindAttribute(const std::string &str)
virtual Item * clone() const POL_OVERRIDE