diff --git a/src/xrEngine/FDemoRecord.cpp b/src/xrEngine/FDemoRecord.cpp index ba4d224f4e2..a9c58bb734b 100644 --- a/src/xrEngine/FDemoRecord.cpp +++ b/src/xrEngine/FDemoRecord.cpp @@ -423,7 +423,7 @@ void CDemoRecord::IR_OnKeyboardPress(int dik) if (dik == DIK_ESCAPE) fLifeTime = -1; -#ifndef MASTER_GOLD +#ifdef DEBUG // ndef MASTER_GOLD // Xottab_DUTY: Teleport to demo cam in Debug configuration if (dik == DIK_RETURN) { if (g_pGameLevel->CurrentEntity()) @@ -432,7 +432,7 @@ void CDemoRecord::IR_OnKeyboardPress(int dik) fLifeTime = -1; } } -#endif // #ifndef MASTER_GOLD +#endif if (dik == DIK_PAUSE) Device.Pause(!Device.Paused(), TRUE, TRUE, "demo_record"); diff --git a/src/xrGame/Car.cpp b/src/xrGame/Car.cpp index 252d7b58aa4..5314c145db4 100644 --- a/src/xrGame/Car.cpp +++ b/src/xrGame/Car.cpp @@ -844,7 +844,7 @@ void CCar::CreateSkeleton(CSE_Abstract* po) m_pPhysicsShell->SetAirResistance(0.f, 0.f); m_pPhysicsShell->SetPrefereExactIntegration(); */ - m_pPhysicsShell = P_build_Shell(this, true, &bone_map); + m_pPhysicsShell = P_build_Shell(this, false, &bone_map); //-Alundaio ApplySpawnIniToPhysicShell(&po->spawn_ini(), m_pPhysicsShell, false); diff --git a/src/xrGame/WeaponMagazined.cpp b/src/xrGame/WeaponMagazined.cpp index d32da62d227..42366d1c7f2 100644 --- a/src/xrGame/WeaponMagazined.cpp +++ b/src/xrGame/WeaponMagazined.cpp @@ -1338,34 +1338,30 @@ bool CWeaponMagazined::GetBriefInfo(II_BriefInfo& info) GetSuitableAmmoTotal(); // update m_BriefInfo_CalcFrame info.grenade = ""; - u32 at_size = m_ammoTypes.size(); + const u32 at_size = m_ammoTypes.size(); if (unlimited_ammo() || at_size == 0) { info.fmj_ammo._set("--"); info.ap_ammo._set("--"); + info.third_ammo._set("--"); //Alundaio } else { // GetSuitableAmmoTotal(); //mp = all type + //Alundaio: Added third ammo type and cleanup + info.fmj_ammo._set(""); + info.ap_ammo._set(""); + info.third_ammo._set(""); - xr_sprintf(int_str, "%d", GetAmmoCount(0)); // !!!!!!!!!!! == 0 temp - if (m_ammoType == 0) - info.fmj_ammo = int_str; - else - info.ap_ammo = int_str; + xr_sprintf(int_str, "%d", GetAmmoCount(m_ammoType)); - if (at_size == 2) - { - xr_sprintf(int_str, "%d", GetAmmoCount(1)); - if (m_ammoType == 0) - info.ap_ammo = int_str; - else - info.fmj_ammo = int_str; - } + if (m_ammoType == 0) + info.fmj_ammo._set(int_str); + else if (m_ammoType == 1) + info.ap_ammo._set(int_str); else - { - info.ap_ammo = ""; - } + info.third_ammo._set(int_str); + //-Alundaio } if (ae != 0 && m_magazine.size() != 0) diff --git a/src/xrGame/WeaponMagazinedWGrenade.cpp b/src/xrGame/WeaponMagazinedWGrenade.cpp index 2d2028e6ef2..d1deb596fca 100644 --- a/src/xrGame/WeaponMagazinedWGrenade.cpp +++ b/src/xrGame/WeaponMagazinedWGrenade.cpp @@ -926,26 +926,25 @@ bool CWeaponMagazinedWGrenade::GetBriefInfo(II_BriefInfo& info) { info.fmj_ammo._set("--"); info.ap_ammo._set("--"); + info.third_ammo._set("--"); //Alundaio } else { - u8 ammo_type = m_bGrenadeMode ? m_ammoType2 : m_ammoType; - xr_sprintf(int_str, "%d", m_bGrenadeMode ? GetAmmoCount2(0) : GetAmmoCount(0)); - if (ammo_type == 0) + //Alundaio: Added third ammo type and cleanup + info.fmj_ammo._set(""); + info.ap_ammo._set(""); + info.third_ammo._set(""); + + const u8 ammo_type = m_bGrenadeMode ? m_ammoType2 : m_ammoType; + xr_sprintf(int_str, "%d", m_bGrenadeMode ? GetAmmoCount2(ammo_type) : GetAmmoCount(ammo_type)); + + if (m_ammoType == 0) info.fmj_ammo._set(int_str); - else + else if (m_ammoType == 1) info.ap_ammo._set(int_str); - - if (at_size == 2) - { - xr_sprintf(int_str, "%d", m_bGrenadeMode ? GetAmmoCount2(1) : GetAmmoCount(1)); - if (ammo_type == 0) - info.ap_ammo._set(int_str); - else - info.fmj_ammo._set(int_str); - } else - info.ap_ammo._set(""); + info.third_ammo._set(int_str); + //-Alundaio } if (ae != 0 && m_magazine.size() != 0) diff --git a/src/xrGame/inventory_item.h b/src/xrGame/inventory_item.h index 86a756bd39d..dcbf7d464a6 100644 --- a/src/xrGame/inventory_item.h +++ b/src/xrGame/inventory_item.h @@ -279,6 +279,7 @@ class CInventoryItem : public CAttachableItem, bool has_upgrade_group(const shared_str& upgrade_group_id); void add_upgrade(const shared_str& upgrade_id, bool loading); bool get_upgrades_str(string2048& res) const; + Upgrades_type get_upgrades() { return m_upgrades; } //Alundaio bool equal_upgrades(Upgrades_type const& other_upgrades) const; diff --git a/src/xrGame/script_game_object.cpp b/src/xrGame/script_game_object.cpp index 04850dc4727..bd553e5e547 100644 --- a/src/xrGame/script_game_object.cpp +++ b/src/xrGame/script_game_object.cpp @@ -563,7 +563,7 @@ bool CScriptGameObject::invulnerable() const return (false); } - return (monster->invulnerable()); + return monster->invulnerable(); } void CScriptGameObject::invulnerable(bool invulnerable) @@ -578,14 +578,15 @@ void CScriptGameObject::invulnerable(bool invulnerable) monster->invulnerable(invulnerable); } -LPCSTR CScriptGameObject::get_smart_cover_description() const + +pcstr CScriptGameObject::get_smart_cover_description() const { smart_cover::object* smart_cover_object = smart_cast(&object()); if (!smart_cover_object) { ai().script_engine().script_log( LuaMessageType::Error, "smart_cover::object : cannot access class member get_smart_cover_description!"); - return (0); + return nullptr; } return smart_cover_object->cover().description()->table_id().c_str(); } @@ -593,7 +594,7 @@ LPCSTR CScriptGameObject::get_smart_cover_description() const void CScriptGameObject::set_visual_name(LPCSTR visual) { object().cNameVisual_set(visual); } LPCSTR CScriptGameObject::get_visual_name() const { return object().cNameVisual().c_str(); } -bool CScriptGameObject::IsActorOutdoors() const +bool CScriptGameObject::IsActorIndoors() const { // Check to make sure all the params are available (we're in game and such). if (!g_pGameLevel) @@ -606,4 +607,4 @@ bool CScriptGameObject::IsActorOutdoors() const // Now do the real check! This is a copy out of another section of code that is also hard coded. // I don't know what the proper limit for this is supposed to be, but this seems good enough. return e->renderable_ROS()->get_luminocity_hemi() > 0.05f; -} \ No newline at end of file +} diff --git a/src/xrGame/script_game_object.h b/src/xrGame/script_game_object.h index ed3298bf9d7..128d82ca28c 100644 --- a/src/xrGame/script_game_object.h +++ b/src/xrGame/script_game_object.h @@ -402,12 +402,29 @@ class CScriptGameObject int Weapon_Silencer_Status(); //Alundaio + //Weapon void Weapon_AddonAttach(CScriptGameObject* item); void Weapon_AddonDetach(pcstr item_section); + //Weapon & Outfit + bool HasUpgrade(pcstr upgrade) const; + void AddUpgrade(pcstr upgrade); + void IterateInstalledUpgrades(luabind::functor functor); + + //Car + CScriptGameObject* GetAttachedVehicle(); void AttachVehicle(CScriptGameObject* veh); void DetachVehicle(); - void ForceSetPosition(Fvector3 pos); + + //Any class that has PPhysicsShell + void ForceSetPosition(Fvector3 pos, bool bActivate); + + //Any class that is derived from CHudItem + u32 PlayHudMotion(pcstr M, bool mixIn, u32 state); + void SwitchState(u32 state); + u32 GetState(); + void ActivateHudItem(); + void DeactivateHudItem(); //-Alundaio LPCSTR ProfileName(); @@ -705,7 +722,7 @@ class CScriptGameObject bool invulnerable() const; void invulnerable(bool invulnerable); - LPCSTR get_smart_cover_description() const; + pcstr get_smart_cover_description() const; void set_visual_name(LPCSTR visual); LPCSTR get_visual_name() const; @@ -842,7 +859,7 @@ class CScriptGameObject bool isTorch() const; bool isWeaponGL() const; bool isInventoryBox() const; - bool IsActorOutdoors() const; + bool IsActorIndoors() const; void SetHealthEx(float hp); //-AVO diff --git a/src/xrGame/script_game_object3.cpp b/src/xrGame/script_game_object3.cpp index c89f42ca02d..e1eae3b0c28 100644 --- a/src/xrGame/script_game_object3.cpp +++ b/src/xrGame/script_game_object3.cpp @@ -42,6 +42,8 @@ #include "Artefact.h" #include "holder_custom.h" #include "Actor.h" +#include "CharacterPhysicsSupport.h" +#include "player_hud.h" //-Alundaio namespace MemorySpace @@ -1224,111 +1226,233 @@ bool CScriptGameObject::is_weapon_going_to_be_strapped(CScriptGameObject const* //Alundaio: Taken from Radium float CScriptGameObject::GetArtefactHealthRestoreSpeed() { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - return artefact->GetHealthPower(); + return artefact->GetHealthPower(); } float CScriptGameObject::GetArtefactRadiationRestoreSpeed() { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - return artefact->GetRadiationPower(); + return artefact->GetRadiationPower(); } float CScriptGameObject::GetArtefactSatietyRestoreSpeed() { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - return artefact->GetSatietyPower(); + return artefact->GetSatietyPower(); } float CScriptGameObject::GetArtefactPowerRestoreSpeed() { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - return artefact->GetPowerPower(); + return artefact->GetPowerPower(); } float CScriptGameObject::GetArtefactBleedingRestoreSpeed() { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - return artefact->GetBleedingPower(); + return artefact->GetBleedingPower(); } void CScriptGameObject::SetArtefactHealthRestoreSpeed(float value) { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - artefact->SetHealthPower(value); + artefact->SetHealthPower(value); } void CScriptGameObject::SetArtefactRadiationRestoreSpeed(float value) { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - artefact->SetRadiationPower(value); + artefact->SetRadiationPower(value); } void CScriptGameObject::SetArtefactSatietyRestoreSpeed(float value) { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - artefact->SetSatietyPower(value); + artefact->SetSatietyPower(value); } void CScriptGameObject::SetArtefactPowerRestoreSpeed(float value) { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - artefact->SetPowerPower(value); + artefact->SetPowerPower(value); } void CScriptGameObject::SetArtefactBleedingRestoreSpeed(float value) { - CArtefact* artefact = smart_cast(&object()); - THROW(artefact); + CArtefact* artefact = smart_cast(&object()); + THROW(artefact); - artefact->SetBleedingPower(value); + artefact->SetBleedingPower(value); } //Alundaio void CScriptGameObject::AttachVehicle(CScriptGameObject* veh) { - CActor *actor = smart_cast(&object()); - if (actor) - { - CHolderCustom* vehicle = smart_cast(veh); - if (vehicle) - actor->attach_Vehicle(vehicle); - } + CActor* actor = smart_cast(&object()); + if (actor) + { + CHolderCustom* vehicle = veh->object().cast_holder_custom();//smart_cast(veh->object()); + if (vehicle) + actor->attach_Vehicle(vehicle); + } } void CScriptGameObject::DetachVehicle() { - CActor *actor = smart_cast(&object()); - if (actor) - actor->detach_Vehicle(); + CActor* actor = smart_cast(&object()); + if (actor) + actor->detach_Vehicle(); +} + +CScriptGameObject* CScriptGameObject::GetAttachedVehicle() +{ + CActor* actor = smart_cast(&object()); + if (!actor) + return nullptr; + + CHolderCustom* H = actor->Holder(); + if (!H) + return nullptr; + + CGameObject* GO = smart_cast(H); + if (!GO) + return nullptr; + + return GO->lua_game_object(); +} + +u32 CScriptGameObject::PlayHudMotion(pcstr M, bool mixIn, u32 state) +{ + CWeapon* Weapon = object().cast_weapon(); + if (Weapon) + { + if (!Weapon->isHUDAnimationExist(M)) + return 0; + + return Weapon->PlayHUDMotion(M, mixIn, Weapon, state); + } + + CHudItem* itm = object().cast_inventory_item()->cast_hud_item(); + if (!itm) + return 0; + + if (!itm->isHUDAnimationExist(M)) + return 0; + + return itm->PlayHUDMotion(M, mixIn, itm, state); +} + +void CScriptGameObject::SwitchState(u32 state) +{ + CWeapon* Weapon = object().cast_weapon(); + if (Weapon) + { + Weapon->SwitchState(state); + return; + } + + CInventoryItem* IItem = object().cast_inventory_item(); + if (IItem) + { + CHudItem* itm = IItem->cast_hud_item(); + if (itm) + itm->SwitchState(state); + } +} + +u32 CScriptGameObject::GetState() +{ + CWeapon* Weapon = object().cast_weapon(); + if (Weapon) + { + return Weapon->GetState(); + } + + CInventoryItem* IItem = object().cast_inventory_item(); + if (IItem) + { + CHudItem* itm = IItem->cast_hud_item(); + if (itm) + return itm->GetState(); + } + + return 65535; +} + +void CScriptGameObject::ActivateHudItem() +{ + CWeapon* Weapon = object().cast_weapon(); + if (Weapon) + { + Weapon->ActivateItem(); + return; + } + + CInventoryItem* IItem = object().cast_inventory_item(); + if (!IItem) + return; + + IItem->ActivateItem(); +} + +void CScriptGameObject::DeactivateHudItem() +{ + CWeapon* Weapon = object().cast_weapon(); + if (Weapon) + { + Weapon->DeactivateItem(); + return; + } + + CInventoryItem* IItem = object().cast_inventory_item(); + if (!IItem) + return; + + IItem->DeactivateItem(); } -void CScriptGameObject::ForceSetPosition(Fvector3 pos) +void CScriptGameObject::ForceSetPosition(Fvector pos, bool bActivate = false) { - CPhysicsShellHolder* P = smart_cast(this); - if (!P) - return; + CPhysicsShellHolder* sh = object().cast_physics_shell_holder(); + if (!sh) + return; + + CPhysicsShell* shell = sh->PPhysicsShell(); + if (shell) + { + if (bActivate) + sh->activate_physic_shell(); + + Fmatrix M = object().XFORM(); + M.c = pos; + M.set(M); - Fmatrix M = P->XFORM(); - M.translate(pos); - P->ForceTransform(M); + shell->SetGlTransformDynamic(M); + if (sh->character_physics_support()) + sh->character_physics_support()->ForceTransform(M); + } + else + ai().script_engine().script_log(LuaMessageType::Error, "force_set_position: object %s has no physics shell!", + *object().cName()); } + //-Alundaio diff --git a/src/xrGame/script_game_object_inventory_owner.cpp b/src/xrGame/script_game_object_inventory_owner.cpp index a80a0bca2a2..d3f5fcd51aa 100644 --- a/src/xrGame/script_game_object_inventory_owner.cpp +++ b/src/xrGame/script_game_object_inventory_owner.cpp @@ -47,6 +47,10 @@ #include "doors_door.h" #include "Torch.h" #include "PhysicObject.h" +//Alundaio +#include "inventory_upgrade_manager.h" +#include "inventory_item.h" +//-Alundaio bool CScriptGameObject::GiveInfoPortion(LPCSTR info_id) { @@ -1705,7 +1709,13 @@ void CScriptGameObject::Weapon_AddonAttach(CScriptGameObject* item) return; } - auto pItm = smart_cast(item); + CInventoryItem* pItm = item->object().cast_inventory_item(); + if (!pItm) + { + ai().script_engine().script_log(LuaMessageType::Error, "CWeaponMagazined : trying to attach non-CInventoryItem!"); + return; + } + if (weapon->CanAttach(pItm)) weapon->Attach(pItm, true); } @@ -1722,4 +1732,45 @@ void CScriptGameObject::Weapon_AddonDetach(pcstr item_section) if (weapon->CanDetach(item_section)) weapon->Detach(item_section, true); } + +void CScriptGameObject::AddUpgrade(pcstr upgrade) +{ + CInventoryItem* item = smart_cast(&object()); + if (!item) + { + ai().script_engine().script_log(LuaMessageType::Error, "CInventoryItem : cannot access class member AddUpgrade!"); + return; + } + + if (!pSettings->section_exist(upgrade)) + return; + + item->install_upgrade(upgrade); + //ai().alife().inventory_upgrade_manager().upgrade_install(*item, (upgrade), false); +} + +bool CScriptGameObject::HasUpgrade(pcstr upgrade) const +{ + CInventoryItem* item = smart_cast(&object()); + if (!item) + { + ai().script_engine().script_log(LuaMessageType::Error, "CInventoryItem : cannot access class member HasUpgrade!"); + return false; + } + + if (!pSettings->section_exist(upgrade)) + return false; + + return item->verify_upgrade(upgrade); +} + +void CScriptGameObject::IterateInstalledUpgrades(luabind::functor functor) +{ + CInventoryItem* Item = smart_cast(&object()); + if (!Item) + return; + + for (auto upgrade : Item->get_upgrades()) + functor(upgrade.c_str(), object().lua_game_object()); +} //Alundaio: END diff --git a/src/xrGame/script_game_object_script3.cpp b/src/xrGame/script_game_object_script3.cpp index 90ca1df5234..648db056d7b 100644 --- a/src/xrGame/script_game_object_script3.cpp +++ b/src/xrGame/script_game_object_script3.cpp @@ -355,15 +355,32 @@ class_& script_register_game_object2(class_GetInvGridRect().rb; if (iWH.x > 1 || iWH.y > 1) return false; diff --git a/src/xrGame/ui/UIHudStatesWnd.cpp b/src/xrGame/ui/UIHudStatesWnd.cpp index e9f382694e2..be5a8fe0413 100644 --- a/src/xrGame/ui/UIHudStatesWnd.cpp +++ b/src/xrGame/ui/UIHudStatesWnd.cpp @@ -109,6 +109,7 @@ void CUIHudStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path) m_ui_weapon_cur_ammo = UIHelper::CreateTextWnd(xml, "static_cur_ammo", this); m_ui_weapon_fmj_ammo = UIHelper::CreateTextWnd(xml, "static_fmj_ammo", this); m_ui_weapon_ap_ammo = UIHelper::CreateTextWnd(xml, "static_ap_ammo", this); + m_ui_weapon_third_ammo = UIHelper::CreateTextWnd(xml, "static_third_ammo", this); //Alundaio: Option to display a third ammo type m_fire_mode = UIHelper::CreateTextWnd(xml, "static_fire_mode", this); m_ui_grenade = UIHelper::CreateTextWnd(xml, "static_grenade", this); @@ -308,12 +309,17 @@ void CUIHudStatesWnd::UpdateActiveItemInfo(CActor* actor) m_ui_weapon_cur_ammo->Show(true); m_ui_weapon_fmj_ammo->Show(true); m_ui_weapon_ap_ammo->Show(true); + m_fire_mode->Show(true); m_ui_grenade->Show(true); m_ui_weapon_cur_ammo->SetText(m_item_info.cur_ammo.c_str()); m_ui_weapon_fmj_ammo->SetText(m_item_info.fmj_ammo.c_str()); m_ui_weapon_ap_ammo->SetText(m_item_info.ap_ammo.c_str()); + //Alundaio: + if (m_ui_weapon_third_ammo) + m_ui_weapon_third_ammo->SetText(m_item_info.third_ammo.c_str()); + //-Alundaio m_ui_grenade->SetText(m_item_info.grenade.c_str()); diff --git a/src/xrGame/ui/UIHudStatesWnd.h b/src/xrGame/ui/UIHudStatesWnd.h index aeb8246e109..d4ab4fd7d0a 100644 --- a/src/xrGame/ui/UIHudStatesWnd.h +++ b/src/xrGame/ui/UIHudStatesWnd.h @@ -31,6 +31,7 @@ class CUIHudStatesWnd : public CUIWindow CUITextWnd* m_ui_weapon_cur_ammo; CUITextWnd* m_ui_weapon_fmj_ammo; CUITextWnd* m_ui_weapon_ap_ammo; + CUITextWnd* m_ui_weapon_third_ammo; //Alundaio CUITextWnd* m_fire_mode; CUITextWnd* m_ui_grenade; II_BriefInfo m_item_info; diff --git a/src/xrServerEntities/inventory_space.h b/src/xrServerEntities/inventory_space.h index cac0b5b2edd..90c1bdbc26a 100644 --- a/src/xrServerEntities/inventory_space.h +++ b/src/xrServerEntities/inventory_space.h @@ -18,7 +18,14 @@ enum TORCH_SLOT, // torch ARTEFACT_SLOT, // artefact HELMET_SLOT, - LAST_SLOT = HELMET_SLOT + //Alundaio: More slots for custom uses + CUSTOM_SLOT_1, + CUSTOM_SLOT_2, + CUSTOM_SLOT_3, + CUSTOM_SLOT_4, + CUSTOM_SLOT_5, + //-Alundaio + LAST_SLOT = CUSTOM_SLOT_5 }; #define RUCK_HEIGHT 280 @@ -65,6 +72,7 @@ struct II_BriefInfo shared_str cur_ammo; shared_str fmj_ammo; shared_str ap_ammo; + shared_str third_ammo; //Alundaio shared_str fire_mode; shared_str grenade; @@ -77,6 +85,7 @@ struct II_BriefInfo cur_ammo = ""; fmj_ammo = ""; ap_ammo = ""; + third_ammo = ""; //Alundaio fire_mode = ""; grenade = ""; }