Skip to content

Commit

Permalink
Game objects testing functions replaced with game object casting (e.g…
Browse files Browse the repository at this point in the history
…. 'bool is_car' -> 'CCar* cast_Car')
  • Loading branch information
qweasdd136963 committed Oct 4, 2018
1 parent 985af75 commit 529684f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 409 deletions.
2 changes: 1 addition & 1 deletion src/Common/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/* Scripts */
#define MORE_INVENTORY_SLOTS // Adds 5 more slots CUSTOM_SLOT_1..5
#define GAME_OBJECT_EXTENDED_EXPORTS // see: script_game_object*.cpp/h
#define GAME_OBJECT_TESTING_EXPORTS // see: script_game_object4.cpp functions for object testing (ie. is_stalker(), is_heli())
#define GAME_OBJECT_CASTING_EXPORTS // see: script_game_object4.cpp functions for object casting (ie. cast_Car(), cast_Heli())
#define NAMESPACE_LEVEL_EXPORTS // see: level_script.cpp

/* Visual */
Expand Down
43 changes: 0 additions & 43 deletions src/xrGame/script_game_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,49 +787,6 @@ class CScriptGameObject
void unlock_door_for_npc();
bool is_door_blocked_by_npc() const;
bool is_weapon_going_to_be_strapped(CScriptGameObject const* object) const;

//AVO: functions for object testing
#ifdef GAME_OBJECT_TESTING_EXPORTS
//bool isGameObject() const;
//bool isCar() const;
//bool isHeli() const;
//bool isHolderCustom() const;
bool isEntityAlive() const;
bool isInventoryItem() const;
bool isInventoryOwner() const;
bool isActor() const;
bool isCustomMonster() const;
bool isWeapon() const;
//bool isMedkit() const;
//bool isEatableItem() const;
//bool isAntirad() const;
bool isCustomOutfit() const;
bool isScope() const;
bool isSilencer() const;
bool isGrenadeLauncher() const;
bool isWeaponMagazined() const;
bool isSpaceRestrictor() const;
bool isStalker() const;
bool isAnomaly() const;
bool isMonster() const;
//bool isExplosive() const;
//bool isScriptZone() const;
//bool isProjector() const;
bool isTrader() const;
bool isHudItem() const;
//bool isFoodItem() const;
bool isArtefact() const;
bool isAmmo() const;
//bool isMissile() const;
//bool isPhysicsShellHolder() const;
//bool isGrenade() const;
//bool isBottleItem() const;
//bool isTorch() const;
bool isWeaponGL() const;
bool isInventoryBox() const;

#endif // GAME_OBJECT_TESTING_EXPORTS
//-AVO

#ifdef GAME_OBJECT_EXTENDED_EXPORTS
void SetHealthEx(float hp); //AVO
Expand Down
325 changes: 1 addition & 324 deletions src/xrGame/script_game_object4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void CScriptGameObject::stop_particles(LPCSTR pname, LPCSTR bone)
LuaMessageType::Error, "Cant stop particles, bone [%s] is not visible now", bone);
}

#ifdef GAME_OBJECT_TESTING_EXPORTS
#ifdef GAME_OBJECT_EXTENDED_EXPORTS
//AVO: directly set entity health instead of going through normal health property which operates on delta
void CScriptGameObject::SetHealthEx(float hp)
{
Expand All @@ -378,327 +378,4 @@ void CScriptGameObject::SetHealthEx(float hp)
obj->SetfHealth(hp);
}
//-AVO

// AVO: functions for testing object class
// Credits: KD
//#include "Car.h"
//#include "helicopter.h"
#include "Actor.h"
#include "CustomOutfit.h"
//#include "CustomZone.h"
#include "ai/Monsters/BaseMonster/base_monster.h"
//#include "medkit.h"
//#include "antirad.h"
#include "Scope.h"
#include "Silencer.h"
//#include "Torch.h"
#include "GrenadeLauncher.h"
#include "searchlight.h"
//#include "WeaponAmmo.h"
//#include "Grenade.h"
//#include "BottleItem.h"
#include "WeaponMagazinedWGrenade.h"

// Xottab_DUTY: commented this macro, because of substituting it
/*
#define TEST_OBJECT_CLASS(A, B)\
bool A() const\
{\
auto l_tpEntity = smart_cast<B*>(&object());\
if (!l_tpEntity)\
return false;\
return true;\
}\
*/

