Add get_map_objectives native for CS (bug 5820, r=Nextra)

Former-commit-id: 47487a4aa7b32a5767c2a23df5ddc7e9643c3428
This commit is contained in:
Vincent Herbet 2013-08-08 19:11:12 +02:00
parent 225494b559
commit 0afe87be0a
2 changed files with 48 additions and 0 deletions

View File

@ -370,6 +370,36 @@ static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
return 8;
}
enum MapObjective
{
MapObjective_Bomb = (1<<0),
MapObjective_Hostage = (1<<1),
MapObjective_Vip = (1<<2),
MapObjective_Escape = (1<<3),
};
static cell AMX_NATIVE_CALL get_map_objectives(AMX *amx, cell *params)
{
int flags = 0;
if (!FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", "func_bomb_target")) ||
!FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", "info_bomb_target")))
flags |= MapObjective_Bomb;
if (!FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", "func_hostage_rescue")) ||
!FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", "info_hostage_rescue")) ||
!FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", "hostage_entity"))) // there are maps with only this and using team spawn as rescue zone.
flags |= MapObjective_Hostage;
if (!FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", "func_vip_safetyzone")))
flags |= MapObjective_Vip;
if (!FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", "func_escapezone")))
flags |= MapObjective_Escape;
return flags;
}
AMX_NATIVE_INFO stats_Natives[] = {
{ "get_stats", get_stats},
{ "get_stats2", get_stats2},
@ -395,6 +425,8 @@ AMX_NATIVE_INFO stats_Natives[] = {
{ "xmod_get_maxweapons", get_maxweapons },
{ "xmod_get_stats_size", get_stats_size },
{ "get_map_objectives", get_map_objectives },
//***************************************
//{ "get_weaponname", get_wpnname },

View File

@ -66,3 +66,19 @@ native xmod_get_maxweapons();
native xmod_get_stats_size();
/************* Shared Natives End ********************************/
enum MapObjective
{
MapObjective_Bomb = (1<<0),
MapObjective_Hostage = (1<<1),
MapObjective_Vip = (1<<2),
MapObjective_Escape = (1<<3),
};
/**
* Gets current map objectives.
*
* @return Returns a bits sum if objectives are found, otherwise 0.
* See MapObjective_* constants.
*/
native MapObjective:get_map_objectives();