Horizon Official Technical Documentation
Horizon::Zone::PlayerComponent Class Reference

#include <PlayerComponent.hpp>

+ Inheritance diagram for Horizon::Zone::PlayerComponent:
+ Collaboration diagram for Horizon::Zone::PlayerComponent:

Public Member Functions

 PlayerComponent ()
 
 PlayerComponent (std::shared_ptr< GameLogicProcess > container)
 
 ~PlayerComponent ()
 
void sync_definitions (std::shared_ptr< sol::state > state)
 
void sync_data_types (std::shared_ptr< sol::state > state)
 
void sync_functions (std::shared_ptr< sol::state > state)
 
void perform_command_from_player (std::shared_ptr< Units::Player > player, std::string const &cmd)
 
- Public Member Functions inherited from Horizon::Zone::LUAComponent
 LUAComponent ()
 
 LUAComponent (std::shared_ptr< GameLogicProcess > container)
 
 ~LUAComponent ()
 
virtual void sync_definitions (std::shared_ptr< sol::state > state)=0
 
virtual void sync_data_types (std::shared_ptr< sol::state > state)=0
 
virtual void sync_functions (std::shared_ptr< sol::state > state)=0
 
std::shared_ptr< GameLogicProcessget_container ()
 

Constructor & Destructor Documentation

◆ PlayerComponent() [1/2]

Horizon::Zone::PlayerComponent::PlayerComponent ( )
inline
47{ }

◆ PlayerComponent() [2/2]

Horizon::Zone::PlayerComponent::PlayerComponent ( std::shared_ptr< GameLogicProcess container)
inline
48: LUAComponent(container) { }
LUAComponent()
Definition: LUAComponent.hpp:42

◆ ~PlayerComponent()

Horizon::Zone::PlayerComponent::~PlayerComponent ( )
inline
49{ }

Member Function Documentation

◆ perform_command_from_player()

void PlayerComponent::perform_command_from_player ( std::shared_ptr< Units::Player player,
std::string const &  cmd 
)
103{
104 try {
105 std::string script_root_path = sZone->config().get_script_root_path().string();
106 sol::load_result fx = player->lua_state()->load_file(script_root_path + "internal/at_command_main.lua");
107 sol::protected_function_result result = fx(player, cmd);
108 if (!result.valid()) {
109 sol::error err = result;
110 HLog(error) << "PlayerComponent::perform_command_from_player: " << err.what();
111 }
112 } catch (sol::error &e) {
113 HLog(error) << "PlayerComponent::perform_command_from_player: " << e.what();
114 }
115}
#define HLog(type)
Definition: Logger.hpp:122
#define sZone
Definition: Zone.hpp:247

References HLog, and sZone.

◆ sync_data_types()

void PlayerComponent::sync_data_types ( std::shared_ptr< sol::state >  state)
virtual

Implements Horizon::Zone::LUAComponent.

62{
63 state->new_usertype<Assets::Inventory>("Inventory",
64 "add_item", sol::resolve<enum Horizon::Zone::Assets::inventory_addition_result_type(uint32_t, uint16_t, bool)>(&Assets::Inventory::add_item)
65 );
66
67 state->new_usertype<Assets::Storage>("Storage",
68 "notify_all", &Assets::Storage::notify_all
69 );
70
71 sol::usertype<Horizon::Zone::Units::Player> a = state->new_usertype<Horizon::Zone::Units::Player>("Player");
72
73 a["unit"] = [](std::shared_ptr<Horizon::Zone::Units::Player> player) { return player->shared_from_this(); };
74
76 a["send_npc_next_dialog"] = &Horizon::Zone::Units::Player::send_npc_next_dialog;
77 a["send_npc_close_dialog"] = &Horizon::Zone::Units::Player::send_npc_close_dialog;
78 a["send_npc_menu_list"] = &Horizon::Zone::Units::Player::send_npc_menu_list;
82 a["message"] = [] (std::shared_ptr<Horizon::Zone::Units::Player> player, std::string const &message)
83 {
84 player->get_session()->clif()->notify_chat(message);
85 };
91}
Definition: Inventory.hpp:74
inventory_addition_result_type add_item(std::shared_ptr< Horizon::Zone::Units::Item > floor_item)
Definition: Inventory.cpp:306
Definition: Storage.hpp:70
void notify_all()
Definition: Storage.cpp:191
Definition: Player.hpp:62
void send_npc_next_dialog(uint32_t npc_guid)
Definition: Player.cpp:472
bool perform_action(player_action_type action)
Definition: Player.cpp:706
void send_npc_close_dialog(uint32_t npc_guid)
Definition: Player.cpp:477
void send_npc_dialog(uint32_t npc_guid, std::string dialog)
Definition: Player.cpp:467
bool on_skill_failure(int16_t skill_id, int message_type, int item_id, skill_use_fail_cause_type cause)
Definition: Player.cpp:685
void send_npc_menu_list(uint32_t npc_guid, std::string const &menu)
Definition: Player.cpp:482
std::shared_ptr< skill_learnt_info > get_learnt_skill(uint16_t skill_id)
Definition: Player.hpp:181
std::shared_ptr< Assets::Inventory > inventory()
Definition: Player.hpp:164
bool perform_skill(int16_t skill_id, int16_t skill_lv)
Definition: Player.cpp:660
bool job_change(int32_t job_id)
Definition: Player.cpp:645
bool move_to_map(std::shared_ptr< Map > map, MapCoords coords={ 0, 0 })
Definition: Player.cpp:423
std::shared_ptr< Assets::Storage > get_storage(int32_t storage_id)
Definition: Player.cpp:288

