Pol  Revision:cb584c9
attack.cpp
Go to the documentation of this file.
1 
12 #include <cstdio>
13 
14 #include "../../clib/clib_endian.h"
15 #include "../../clib/rawtypes.h"
16 #include "../cmbtcfg.h"
17 #include "../globals/settings.h"
18 #include "../guardrgn.h"
19 #include "../network/client.h"
20 #include "../pktin.h"
21 #include "../ufunc.h"
22 #include "charactr.h"
23 
24 namespace Pol
25 {
26 namespace Mobile
27 {
29 {
30  if ( client->chr->dead() )
31  {
32  private_say_above( client->chr, client->chr, "I am dead and cannot do that." );
33  return;
34  }
35 
36  u32 serial = cfBEu32( msg->serial );
37  Character* defender = Core::find_character( serial );
38  if ( defender != nullptr )
39  {
40  if ( !( Core::settingsManager.combat_config.attack_self ) )
41  {
42  if ( defender->serial == client->chr->serial )
43  {
44  client->chr->send_highlight();
45  return;
46  }
47  }
48 
49  if ( !client->chr->is_visible_to_me( defender ) )
50  {
51  client->chr->send_highlight();
52  return;
53  }
54  if ( Core::pol_distance( client->chr->x, client->chr->y, defender->x, defender->y ) > 20 )
55  {
56  client->chr->send_highlight();
57  return;
58  }
59 
60  if ( defender->acct != nullptr )
61  {
62  if ( Core::JusticeRegion::RunNoCombatCheck( defender->client ) == true )
63  {
64  client->chr->send_highlight();
65  Core::send_sysmessage( client, "Combat is not allowed in this area." );
66  return;
67  }
68  }
69  client->chr->select_opponent( serial );
70  }
71 }
72 }
73 }
void handle_attack(Network::Client *client, Core::PKTIN_05 *msg)
Definition: attack.cpp:28
void select_opponent(u32 opp_serial)
Definition: charactr.cpp:3044
Network::Client * client
Definition: charactr.h:871
#define cfBEu32(x)
Definition: clib_endian.h:43
bool is_visible_to_me(const Character *chr) const
Definition: charactr.cpp:2658
Mobile::Character * chr
Definition: client.h:182
bool private_say_above(Character *chr, const UObject *obj, const char *text, unsigned short font, unsigned short color, unsigned int journal_print)
Definition: ufunc.cpp:1328
unsigned int u32
Definition: rawtypes.h:27
void send_highlight() const
Definition: charactr.cpp:2937
Mobile::Character * find_character(u32 serial)
Definition: fnsearch.cpp:60
SettingsManager settingsManager
Definition: settings.cpp:14
Core::AccountRef acct
Definition: charactr.h:914
unsigned short pol_distance(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
Definition: ufunc.cpp:481
static bool RunNoCombatCheck(Network::Client *client)
Definition: guardrgn.cpp:88
Definition: berror.cpp:12
bool dead() const
Definition: charactr.h:931
void send_sysmessage(Network::Client *client, const char *text, unsigned short font, unsigned short color)
Definition: ufunc.cpp:1147