/*
bool CScriptGameObject::isGameObject() const
{
auto l_tpEntity = smart_cast<CGameObject*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isCar() const
{
auto l_tpEntity = smart_cast<CCar*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isHeli() const
{
auto l_tpEntity = smart_cast<CHelicopter*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isHolderCustom() const
{
auto l_tpEntity = smart_cast<CHolderCustom*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

bool CScriptGameObject::isEntityAlive() const
{
auto l_tpEntity = smart_cast<CEntityAlive*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isInventoryItem() const
{
auto l_tpEntity = smart_cast<CInventoryItem*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isInventoryOwner() const
{
auto l_tpEntity = smart_cast<CInventoryOwner*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isActor() const
{
auto l_tpEntity = smart_cast<CActor*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isCustomMonster() const
{
auto l_tpEntity = smart_cast<CCustomMonster*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isWeapon() const
{
auto l_tpEntity = smart_cast<CWeapon*>(&object());
if (!l_tpEntity) return false;
return true;
}
/*
bool CScriptGameObject::isMedkit() const
{
auto l_tpEntity = smart_cast<CMedkit*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isEatableItem() const
{
auto l_tpEntity = smart_cast<CEatableItem*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isAntirad() const
{
auto l_tpEntity = smart_cast<CAntirad*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

bool CScriptGameObject::isCustomOutfit() const
{
auto l_tpEntity = smart_cast<CCustomOutfit*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isScope() const
{
auto l_tpEntity = smart_cast<CScope*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isSilencer() const
{
auto l_tpEntity = smart_cast<CSilencer*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isGrenadeLauncher() const
{
auto l_tpEntity = smart_cast<CGrenadeLauncher*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isWeaponMagazined() const
{
auto l_tpEntity = smart_cast<CWeaponMagazined*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isSpaceRestrictor() const
{
auto l_tpEntity = smart_cast<CSpaceRestrictor*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isStalker() const
{
auto l_tpEntity = smart_cast<CAI_Stalker*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isAnomaly() const
{
auto l_tpEntity = smart_cast<CCustomZone*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isMonster() const
{
auto l_tpEntity = smart_cast<CBaseMonster*>(&object());
if (!l_tpEntity) return false;
return true;
}

/*
bool CScriptGameObject::isExplosive() const
{
auto l_tpEntity = smart_cast<CExplosive*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isScriptZone() const
{
auto l_tpEntity = smart_cast<CScriptZone*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isProjector() const
{
auto l_tpEntity = smart_cast<CProjector*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

bool CScriptGameObject::isTrader() const
{
auto l_tpEntity = smart_cast<CAI_Trader*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isHudItem() const
{
auto l_tpEntity = smart_cast<CHudItem*>(&object());
if (!l_tpEntity) return false;
return true;
}

/*
bool CScriptGameObject::isFoodItem() const
{
auto l_tpEntity = smart_cast<CFoodItem*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

bool CScriptGameObject::isArtefact() const
{
auto l_tpEntity = smart_cast<CArtefact*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isAmmo() const
{
auto l_tpEntity = smart_cast<CWeaponAmmo*>(&object());
if (!l_tpEntity) return false;
return true;
}

/*
bool CScriptGameObject::isMissile() const
{
auto l_tpEntity = smart_cast<CMissile*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isPhysicsShellHolder() const
{
auto l_tpEntity = smart_cast<CPhysicsShellHolder*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isGrenade() const
{
auto l_tpEntity = smart_cast<CGrenade*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isBottleItem() const
{
auto l_tpEntity = smart_cast<CBottleItem*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

/*
bool CScriptGameObject::isTorch() const
{
auto l_tpEntity = smart_cast<CTorch*>(&object());
if (!l_tpEntity) return false;
return true;
}
*/

bool CScriptGameObject::isWeaponGL() const
{
auto l_tpEntity = smart_cast<CWeaponMagazinedWGrenade*>(&object());
if (!l_tpEntity) return false;
return true;
}

bool CScriptGameObject::isInventoryBox() const
{
auto l_tpEntity = smart_cast<CInventoryBox*>(&object());
if (!l_tpEntity) return false;
return true;
}
#endif
//-AVO
Loading

0 comments on commit 529684f

Please sign in to comment.