2016-01-28 14:52:40 +01:00
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* @par History
|
|
|
|
|
* - 2005/11/26 MuadDib: Added update code for updating highlight packet to client.
|
|
|
|
|
* - 2005/11/26 Shinigami: added Character check
|
|
|
|
|
* - 2005/11/25 MuadDib: Added distance check in handle_attack.
|
|
|
|
|
* - 2006/03/07 MuadDib: Added Justice Region NoCombat check to attack request.
|
|
|
|
|
* - 2009/01/03 MuadDib: Removed logging of null defenders. Who cares if it's empty :o
|
|
|
|
|
*/
|
2016-02-11 22:54:43 +01:00
|
|
|
|
|
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
#include <cstdio>
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "../../clib/clib_endian.h"
|
|
|
|
|
#include "../../clib/rawtypes.h"
|
|
|
|
|
#include "../cmbtcfg.h"
|
|
|
|
|
#include "../globals/settings.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
#include "../network/client.h"
|
2018-12-30 21:35:54 +01:00
|
|
|
#include "../network/pktin.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
#include "../ufunc.h"
|
2018-01-29 21:55:48 +01:00
|
|
|
#include "charactr.h"
|
2021-09-10 20:17:25 +02:00
|
|
|
#include "regions/guardrgn.h"
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
namespace Pol
|
|
|
|
|
{
|
|
|
|
|
namespace Mobile
|
|
|
|
|
{
|
|
|
|
|
void handle_attack( Network::Client* client, Core::PKTIN_05* msg )
|
|
|
|
|
{
|
|
|
|
|
if ( client->chr->dead() )
|
|
|
|
|
{
|
|
|
|
|
private_say_above( client->chr, client->chr, "I am dead and cannot do that." );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-02-11 22:54:43 +01:00
|
|
|
|
2016-02-19 19:26:35 +01:00
|
|
|
u32 serial = cfBEu32( msg->serial );
|
|
|
|
|
Character* defender = Core::find_character( serial );
|
2023-12-25 22:02:52 +01:00
|
|
|
if ( defender == nullptr )
|
|
|
|
|
return;
|
|
|
|
|
if ( !( Core::settingsManager.combat_config.attack_self ) )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
2023-12-25 22:02:52 +01:00
|
|
|
if ( defender->serial == client->chr->serial )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
client->chr->send_highlight();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-12-25 22:02:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !client->chr->is_visible_to_me( defender ) )
|
|
|
|
|
{
|
|
|
|
|
client->chr->send_highlight();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( defender->acct != nullptr )
|
|
|
|
|
{
|
|
|
|
|
if ( Core::JusticeRegion::RunNoCombatCheck( defender->client ) == true )
|
2016-02-19 19:26:35 +01:00
|
|
|
{
|
|
|
|
|
client->chr->send_highlight();
|
2023-12-25 22:02:52 +01:00
|
|
|
Core::send_sysmessage( client, "Combat is not allowed in this area." );
|
2016-02-19 19:26:35 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2016-02-11 22:54:43 +01:00
|
|
|
}
|
2023-12-25 22:02:52 +01:00
|
|
|
client->chr->select_opponent( serial );
|
2016-02-11 22:54:43 +01:00
|
|
|
}
|
2018-12-30 21:35:54 +01:00
|
|
|
} // namespace Mobile
|
|
|
|
|
} // namespace Pol
|