References Horizon::Zone::Assets::Inventory::add_item(), Horizon::Zone::Units::Player::get_learnt_skill(), Horizon::Zone::Units::Player::get_storage(), Horizon::Zone::Units::Player::inventory(), Horizon::Zone::Units::Player::job_change(), Horizon::Zone::Units::Player::move_to_map(), Horizon::Zone::Assets::Storage::notify_all(), Horizon::Zone::Units::Player::on_skill_failure(), Horizon::Zone::Units::Player::perform_action(), Horizon::Zone::Units::Player::perform_skill(), Horizon::Zone::Units::Player::send_npc_close_dialog(), Horizon::Zone::Units::Player::send_npc_dialog(), Horizon::Zone::Units::Player::send_npc_menu_list(), and Horizon::Zone::Units::Player::send_npc_next_dialog().

+ Here is the call graph for this function:

◆ sync_definitions()

void PlayerComponent::sync_definitions ( std::shared_ptr< sol::state >  state)
virtual

Implements Horizon::Zone::LUAComponent.

43{
44 state->create_named_table("PlayerActionType",
45 "Attack", PLAYER_ACT_ATTACK,
46 "ItemPickup", PLAYER_ACT_ITEM_PICKUP,
47 "Sit", PLAYER_ACT_SIT,
48 "Stand", PLAYER_ACT_STAND,
49 "AttackNoMotion", PLAYER_ACT_ATTACK_NOMOTION,
50 "Splash", PLAYER_ACT_SPLASH,
51 "Skill", PLAYER_ACT_SKILL,
52 "AttackRepeat", PLAYER_ACT_ATTACK_REPEAT,
53 "AttackMultiple", PLAYER_ACT_ATTACK_MULTIPLE,
54 "AttackMultipleNoMotion", PLAYER_ACT_ATTACK_MULTIPLE_NOMOTION,
55 "AttackCritical", PLAYER_ACT_ATTACK_CRITICAL,
56 "AttackLucky", PLAYER_ACT_ATTACK_LUCKY,
57 "TouchSkill", PLAYER_ACT_TOUCHSKILL
58 );
59}
@ PLAYER_ACT_SIT
Definition: PlayerDefinitions.hpp:36
@ PLAYER_ACT_ATTACK_REPEAT
Definition: PlayerDefinitions.hpp:41
@ PLAYER_ACT_STAND
Definition: PlayerDefinitions.hpp:37
@ PLAYER_ACT_ATTACK_NOMOTION
Definition: PlayerDefinitions.hpp:38
@ PLAYER_ACT_ATTACK_MULTIPLE
Definition: PlayerDefinitions.hpp:42
@ PLAYER_ACT_SPLASH
Definition: PlayerDefinitions.hpp:39
@ PLAYER_ACT_ATTACK_LUCKY
Definition: PlayerDefinitions.hpp:45
@ PLAYER_ACT_ATTACK
Definition: PlayerDefinitions.hpp:34
@ PLAYER_ACT_ATTACK_CRITICAL
Definition: PlayerDefinitions.hpp:44
@ PLAYER_ACT_ATTACK_MULTIPLE_NOMOTION
Definition: PlayerDefinitions.hpp:43
@ PLAYER_ACT_ITEM_PICKUP
Definition: PlayerDefinitions.hpp:35
@ PLAYER_ACT_TOUCHSKILL
Definition: PlayerDefinitions.hpp:46
@ PLAYER_ACT_SKILL
Definition: PlayerDefinitions.hpp:40

References PLAYER_ACT_ATTACK, PLAYER_ACT_ATTACK_CRITICAL, PLAYER_ACT_ATTACK_LUCKY, PLAYER_ACT_ATTACK_MULTIPLE, PLAYER_ACT_ATTACK_MULTIPLE_NOMOTION, PLAYER_ACT_ATTACK_NOMOTION, PLAYER_ACT_ATTACK_REPEAT, PLAYER_ACT_ITEM_PICKUP, PLAYER_ACT_SIT, PLAYER_ACT_SKILL, PLAYER_ACT_SPLASH, PLAYER_ACT_STAND, and PLAYER_ACT_TOUCHSKILL.

◆ sync_functions()

void PlayerComponent::sync_functions ( std::shared_ptr< sol::state >  state)
virtual

Implements Horizon::Zone::LUAComponent.

94{
95 state->set_function("cast_unit_to_player",
96 [] (std::shared_ptr<Unit> e)
97 {
98 return e->template downcast<Horizon::Zone::Units::Player>();
99 });
100}

The documentation for this class was generated from the following files: