41 #include "../../bscript/bobject.h" 42 #include "../../clib/compilerspecifics.h" 43 #include "../../clib/passert.h" 44 #include "../../clib/rawtypes.h" 45 #include "../../clib/refptr.h" 46 #include "../../clib/strset.h" 47 #include "../../clib/weakptr.h" 48 #include "../action.h" 49 #include "../baseobject.h" 50 #include "../dynproperties.h" 51 #include "../gameclck.h" 52 #include "../polclock.h" 53 #include "../reftypes.h" 54 #include "../skillid.h" 55 #include "../uconst.h" 56 #include "../uobject.h" 73 class WornItemsContainer;
129 void createchar2( Accounts::Account* acct,
unsigned index );
130 void undo_get_item( Mobile::Character* chr, Items::Item* item );
136 class UOExecutorModule;
147 AttributeValue() : _base( 0 ), _temp( 0 ), _intrinsic( 0 ), _lockstate( 0 ), _cap( 0 ) {}
153 return ( v > 0 ) ? ( v / 10 ) : 0;
160 return ( v > 0 ) ? v : 0;
163 int base()
const {
return _base; }
164 void base(
unsigned short base )
174 unsigned char lock()
const {
return _lockstate; }
175 void lock(
unsigned char lockstate ) { _lockstate = lockstate; }
176 unsigned short cap()
const {
return _cap; }
177 void cap(
unsigned short cap ) { _cap =
cap; }
190 VitalValue() : _current( 0 ), _maximum( 0 ), _regenrate( 0 ) {}
197 return ( _current / 100 ) * 1000 / ( _maximum / 100 );
209 if ( _current > _maximum )
214 _current = ones * 100;
215 if ( _current > _maximum )
221 if ( _current > _maximum )
227 if ( _current >= hamt )
240 unsigned newcur = _current + hamt;
241 if ( newcur > _maximum || newcur < _current )
355 virtual
unsigned int weight() const POL_OVERRIDE;
357 virtual
bool setgraphic(
u16 newobjtype ) POL_OVERRIDE;
358 virtual
void on_color_changed() POL_OVERRIDE;
359 virtual
void setfacing(
u8 newfacing ) POL_OVERRIDE;
360 virtual
void on_facing_changed() POL_OVERRIDE;
362 virtual
void readProperties( Clib::ConfigElem& elem ) POL_OVERRIDE;
364 virtual Bscript::
BObjectImp* make_ref() POL_OVERRIDE;
366 virtual Bscript::
BObjectImp* get_script_member( const
char* membername ) const POL_OVERRIDE;
367 virtual Bscript::
BObjectImp* get_script_member_id( const
int id ) const POL_OVERRIDE;
368 virtual Bscript::
BObjectImp* set_script_member( const
char* membername,
369 const
std::
string& value ) POL_OVERRIDE;
370 virtual Bscript::
BObjectImp* set_script_member( const
char* membername,
int value ) POL_OVERRIDE;
371 virtual Bscript::
BObjectImp* set_script_member_id( const
int id, const
std::
string& value )
373 virtual Bscript::
BObjectImp* set_script_member_id( const
int id,
374 int value ) POL_OVERRIDE;
375 virtual Bscript::
BObjectImp* set_script_member_id_double( const
int id,
376 double value ) POL_OVERRIDE;
377 virtual Bscript::
BObjectImp* script_method( const
char* methodname,
378 Bscript::
Executor& ex ) POL_OVERRIDE;
379 virtual Bscript::
BObjectImp* script_method_id( const
int id, Bscript::
Executor& ex ) POL_OVERRIDE;
380 virtual Bscript::
BObjectImp* custom_script_method( const
char* methodname,
381 Bscript::
Executor& ex ) POL_OVERRIDE;
382 virtual
bool script_isa(
unsigned isatype ) const POL_OVERRIDE;
383 virtual const
char* target_tag() const POL_OVERRIDE;
386 virtual const
char* classname() const POL_OVERRIDE;
387 virtual
void printOn( Clib::StreamWriter& sw ) const POL_OVERRIDE;
388 virtual
void printSelfOn( Clib::StreamWriter& sw ) const POL_OVERRIDE;
389 virtual
void printProperties( Clib::StreamWriter& sw ) const POL_OVERRIDE;
390 virtual
void printDebugProperties( Clib::StreamWriter& sw ) const POL_OVERRIDE;
397 virtual Items::
UWeapon* intrinsic_weapon();
399 virtual
void inform_disengaged(
Character* disengaged );
400 virtual
void inform_engaged(
Character* engaged );
401 virtual
void inform_criminal(
Character* thecriminal );
402 virtual
void inform_leftarea(
Character* wholeft );
403 virtual
void inform_enteredarea(
Character* whoentered );
404 virtual
void inform_moved(
Character* moved );
405 virtual
void inform_imoved(
Character* chr );
406 virtual
double armor_absorb_damage(
double damage );
407 virtual
void get_hitscript_params(
double damage, Items::UArmor** parmor,
408 unsigned short* rawdamage );
409 virtual
unsigned short ar() const;
410 virtual
void refresh_ar();
412 virtual
void apply_raw_damage_hundredths(
unsigned int damage,
Character* source,
413 bool userepsys = true,
414 bool send_damage_packet = false );
415 void on_swing_failure(
Character* attacker );
416 virtual
void on_death( Items::
Item* corpse );
418 virtual
bool can_be_renamed_by( const
Character* chr ) const;
420 virtual
void repsys_on_attack(
Character* defender );
421 virtual
void repsys_on_damage(
Character* defender );
422 virtual
void repsys_on_help(
Character* recipient );
423 virtual
unsigned char hilite_color_idx( const
Character* seen_by ) const;
424 virtual
unsigned short name_color( const
Character* seen_by ) const;
427 virtual
u16 get_damaged_sound() const;
431 unsigned short carrying_capacity() const;
432 bool layer_is_equipped(
int layer ) const;
434 bool strong_enough_to_equip( const Items::
Item* item ) const;
435 bool equippable( const Items::
Item* item ) const;
436 bool is_equipped( const Items::
Item* item ) const;
437 void equip( Items::
Item* item );
438 void unequip( Items::
Item* item );
442 Items::
Item* wornitem(
int layer ) const;
443 unsigned int gold_carried() const;
444 void spend_gold(
unsigned int amount );
447 void clear_gotten_item();
449 void add_remote_container( Items::Item* );
450 Items::Item* search_remote_containers(
u32 find_serial,
bool* isRemoteContainer ) const;
451 bool mightsee( const Items::Item* item ) const;
453 Items::Item* find_wornitem(
u32 find_serial ) const;
454 bool has_shield() const;
455 Items::UArmor* get_shield() const;
459 bool on_mount() const;
460 static Core::
MOVEMODE decode_movemode( const
std::
string& str );
461 static
std::
string encode_movemode( Core::
MOVEMODE movemode );
463 void getpos_ifmove( Core::
UFACING i_facing,
unsigned short* px,
unsigned short* py );
464 bool can_face( Core::
UFACING i_facing );
465 bool face( Core::
UFACING i_facing,
int flags = 0 );
466 bool move(
unsigned char dir );
467 bool CustomHousingMove(
unsigned char i_dir );
468 void tellmove(
void );
469 void check_region_changes();
470 void check_weather_region_change(
bool force = false );
471 void check_light_region_change();
472 void check_justice_region_change();
473 void check_music_region_change();
474 void realm_changed();
476 bool CheckPushthrough();
478 void position_changed(
void );
482 void select_opponent(
u32 opp_serial );
483 void set_opponent(
Character* opponent,
bool inform_old_opponent = true );
485 void clear_opponent_of();
488 unsigned short get_weapon_skill() const;
489 Core::
USKILLID weapon_skillid() const;
492 Core::
UACTION weapon_anim() const;
493 unsigned short random_weapon_damage() const;
494 unsigned short min_weapon_damage() const;
495 unsigned short max_weapon_damage() const;
496 void damage_weapon();
497 void do_attack_effects(
Character* target );
498 void do_imhit_effects();
499 void do_hit_success_effects();
500 void do_hit_failure_effects();
502 bool is_attackable(
Character* who ) const;
504 Character* get_attackable_opponent() const;
506 Items::UArmor* choose_armor() const;
508 void showarmor() const;
510 void reset_swing_timer();
511 void check_attack_after_move();
513 void send_highlight() const;
514 bool manual_set_swing_timer(
int time );
516 const CharacterSet& hostiles() const;
517 void run_hit_script(
Character* defender,
double damage );
520 void schedule_attack();
521 static
void swing_task_func(
Character* chr );
525 void disable_regeneration_for(
int seconds );
526 void resetEquipableProperties();
527 void updateEquipableProperties( Items::Item* item );
529 u16 strength() const;
530 u16 intelligence() const;
531 u16 dexterity() const;
533 u16 max_hits() const;
534 u32 max_hits_hundredths() const;
535 u16 max_mana() const;
536 u16 max_stamina() const;
538 void set_strength(
u16 strength );
539 void set_intelligence(
u16 intelligence );
540 void set_dexterity(
u16 dexterity );
541 void validate_stat_ranges();
543 double apply_damage(
double damage,
Character* source =
nullptr,
bool userepsys = true,
544 bool send_damage_packet = false );
545 void heal_damage_hundredths(
unsigned int damage );
550 bool check_skill( Core::
USKILLID skillid,
int difficulty,
unsigned short pointvalue );
554 void set_caps_to_default();
556 const
VitalValue& vital(
unsigned vitalid ) const;
558 void regen_vital( const Core::
Vital* );
559 void calc_vital_stuff(
bool i_mod = true,
bool v_mod = true );
560 void calc_single_vital( const Core::Vital* pVital );
561 void calc_single_attribute( const
Attribute* pAttr );
562 void set_vitals_to_maximum();
563 void produce( const Core::Vital* pVital,
VitalValue& vv,
unsigned int amt );
564 bool consume( const Core::Vital* pVital,
VitalValue& vv,
unsigned int amt );
565 void set_current_ones( const Core::Vital* pVital,
VitalValue& vv,
unsigned int ones );
566 void set_current( const Core::Vital* pVital,
VitalValue& vv,
unsigned int ones );
572 Bscript::
ObjArray* GetReportables() const;
573 Bscript::
ObjArray* GetAggressorTo() const;
574 Bscript::
ObjArray* GetLawFullyDamaged() const;
576 bool is_aggressor_to( const
Character* chr ) const;
578 void remove_as_aggressor_to(
Character* chr );
580 bool has_lawfully_damaged( const
Character* chr ) const;
582 void remove_as_lawful_damager(
Character* chr );
584 bool is_criminal() const;
585 bool is_temporally_criminal() const;
586 void restart_criminal_timer( Core::
polclock_t until );
587 void clear_criminal_timer();
589 bool is_murderer() const;
590 bool is_innocent_to( const
Character* chr ) const;
591 void make_criminal(
int level = 1 );
592 void make_murderer(
bool newlval = true );
593 void make_aggressor_to(
Character* chr );
594 void make_lawfullydamaged_to(
Character* chr );
596 void add_to_be_reportable(
u32 serial );
597 void clear_to_be_reportables();
598 void commit_to_reportables();
600 void clear_my_aggressors();
601 void clear_my_lawful_damagers();
602 void check_undamaged();
604 void on_criminal_changed();
605 void on_murderer_changed();
606 void on_aggressor_changed();
607 void on_lawfullydamaged_changed();
612 unsigned int guildid() const;
613 bool is_guild_ally( const
Character* chr ) const;
614 bool is_guild_enemy( const
Character* chr ) const;
621 bool party_can_loot() const;
622 void set_party_can_loot(
bool );
623 void set_party_invite_timeout();
624 bool has_party_invite_timeout() const;
625 void cancel_party_invite_timeout();
629 bool is_trading() const;
630 void create_trade_container();
632 bool trade_accepted() const;
633 void trade_accepted(
bool newvalue );
637 void schedule_spell( Core::
USpell* );
638 bool casting_spell() const;
639 bool skill_ex_active() const;
644 bool start_itemuse_script( Bscript::
EScriptProgram* prog, Items::Item* item,
645 bool start_attached );
646 bool start_spell_script( Bscript::
EScriptProgram* prog, Core::USpell* spell );
654 void stop_skill_script();
658 bool logged_in() const;
659 void logged_in(
bool newvalue );
660 bool connected() const;
661 void connected(
bool newvalue );
662 bool has_active_client() const;
663 bool has_active_prompt() const;
664 bool has_active_gump() const;
665 bool is_house_editing() const;
666 bool target_cursor_busy() const;
667 u16 last_textcolor() const;
668 void last_textcolor(
u16 new_color );
670 u8 get_flag1( Network::
Client* other_client ) const;
674 void on_aos_ext_stat_changed();
675 void on_cmdlevel_changed();
676 void on_poison_changed();
677 void on_hidden_changed();
678 void on_concealed_changed();
680 bool warmode() const;
681 void set_warmode(
bool warmode );
682 void set_stealthsteps(
unsigned short newval );
683 bool doors_block() const;
684 bool ignores_line_of_sight() const;
686 bool is_visible() const;
687 bool is_visible_to_me( const
Character* chr ) const;
689 void hidden(
bool value );
691 unsigned char concealed() const;
692 void concealed(
unsigned char value );
693 bool is_concealed_from_me( const
Character* chr ) const;
696 bool paralyzed() const;
697 bool squelched() const;
698 bool deafened() const;
699 bool poisoned() const;
700 void poisoned(
bool value );
701 unsigned char cmdlevel() const;
702 void cmdlevel(
unsigned char value,
bool update_on_change = true );
707 bool can_access( const Items::Item* item,
int range = -1 ) const;
709 bool can_move( const Items::Item* item ) const;
710 bool can_rename( const
Character* chr ) const;
711 bool can_clothe( const
Character* chr ) const;
712 bool can_hearghosts() const;
713 bool can_be_heard_as_ghost() const;
714 bool can_seeinvisitems() const;
715 bool can_dblclickany() const;
716 bool can_moveanydist() const;
717 bool can_plogany() const;
718 bool can_speedhack() const;
719 bool can_freemove() const;
721 bool has_privilege( const
char* priv ) const;
722 bool setting_enabled( const
char* setting ) const;
723 void grant_privilege( const
char* priv );
724 void revoke_privilege( const
char* priv );
725 void set_setting( const
char* setting,
bool value );
726 std::
string all_settings() const;
727 std::
string all_privs() const;
728 void set_privs( const
std::
string& privlist );
730 void check_concealment_level();
733 void refresh_cached_settings(
bool update = true );
737 void readCommonProperties( Clib::ConfigElem& elem );
738 void readAttributesAndVitals( Clib::ConfigElem& elem );
744 void printWornItems( Clib::StreamWriter& sw_pc, Clib::StreamWriter& sw_equip ) const;
751 friend
void Core::
createchar2( Accounts::Account* acct,
unsigned index );
755 void removal_cleanup();
756 void disconnect_cleanup();
757 int charindex() const;
758 void on_delete_from_account();
766 void addBuff(
u16 icon,
u16 duration,
u32 cl_name,
u32 cl_descr,
767 const
std::vector<
u32>& arguments );
768 bool delBuff(
u16 icon );
784 Items::UArmor* shield;
785 std::vector<Items::UArmor*> armor_;
794 GOTTEN_ITEM_IN_CONTAINER
795 } gotten_item_source;
839 typedef std::map<Core::CharacterRef, Core::polclock_t>
MobileCont;
933 return mob_flags_.get( MOB_FLAGS::DEAD );
938 return !( hidden() || concealed_ );
943 return mob_flags_.get( MOB_FLAGS::HIDDEN );
948 if ( value != hidden() )
950 mob_flags_.change( MOB_FLAGS::HIDDEN, value );
962 if ( concealed_ != value )
965 on_concealed_changed();
971 return mob_flags_.get( MOB_FLAGS::FROZEN );
976 return mob_flags_.get( MOB_FLAGS::PARALYZED );
981 return mob_flags_.get( MOB_FLAGS::POISONED );
986 if ( value != poisoned() )
988 mob_flags_.change( MOB_FLAGS::POISONED, value );
1000 if ( cmdlevel_ != value )
1003 if ( update_on_change )
1004 on_cmdlevel_changed();
1015 return ( script_ex !=
nullptr );
1020 return ( spell_task !=
nullptr );
1030 return cached_settings.get( PRIV_FLAGS::LOS_ANY );
1034 return cached_settings.get( PRIV_FLAGS::SEE_INVIS_ITEMS );
1038 return cached_settings.get( PRIV_FLAGS::DBLCLICK_ANY );
1043 return ( shield !=
nullptr );
1053 passert( attrid < attributes.size() );
1054 return attributes[attrid];
1058 passert( attributes.size() > attrid );
1059 return attributes[attrid];
1063 passert( vitals.size() > vitalid );
1064 return vitals[vitalid];
1068 passert( vitalid < vitals.size() );
1069 return vitals[vitalid];
1084 if ( chr != thecriminal )
1090 if ( chr != wholeft )
1098 if ( chr != whoentered )
void handle_script_cursor(Character *chr, UObject *obj)
ToBeReportableList to_be_reportable_
void ClientCreateChar(Network::Client *client, PKTIN_00 *msg)
Core::gameclock_t created_at
void NpcPropagateMove(Character *chr, Character *moved)
void current_ones(int ones)
bool operator<(T *ptr, const ref_ptr< T > &rptr)
unsigned char lock() const
bool skill_ex_active() const
bool can_dblclickany() const
unsigned char concealed() const
unsigned short cap() const
std::map< u16, Buff > buffs_
MobileCont lawfully_damaged_
int current_thousands() const
Core::UOExecutor * script_ex
time_t disable_regeneration_until
Core::polclock_t polclock
static const SkillStatCap DEFAULT
Items::UArmor * get_shield() const
std::set< reportable_t > ReportableList
unsigned char cmdlevel() const
Core::TargetCursor * tcursor2
std::map< Core::CharacterRef, Core::polclock_t > MobileCont
bool casting_spell() const
static const ExtStatBarFollowers DEFAULT
std::vector< AttributeValue > attributes
void cap(unsigned short cap)
void menu_selection_made(Network::Client *client, MenuItem *mi, PKTIN_7D *msg)
bool can_seeinvisitems() const
void NpcPropagateLeftArea(Character *chr, Character *wholeft)
void NpcPropagateEnteredArea(Character *chr, Character *whoentered)
void write_npcs(SaveContext &sc)
void undo_get_item(Mobile::Character *chr, Items::Item *item)
#define DYN_PROPERTY_POINTER(name, type, id)
bool consume(unsigned int hamt)
void base(unsigned short base)
ref_ptr< Core::UContainer > trading_cont
weak_ptr< Core::Menu > menu
Core::OneShotTask * repsys_task_
const AttributeValue & attribute(unsigned attrid) const
Core::CharacterRef trading_with
virtual unsigned short ar() const
virtual void inform_moved(Character *moved)
void createchar2(Accounts::Account *acct, unsigned index)
ref_ptr< Mobile::Character > CharacterRef
virtual void inform_leftarea(Character *wholeft)
Core::polclock_t swing_timer_start_clock_
void intrinsic_mod(short val)
int effective_tenths() const
ReportableList reportable_
Core::AttributeFlags< PRIV_FLAGS > cached_settings
std::vector< u32 > arguments
void temp_mod(short temp)
std::set< USERIAL > ToBeReportableList
Core::AttributeFlags< MOB_FLAGS > mob_flags_
const unsigned ATTRIBUTE_MAX_BASE
static const MovementCostMod DEFAULT
void lock(unsigned char lockstate)
int intrinsic_mod() const
virtual void inform_criminal(Character *thecriminal)
std::set< Character * > CharacterSet
void NpcPropagateCriminal(Character *chr, Character *thecriminal)
Core::polclock_t criminal_until_
#define DYN_PROPERTY(name, type, id, defaultvalue)
const CharacterSet & hostiles() const
virtual void inform_enteredarea(Character *whoentered)
const VitalValue & vital(unsigned vitalid) const
bool ignores_line_of_sight() const
Core::OneShotTask * swing_task
void produce(unsigned int hamt)
void write_characters(SaveContext &sc)
std::vector< Core::ItemRef > remote_containers_
void ClientCreateCharKR(Network::Client *client, PKTIN_8D *msg)
Core::OneShotTask * party_decline_timeout_
void start_script(const char *filename, Bscript::BObjectImp *param0, Bscript::BObjectImp *param1)
Core::OneShotTask * spell_task
bool is_at_maximum() const
void ClientCreateChar70160(Network::Client *client, PKTIN_F8 *msg)
std::vector< VitalValue > vitals
virtual void inform_imoved(Character *chr)