4343#include " damage_manager.h" // Alundaio: For set_visual
4444#include " ai/phantom/phantom.h"
4545
46+ #include " UIGameCustom.h"
47+ #include " ui/UIActorMenu.h"
48+ #include " InventoryBox.h"
49+
4650class CScriptBinderObject ;
4751
4852// ////////////////////////////////////////////////////////////////////////
@@ -360,6 +364,14 @@ void CScriptGameObject::SetAmmoType(u8 type)
360364 weapon->SetAmmoType (type);
361365}
362366
367+ u8 CScriptGameObject::GetAmmoType ()
368+ {
369+ CWeapon* weapon = smart_cast<CWeapon*>(&object ());
370+ if (!weapon) return 255 ;
371+
372+ return weapon->GetAmmoType ();
373+ }
374+
363375void CScriptGameObject::SetMainWeaponType (u32 type)
364376{
365377 CWeapon* weapon = smart_cast<CWeapon*>(&object ());
@@ -379,15 +391,15 @@ void CScriptGameObject::SetWeaponType(u32 type)
379391u32 CScriptGameObject::GetMainWeaponType ()
380392{
381393 CWeapon* weapon = smart_cast<CWeapon*>(&object ());
382- if (!weapon) return 0 ;
394+ if (!weapon) return 255 ;
383395
384396 return weapon->ef_main_weapon_type ();
385397}
386398
387399u32 CScriptGameObject::GetWeaponType ()
388400{
389401 CWeapon* weapon = smart_cast<CWeapon*>(&object ());
390- if (!weapon) return 0 ;
402+ if (!weapon) return 255 ;
391403
392404 return weapon->ef_weapon_type ();
393405}
@@ -403,7 +415,7 @@ bool CScriptGameObject::HasAmmoType(u8 type)
403415u8 CScriptGameObject::GetWeaponSubstate ()
404416{
405417 CWeapon* weapon = smart_cast<CWeapon*>(&object ());
406- if (!weapon) return 0 ;
418+ if (!weapon) return 255 ;
407419
408420 return weapon->m_sub_state ;
409421}
@@ -673,9 +685,104 @@ void CScriptGameObject::PhantomSetEnemy(CScriptGameObject* enemy)
673685 if (!phant)
674686 return ;
675687
676- IGameObject* obj = smart_cast<IGameObject*>(enemy);
677- if (!obj)
688+ phant->SetEnemy (&enemy->object ());
689+ }
690+
691+ // Allows to force use an object if passed obj is the actor
692+ bool CScriptGameObject::Use (CScriptGameObject* obj)
693+ {
694+ bool ret = object ().use (&obj->object ());
695+
696+ CActor* actor = smart_cast<CActor*>(&obj->object ());
697+ if (!actor)
698+ return ret;
699+
700+ CInventoryOwner* pActorInv = smart_cast<CInventoryOwner*>(actor);
701+ if (!pActorInv)
702+ return ret;
703+
704+ CUIActorMenu& ActorMenu = CurrentGameUI ()->GetActorMenu ();
705+
706+ CInventoryBox* pBox = smart_cast<CInventoryBox*>(&object ());
707+ if (pBox)
708+ {
709+ ActorMenu.SetActor (pActorInv);
710+ ActorMenu.SetInvBox (pBox);
711+
712+ ActorMenu.SetMenuMode (mmDeadBodySearch);
713+ ActorMenu.ShowDialog (true );
714+
715+ return true ;
716+ }
717+ else
718+ {
719+ CInventoryOwner* pOtherOwner = smart_cast<CInventoryOwner*>(&object ());
720+ if (!pOtherOwner)
721+ return ret;
722+
723+ /*
724+ CEntityAlive* e = smart_cast<CEntityAlive*>(pOtherOwner);
725+ if (e && e->g_Alive())
726+ {
727+ actor->RunTalkDialog(pOtherOwner, false);
728+ return true;
729+ }
730+ */
731+
732+ ActorMenu.SetActor (pActorInv);
733+ ActorMenu.SetPartner (pOtherOwner);
734+
735+ ActorMenu.SetMenuMode (mmDeadBodySearch);
736+ ActorMenu.ShowDialog (true );
737+
738+ return true ;
739+ }
740+
741+ return false ;
742+ }
743+
744+ void CScriptGameObject::StartTrade (CScriptGameObject* obj)
745+ {
746+ CActor* actor = smart_cast<CActor*>(&obj->object ());
747+ if (!actor)
678748 return ;
679-
680- phant->SetEnemy (obj);
749+
750+ CInventoryOwner* pActorInv = smart_cast<CInventoryOwner*>(actor);
751+ if (!pActorInv)
752+ return ;
753+
754+ CInventoryOwner* pOtherOwner = smart_cast<CInventoryOwner*>(&object ());
755+ if (!pOtherOwner)
756+ return ;
757+
758+ CUIActorMenu& ActorMenu = CurrentGameUI ()->GetActorMenu ();
759+
760+ ActorMenu.SetActor (pActorInv);
761+ ActorMenu.SetPartner (pOtherOwner);
762+
763+ ActorMenu.SetMenuMode (mmTrade);
764+ ActorMenu.ShowDialog (true );
765+ }
766+
767+ void CScriptGameObject::StartUpgrade (CScriptGameObject* obj)
768+ {
769+ CActor* actor = smart_cast<CActor*>(&obj->object ());
770+ if (!actor)
771+ return ;
772+
773+ CInventoryOwner* pActorInv = smart_cast<CInventoryOwner*>(actor);
774+ if (!pActorInv)
775+ return ;
776+
777+ CInventoryOwner* pOtherOwner = smart_cast<CInventoryOwner*>(&object ());
778+ if (!pOtherOwner)
779+ return ;
780+
781+ CUIActorMenu& ActorMenu = CurrentGameUI ()->GetActorMenu ();
782+
783+ ActorMenu.SetActor (pActorInv);
784+ ActorMenu.SetPartner (pOtherOwner);
785+
786+ ActorMenu.SetMenuMode (mmUpgrade);
787+ ActorMenu.ShowDialog (true );
681788}
0 commit comments