Skip to content

Commit

Permalink
+ added weapon_addon_attach and weapon_addon_detach exports (not work…
Browse files Browse the repository at this point in the history
…ing...)

* more detailed information on VERIFY in CPlanner::current_action_id() in action_planner_inline.h
  • Loading branch information
revolucas authored and Xottab-DUTY committed Aug 19, 2017
1 parent ae9b838 commit 8f694c7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/xrGame/action_planner_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ IC typename CPlanner::CConditionEvaluator& CPlanner::evaluator(const _condition_
TEMPLATE_SPECIALIZATION
IC typename CPlanner::_action_id_type CPlanner::current_action_id() const
{
VERIFY(initialized());
VERIFY2(initialized(), make_string("ERROR: action by id [%d] not initialized!", m_current_action_id)); //Alundaio: More detailed information needed
return (m_current_action_id);
}

TEMPLATE_SPECIALIZATION
IC typename CPlanner::COperator& CPlanner::current_action() { return (action(current_action_id())); }
TEMPLATE_SPECIALIZATION
IC bool CPlanner::initialized() const { return (m_initialized); }
IC bool CPlanner::initialized() const { return m_initialized; }
TEMPLATE_SPECIALIZATION
IC void CPlanner::add_condition(_world_operator* action, _condition_type condition_id, _value_type condition_value)
{
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/script_game_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ class CScriptGameObject
int Weapon_Scope_Status();
int Weapon_Silencer_Status();

void Weapon_AddonAttach(CScriptGameObject& item); //Alundaio
void Weapon_AddonDetach(pcstr item_section); //Alundaio

LPCSTR ProfileName();
LPCSTR CharacterName();
LPCSTR CharacterIcon();
Expand Down
55 changes: 42 additions & 13 deletions src/xrGame/script_game_object_inventory_owner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
#include "script_game_object.h"
#include "script_game_object_impl.h"
#include "InventoryOwner.h"
#include "Pda.h"
#include "PDA.h"
#include "xrMessages.h"
#include "character_info.h"
#include "gametask.h"
#include "actor.h"
#include "GameTask.h"
#include "Actor.h"
#include "Level.h"
#include "date_time.h"
#include "uigamesp.h"
#include "UIGameSP.h"
#include "restricted_object.h"
#include "xrScriptEngine/script_engine.hpp"
#include "attachable_item.h"
#include "script_entity.h"
#include "string_table.h"
#include "alife_registry_wrappers.h"
#include "relation_registry.h"
#include "custommonster.h"
#include "actorcondition.h"
#include "CustomMonster.h"
#include "ActorCondition.h"
#include "xrAICore/Navigation/level_graph.h"
#include "huditem.h"
#include "HudItem.h"
#include "ui/UItalkWnd.h"
#include "inventory.h"
#include "infoportion.h"
#include "Inventory.h"
#include "InfoPortion.h"
#include "AI/Monsters/BaseMonster/base_monster.h"
#include "weaponmagazined.h"
#include "ai/stalker/ai_stalker.h"
#include "WeaponMagazined.h"
#include "Ai/Stalker/ai_stalker.h"
#include "agent_manager.h"
#include "agent_member_manager.h"
#include "stalker_animation_manager.h"
Expand All @@ -42,11 +42,11 @@
#include "ai/stalker/ai_stalker_impl.h"
#include "smart_cover_object.h"
#include "smart_cover.h"
#include "customdetector.h"
#include "CustomDetector.h"
#include "doors_manager.h"
#include "doors_door.h"
#include "Torch.h"
#include "physicobject.h"
#include "PhysicObject.h"

bool CScriptGameObject::GiveInfoPortion(LPCSTR info_id)
{
Expand Down Expand Up @@ -1693,3 +1693,32 @@ bool CScriptGameObject::is_door_blocked_by_npc() const
VERIFY2(m_door, make_string("object %s hasn't been registered as a door already", m_game_object->cName().c_str()));
return ai().doors().is_door_blocked(m_door);
}


//Alundaio: Methods for exporting the ability to detach/attach addons for magazined weapons
void CScriptGameObject::Weapon_AddonAttach(CScriptGameObject& item)
{
auto weapon = smart_cast<CWeaponMagazined*>(&object());
if (!weapon)
{
ai().script_engine().script_log(LuaMessageType::Error, "CWeaponMagazined : cannot access class member Weapon_AddonAttach!");
return;
}

if (weapon->CanAttach((PIItem)&item))
weapon->Attach((PIItem)&item, true);
}

void CScriptGameObject::Weapon_AddonDetach(pcstr item_section)
{
auto weapon = smart_cast<CWeaponMagazined*>(&object());
if (!weapon)
{
ai().script_engine().script_log(LuaMessageType::Error, "CWeaponMagazined : cannot access class member Weapon_AddonDetach!");
return;
}

if (weapon->CanDetach(item_section))
weapon->Detach(item_section, true);
}
//Alundaio: END
5 changes: 5 additions & 0 deletions src/xrGame/script_game_object_script3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ class_<CScriptGameObject>& script_register_game_object2(class_<CScriptGameObject
.def("weapon_scope_status", &CScriptGameObject::Weapon_Scope_Status)
.def("weapon_silencer_status", &CScriptGameObject::Weapon_Silencer_Status)

//Alundaio: Extended exports
.def("weapon_addon_attach", &CScriptGameObject::Weapon_AddonAttach)
.def("weapon_addon_detach", &CScriptGameObject::Weapon_AddonDetach)
//Alundaio: END

.def("allow_sprint", &CScriptGameObject::AllowSprint)

.def("set_start_dialog", &CScriptGameObject::SetStartDialog)
Expand Down

0 comments on commit 8f694c7

Please sign in to comment.