16 #include "../clib/cfgelem.h" 17 #include "../clib/cfgfile.h" 18 #include "../clib/cfgsect.h" 19 #include "../clib/logfacility.h" 20 #include "../clib/rawtypes.h" 87 elem.
remove_bool(
"PartyHelpFullCountsAsCriminal",
false );
150 while ( cf.
read( elem ) )
152 if ( namecoloring.
matches( elem ) )
156 else if ( general.
matches( elem ) )
160 else if ( hooks.
matches( elem ) && !reload )
189 bool refreshall =
false;
195 for ( Mobile::Character::CharacterSet::iterator h_itr = amy->
opponent_of.begin();
204 defensive_hostiles.insert( hostile_bob );
227 Mobile::Character::MobileCont::iterator itr;
232 Mobile::Character::MobileCont::iterator save_itr = itr;
246 if ( !other->orphan() )
254 POLLOG <<
"NOTE: repsys crash avoidance...\n";
270 Mobile::Character::MobileCont::iterator save_itr = itr;
284 if ( !other->orphan() )
292 POLLOG <<
"NOTE: repsys crash avoidance...\n";
306 for ( Mobile::Character::CharacterSet::iterator h_itr = defensive_hostiles.begin();
307 h_itr != defensive_hostiles.end(); ++h_itr )
361 unsigned short color );
410 if ( amy_attacker == bob_defender )
413 bool refresh =
false;
438 std::string msg =
"*" + amy_attacker->
name() +
" is attacking you!*";
450 if ( amy_attacker->
client )
519 Party* party = amy->party();
568 if ( hook_highlight != -1 )
569 return (
unsigned char)hook_highlight;
601 if ( hook_color != -1 )
602 return (
unsigned short)hook_color;
682 auto thisguild = guild();
683 auto otherguild = chr->guild();
684 return ( thisguild !=
nullptr && otherguild !=
nullptr &&
698 auto thisguild = guild();
699 auto otherguild = chr->guild();
700 return ( thisguild !=
nullptr && otherguild !=
nullptr &&
712 if ( itr == aggressor_to_.end() )
718 if ( until > ( *itr ).second )
719 ( *itr ).second = until;
726 return ( lawfully_damaged_.find(
Core::CharacterRef( in_chr ) ) != lawfully_damaged_.end() );
732 if ( itr == lawfully_damaged_.end() )
738 if ( when > ( *itr ).second )
739 ( *itr ).second = when;
751 return is_temporally_criminal() || is_murderer();
760 if ( until > criminal_until_ )
767 criminal_until_ = until;
778 return mob_flags_.get( MOB_FLAGS::MURDERER );
825 NPC* npc =
static_cast<NPC*
>( defender );
855 master_->Character::repsys_on_attack( defender );
887 NPC* npc =
static_cast<NPC*
>( defender );
916 master_->Character::repsys_on_damage( defender );
948 NPC* npc =
static_cast<NPC*
>( helped );
978 master_->Character::repsys_on_help( helped );
1005 NPC* t_amy =
const_cast<NPC*
>( this );
1009 if ( hook_highlight != -1 )
1010 return (
unsigned char)( hook_highlight );
1024 switch ( template_.alignment )
1029 if ( is_murderer() )
1031 else if ( is_criminal() )
1046 NPC* t_amy =
const_cast<NPC*
>( this );
1050 if ( hook_color != -1 )
1051 return (
unsigned short)hook_color;
1056 if ( this->invul() )
1065 switch ( template_.alignment )
1070 if ( is_murderer() )
1072 else if ( is_criminal() )
1096 bool was_criminal = is_criminal();
1104 restart_criminal_timer( timeout_at );
1109 clear_criminal_timer();
1113 if ( !orphan() && was_criminal != is_criminal() )
1116 on_criminal_changed();
1122 bool refresh = ( mob_flags_.get( MOB_FLAGS::MURDERER ) != newval );
1125 mob_flags_.change( MOB_FLAGS::MURDERER, newval );
1127 if ( !orphan() && refresh )
1130 on_murderer_changed();
1140 restart_aggressor_timer( chr, aggr_timeout_at );
1143 on_aggressor_changed();
1153 restart_lawfully_damaged_timer( chr, aggr_timeout_at );
1156 on_lawfullydamaged_changed();
1165 to_be_reportable_.insert( repserial );
1170 to_be_reportable_.clear();
1177 ToBeReportableList::iterator itr = to_be_reportable_.begin(), end = to_be_reportable_.end();
1178 for ( ; itr != end; ++itr )
1183 reportable_.insert( rt );
1186 to_be_reportable_.clear();
1194 reportable_.erase( rt );
1199 ToBeReportableList::iterator itr = to_be_reportable_.begin(), end = to_be_reportable_.end();
1200 for ( ; itr != end; ++itr )
1202 u32 repserial = ( *itr );
1204 if ( aggressor !=
nullptr )
1213 aggressor_to_.erase( ref );
1214 if ( chr->
client !=
nullptr )
1218 if ( client !=
nullptr )
1226 ToBeReportableList::iterator itr = to_be_reportable_.begin(), end = to_be_reportable_.end();
1227 for ( ; itr != end; ++itr )
1229 u32 repserial = ( *itr );
1231 if ( damager !=
nullptr )
1241 lawfully_damaged_.erase( ref );
1243 if ( chr->
client !=
nullptr )
1247 if ( client !=
nullptr )
static void repsys_task(Mobile::Character *chr)
[2] Timeouts When Any of Amy's Rep-system timers time out
unsigned short Invulnerable
void load_repsys_cfg_general(Clib::ConfigElem &elem)
struct Pol::Core::RepSys_Cfg::@56 General
unsigned short GuildEnemy
void on_lawfullydamaged_changed()
ExportedFunction * HighLightColor
bool is_criminal() const
A Mobile is Criminal if: he has an active Criminal Timer, which has not timed out. OR he is a murderer.
void add_to_be_reportable(u32 serial)
void set_opponent(Character *opponent, bool inform_old_opponent=true)
#define CHAR_HILITE_ATTACKABLE
Character * master() const
static void on_pc_attacks_pc(Mobile::Character *attacker, Mobile::Character *defender)
[3] Player attacks another Player When Amy attacks Bob These rules are applied:
polclock_t earliest_timer(polclock_t timer1_until, polclock_t timer2_until)
void make_lawfullydamaged_to(Character *chr)
static bool AreAllies(Guild *g1, Guild *g2)
MobileCont lawfully_damaged_
ExportedFunction * OnHelp
void clear_reportable(u32 serial, Core::polclock_t time)
void restart_criminal_timer(Core::polclock_t until)
static void on_pc_helps_pc(Mobile::Character *helper, Mobile::Character *helped)
[5] Player Helps Another Player When Amy Helps Bob These rules applied:
void on_aggressor_changed()
Core::polclock_t polclock
static bool AreEnemies(Guild *g1, Guild *g2)
unsigned short AggressorFlagTimeout
virtual void repsys_on_help(Character *recipient)
[15] Mobile (MA) Helps Mobile (MB)
unsigned short Attackable
bool private_say_above_ex(Mobile::Character *chr, const UObject *obj, const char *text, unsigned short color)
bool PartyHelpFullCountsAsCriminal
bool is_member(u32 serial) const
#define THREAD_CHECKPOINT(thread, check)
virtual unsigned char hilite_color_idx(const Character *seen_by) const POL_OVERRIDE
[16] NPC Highlighting If the NPC has a master, Highlight color is the same as the Master's...
virtual void repsys_on_damage(Character *defender)
[14] Mobile (MA) Damages Mobile (MB)
ExportedFunction * OnAttack
void send_create_mobile_if_nearby_cansee(Client *client, const Character *chr)
static void InRange(u16 x, u16 y, const Realms::Realm *realm, unsigned range, F &&f)
bool matches(const ConfigElem &elem)
virtual void repsys_on_help(Character *recipient) POL_OVERRIDE
[15.2] NPC (MA) Helps Mobile (MB) If MA has a Master (Amy), Apply 'Player Helps Mobile' rules[->15...
virtual unsigned short name_color(const Character *seen_by) const
struct Pol::Core::RepSys_Cfg::@57 Hooks
void load_repsys_cfg_hooks(Clib::ConfigElem &elem)
bool is_aggressor_to(const Character *chr) const
#define CHAR_HILITE_FRIEND
void load_repsys_cfg_namecoloring(Clib::ConfigElem &elem)
Reputation System.
void make_aggressor_to(Character *chr)
virtual void repsys_on_damage(Character *defender) POL_OVERRIDE
[14.2] NPC (MA) Damages Mobile (MB) If MA has a Master (Amy), Apply 'Player Damages Mobile' rules[->1...
void on_murderer_changed()
void restart_lawfully_damaged_timer(Character *chr, Core::polclock_t until)
bool is_guild_enemy(const Character *chr) const
[10.2] Guild Enemies Bob and Amy are Guild Enemies if: Bob is in a guild, AND Amy is in a guild...
#define CHAR_HILITE_CRIMINAL
virtual void repsys_on_attack(Character *defender)
[13] Mobile (MA) Attacks Mobile (MA)
void send_move(Client *client, const Character *chr)
void remove_as_lawful_damager(Character *chr)
virtual void cancel(void) POL_OVERRIDE
const unsigned CST_NORMAL
polclock_t next_run_clock() const
bool is_temporally_criminal() const
virtual unsigned short name_color(const Character *seen_by) const POL_OVERRIDE
#define CHAR_HILITE_INNOCENT
Core::OneShotTask * repsys_task_
#define CHAR_HILITE_MURDERER
ref_ptr< Mobile::Character > CharacterRef
void unload_repsys_cfg_hooks()
ExportedFunction * OnDamage
virtual unsigned char hilite_color_idx(const Character *seen_by) const
#define CHAR_HILITE_ENEMY
void restart_aggressor_timer(Character *chr, Core::polclock_t until)
virtual Bscript::BObjectImp * make_ref() POL_OVERRIDE
void load_repsys_cfg(bool reload)
#define CHAR_HILITE_INVUL
bool has_lawfully_damaged(const Character *chr) const
void on_criminal_changed()
static void de_escalate(Mobile::Character *amy, Mobile::Character *bob)
[7] De-Escalation To De-escalate Amy and Bob: if Amy's opponent is Bob, Amy clears her opponent If Bo...
SettingsManager settingsManager
void make_murderer(bool newlval=true)
void commit_to_reportables()
static unsigned char hilite_color_idx(const Mobile::Character *chr, const Mobile::Character *who)
[8] Highlighting and Name Coloring if Amy looks at Bob, coloring is as follows: if Bob is invul and i...
Mobile::Character * system_find_mobile(u32 serial)
bool is_innocent_to(const Character *chr) const
[9] Innocent Status Bob is Innocent to Amy if: Bob is Innocent to Amy only if NONE of the following a...
bool remove_prop(const char *propname, std::string *value)
CombatConfig combat_config
std::set< Character * > CharacterSet
void NpcPropagateCriminal(Character *chr, Character *thecriminal)
Core::polclock_t criminal_until_
void make_criminal(int level=1)
To Set Amy Criminal (For a LevelOfOffense)
static unsigned short name_color(const Mobile::Character *seen_by, const Mobile::Character *who)
unsigned short CriminalFlagInterval
static void schedule_repsys_task(Mobile::Character *chr, polclock_t runat)
unsigned short remove_ushort(const char *propname)
ExportedFunction * FindExportedFunction(Clib::ConfigElem &elem, const Plib::Package *pkg, const std::string &descriptor, unsigned nargs, bool complain_if_missing)
void clear_criminal_timer()
void remove_as_aggressor_to(Character *chr)
bool isa(UOBJ_CLASS uobj_class) const
void clear_my_aggressors()
void clear_to_be_reportables()
int call_long(Bscript::BObjectImp *p0)
ExportedFunction * NameColor
struct Pol::Core::RepSys_Cfg::@55 NameColoring
static void on_pc_damages_pc(Mobile::Character *attacker, Mobile::Character *defender)
[4] Player Damages Player When Amy damages Bob These rules applied:
bool read(ConfigElem &elem)
bool timer_expired(polclock_t timer_until, polclock_t now)
void clear_my_lawful_damagers()
virtual std::string name() const
void send_create_mobile_to_nearby_cansee(const Character *chr)
Core::NpcTemplate::ALIGNMENT alignment() const
bool is_guild_ally(const Character *chr) const
[10] Guild Rules The following Guild Rules are only temporary pending a more complete system ...
const polclock_t POLCLOCKS_PER_SEC
bool remove_bool(const char *propname)
virtual void repsys_on_attack(Character *defender) POL_OVERRIDE
[13.2] NPC (MA) Attacks Mobile (MB) If MA has a Master (Amy), Apply 'Player Attacks Mobile' rules[->1...