Skip to content
Permalink
Browse files

moved min/max damage calculation where it belongs, removed unused

weapontmpl member
  • Loading branch information...
turleypol committed Oct 3, 2019
1 parent 1b6594e commit dc8913b485503154b61c91232b4a31139f1d7ce6
Showing with 31 additions and 30 deletions.
  1. +22 −11 pol-core/pol/item/weapon.cpp
  2. +5 −4 pol-core/pol/item/weapon.h
  3. +2 −3 pol-core/pol/item/wepntmpl.h
  4. +2 −12 pol-core/pol/mobile/charactr.cpp
@@ -97,7 +97,6 @@ WeaponDesc::WeaponDesc( u32 objtype, Clib::ConfigElem& elem, const Plib::Package
projectile_type( 0 ),
projectile_anim( 0 ),
projectile_sound( 0 ),
projectile_action( static_cast<Core::UACTION>( 0 ) ),
anim( remove_action( elem, "Anim", Core::ACTION_HUMAN_ATTACK ) ),
mounted_anim( remove_action( elem, "MountedAnim", anim ) ),
hit_sound( elem.remove_ushort( "HITSOUND", 0 ) ),
@@ -212,7 +211,6 @@ size_t WeaponDesc::estimatedSize() const
+ sizeof( unsigned short ) /*projectile_type*/
+ sizeof( unsigned short ) /*projectile_anim*/
+ sizeof( unsigned short ) /*projectile_sound*/
+ sizeof( Core::UACTION ) /*projectile_action*/
+ sizeof( Core::UACTION ) /*anim*/
+ sizeof( Core::UACTION ) /*mounted_anim*/
+ sizeof( unsigned short ) /*hit_sound*/
@@ -376,6 +374,26 @@ unsigned short UWeapon::get_random_damage() const
return USHRT_MAX;
}

unsigned short UWeapon::min_weapon_damage() const
{
int dmg = static_cast<int>( WEAPON_TMPL->damage_dice.min_value() ) + damage_mod();
if ( dmg < 0 )
return 0;
else if ( dmg <= USHRT_MAX )
return static_cast<unsigned short>( dmg );
return USHRT_MAX;
}

unsigned short UWeapon::max_weapon_damage() const
{
int dmg = static_cast<int>( WEAPON_TMPL->damage_dice.max_value() ) + damage_mod();
if ( dmg < 0 )
return 0;
else if ( dmg <= USHRT_MAX )
return static_cast<unsigned short>( dmg );
return USHRT_MAX;
}

bool UWeapon::is_projectile() const
{
passert( tmpl != nullptr );
@@ -394,13 +412,6 @@ unsigned short UWeapon::projectile_anim() const
return WEAPON_TMPL->projectile_anim;
}

/*
UACTION UWeapon::projectile_action() const
{
return tmpl->projectile_action;
}
*/

Core::UACTION UWeapon::anim() const
{
passert( tmpl != nullptr );
@@ -519,5 +530,5 @@ bool UWeapon::get_method_hook( const char* methodname, Bscript::Executor* ex,
return true;
return base::get_method_hook( methodname, ex, hook, PC );
}
}
}
} // namespace Items
} // namespace Pol
@@ -54,7 +54,7 @@ namespace Mobile
{
class Attribute;
class Character;
}
} // namespace Mobile
namespace Items
{
class UWeapon;
@@ -73,12 +73,13 @@ class UWeapon final : public Equipment

const Mobile::Attribute& attribute() const;
unsigned short get_random_damage() const;
unsigned short min_weapon_damage() const;
unsigned short max_weapon_damage() const;
bool is_projectile() const;
bool consume_projectile( Core::UContainer* cont ) const;
bool in_range( const Mobile::Character* wielder, const Mobile::Character* target ) const;
unsigned short projectile_sound() const;
unsigned short projectile_anim() const;
// UACTION projectile_action() const;
Core::UACTION anim() const;
Core::UACTION mounted_anim() const;
unsigned short hit_sound() const;
@@ -148,6 +149,6 @@ bool isa_weapon( u32 objtype );
UWeapon* create_intrinsic_weapon( Clib::ConfigElem& elem );
UWeapon* create_intrinsic_weapon_from_npctemplate( Clib::ConfigElem& elem,
const Plib::Package* pkg );
}
}
} // namespace Items
} // namespace Pol
#endif
@@ -47,7 +47,6 @@ class WeaponDesc : public Core::EquipDesc
unsigned short projectile_type;
unsigned short projectile_anim;
unsigned short projectile_sound;
Core::UACTION projectile_action;
Core::UACTION anim;
Core::UACTION mounted_anim;
unsigned short hit_sound;
@@ -58,6 +57,6 @@ class WeaponDesc : public Core::EquipDesc
unsigned short minrange;
unsigned short maxrange;
};
}
}
} // namespace Items
} // namespace Pol
#endif
@@ -3141,22 +3141,12 @@ unsigned short Character::random_weapon_damage() const

unsigned short Character::min_weapon_damage() const
{
int dmg = static_cast<int>( weapon->descriptor().damage_dice.min_value() ) + weapon->damage_mod();
if ( dmg < 0 )
return 0;
else if ( dmg <= USHRT_MAX )
return static_cast<unsigned short>( dmg );
return USHRT_MAX;
return weapon->min_weapon_damage();
}

unsigned short Character::max_weapon_damage() const
{
int dmg = static_cast<int>( weapon->descriptor().damage_dice.max_value() ) + weapon->damage_mod();
if ( dmg < 0 )
return 0;
else if ( dmg <= USHRT_MAX )
return static_cast<unsigned short>( dmg );
return USHRT_MAX;
return weapon->max_weapon_damage();
}

void Character::damage_weapon()

0 comments on commit dc8913b

Please sign in to comment.
You can’t perform that action at this time.