Moved sven module of out trunk for now

This commit is contained in:
Scott Ehlert 2008-08-16 07:46:30 +00:00
parent 633a81f864
commit f942a857d0
14 changed files with 0 additions and 8683 deletions

View File

@ -1,254 +0,0 @@
/* ======== Simple Trie ========
* Copyright (C) 2006-2007 Kuchiki Rukia
* No warranties of any kind
*
* License: zlib/libpng
*
* Author(s): Radical Edward
* Notes: Generic simple trie
* ============================
*/
// Rukia: Digital trees, or tries, are a combination of vector and tree structures.
// They have garanteed O(1) worst case (literally O(m), constant for key length).
// However, unless optimized (such as in Judy Arrays), they have terrible memory performance.
// We will use a naive approach, due to time constraints.
// Judy Arrays would be a better approach, but would destroy the point of the assignment.
#ifndef __TRIE_CLASS__
#define __TRIE_CLASS__
// Rukia: HACK: Usage of assert to force metatemplates to work right.
#include <cassert>
#include <string.h>
// Rukia: Metaprogramming to aid in compile time constants and such.
template<size_t base, size_t N>
struct Exponential
{
enum { value = base * Exponential<base,N - 1>::value };
};
template <size_t base>
struct Exponential<base,0>
{
enum { value = 1 };
};
// Rukia: NOTE: This is extremely ugly for these reasons:
// 1. It relies on template metaprogramming
// 2. It is unoptimized
// 3. It was written in exactly 1 hour and 7 minutes.
// However, preliminary tests show it is faster than the STL hashmap, in current form.
// HACK: Optimize further into a patricia tree and partial specialization digital tree (Judy Array).
// Rukia: HACK: To optimize:
// 1. Add two bitvectors (vector<bool>) to each node.
// * 0 0 = nothing at all
// * 1 0 = compressed nodes 1
// * 0 1 = compressed nodes 2
// * 1 1 = uncompressed node
// 2. Add compressed node 1; a simple holder for one value
// 3. Add compressed node 2; a vector with a bitlookup table for up to 2^sizeof(C) values
// 4. Allow for hytersis in deletion for until 1 insert (will increase speed on multiple in row insert/deletes
// Rukia: Templates <Key, Value, Compare by>
template <typename K, typename V, typename C = unsigned char>
class Trie
{
public:
// Rukia: HACK: Remove this from Trie class eventually; it looks ugly and is slow.
class TrieNode
{
friend class Trie;
public:
TrieNode()
{
// Rukia: Render all pointers NULL.
// Rukia: HACK: Reformat this somehow, it is ugly.
// Rukia: Use 0, not NULL. GCC dislikes usage of NULL.
memset(reinterpret_cast<void*>(Children),0,Exponential<2,8*sizeof(C)>::value * sizeof(TrieNode*));
Value = NULL;
}
// Rukia: We can garantee this will be an OK delete; either value, or NULL.
~TrieNode()
{
if( Value != NULL) { delete Value; }
for(register long i = 0; i < Exponential<2,8*sizeof(C)>::value; i++)
{
delete Children[i];
}
}
void Clear()
{
if( Value != NULL) { delete Value; }
for(register long i = 0; i < Exponential<2,8*sizeof(C)>::value; i++)
{
delete Children[i];
Children[i] = NULL;
}
}
// Rukia: Little syntatical sugar for you. Hope you like it.
TrieNode* operator[](C size)
{
return Children[size];
}
void InOrderAlt(void(*func)(V&) )
{
if( Value != NULL) { func(*Value); }
for(register long i = 0; i < Exponential<2,8*sizeof(C)>::value; i++)
{
if(Children[i] != NULL) { (Children[i])->InOrderAlt(func); }
}
}
void Insert(V& newval)
{
if(Value == NULL) { Value = new V; }
*Value = newval;
}
// Rukia: This will be inlined out, and it is never good to expose too much.
V* Retrieve()
{
return Value;
}
// Rukia: Return true if node is redundant, so we can remove it.
// Rukia: HACK: Perhaps optimize for inserts by analyzing usage?
void Delete()
{
delete Value;
Value = NULL;
}
// Rukia: GCC doesn't like redundant friend declarations.
//friend class Trie;
private:
TrieNode* Children[Exponential<2,8*sizeof(C)>::value];
V* Value;
};
friend class TrieNode;
// Rukia: Root/stem node.
TrieNode Stem;
// Simply calls the destructor on any and all children, until everything is dead.
void Clear()
{
Stem.Clear();
}
bool IsValid(const K* key, size_t keylen)
{
return (Retrieve(key,keylen) != NULL);
}
void InOrderAlt(void(*func)(V&) )
{
Stem.InOrderAlt(func);
}
// Rukia: We use const for the key, even though we completely subvert the system.
// Rukia: Why? Because we don't CHANGE it, even if we subvert the system.
V* Retrieve(const K* key, size_t keylen)
{
// Rukia: Convert to comparison types
register C* realkey = (C*)(key);
C CurrKey = *realkey;
// Rukia: HACK: Convert to use bitwise shift operators
register size_t reallen = keylen * (sizeof(K) / sizeof(C) );
if(key == NULL) { return Stem.Retrieve(); }
// Rukia: Iterate through the nodes till we find a NULL one, or run out of key.
register TrieNode* CurrNode = Stem[CurrKey];
// Rukia: HACK: Return NULL, don't use exceptions, they are slow.
if(CurrNode == NULL) { return NULL; }
// Rukia: initialize one lower because we've already decoded one from the key.
for(reallen--;reallen != 0;reallen--)
{
realkey++;
CurrKey = *realkey;
CurrNode = (*CurrNode)[CurrKey];
if(CurrNode == NULL) { return NULL; }
}
return CurrNode->Retrieve();
};
void Insert( const K* key, size_t keylen, V& value)
{
// Rukia: Convert to comparison types
register C* realkey = (C*)(key);
C CurrKey = *realkey;
// Rukia: HACK: Convert to use bitwise shift operators
register size_t reallen = keylen * (sizeof(K) / sizeof(C) );
if(key == NULL) { Stem.Retrieve(); }
// Rukia: Iterate through the nodes till we find a NULL one, or run out of key.
register TrieNode* CurrNode = Stem[CurrKey];
register TrieNode* TmpNode = NULL;
// Rukia: HACK: Maybe an internal memory allocator?
// Rukia: HACK: Quickly resort to 'friend'; reduces encapsulation, but worth the cost.
if(CurrNode == NULL) { CurrNode = new TrieNode(); Stem.Children[CurrKey] = CurrNode; }
// Rukia: initialize one lower because we've already decoded one from the key.
for(reallen--;reallen != 0;reallen--)
{
realkey++;
CurrKey = *realkey;
TmpNode = (*CurrNode)[CurrKey];
if(TmpNode == NULL) { TmpNode = new TrieNode; CurrNode->Children[CurrKey] = TmpNode; }
CurrNode = TmpNode;
}
CurrNode->Insert(value);
}
// Rukia: HACK HACK HACK: Fix this SOON. Delete will NOT delete nodes, and has no hystersis operandi.
void Delete( const K* key, size_t keylen)
{
// Rukia: Convert to comparison types
register C* realkey = (C*)(key);
C CurrKey = *realkey;
// Rukia: HACK: Convert to use bitwise shift operators
register size_t reallen = keylen * (sizeof(K) / sizeof(C) );
if(key == NULL) { Stem.Delete(); return; }
// Rukia: Iterate through the nodes till we find a NULL one, or run out of key.
register TrieNode* CurrNode = Stem[CurrKey];
// Rukia: HACK: Return NULL, don't use exceptions, they are slow.
if(CurrNode == NULL) { return; }
// Rukia: initialize one lower because we've already decoded one from the key.
for(reallen--;reallen != 0;reallen--)
{
realkey++;
CurrKey = *realkey;
CurrNode = (*CurrNode)[CurrKey];
if(CurrNode == NULL) { return; }
}
CurrNode->Delete();
}
};
#endif

View File

@ -1,344 +0,0 @@
/* AMX Mod X
* Sven Co-op Module
*
* by the AMX Mod X Development Team
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#include "svencoop.h"
//
// EXTERNS
//
int gmsgScoreInfo;
KeyValueData g_kvd;
Trie<char,String> g_allyNameTrie, g_enemyNameTrie;
//
// GLOBALS
//
int g_lastDeadflag[33] = { 0 }, g_grenadeCount = 0,
g_spawnFwd = -1, g_healFwd = -1, g_grenadeFwd = -1;
edict_t *g_grenadeList[32] = { NULL };
//
// AMXX HOOKS
//
void OnAmxxAttach()
{
MF_AddNatives(svencoop_Exports);
// sc_set_displayname
g_kvd.szClassName = "";
g_kvd.szKeyName = "";
g_kvd.szValue = "";
g_kvd.fHandled = 0;
// sc_get_displayname, default displaynames
g_allyNameTrie.Insert("monster_alien_babyvoltigore", 27, String("Friendly Baby Voltigore"));
g_enemyNameTrie.Insert("monster_alien_babyvoltigore", 27, String("Baby Voltigore"));
g_allyNameTrie.Insert("monster_alien_controller", 24, String("Friendly Alien Controller"));
g_enemyNameTrie.Insert("monster_alien_controller", 24, String("Alien Controller"));
g_allyNameTrie.Insert("monster_alien_grunt", 19, String("Friendly Alien Grunt"));
g_enemyNameTrie.Insert("monster_alien_grunt", 19, String("Alien Grunt"));
g_allyNameTrie.Insert("monster_alien_slave", 19, String("Friendly Alien Slave"));
g_enemyNameTrie.Insert("monster_alien_slave", 19, String("Alien Slave"));
g_allyNameTrie.Insert("monster_vortigaunt", 18, String("Friendly Alien Slave"));
g_enemyNameTrie.Insert("monster_vortigaunt", 18, String("Alien Slave"));
g_allyNameTrie.Insert("monster_alien_voltigore", 23, String("Friendly Voltigore"));
g_enemyNameTrie.Insert("monster_alien_voltigore", 23, String("Voltigore"));
g_allyNameTrie.Insert("monster_apache", 14, String("Apache"));
g_enemyNameTrie.Insert("monster_apache", 14, String("Apache"));
g_allyNameTrie.Insert("monster_blkop_apache", 20, String("Apache"));
g_enemyNameTrie.Insert("monster_blkop_apache", 20, String("Apache"));
g_allyNameTrie.Insert("monster_assassin_repel", 22, String("Friendly Male Assassin"));
g_enemyNameTrie.Insert("monster_assassin_repel", 22, String("Male Assassin"));
g_allyNameTrie.Insert("monster_male_assassin", 21, String("Friendly Male Assassin"));
g_enemyNameTrie.Insert("monster_male_assassin", 21, String("Male Assassin"));
g_allyNameTrie.Insert("monster_babycrab", 16, String("Friendly Head Crab"));
g_enemyNameTrie.Insert("monster_babycrab", 16, String("Head Crab"));
g_allyNameTrie.Insert("monster_headcrab", 16, String("Friendly Head Crab"));
g_enemyNameTrie.Insert("monster_headcrab", 16, String("Head Crab"));
g_allyNameTrie.Insert("monster_babygarg", 16, String("Friendly Baby Gargantua"));
g_enemyNameTrie.Insert("monster_babygarg", 16, String("Baby Gargantua"));
g_allyNameTrie.Insert("monster_barnacle", 16, String("Barnacle"));
g_enemyNameTrie.Insert("monster_barnacle", 16, String("Barnacle"));
g_allyNameTrie.Insert("monster_barney", 14, String("Barney"));
g_enemyNameTrie.Insert("monster_barney", 14, String("Barnabus"));
g_allyNameTrie.Insert("monster_bigmomma", 16, String("Friendly Big Momma"));
g_enemyNameTrie.Insert("monster_bigmomma", 16, String("Big Momma"));
g_allyNameTrie.Insert("monster_blkop_osprey", 20, String("Friendly Black Ops Osprey"));
g_enemyNameTrie.Insert("monster_blkop_osprey", 20, String("Black Ops Osprey"));
g_allyNameTrie.Insert("monster_bloater", 15, String("Friendly Bloater"));
g_enemyNameTrie.Insert("monster_bloater", 15, String("Bloater"));
g_allyNameTrie.Insert("monster_bullchicken", 19, String("Friendly Bull Squid"));
g_enemyNameTrie.Insert("monster_bullchicken", 19, String("Bull Squid"));
g_allyNameTrie.Insert("monster_chumtoad", 16, String("Chubby"));
g_enemyNameTrie.Insert("monster_chumtoad", 16, String("Chumtoad"));
g_allyNameTrie.Insert("monster_cleansuit_scientist", 27, String("Cleansuit Scientist"));
g_enemyNameTrie.Insert("monster_cleansuit_scientist", 27, String("Cleansuit Scientist"));
g_allyNameTrie.Insert("monster_cockroach", 17, String("Roach"));
g_enemyNameTrie.Insert("monster_cockroach", 17, String("Roach"));
g_allyNameTrie.Insert("monster_gargantua", 17, String("Friendly Gargantua"));
g_enemyNameTrie.Insert("monster_gargantua", 17, String("Gargantua"));
g_allyNameTrie.Insert("monster_gman", 12, String("Government Man"));
g_enemyNameTrie.Insert("monster_gman", 12, String("Government Man"));
g_allyNameTrie.Insert("monster_gonome", 14, String("Friendly Gonome"));
g_enemyNameTrie.Insert("monster_gonome", 14, String("Gonome"));
g_allyNameTrie.Insert("monster_houndeye", 16, String("Friendly Hound Eye"));
g_enemyNameTrie.Insert("monster_houndeye", 16, String("Hound Eye"));
g_allyNameTrie.Insert("monster_human_assassin", 22, String("Friendly Female Assassin"));
g_enemyNameTrie.Insert("monster_human_assassin", 22, String("Female Assassin"));
g_allyNameTrie.Insert("monster_human_grunt", 19, String("Friendly Human Grunt"));
g_enemyNameTrie.Insert("monster_human_grunt", 19, String("Human Grunt"));
g_allyNameTrie.Insert("monster_grunt_repel", 19, String("Friendly Human Grunt"));
g_enemyNameTrie.Insert("monster_grunt_repel", 19, String("Human Grunt"));
g_allyNameTrie.Insert("monster_human_grunt_ally", 24, String("Ally Grunt"));
g_enemyNameTrie.Insert("monster_human_grunt_ally", 24, String("Enemy Grunt"));
g_allyNameTrie.Insert("monster_grunt_ally_repel", 24, String("Ally Grunt"));
g_enemyNameTrie.Insert("monster_grunt_ally_repel", 24, String("Enemy Grunt"));
g_allyNameTrie.Insert("monster_human_medic_ally", 24, String("Medic Grunt"));
g_enemyNameTrie.Insert("monster_human_medic_ally", 24, String("Enemy Medic Grunt"));
g_allyNameTrie.Insert("monster_medic_ally_repel", 24, String("Medic Grunt"));
g_enemyNameTrie.Insert("monster_medic_ally_repel", 24, String("Enemy Medic Grunt"));
g_allyNameTrie.Insert("monster_human_torch_ally", 24, String("Torch Grunt"));
g_enemyNameTrie.Insert("monster_human_torch_ally", 24, String("Enemy Torch Grunt"));
g_allyNameTrie.Insert("monster_torch_ally_repel", 24, String("Torch Grunt"));
g_enemyNameTrie.Insert("monster_torch_ally_repel", 24, String("Enemy Torch Grunt"));
g_allyNameTrie.Insert("monster_hwgrunt", 15, String("Friendly Heavy Weapons Grunt"));
g_enemyNameTrie.Insert("monster_hwgrunt", 15, String("Heavy Weapons Grunt"));
g_allyNameTrie.Insert("monster_hwgrunt_repel", 21, String("Friendly Heavy Weapons Grunt"));
g_enemyNameTrie.Insert("monster_hwgrunt_repel", 21, String("Heavy Weapons Grunt"));
g_allyNameTrie.Insert("monster_ichthyosaur", 19, String("Friendly Ichthyosaur"));
g_enemyNameTrie.Insert("monster_ichthyosaur", 19, String("Ichthyosaur"));
g_allyNameTrie.Insert("monster_leech", 13, String("Leech"));
g_enemyNameTrie.Insert("monster_leech", 13, String("Leech"));
g_allyNameTrie.Insert("monster_miniturret", 18, String("Mini-Turret"));
g_enemyNameTrie.Insert("monster_miniturret", 18, String("Mini-Turret"));
g_allyNameTrie.Insert("monster_nihilanth", 17, String(""));
g_enemyNameTrie.Insert("monster_nihilanth", 17, String(""));
g_allyNameTrie.Insert("monster_osprey", 14, String("Friendly Osprey Helicopter"));
g_enemyNameTrie.Insert("monster_osprey", 14, String("Osprey Helicopter"));
g_allyNameTrie.Insert("monster_otis", 12, String("Otis"));
g_enemyNameTrie.Insert("monster_otis", 12, String("Enemy Otis"));
g_allyNameTrie.Insert("monster_pitdrone", 16, String("Friendly Pit Drone"));
g_enemyNameTrie.Insert("monster_pitdrone", 16, String("Pit Drone"));
g_allyNameTrie.Insert("monster_rat", 11, String("Rat"));
g_enemyNameTrie.Insert("monster_rat", 11, String("Rat"));
g_allyNameTrie.Insert("monster_robogrunt", 17, String("Friendly Robo Grunt"));
g_enemyNameTrie.Insert("monster_robogrunt", 17, String("Robo Grunt"));
g_allyNameTrie.Insert("monster_robogrunt_repel", 23, String("Friendly Robo Grunt"));
g_enemyNameTrie.Insert("monster_robogrunt_repel", 23, String("Robo Grunt"));
g_allyNameTrie.Insert("monster_scientist", 17, String("Scientist"));
g_enemyNameTrie.Insert("monster_scientist", 17, String("Scientist"));
g_allyNameTrie.Insert("monster_sitting_scientist", 25, String("Scientist"));
g_enemyNameTrie.Insert("monster_sitting_scientist", 25, String("Scientist"));
g_allyNameTrie.Insert("monster_sentry", 14, String("Sentry Turret"));
g_enemyNameTrie.Insert("monster_sentry", 14, String("Sentry Turret"));
g_allyNameTrie.Insert("monster_shockroach", 18, String("Friendly Shock Roach"));
g_enemyNameTrie.Insert("monster_shockroach", 18, String("Shock Roach"));
g_allyNameTrie.Insert("monster_shocktrooper", 20, String("Friendly Shock Trooper"));
g_enemyNameTrie.Insert("monster_shocktrooper", 20, String("Shock Trooper"));
g_allyNameTrie.Insert("monster_snark", 13, String("Snark"));
g_enemyNameTrie.Insert("monster_snark", 13, String("Snark"));
g_allyNameTrie.Insert("monster_tentacle", 16, String("Tentacle"));
g_enemyNameTrie.Insert("monster_tentacle", 16, String("Tentacle"));
g_allyNameTrie.Insert("monster_tentaclemaw", 19, String("Tentacle"));
g_enemyNameTrie.Insert("monster_tentaclemaw", 19, String("Tentacle"));
g_allyNameTrie.Insert("monster_turret", 14, String("Turret"));
g_enemyNameTrie.Insert("monster_turret", 14, String("Turret"));
g_allyNameTrie.Insert("monster_zombie", 14, String("Friendly Zombie"));
g_enemyNameTrie.Insert("monster_zombie", 14, String("Zombie"));
g_allyNameTrie.Insert("monster_zombie_barney", 21, String("Friendly Zombie Barney"));
g_enemyNameTrie.Insert("monster_zombie_barney", 21, String("Zombie Barney"));
g_allyNameTrie.Insert("monster_zombie_soldier", 22, String("Friendly Zombie Soldier"));
g_enemyNameTrie.Insert("monster_zombie_soldier", 22, String("Zombie Soldier"));
}
void OnPluginsLoaded()
{
g_spawnFwd = MF_RegisterForward("sc_client_spawn", ET_IGNORE, FP_CELL, FP_DONE);
g_healFwd = MF_RegisterForward("sc_client_heal", ET_IGNORE, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
g_grenadeFwd = MF_RegisterForward("sc_grenade_throw", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
//
// METAMOD HOOKS
//
/***GetEntityAPI2******************/
// sc_client_heal
void DispatchThink(edict_t *pEntity)
{
if(g_healFwd != -1 && UTIL_IsMonster(pEntity))
*((float *)pEntity->pvPrivateData + OFFSET_LAST_HEALTH) = pEntity->v.health;
RETURN_META(MRES_IGNORED);
}
// sc_get_displayname
void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd)
{
// catch displayname and store it ourselves for our native
// TODO: store this somewhere else besides in the pev
if(FStrEq(pkvd->szKeyName, "displayname"))
pentKeyvalue->v.message = ALLOC_STRING(pkvd->szValue);
RETURN_META(MRES_IGNORED);
}
// sc_client_spawn
void ClientPutInServer(edict_t *pPlayer)
{
g_lastDeadflag[ENTINDEX(pPlayer)] = -1;
RETURN_META(MRES_IGNORED);
}
// sc_client_spawn / sc_client_heal
void PlayerPreThink(edict_t *pPlayer)
{
if(g_spawnFwd != -1)
{
int index = ENTINDEX(pPlayer);
if(g_lastDeadflag[index] == -1 || (g_lastDeadflag[index] != DEAD_NO && pPlayer->v.deadflag == DEAD_NO))
MF_ExecuteForward(g_spawnFwd, index);
g_lastDeadflag[index] = pPlayer->v.deadflag;
}
if(g_healFwd != -1)
*((float *)pPlayer->pvPrivateData + OFFSET_LAST_HEALTH) = pPlayer->v.health;
RETURN_META(MRES_IGNORED);
}
// sc_grenade_throw
void StartFrame()
{
if(g_grenadeFwd == -1 || !g_grenadeCount)
RETURN_META(MRES_IGNORED);
edict_t *pGrenade = g_grenadeList[0];
if(!FNullEnt(pGrenade) && pGrenade->v.owner)
{
const char *model = STRING(pGrenade->v.model);
int wId = 0;
switch(model[7])
{
case 'g': wId = SCW_ARGRENADE; break; // models/grenade.mdl
case 'w': wId = SCW_HANDGRENADE; break; // models/w_grenade.mdl
//case 'c': wId = SCW_BANANA; break; // models/cretegibs.mdl
}
if(wId) MF_ExecuteForward(g_grenadeFwd, ENTINDEX(pGrenade->v.owner),
ENTINDEX(pGrenade), wId, UTIL_IsPlayer(pGrenade->v.owner));
}
// shift the list
g_grenadeList[0] = NULL;
if(--g_grenadeCount)
{
for(int i=1;i<=g_grenadeCount;i++) g_grenadeList[i-1] = g_grenadeList[i];
g_grenadeList[g_grenadeCount] = NULL;
}
RETURN_META(MRES_IGNORED);
}
/***GetEntityAPI2_Post*************/
// sc_set_frags
void ServerActivate_Post(struct edict_s *, int, int)
{
gmsgScoreInfo = GET_USER_MSG_ID(PLID, "ScoreInfo", NULL);
RETURN_META(MRES_IGNORED);
}
/***GetEngineAPI*******************/
// sc_client_heal
void EmitSound(edict_t *pEntity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch)
{
if(g_healFwd == -1 || !UTIL_IsPlayer(pEntity) || channel != CHAN_WEAPON || strcmp(sample, "items/medshot4.wav") != 0)
RETURN_META(MRES_IGNORED);
Vector trStart = pEntity->v.origin;
if(pEntity->v.flags & FL_DUCKING) trStart.z += 12.0;
else trStart.z += 28.0;
Vector trEnd = trStart + gpGlobals->v_forward * 32;
TraceResult tr;
TRACE_LINE(trStart, trEnd, dont_ignore_monsters, pEntity, &tr);
if(tr.flFraction == 1.0)
TRACE_HULL(trStart, trEnd, dont_ignore_monsters, head_hull, pEntity, &tr);
if(!FNullEnt(tr.pHit))
{
float amount = tr.pHit->v.health - *((float *)tr.pHit->pvPrivateData + OFFSET_LAST_HEALTH);
if(UTIL_IsPlayer(tr.pHit))
MF_ExecuteForward(g_healFwd, ENTINDEX(pEntity), ENTINDEX(tr.pHit), amount, 1, 1);
else if(UTIL_IsMonster(tr.pHit))
MF_ExecuteForward(g_healFwd, ENTINDEX(pEntity), ENTINDEX(tr.pHit), amount, 0, *((int *)tr.pHit->pvPrivateData + OFFSET_MONSTER_ALLY));
}
RETURN_META(MRES_IGNORED);
}
/***GetEngineAPI_Post**************/
// sc_grenade_throw
void SetModel_Post(edict_t *pEntity, const char *model)
{
if(g_grenadeFwd == -1)
RETURN_META(MRES_IGNORED);
const char *classname = STRING(pEntity->v.classname);
if(!pEntity->v.owner && classname[0] == 'g' && classname[2] == 'e' && model[7] == 'g')
{
if(g_grenadeCount < sizeof g_grenadeList)
g_grenadeList[g_grenadeCount++] = pEntity;
}
RETURN_META(MRES_IGNORED);
}

View File

@ -1,23 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "svencoop", "svencoop.vcproj", "{AB148B92-4F47-42E6-8268-AB4E588EC6A2}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Debug.ActiveCfg = Debug|Win32
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Debug.Build.0 = Debug|Win32
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Release.ActiveCfg = Release|Win32
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@ -1,218 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="svencoop"
ProjectGUID="{AB148B92-4F47-42E6-8268-AB4E588EC6A2}"
RootNamespace="svencoop"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\;..\sdk"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SVENCOOP_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/svencoop.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="Debug/svencoop_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=""
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/svencoop_amx_debug.pdb"
ImportLibrary=".\Debug/svencoop_amx_debug.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/cstrike.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1053"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\;..\sdk"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SVENCOOP_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/svencoop.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="Release/svencoop_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=""
ProgramDatabaseFile=".\Release/svencoop_amx.pdb"
ImportLibrary=".\Release/svencoop_amx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/cstrike.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1053"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\moduleconfig.cpp">
</File>
<File
RelativePath="..\svencoop.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\svencoop.h">
</File>
<File
RelativePath="..\Trie.h">
</File>
</Filter>
<Filter
Name="Module SDK"
Filter="">
<File
RelativePath="..\sdk\moduleconfig.h">
</File>
<Filter
Name="AMXX STL"
Filter="">
<File
RelativePath="..\sdk\CString.h">
</File>
</Filter>
<Filter
Name="SDK Base"
Filter="">
<File
RelativePath="..\sdk\amxxmodule.cpp">
</File>
<File
RelativePath="..\sdk\amxxmodule.h">
</File>
</Filter>
</Filter>
<Filter
Name="Pawn Includes"
Filter="">
<File
RelativePath="..\svencoop.inc">
</File>
<File
RelativePath="..\svencoop_const.inc">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "svencoop", "svencoop.vcproj", "{AB148B92-4F47-42E6-8268-AB4E588EC6A2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Debug|Win32.ActiveCfg = Debug|Win32
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Debug|Win32.Build.0 = Debug|Win32
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Release|Win32.ActiveCfg = Release|Win32
{AB148B92-4F47-42E6-8268-AB4E588EC6A2}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,296 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="svencoop"
ProjectGUID="{AB148B92-4F47-42E6-8268-AB4E588EC6A2}"
RootNamespace="svencoop"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug/cstrike.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\;..\sdk"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SVENCOOP_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Debug/svencoop.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1053"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="Debug/svencoop_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
ModuleDefinitionFile=""
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/svencoop_amx_debug.pdb"
ImportLibrary=".\Debug/svencoop_amx_debug.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release/cstrike.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\;..\sdk"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SVENCOOP_EXPORTS"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Release/svencoop.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1053"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="Release/svencoop_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
ModuleDefinitionFile=""
ProgramDatabaseFile=".\Release/svencoop_amx.pdb"
ImportLibrary=".\Release/svencoop_amx.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="..\moduleconfig.cpp"
>
</File>
<File
RelativePath="..\svencoop.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\svencoop.h"
>
</File>
<File
RelativePath="..\Trie.h"
>
</File>
</Filter>
<Filter
Name="Module SDK"
>
<File
RelativePath="..\sdk\moduleconfig.h"
>
</File>
<Filter
Name="AMXX STL"
>
<File
RelativePath="..\sdk\CString.h"
>
</File>
</Filter>
<Filter
Name="SDK Base"
>
<File
RelativePath="..\sdk\amxxmodule.cpp"
>
</File>
<File
RelativePath="..\sdk\amxxmodule.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Pawn Includes"
>
<File
RelativePath="..\svencoop.inc"
>
</File>
<File
RelativePath="..\svencoop_const.inc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,413 +0,0 @@
/* AMX Mod X
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#ifndef _INCLUDE_CSTRING_H
#define _INCLUDE_CSTRING_H
#include <string.h>
#include <stdio.h>
//by David "BAILOPAN" Anderson
class String
{
public:
String()
{
v = NULL;
a_size = 0;
//assign("");
}
~String()
{
if (v)
delete [] v;
}
String(const char *src)
{
v = NULL;
a_size = 0;
assign(src);
}
const char * _fread(FILE *fp)
{
Grow(512, false);
char *ret = fgets(v, 511, fp);
return ret;
}
String(const String &src)
{
v = NULL;
a_size = 0;
assign(src.c_str());
}
const char *c_str() { return v?v:""; }
const char *c_str() const { return v?v:""; }
void append(const char *t)
{
Grow(size() + strlen(t) + 1);
strcat(v, t);
}
void append(const char c)
{
size_t len = size();
Grow(len + 2);
v[len] = c;
v[len + 1] = '\0';
}
void append(String &d)
{
append(d.c_str());
}
void assign(const String &src)
{
assign(src.c_str());
}
void assign(const char *d)
{
if (!d)
{
clear();
} else {
size_t len = strlen(d);
Grow(len + 1, false);
memcpy(v, d, len);
v[len] = '\0';
}
}
void clear()
{
if (v)
v[0] = '\0';
}
int compare (const char *d) const
{
if (!v)
return strcmp("", d);
else
return strcmp(v, d);
}
//Added this for amxx inclusion
bool empty()
{
if (!v)
return true;
if (v[0] == '\0')
return true;
return false;
}
size_t size()
{
if (v)
return strlen(v);
else
return 0;
}
int find(const char c, int index = 0)
{
int len = static_cast<int>(size());
if (len < 1)
return npos;
if (index >= len || index < 0)
return npos;
int i = 0;
for (i=index; i<len; i++)
{
if (v[i] == c)
{
return i;
}
}
return npos;
}
bool is_space(int c)
{
if (c == '\f' || c == '\n' ||
c == '\t' || c == '\r' ||
c == '\v' || c == ' ')
{
return true;
}
return false;
}
void reparse_newlines()
{
size_t len = size();
int offs = 0;
char c;
if (!len)
return;
for (size_t i=0; i<len; i++)
{
c = v[i];
if (c == '^' && (i != len-1))
{
c = v[++i];
if (c == 'n')
c = '\n';
else if (c == 't')
c = '\t';
offs++;
}
v[i-offs] = c;
}
v[len-offs] = '\0';
}
void trim()
{
if (!v)
return;
unsigned int i = 0;
unsigned int j = 0;
size_t len = strlen(v);
if (len == 1)
{
if (is_space(v[i]))
{
clear();
return;
}
}
unsigned char c0 = v[0];
if (is_space(c0))
{
for (i=0; i<len; i++)
{
if (!is_space(v[i]) || (is_space(v[i]) && ((unsigned char)i==len-1)))
{
erase(0, i);
break;
}
}
}
len = strlen(v);
if (len < 1)
{
return;
}
if (is_space(v[len-1]))
{
for (i=len-1; i>=0; i--)
{
if (!is_space(v[i])
|| (is_space(v[i]) && i==0))
{
erase(i+1, j);
break;
}
j++;
}
}
if (len == 1)
{
if (is_space(v[0]))
{
clear();
return;
}
}
}
void erase(unsigned int start, int num = npos)
{
if (!v)
return;
unsigned int i = 0;
size_t len = size();
//check for bounds
if (num == npos || start+num > len-start)
num = len - start;
//do the erasing
bool copyflag = false;
for (i=0; i<len; i++)
{
if (i>=start && i<start+num)
{
if (i+num < len)
{
v[i] = v[i+num];
} else {
v[i] = 0;
}
copyflag = true;
} else if (copyflag) {
if (i+num < len)
{
v[i] = v[i+num];
} else {
v[i] = 0;
}
}
}
len -= num;
v[len] = 0;
}
String substr(unsigned int index, int num = npos)
{
if (!v)
{
String b("");
return b;
}
String ns;
size_t len = size();
if (index >= len || !v)
return ns;
if (num == npos)
{
num = len - index;
} else if (index+num >= len) {
num = len - index;
}
unsigned int i = 0;
unsigned int nslen = num + 2;
ns.Grow(nslen);
for (i=index; i<index+num; i++)
ns.append(v[i]);
return ns;
}
void toLower()
{
if (!v)
return;
unsigned int i = 0;
size_t len = strlen(v);
for (i=0; i<len; i++)
{
if (v[i] >= 65 && v[i] <= 90)
v[i] &= ~(1<<5);
}
}
String & operator = (const String &src)
{
assign(src);
return *this;
}
String & operator = (const char *src)
{
assign(src);
return *this;
}
char operator [] (unsigned int index)
{
if (index > size() || !v)
{
return -1;
} else {
return v[index];
}
}
int at(int a)
{
if (a < 0 || a >= (int)size() || !v)
return -1;
return v[a];
}
bool at(int at, char c)
{
if (at < 0 || at >= (int)size() || !v)
return false;
v[at] = c;
return true;
}
private:
void Grow(unsigned int d, bool copy=true)
{
if (d <= a_size)
return;
char *n = new char[d + 1];
if (copy && v)
strcpy(n, v);
if (v)
delete [] v;
else
strcpy(n, "");
v = n;
a_size = d + 1;
}
char *v;
unsigned int a_size;
public:
static const int npos = -1;
};
#endif //_INCLUDE_CSTRING_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,492 +0,0 @@
// Configuration
#ifndef __MODULECONFIG_H__
#define __MODULECONFIG_H__
// Module info
#define MODULE_NAME "SvenCoop"
#define MODULE_VERSION "1.77"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "SVEN"
#define MODULE_LIBRARY "svencoop"
#define MODULE_LIBCLASS ""
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
#define MODULE_RELOAD_ON_MAPCHANGE
#ifdef __DATE__
#define MODULE_DATE __DATE__
#else // __DATE__
#define MODULE_DATE "Unknown"
#endif // __DATE__
// metamod plugin?
#define USE_METAMOD
// use memory manager/tester?
// note that if you use this, you cannot construct/allocate
// anything before the module attached (OnAmxxAttach).
// be careful of default constructors using new/malloc!
// #define MEMORY_TEST
// Unless you use STL or exceptions, keep this commented.
// It allows you to compile without libstdc++.so as a dependency
// #define NO_ALLOC_OVERRIDES
// Uncomment this if you are using MSVC8 or greater and want to fix some of the compatibility issues yourself
// #define NO_MSVC8_AUTO_COMPAT
/**
* AMXX Init functions
* Also consider using FN_META_*
*/
/** AMXX query */
//#define FN_AMXX_QUERY OnAmxxQuery
/** AMXX attach
* Do native functions init here (MF_AddNatives)
*/
#define FN_AMXX_ATTACH OnAmxxAttach
/** AMXX Detach (unload) */
//#define FN_AMXX_DETACH OnAmxxDetach
/** All plugins loaded
* Do forward functions init here (MF_RegisterForward)
*/
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
/** All plugins are about to be unloaded */
//#define FN_AMXX_PLUGINSUNLOADING OnPluginsUnloading
/** All plugins are now unloaded */
//#define FN_AMXX_PLUGINSUNLOADED OnPluginsUnloaded
/**** METAMOD ****/
// If your module doesn't use metamod, you may close the file now :)
#ifdef USE_METAMOD
// ----
// Hook Functions
// Uncomment these to be called
// You can also change the function name
// - Metamod init functions
// Also consider using FN_AMXX_*
// Meta query
//#define FN_META_QUERY OnMetaQuery
// Meta attach
//#define FN_META_ATTACH OnMetaAttach
// Meta detach
//#define FN_META_DETACH OnMetaDetach
// (wd) are Will Day's notes
// - GetEntityAPI2 functions
// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */
// #define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
#define FN_DispatchThink DispatchThink /* pfnThink() */
// #define FN_DispatchUse DispatchUse /* pfnUse() */
// #define FN_DispatchTouch DispatchTouch /* pfnTouch() */
// #define FN_DispatchBlocked DispatchBlocked /* pfnBlocked() */
#define FN_DispatchKeyValue DispatchKeyValue /* pfnKeyValue() */
// #define FN_DispatchSave DispatchSave /* pfnSave() */
// #define FN_DispatchRestore DispatchRestore /* pfnRestore() */
// #define FN_DispatchObjectCollsionBox DispatchObjectCollsionBox /* pfnSetAbsBox() */
// #define FN_SaveWriteFields SaveWriteFields /* pfnSaveWriteFields() */
// #define FN_SaveReadFields SaveReadFields /* pfnSaveReadFields() */
// #define FN_SaveGlobalState SaveGlobalState /* pfnSaveGlobalState() */
// #define FN_RestoreGlobalState RestoreGlobalState /* pfnRestoreGlobalState() */
// #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */
// #define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */
// #define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */
// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
#define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
#define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
#define FN_StartFrame StartFrame /* pfnStartFrame() */
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
// #define FN_PlayerCustomization PlayerCustomization /* pfnPlayerCustomization() Notifies .dll of new customization for player. */
// #define FN_SpectatorConnect SpectatorConnect /* pfnSpectatorConnect() Called when spectator joins server */
// #define FN_SpectatorDisconnect SpectatorDisconnect /* pfnSpectatorDisconnect() Called when spectator leaves the server */
// #define FN_SpectatorThink SpectatorThink /* pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t) */
// #define FN_Sys_Error Sys_Error /* pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2 */
// #define FN_PM_Move PM_Move /* pfnPM_Move() (wd) SDK2 */
// #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */
// #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */
// #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */
// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */
// #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */
// #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */
// #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */
// #define FN_GetWeaponData GetWeaponData /* pfnGetWeaponData() (wd) SDK2 */
// #define FN_CmdStart CmdStart /* pfnCmdStart() (wd) SDK2 */
// #define FN_CmdEnd CmdEnd /* pfnCmdEnd() (wd) SDK2 */
// #define FN_ConnectionlessPacket ConnectionlessPacket /* pfnConnectionlessPacket() (wd) SDK2 */
// #define FN_GetHullBounds GetHullBounds /* pfnGetHullBounds() (wd) SDK2 */
// #define FN_CreateInstancedBaselines CreateInstancedBaselines /* pfnCreateInstancedBaselines() (wd) SDK2 */
// #define FN_InconsistentFile InconsistentFile /* pfnInconsistentFile() (wd) SDK2 */
// #define FN_AllowLagCompensation AllowLagCompensation /* pfnAllowLagCompensation() (wd) SDK2 */
// - GetEntityAPI2_Post functions
// #define FN_GameDLLInit_Post GameDLLInit_Post
// #define FN_DispatchSpawn_Post DispatchSpawn_Post
// #define FN_DispatchThink_Post DispatchThink_Post
// #define FN_DispatchUse_Post DispatchUse_Post
// #define FN_DispatchTouch_Post DispatchTouch_Post
// #define FN_DispatchBlocked_Post DispatchBlocked_Post
// #define FN_DispatchKeyValue_Post DispatchKeyValue_Post
// #define FN_DispatchSave_Post DispatchSave_Post
// #define FN_DispatchRestore_Post DispatchRestore_Post
// #define FN_DispatchObjectCollsionBox_Post DispatchObjectCollsionBox_Post
// #define FN_SaveWriteFields_Post SaveWriteFields_Post
// #define FN_SaveReadFields_Post SaveReadFields_Post
// #define FN_SaveGlobalState_Post SaveGlobalState_Post
// #define FN_RestoreGlobalState_Post RestoreGlobalState_Post
// #define FN_ResetGlobalState_Post ResetGlobalState_Post
// #define FN_ClientConnect_Post ClientConnect_Post
// #define FN_ClientDisconnect_Post ClientDisconnect_Post
// #define FN_ClientKill_Post ClientKill_Post
// #define FN_ClientPutInServer_Post ClientPutInServer_Post
// #define FN_ClientCommand_Post ClientCommand_Post
// #define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post
#define FN_ServerActivate_Post ServerActivate_Post
// #define FN_ServerDeactivate_Post ServerDeactivate_Post
// #define FN_PlayerPreThink_Post PlayerPreThink_Post
// #define FN_PlayerPostThink_Post PlayerPostThink_Post
// #define FN_StartFrame_Post StartFrame_Post
// #define FN_ParmsNewLevel_Post ParmsNewLevel_Post
// #define FN_ParmsChangeLevel_Post ParmsChangeLevel_Post
// #define FN_GetGameDescription_Post GetGameDescription_Post
// #define FN_PlayerCustomization_Post PlayerCustomization_Post
// #define FN_SpectatorConnect_Post SpectatorConnect_Post
// #define FN_SpectatorDisconnect_Post SpectatorDisconnect_Post
// #define FN_SpectatorThink_Post SpectatorThink_Post
// #define FN_Sys_Error_Post Sys_Error_Post
// #define FN_PM_Move_Post PM_Move_Post
// #define FN_PM_Init_Post PM_Init_Post
// #define FN_PM_FindTextureType_Post PM_FindTextureType_Post
// #define FN_SetupVisibility_Post SetupVisibility_Post
// #define FN_UpdateClientData_Post UpdateClientData_Post
// #define FN_AddToFullPack_Post AddToFullPack_Post
// #define FN_CreateBaseline_Post CreateBaseline_Post
// #define FN_RegisterEncoders_Post RegisterEncoders_Post
// #define FN_GetWeaponData_Post GetWeaponData_Post
// #define FN_CmdStart_Post CmdStart_Post
// #define FN_CmdEnd_Post CmdEnd_Post
// #define FN_ConnectionlessPacket_Post ConnectionlessPacket_Post
// #define FN_GetHullBounds_Post GetHullBounds_Post
// #define FN_CreateInstancedBaselines_Post CreateInstancedBaselines_Post
// #define FN_InconsistentFile_Post InconsistentFile_Post
// #define FN_AllowLagCompensation_Post AllowLagCompensation_Post
// - GetEngineAPI functions
// #define FN_PrecacheModel PrecacheModel
// #define FN_PrecacheSound PrecacheSound
// #define FN_SetModel SetModel
// #define FN_ModelIndex ModelIndex
// #define FN_ModelFrames ModelFrames
// #define FN_SetSize SetSize
// #define FN_ChangeLevel ChangeLevel
// #define FN_GetSpawnParms GetSpawnParms
// #define FN_SaveSpawnParms SaveSpawnParms
// #define FN_VecToYaw VecToYaw
// #define FN_VecToAngles VecToAngles
// #define FN_MoveToOrigin MoveToOrigin
// #define FN_ChangeYaw ChangeYaw
// #define FN_ChangePitch ChangePitch
// #define FN_FindEntityByString FindEntityByString
// #define FN_GetEntityIllum GetEntityIllum
// #define FN_FindEntityInSphere FindEntityInSphere
// #define FN_FindClientInPVS FindClientInPVS
// #define FN_EntitiesInPVS EntitiesInPVS
// #define FN_MakeVectors MakeVectors
// #define FN_AngleVectors AngleVectors
// #define FN_CreateEntity CreateEntity
// #define FN_RemoveEntity RemoveEntity
// #define FN_CreateNamedEntity CreateNamedEntity
// #define FN_MakeStatic MakeStatic
// #define FN_EntIsOnFloor EntIsOnFloor
// #define FN_DropToFloor DropToFloor
// #define FN_WalkMove WalkMove
// #define FN_SetOrigin SetOrigin
#define FN_EmitSound EmitSound
// #define FN_EmitAmbientSound EmitAmbientSound
// #define FN_TraceLine TraceLine
// #define FN_TraceToss TraceToss
// #define FN_TraceMonsterHull TraceMonsterHull
// #define FN_TraceHull TraceHull
// #define FN_TraceModel TraceModel
// #define FN_TraceTexture TraceTexture
// #define FN_TraceSphere TraceSphere
// #define FN_GetAimVector GetAimVector
// #define FN_ServerCommand ServerCommand
// #define FN_ServerExecute ServerExecute
// #define FN_engClientCommand engClientCommand
// #define FN_ParticleEffect ParticleEffect
// #define FN_LightStyle LightStyle
// #define FN_DecalIndex DecalIndex
// #define FN_PointContents PointContents
// #define FN_MessageBegin MessageBegin
// #define FN_MessageEnd MessageEnd
// #define FN_WriteByte WriteByte
// #define FN_WriteChar WriteChar
// #define FN_WriteShort WriteShort
// #define FN_WriteLong WriteLong
// #define FN_WriteAngle WriteAngle
// #define FN_WriteCoord WriteCoord
// #define FN_WriteString WriteString
// #define FN_WriteEntity WriteEntity
// #define FN_CVarRegister CVarRegister
// #define FN_CVarGetFloat CVarGetFloat
// #define FN_CVarGetString CVarGetString
// #define FN_CVarSetFloat CVarSetFloat
// #define FN_CVarSetString CVarSetString
// #define FN_AlertMessage AlertMessage
// #define FN_EngineFprintf EngineFprintf
// #define FN_PvAllocEntPrivateData PvAllocEntPrivateData
// #define FN_PvEntPrivateData PvEntPrivateData
// #define FN_FreeEntPrivateData FreeEntPrivateData
// #define FN_SzFromIndex SzFromIndex
// #define FN_AllocString AllocString
// #define FN_GetVarsOfEnt GetVarsOfEnt
// #define FN_PEntityOfEntOffset PEntityOfEntOffset
// #define FN_EntOffsetOfPEntity EntOffsetOfPEntity
// #define FN_IndexOfEdict IndexOfEdict
// #define FN_PEntityOfEntIndex PEntityOfEntIndex
// #define FN_FindEntityByVars FindEntityByVars
// #define FN_GetModelPtr GetModelPtr
// #define FN_RegUserMsg RegUserMsg
// #define FN_AnimationAutomove AnimationAutomove
// #define FN_GetBonePosition GetBonePosition
// #define FN_FunctionFromName FunctionFromName
// #define FN_NameForFunction NameForFunction
// #define FN_ClientPrintf ClientPrintf
// #define FN_ServerPrint ServerPrint
// #define FN_Cmd_Args Cmd_Args
// #define FN_Cmd_Argv Cmd_Argv
// #define FN_Cmd_Argc Cmd_Argc
// #define FN_GetAttachment GetAttachment
// #define FN_CRC32_Init CRC32_Init
// #define FN_CRC32_ProcessBuffer CRC32_ProcessBuffer
// #define FN_CRC32_ProcessByte CRC32_ProcessByte
// #define FN_CRC32_Final CRC32_Final
// #define FN_RandomLong RandomLong
// #define FN_RandomFloat RandomFloat
// #define FN_SetView SetView
// #define FN_Time Time
// #define FN_CrosshairAngle CrosshairAngle
// #define FN_LoadFileForMe LoadFileForMe
// #define FN_FreeFile FreeFile
// #define FN_EndSection EndSection
// #define FN_CompareFileTime CompareFileTime
// #define FN_GetGameDir GetGameDir
// #define FN_Cvar_RegisterVariable Cvar_RegisterVariable
// #define FN_FadeClientVolume FadeClientVolume
// #define FN_SetClientMaxspeed SetClientMaxspeed
// #define FN_CreateFakeClient CreateFakeClient
// #define FN_RunPlayerMove RunPlayerMove
// #define FN_NumberOfEntities NumberOfEntities
// #define FN_GetInfoKeyBuffer GetInfoKeyBuffer
// #define FN_InfoKeyValue InfoKeyValue
// #define FN_SetKeyValue SetKeyValue
// #define FN_SetClientKeyValue SetClientKeyValue
// #define FN_IsMapValid IsMapValid
// #define FN_StaticDecal StaticDecal
// #define FN_PrecacheGeneric PrecacheGeneric
// #define FN_GetPlayerUserId GetPlayerUserId
// #define FN_BuildSoundMsg BuildSoundMsg
// #define FN_IsDedicatedServer IsDedicatedServer
// #define FN_CVarGetPointer CVarGetPointer
// #define FN_GetPlayerWONId GetPlayerWONId
// #define FN_Info_RemoveKey Info_RemoveKey
// #define FN_GetPhysicsKeyValue GetPhysicsKeyValue
// #define FN_SetPhysicsKeyValue SetPhysicsKeyValue
// #define FN_GetPhysicsInfoString GetPhysicsInfoString
// #define FN_PrecacheEvent PrecacheEvent
// #define FN_PlaybackEvent PlaybackEvent
// #define FN_SetFatPVS SetFatPVS
// #define FN_SetFatPAS SetFatPAS
// #define FN_CheckVisibility CheckVisibility
// #define FN_DeltaSetField DeltaSetField
// #define FN_DeltaUnsetField DeltaUnsetField
// #define FN_DeltaAddEncoder DeltaAddEncoder
// #define FN_GetCurrentPlayer GetCurrentPlayer
// #define FN_CanSkipPlayer CanSkipPlayer
// #define FN_DeltaFindField DeltaFindField
// #define FN_DeltaSetFieldByIndex DeltaSetFieldByIndex
// #define FN_DeltaUnsetFieldByIndex DeltaUnsetFieldByIndex
// #define FN_SetGroupMask SetGroupMask
// #define FN_engCreateInstancedBaseline engCreateInstancedBaseline
// #define FN_Cvar_DirectSet Cvar_DirectSet
// #define FN_ForceUnmodified ForceUnmodified
// #define FN_GetPlayerStats GetPlayerStats
// #define FN_AddServerCommand AddServerCommand
// #define FN_Voice_GetClientListening Voice_GetClientListening
// #define FN_Voice_SetClientListening Voice_SetClientListening
// #define FN_GetPlayerAuthId GetPlayerAuthId
// - GetEngineAPI_Post functions
// #define FN_PrecacheModel_Post PrecacheModel_Post
// #define FN_PrecacheSound_Post PrecacheSound_Post
#define FN_SetModel_Post SetModel_Post
// #define FN_ModelIndex_Post ModelIndex_Post
// #define FN_ModelFrames_Post ModelFrames_Post
// #define FN_SetSize_Post SetSize_Post
// #define FN_ChangeLevel_Post ChangeLevel_Post
// #define FN_GetSpawnParms_Post GetSpawnParms_Post
// #define FN_SaveSpawnParms_Post SaveSpawnParms_Post
// #define FN_VecToYaw_Post VecToYaw_Post
// #define FN_VecToAngles_Post VecToAngles_Post
// #define FN_MoveToOrigin_Post MoveToOrigin_Post
// #define FN_ChangeYaw_Post ChangeYaw_Post
// #define FN_ChangePitch_Post ChangePitch_Post
// #define FN_FindEntityByString_Post FindEntityByString_Post
// #define FN_GetEntityIllum_Post GetEntityIllum_Post
// #define FN_FindEntityInSphere_Post FindEntityInSphere_Post
// #define FN_FindClientInPVS_Post FindClientInPVS_Post
// #define FN_EntitiesInPVS_Post EntitiesInPVS_Post
// #define FN_MakeVectors_Post MakeVectors_Post
// #define FN_AngleVectors_Post AngleVectors_Post
// #define FN_CreateEntity_Post CreateEntity_Post
// #define FN_RemoveEntity_Post RemoveEntity_Post
// #define FN_CreateNamedEntity_Post CreateNamedEntity_Post
// #define FN_MakeStatic_Post MakeStatic_Post
// #define FN_EntIsOnFloor_Post EntIsOnFloor_Post
// #define FN_DropToFloor_Post DropToFloor_Post
// #define FN_WalkMove_Post WalkMove_Post
// #define FN_SetOrigin_Post SetOrigin_Post
// #define FN_EmitSound_Post EmitSound_Post
// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post
// #define FN_TraceLine_Post TraceLine_Post
// #define FN_TraceToss_Post TraceToss_Post
// #define FN_TraceMonsterHull_Post TraceMonsterHull_Post
// #define FN_TraceHull_Post TraceHull_Post
// #define FN_TraceModel_Post TraceModel_Post
// #define FN_TraceTexture_Post TraceTexture_Post
// #define FN_TraceSphere_Post TraceSphere_Post
// #define FN_GetAimVector_Post GetAimVector_Post
// #define FN_ServerCommand_Post ServerCommand_Post
// #define FN_ServerExecute_Post ServerExecute_Post
// #define FN_engClientCommand_Post engClientCommand_Post
// #define FN_ParticleEffect_Post ParticleEffect_Post
// #define FN_LightStyle_Post LightStyle_Post
// #define FN_DecalIndex_Post DecalIndex_Post
// #define FN_PointContents_Post PointContents_Post
// #define FN_MessageBegin_Post MessageBegin_Post
// #define FN_MessageEnd_Post MessageEnd_Post
// #define FN_WriteByte_Post WriteByte_Post
// #define FN_WriteChar_Post WriteChar_Post
// #define FN_WriteShort_Post WriteShort_Post
// #define FN_WriteLong_Post WriteLong_Post
// #define FN_WriteAngle_Post WriteAngle_Post
// #define FN_WriteCoord_Post WriteCoord_Post
// #define FN_WriteString_Post WriteString_Post
// #define FN_WriteEntity_Post WriteEntity_Post
// #define FN_CVarRegister_Post CVarRegister_Post
// #define FN_CVarGetFloat_Post CVarGetFloat_Post
// #define FN_CVarGetString_Post CVarGetString_Post
// #define FN_CVarSetFloat_Post CVarSetFloat_Post
// #define FN_CVarSetString_Post CVarSetString_Post
// #define FN_AlertMessage_Post AlertMessage_Post
// #define FN_EngineFprintf_Post EngineFprintf_Post
// #define FN_PvAllocEntPrivateData_Post PvAllocEntPrivateData_Post
// #define FN_PvEntPrivateData_Post PvEntPrivateData_Post
// #define FN_FreeEntPrivateData_Post FreeEntPrivateData_Post
// #define FN_SzFromIndex_Post SzFromIndex_Post
// #define FN_AllocString_Post AllocString_Post
// #define FN_GetVarsOfEnt_Post GetVarsOfEnt_Post
// #define FN_PEntityOfEntOffset_Post PEntityOfEntOffset_Post
// #define FN_EntOffsetOfPEntity_Post EntOffsetOfPEntity_Post
// #define FN_IndexOfEdict_Post IndexOfEdict_Post
// #define FN_PEntityOfEntIndex_Post PEntityOfEntIndex_Post
// #define FN_FindEntityByVars_Post FindEntityByVars_Post
// #define FN_GetModelPtr_Post GetModelPtr_Post
// #define FN_RegUserMsg_Post RegUserMsg_Post
// #define FN_AnimationAutomove_Post AnimationAutomove_Post
// #define FN_GetBonePosition_Post GetBonePosition_Post
// #define FN_FunctionFromName_Post FunctionFromName_Post
// #define FN_NameForFunction_Post NameForFunction_Post
// #define FN_ClientPrintf_Post ClientPrintf_Post
// #define FN_ServerPrint_Post ServerPrint_Post
// #define FN_Cmd_Args_Post Cmd_Args_Post
// #define FN_Cmd_Argv_Post Cmd_Argv_Post
// #define FN_Cmd_Argc_Post Cmd_Argc_Post
// #define FN_GetAttachment_Post GetAttachment_Post
// #define FN_CRC32_Init_Post CRC32_Init_Post
// #define FN_CRC32_ProcessBuffer_Post CRC32_ProcessBuffer_Post
// #define FN_CRC32_ProcessByte_Post CRC32_ProcessByte_Post
// #define FN_CRC32_Final_Post CRC32_Final_Post
// #define FN_RandomLong_Post RandomLong_Post
// #define FN_RandomFloat_Post RandomFloat_Post
// #define FN_SetView_Post SetView_Post
// #define FN_Time_Post Time_Post
// #define FN_CrosshairAngle_Post CrosshairAngle_Post
// #define FN_LoadFileForMe_Post LoadFileForMe_Post
// #define FN_FreeFile_Post FreeFile_Post
// #define FN_EndSection_Post EndSection_Post
// #define FN_CompareFileTime_Post CompareFileTime_Post
// #define FN_GetGameDir_Post GetGameDir_Post
// #define FN_Cvar_RegisterVariable_Post Cvar_RegisterVariable_Post
// #define FN_FadeClientVolume_Post FadeClientVolume_Post
// #define FN_SetClientMaxspeed_Post SetClientMaxspeed_Post
// #define FN_CreateFakeClient_Post CreateFakeClient_Post
// #define FN_RunPlayerMove_Post RunPlayerMove_Post
// #define FN_NumberOfEntities_Post NumberOfEntities_Post
// #define FN_GetInfoKeyBuffer_Post GetInfoKeyBuffer_Post
// #define FN_InfoKeyValue_Post InfoKeyValue_Post
// #define FN_SetKeyValue_Post SetKeyValue_Post
// #define FN_SetClientKeyValue_Post SetClientKeyValue_Post
// #define FN_IsMapValid_Post IsMapValid_Post
// #define FN_StaticDecal_Post StaticDecal_Post
// #define FN_PrecacheGeneric_Post PrecacheGeneric_Post
// #define FN_GetPlayerUserId_Post GetPlayerUserId_Post
// #define FN_BuildSoundMsg_Post BuildSoundMsg_Post
// #define FN_IsDedicatedServer_Post IsDedicatedServer_Post
// #define FN_CVarGetPointer_Post CVarGetPointer_Post
// #define FN_GetPlayerWONId_Post GetPlayerWONId_Post
// #define FN_Info_RemoveKey_Post Info_RemoveKey_Post
// #define FN_GetPhysicsKeyValue_Post GetPhysicsKeyValue_Post
// #define FN_SetPhysicsKeyValue_Post SetPhysicsKeyValue_Post
// #define FN_GetPhysicsInfoString_Post GetPhysicsInfoString_Post
// #define FN_PrecacheEvent_Post PrecacheEvent_Post
// #define FN_PlaybackEvent_Post PlaybackEvent_Post
// #define FN_SetFatPVS_Post SetFatPVS_Post
// #define FN_SetFatPAS_Post SetFatPAS_Post
// #define FN_CheckVisibility_Post CheckVisibility_Post
// #define FN_DeltaSetField_Post DeltaSetField_Post
// #define FN_DeltaUnsetField_Post DeltaUnsetField_Post
// #define FN_DeltaAddEncoder_Post DeltaAddEncoder_Post
// #define FN_GetCurrentPlayer_Post GetCurrentPlayer_Post
// #define FN_CanSkipPlayer_Post CanSkipPlayer_Post
// #define FN_DeltaFindField_Post DeltaFindField_Post
// #define FN_DeltaSetFieldByIndex_Post DeltaSetFieldByIndex_Post
// #define FN_DeltaUnsetFieldByIndex_Post DeltaUnsetFieldByIndex_Post
// #define FN_SetGroupMask_Post SetGroupMask_Post
// #define FN_engCreateInstancedBaseline_Post engCreateInstancedBaseline_Post
// #define FN_Cvar_DirectSet_Post Cvar_DirectSet_Post
// #define FN_ForceUnmodified_Post ForceUnmodified_Post
// #define FN_GetPlayerStats_Post GetPlayerStats_Post
// #define FN_AddServerCommand_Post AddServerCommand_Post
// #define FN_Voice_GetClientListening_Post Voice_GetClientListening_Post
// #define FN_Voice_SetClientListening_Post Voice_SetClientListening_Post
// #define FN_GetPlayerAuthId_Post GetPlayerAuthId_Post
// #define FN_OnFreeEntPrivateData OnFreeEntPrivateData
// #define FN_GameShutdown GameShutdown
// #define FN_ShouldCollide ShouldCollide
// #define FN_OnFreeEntPrivateData_Post OnFreeEntPrivateData_Post
// #define FN_GameShutdown_Post GameShutdown_Post
// #define FN_ShouldCollide_Post ShouldCollide_Post
#endif // USE_METAMOD
#endif // __MODULECONFIG_H__

View File

@ -1,567 +0,0 @@
/* AMX Mod X
* Sven Co-op Module
*
* by the AMX Mod X Development Team
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#include "svencoop.h"
//
// GLOBALS
//
const char g_weapon_names[24][24] =
{
"",
"weapon_crowbar",
"weapon_9mmhandgun",
"weapon_357",
"weapon_9mmAR",
"",
"weapon_crossbow",
"weapon_shotgun",
"weapon_rpg",
"weapon_gauss",
"weapon_egon",
"weapon_hornetgun",
"weapon_handgrenade",
"weapon_tripmine",
"weapon_satchel",
"weapon_snark",
"weapon_uziakimbo",
"weapon_uzi",
"weapon_medkit",
"weapon_crowbar_electric",
"weapon_pipewrench",
"weapon_minigun",
"weapon_grapple",
"weapon_sniperrifle"
};
const int g_ammo_offsets[25] =
{
-1, // NONE = 0
0, // SCW_CROWBAR = 1
OFFSET_9MM_AMMO, // SCW_9MMHANDGUN = 2
OFFSET_357_AMMO, // SCW_357 = 3
OFFSET_9MM_AMMO, // SCW_9MMAR = 4
-1, // NONE = 5
OFFSET_CROSSBOW_AMMO, // SCW_CROSSBOW = 6
OFFSET_SHOTGUN_AMMO, // SCW_SHOTGUN = 7
OFFSET_RPG_AMMO, // SCW_RPG = 8
OFFSET_ENERGY_AMMO, // SCW_GAUSS = 9
OFFSET_ENERGY_AMMO, // SCW_EGON = 10
OFFSET_HORNETGUN_AMMO, // SCW_HORNETGUN = 11
OFFSET_HANDGRENADE_AMMO,// SCW_HANDGRENADE = 12
OFFSET_TRIPMINE_AMMO, // SCW_TRIPMINE = 13
OFFSET_SATCHEL_AMMO, // SCW_SATCHEL = 14
OFFSET_SNARK_AMMO, // SCW_SNARK = 15
OFFSET_9MM_AMMO, // SCW_UZIAKIMBO = 16
OFFSET_9MM_AMMO, // SCW_UZI = 17
OFFSET_MEDKIT_AMMO, // SCW_MEDKIT = 18
0, // SCW_CROWBAR_ELECTRIC = 19
0, // SCW_PIPEWRENCH = 20
OFFSET_MINIGUN_AMMO, // SCW_MINIGUN = 21
0, // SCW_GRAPPLE = 22
OFFSET_SNIPERRIFLE_AMMO,// SCW_SNIPERRIFLE = 23
OFFSET_ARGRENADE_AMMO // SCW_ARGRENADE = 24
};
//
// MONSTER NATIVES
//
static cell AMX_NATIVE_CALL sc_get_frags(AMX *amx, cell *params) // sc_get_frags(index); = 1 arguments
{
// Gets a monster's or player's frags
// params[1] = monster/player index
// not CHECK_MONSTER because this works for players
CHECK_ENTITY(params[1]);
edict_t *pEdict = GETEDICT(params[1]);
if(!UTIL_IsPlayer(pEdict) && !UTIL_IsMonster(pEdict))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a player or monster_* entity", params[1], STRING(pEdict->v.classname));
return 0;
}
return amx_ftoc(*((float *)pEdict->pvPrivateData + OFFSET_MONSTER_FRAGS));
}
static cell AMX_NATIVE_CALL sc_set_frags(AMX *amx, cell *params) // sc_set_frags(index, Float:value); = 2 arguments
{
// Sets a monster's or player's frags
// params[1] = index = monster/player index
// params[2] = (float) new frags
// not CHECK_MONSTER because this works for players
CHECK_ENTITY(params[1]);
edict_t *pEdict = GETEDICT(params[1]);
if(!UTIL_IsPlayer(pEdict) && !UTIL_IsMonster(pEdict))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a player or monster_* entity", params[1], STRING(pEdict->v.classname));
return 0;
}
float fValue = amx_ctof(params[2]);
*((float *)pEdict->pvPrivateData + OFFSET_MONSTER_FRAGS) = fValue;
if(UTIL_IsPlayer(pEdict))
{
pEdict->v.frags = fValue;
// update scoreboard
if(gmsgScoreInfo)
{
MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo);
WRITE_BYTE(params[1]);
WRITE_SHORT((int)fValue);
WRITE_SHORT(*((int *)pEdict->pvPrivateData + OFFSET_PLAYER_DEATHS));
MESSAGE_END();
}
}
return 1;
}
static cell AMX_NATIVE_CALL sc_get_displayname(AMX *amx, cell *params) // sc_get_displayname(index, displayname[], len); = 3 arguments
{
// Gets a monster's displayname
// params[1] = monster index
// params[2] = return variable
// params[3] = variable len
// check non-player (could be squadmaker)
CHECK_NONPLAYER(params[1]);
edict_t *pEdict = INDEXENT(params[1]);
// check valid types
const char *classname = STRING(pEdict->v.classname);
if(strcmp(classname, "squadmaker") != 0 && strncmp(classname, "monster", 7) != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a monstermaker, squadmaker, or monster_* entity", params[1], classname);
return 0;
}
// check for a custom one
const char *displayname = STRING(pEdict->v.message);
if(displayname[0])
{
MF_SetAmxString(amx, params[2], displayname, params[3]);
return 1; // 1 means custom displayname
}
// maybe from a monstermaker? use its displayname.
if(!strncmp(classname, "monster_", 8) && !FNullEnt(pEdict->v.owner))
{
const char *ownerclass = STRING(pEdict->v.owner->v.classname);
if(!strcmp(ownerclass, "squadmaker") || !strcmp(ownerclass, "monstermaker"))
{
displayname = STRING(pEdict->v.owner->v.message);
if(displayname[0])
{
return MF_SetAmxString(amx, params[2], displayname, params[3]);
return 1; // 1 means custom displayname
}
}
}
String *name = NULL;
if(*((int *)pEdict->pvPrivateData + OFFSET_MONSTER_ALLY))
name = g_allyNameTrie.Retrieve(classname, strlen(classname));
else
name = g_enemyNameTrie.Retrieve(classname, strlen(classname));
if(name != NULL)
{
MF_SetAmxString(amx, params[2], name->c_str(), params[3]);
return -1; // -1 means default displayname
}
return 0; // invalid monster
}
static cell AMX_NATIVE_CALL sc_set_displayname(AMX *amx, cell *params) // sc_set_displayname(index, displayname[], {Float,Sql,Result,_}:...); = 2 arguments
{
// Sets a monster's displayname
// params[1] = monster index
// params[2] = new displayname
// params[3...] = formatting
// check non-player (could be squadmaker)
CHECK_NONPLAYER(params[1]);
edict_t *pEdict = INDEXENT(params[1]);
// check valid types
const char *classname = STRING(pEdict->v.classname);
if(strcmp(classname, "squadmaker") != 0 && strncmp(classname, "monster", 7) != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a monstermaker, squadmaker, or monster_* entity", params[1], classname);
return 0;
}
// fetch string
int len = 0;
char *displayname = MF_FormatAmxString(amx, params, 2, &len);
// set_kvd
KeyValueData *kvd = &g_kvd;
kvd->szClassName = const_cast<char *>(classname);
kvd->szKeyName = const_cast<char *>("displayname");
kvd->szValue = const_cast<char *>(displayname);
kvd->fHandled = 0;
gpGamedllFuncs->dllapi_table->pfnKeyValue(pEdict, kvd);
// remember it
pEdict->v.message = ALLOC_STRING(displayname);
return 1;
}
static cell AMX_NATIVE_CALL sc_is_player_ally(AMX *amx, cell *params) // sc_is_player_ally(index); = 1 arguments
{
// Checks if a monster is a player ally
// params[1] = monster index
CHECK_MONSTER(params[1]);
edict_t *pEdict = INDEXENT(params[1]);
return *((int *)pEdict->pvPrivateData + OFFSET_MONSTER_ALLY);
}
//
// PLAYER NATIVES
// (ammo excluded)
//
static cell AMX_NATIVE_CALL sc_get_user_longjump(AMX *amx, cell *params) // sc_get_user_longjump(index); = 1 arguments
{
// Checks if a player can longjump
// params[1] = player index
CHECK_PLAYER(params[1]);
edict_t *pEdict = MF_GetPlayerEdict(params[1]);
const char *buffer = (*g_engfuncs.pfnGetPhysicsKeyValue)(pEdict, "slj");
if(buffer[0] == '1') return 1;
return 0;
}
static cell AMX_NATIVE_CALL sc_set_user_longjump(AMX *amx, cell *params) // sc_set_user_longjump(index, value); = 2 arguments
{
// Sets if a player can longjump
// params[1] = player index
// params[2] = new value
CHECK_PLAYER(params[1]);
edict_t *pEdict = MF_GetPlayerEdict(params[1]);
if(params[2]) (*g_engfuncs.pfnSetPhysicsKeyValue)(pEdict, "slj", "1");
else (*g_engfuncs.pfnSetPhysicsKeyValue)(pEdict, "slj", "0");
return 1;
}
static cell AMX_NATIVE_CALL sc_get_user_deaths(AMX *amx, cell *params) // sc_get_user_deaths(index); = 1 arguments
{
// Gets the number of times a player has died (duh!)
// params[1] = player index
CHECK_PLAYER(params[1]);
edict_t *pEdict = MF_GetPlayerEdict(params[1]);
return *((int *)pEdict->pvPrivateData + OFFSET_PLAYER_DEATHS);
}
static cell AMX_NATIVE_CALL sc_set_user_deaths(AMX *amx, cell *params) // sc_set_user_deaths(index, value); = 2 arguments
{
// Sets the number of times a player has died
// params[1] = player index
// params[2] = new death amount
CHECK_PLAYER(params[1]);
edict_t *pEdict = MF_GetPlayerEdict(params[1]);
*((int *)pEdict->pvPrivateData + OFFSET_PLAYER_DEATHS) = params[2];
// update scoreboard
if(gmsgScoreInfo)
{
MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo);
WRITE_BYTE(params[1]);
WRITE_SHORT((int)pEdict->v.frags);
WRITE_SHORT(params[2]);
MESSAGE_END();
}
*static_cast<int *>(MF_PlayerPropAddr(params[1], Player_Deaths)) = params[2];
return 1;
}
//
// AMMO NATIVES
//
static cell AMX_NATIVE_CALL sc_get_wbox_ammo(AMX *amx, cell *params) // sc_get_wbox_ammo(index); = 1 arguments
{
// Gets the amount of ammo in dropped ammo weaponbox
// params[1] = weaponbox entity index
CHECK_NONPLAYER(params[1]);
edict_t *pEdict = INDEXENT(params[1]);
if(strcmp(STRING(pEdict->v.classname), "weaponbox") != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a weaponbox entity", params[1], STRING(pEdict->v.classname));
return 0;
}
return *((int *)pEdict->pvPrivateData + OFFSET_WBOX_AMMO);
}
static cell AMX_NATIVE_CALL sc_set_wbox_ammo(AMX *amx, cell *params) // sc_set_wbox_ammo(index, value); = 1 arguments
{
// Sets the amount of ammo in dropped ammo weaponbox
// params[1] = weaponbox entity index
// params[2] = new ammo amount
CHECK_NONPLAYER(params[1]);
edict_t *pEdict = INDEXENT(params[1]);
if(strcmp(STRING(pEdict->v.classname), "weaponbox") != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a weaponbox entity", params[1], STRING(pEdict->v.classname));
return 0;
}
*((int *)pEdict->pvPrivateData + OFFSET_WBOX_AMMO) = params[2];
return 1;
}
static cell AMX_NATIVE_CALL sc_get_weapon_id(AMX *amx, cell *params) // sc_get_weapon_id(index); = 1 arguments
{
// Gets the SCW_* constant of a weapon_* entity
// params[1] = weapon_* entity index
CHECK_NONPLAYER(params[1]);
edict_t *pEdict = INDEXENT(params[1]);
// not a valid weapon_*
if(strncmp(STRING(pEdict->v.classname), "weapon_", 7) != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a weapon_* entity", params[1], STRING(pEdict->v.classname));
return 0;
}
return *((int *)pEdict->pvPrivateData + OFFSET_WEAPON_TYPE);
}
static cell AMX_NATIVE_CALL sc_get_weapon_ammo(AMX *amx, cell *params) // sc_get_weapon_ammo(index1, index2=0); = 2 arguments
{
// Gets the amount of ammo in weapon's clip
// params[1] = weapon_* entity index OR player index
// params[2] = (optional) SCW_* constant if using player index
CHECK_ENTITY(params[1]);
edict_t *pEdict = GETEDICT(params[1]);
// sc_get_weapon_ammo(id, SCW_9MMAR);
if(params[2])
{
if(params[2] < 1 || params[2] > 23 || params[2] == 5)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon index %d", params[2]);
return 0;
}
CHECK_PLAYER(params[1]);
edict_t *pWeapon = NULL;
const char *weaponname = g_weapon_names[params[2]];
while(true)
{
pWeapon = FIND_ENTITY_BY_STRING(pWeapon, "classname", weaponname);
if(FNullEnt(pWeapon) || pWeapon->v.owner == pEdict) break;
}
if(FNullEnt(pWeapon))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d does not have a \"%s\" (index %d)", params[1], weaponname, params[2]);
return 0;
}
return *((int *)pWeapon->pvPrivateData + OFFSET_WEAPON_CLIP);
}
if(strncmp(STRING(pEdict->v.classname), "weapon_", 7) != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a weapon_* entity", params[1], STRING(pEdict->v.classname));
return 0;
}
return *((int *)pEdict->pvPrivateData + OFFSET_WEAPON_CLIP);
}
static cell AMX_NATIVE_CALL sc_set_weapon_ammo(AMX *amx, cell *params) // sc_set_weapon_ammo(index1, value, index2=0); = 3 arguments
{
// Sets the amount of ammo in weapon's clip
// params[1] = weapon_* entity index OR player index
// params[2] = new clip ammo
// params[3] = (optional) SCW_* constant if using player index
CHECK_ENTITY(params[1]);
edict_t *pEdict = GETEDICT(params[1]);
// sc_set_weapon_ammo(id, SCW_9MMAR, 50);
if(params[3])
{
if(params[3] < 1 || params[3] > 23 || params[3] == 5)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon index %d", params[3]);
return 0;
}
CHECK_PLAYER(params[1]);
edict_t *pWeapon = NULL;
const char *weaponname = g_weapon_names[params[3]];
while(true)
{
pWeapon = FIND_ENTITY_BY_STRING(pWeapon, "classname", weaponname);
if(FNullEnt(pWeapon) || pWeapon->v.owner == pEdict) break;
}
if(FNullEnt(pWeapon))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d does not have a \"%s\" (index %d)", params[1], weaponname, params[3]);
return 0;
}
*((int *)pWeapon->pvPrivateData + OFFSET_WEAPON_CLIP) = params[2];
return 1;
}
if(strncmp(STRING(pEdict->v.classname), "weapon_", 7) != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a weapon_* entity", params[1], STRING(pEdict->v.classname));
return 0;
}
*((int *)pEdict->pvPrivateData + OFFSET_WEAPON_CLIP) = params[2];
return 1;
}
static cell AMX_NATIVE_CALL sc_get_user_bpammo(AMX *amx, cell *params) // sc_get_user_bpammo(index, weapon); = 2 arguments
{
// Gets the amount of ammo in player's backpack for a specific weapon
// params[1] = player index
// params[2] = SCW_* constant
CHECK_PLAYER(params[1]);
edict_t *pEdict = MF_GetPlayerEdict(params[1]);
if(params[2] < 1 || params[2] > 23 || params[2] == 5)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon index %d", params[2]);
return 0;
}
// invalid weapon or no bpammo
if(g_ammo_offsets[params[2]] <= 0)
return 0;
return *((int *)pEdict->pvPrivateData + g_ammo_offsets[params[2]]);
}
static cell AMX_NATIVE_CALL sc_set_user_bpammo(AMX *amx, cell *params) // sc_set_user_bpammo(index, weapon, value); = 3 arguments
{
// Gets the amount of ammo in player's backpack for a specific weapon
// params[1] = player index
// params[2] = SCW_* constant
// params[3] = new backpack ammo
CHECK_PLAYER(params[1]);
edict_t *pEdict = MF_GetPlayerEdict(params[1]);
if(params[2] < 1 || params[2] > 23 || params[2] == 5)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weapon index %d", params[2]);
return 0;
}
// invalid weapon or no bpammo
if(g_ammo_offsets[params[2]] <= 0)
return 0;
*((int *)pEdict->pvPrivateData + g_ammo_offsets[params[2]]) = params[3];
return 1;
}
//
// EXPORT LIST
//
AMX_NATIVE_INFO svencoop_Exports[] =
{
// monster natives
{"sc_get_frags", sc_get_frags},
{"sc_set_frags", sc_set_frags},
{"sc_get_displayname", sc_get_displayname},
{"sc_set_displayname", sc_set_displayname},
{"sc_is_player_ally", sc_is_player_ally},
// player natives
{"sc_get_user_longjump", sc_get_user_longjump},
{"sc_set_user_longjump", sc_set_user_longjump},
{"sc_get_user_deaths", sc_get_user_deaths},
{"sc_set_user_deaths", sc_set_user_deaths},
// ammo natives
{"sc_get_wbox_ammo", sc_get_wbox_ammo},
{"sc_set_wbox_ammo", sc_set_wbox_ammo},
{"sc_get_weapon_id", sc_get_weapon_id},
{"sc_get_weapon_ammo", sc_get_weapon_ammo},
{"sc_set_weapon_ammo", sc_set_weapon_ammo},
{"sc_get_user_bpammo", sc_get_user_bpammo},
{"sc_set_user_bpammo", sc_set_user_bpammo},
//------------------- <-- max 19 characters?? bleh!
{NULL, NULL}
};

View File

@ -1,239 +0,0 @@
/* AMX Mod X
* Sven Co-op Module
*
* by the AMX Mod X Development Team
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
#include <extdll.h>
#include <meta_api.h>
#include "amxxmodule.h"
#include "CString.h"
#include "Trie.h"
// right now there is no Linux Sven Co-op, but for the future...
#if defined __linux__
#define EXTRAOFFSET_MONSTER 0
#define EXTRAOFFSET_WEAPON 0
#define EXTRAOFFSET_WBOX 0
#define EXTRAOFFSET_PLAYER 0
#else
#define EXTRAOFFSET_MONSTER 0
#define EXTRAOFFSET_WEAPON 0
#define EXTRAOFFSET_WBOX 0
#define EXTRAOFFSET_PLAYER 0
#endif // defined __linux__
// 32-bit
#if !defined __amd64__
#define OFFSET_LAST_HEALTH 834 // arbitrary, our own storage
// monster offsets
#define OFFSET_MONSTER_FRAGS 9 + EXTRAOFFSET_MONSTER
#define OFFSET_MONSTER_ALLY 10 + EXTRAOFFSET_MONSTER
// player offsets (non-ammo)
#define OFFSET_PLAYER_DEATHS 8624 + EXTRAOFFSET_PLAYER
// weapon offsets
#define OFFSET_WEAPON_TYPE 8224 + EXTRAOFFSET_WEAPON
#define OFFSET_WEAPON_CLIP 8233 + EXTRAOFFSET_WBOX
#define OFFSET_WBOX_AMMO 8255 + EXTRAOFFSET_WBOX
// ammo offsets
#define OFFSET_357_AMMO 8563 + EXTRAOFFSET_PLAYER
#define OFFSET_9MM_AMMO 8557 + EXTRAOFFSET_PLAYER
#define OFFSET_CROSSBOW_AMMO 8566 + EXTRAOFFSET_PLAYER
#define OFFSET_SHOTGUN_AMMO 8558 + EXTRAOFFSET_PLAYER
#define OFFSET_RPG_AMMO 8565 + EXTRAOFFSET_PLAYER
#define OFFSET_ENERGY_AMMO 8564 + EXTRAOFFSET_PLAYER
#define OFFSET_HORNETGUN_AMMO 8571 + EXTRAOFFSET_PLAYER
#define OFFSET_HANDGRENADE_AMMO 8569 + EXTRAOFFSET_PLAYER
#define OFFSET_TRIPMINE_AMMO 8567 + EXTRAOFFSET_PLAYER
#define OFFSET_SATCHEL_AMMO 8568 + EXTRAOFFSET_PLAYER
#define OFFSET_SNARK_AMMO 8570 + EXTRAOFFSET_PLAYER
#define OFFSET_MEDKIT_AMMO 8559 + EXTRAOFFSET_PLAYER
#define OFFSET_MINIGUN_AMMO 8560 + EXTRAOFFSET_PLAYER
#define OFFSET_SNIPERRIFLE_AMMO 8561 + EXTRAOFFSET_PLAYER
#define OFFSET_ARGRENADE_AMMO 8562 + EXTRAOFFSET_PLAYER
// 64-bit (no amd64 Sven Co-op, but thinking ahead)
#else
#define OFFSET_OLD_HEALTH 834
// monster offsets
#define OFFSET_MONSTER_FRAGS 9 + EXTRAOFFSET_MONSTER
#define OFFSET_MONSTER_ALLY 10 + EXTRAOFFSET_MONSTER
// player offsets (non-ammo)
#define OFFSET_PLAYER_DEATHS 8624 + EXTRAOFFSET_PLAYER
// weapon offsets
#define OFFSET_WEAPON_TYPE 8224 + EXTRAOFFSET_WEAPON
#define OFFSET_WEAPON_CLIP 8233 + EXTRAOFFSET_WBOX
#define OFFSET_WBOX_AMMO 8255 + EXTRAOFFSET_WBOX
// ammo offsets
#define OFFSET_357_AMMO 8563 + EXTRAOFFSET_PLAYER
#define OFFSET_9MM_AMMO 8557 + EXTRAOFFSET_PLAYER
#define OFFSET_CROSSBOW_AMMO 8566 + EXTRAOFFSET_PLAYER
#define OFFSET_SHOTGUN_AMMO 8558 + EXTRAOFFSET_PLAYER
#define OFFSET_RPG_AMMO 8565 + EXTRAOFFSET_PLAYER
#define OFFSET_ENERGY_AMMO 8564 + EXTRAOFFSET_PLAYER
#define OFFSET_HORNETGUN_AMMO 8571 + EXTRAOFFSET_PLAYER
#define OFFSET_HANDGRENADE_AMMO 8569 + EXTRAOFFSET_PLAYER
#define OFFSET_TRIPMINE_AMMO 8567 + EXTRAOFFSET_PLAYER
#define OFFSET_SATCHEL_AMMO 8568 + EXTRAOFFSET_PLAYER
#define OFFSET_SNARK_AMMO 8570 + EXTRAOFFSET_PLAYER
#define OFFSET_MEDKIT_AMMO 8559 + EXTRAOFFSET_PLAYER
#define OFFSET_MINIGUN_AMMO 8560 + EXTRAOFFSET_PLAYER
#define OFFSET_SNIPERRIFLE_AMMO 8561 + EXTRAOFFSET_PLAYER
#define OFFSET_ARGRENADE_AMMO 8562 + EXTRAOFFSET_PLAYER
#endif
// weapon ids
enum
{
SCW_CROWBAR = 1,
SCW_9MMHANDGUN = 2,
SCW_357 = 3,
SCW_9MMAR = 4,
SCW_CROSSBOW = 6,
SCW_SHOTGUN = 7,
SCW_RPG = 8,
SCW_GAUSS = 9,
SCW_EGON = 10,
SCW_HORNETGUN = 11,
SCW_HANDGRENADE = 12,
SCW_TRIPMINE = 13,
SCW_SATCHEL = 14,
SCW_SNARK = 15,
SCW_UZIAKIMBO = 16,
SCW_UZI = 17,
SCW_MEDKIT = 18,
SCW_CROWBAR_ELECTRIC = 19,
SCW_PIPEWRENCH = 20,
SCW_MINIGUN = 21,
SCW_GRAPPLE = 22,
SCW_SNIPERRIFLE = 23,
SCW_ARGRENADE = 24
};
//
// externs
//
extern AMX_NATIVE_INFO svencoop_Exports[];
extern int gmsgScoreInfo;
extern KeyValueData g_kvd;
extern Trie<char,String> g_allyNameTrie, g_enemyNameTrie;
//
// inline functions
//
inline bool UTIL_IsPlayer(edict_t *pPlayer)
{
if(strcmp(STRING(pPlayer->v.classname), "player") == 0)
return true;
return false;
}
inline bool UTIL_IsMonster(edict_t *pMonster)
{
if(strncmp(STRING(pMonster->v.classname), "monster_", 8) == 0)
return true;
return false;
}
//
// entity checking defines
//
#define CHECK_ENTITY(x) \
if (x <= 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#define CHECK_PLAYER(x) \
if (x < 1 || x > gpGlobals->maxClients) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \
} else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \
} \
}
#define CHECK_NONPLAYER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \
return 0; \
} \
}
#define CHECK_MONSTER(x) \
if (x < 1 || x <= gpGlobals->maxClients || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Monster entity %d out of range", x); \
return 0; \
} else { \
if (FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid monster entity %d", x); \
return 0; \
} else { \
if(strncmp(STRING(GETEDICT(x)->v.classname),"monster_",8) != 0) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a monster_* entity", x, STRING(GETEDICT(x)->v.classname)); \
return 0; \
} \
} \
}
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))

View File

@ -1,104 +0,0 @@
/* Sven Co-op functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _svencoop_included
#endinput
#endif
#define _svencoop_included
#include <svencoop_const>
/* Gets a monster's or player's frags */
native Float:sc_get_frags(index);
/* Sets a monster's or player's frags */
native sc_set_frags(index, Float:value);
/* Gets a monster's displayname
Returns 1 if custom displayname, 0 if displayname unavailable, -1 if default displayname
*/
native sc_get_displayname(index, displayname[], len);
/* Sets a monster's displayname */
native sc_set_displayname(index, displayname[], {Float,Sql,Result,_}:...);
/* Checks if a monster is a player ally or not */
native sc_is_player_ally(index);
/* Gets if a player has longjump */
native sc_get_user_longjump(index);
/* Sets if a player has longjump */
native sc_set_user_longjump(index, value);
/* Gets a player's deaths */
native sc_get_user_deaths(index);
/* Sets a player's deaths */
native sc_set_user_deaths(index, value);
/* Gets the amount of ammo in dropped ammo weaponbox */
native sc_get_wbox_ammo(index);
/* Sets the amount of ammo in dropped ammo weaponbox */
native sc_set_wbox_ammo(index, value);
/* Gets a weapon's type (in the form of SCW_* constants)
"index" = weapon_* entity
*/
native sc_get_weapon_id(index);
/* Gets the amount of ammo in weapon's clip
Usage 1:
new weapon = find_ent_by_owner(-1,"weapon_9mmAR",id);
sc_get_weapon_ammo(weapon);
Usage 2:
sc_get_weapon_ammo(id,SCW_9MMAR);
*/
native sc_get_weapon_ammo(index1, index2=0);
/* Sets the amount of ammo in weapon's clip
Usage 1:
new weapon = find_ent_by_owner(-1,"weapon_9mmAR",id);
sc_set_weapon_ammo(weapon,50);
Usage 2:
sc_set_weapon_ammo(id,50,SCW_9MMAR);
*/
native sc_set_weapon_ammo(index1, newammo, index2=0);
/* Gets the amount of ammo in players's backpack for a specific weapon
"weapon" = SCW_* constant
*/
native sc_get_user_bpammo(index, weapon);
/* Sets the amount of ammo in players's backpack for a specific weapon
"weapon" = SCW_* constant
*/
native sc_set_user_bpammo(index, weapon, value);
/* Called whenever a player respawns */
forward sc_client_spawn(index);
/* Called whenever a player or monster throws a grenade
"isplayer" is 1 if the thrower is a player, 0 if a monster
*/
forward sc_grenade_throw(index, greindex, wId, isplayer);
/* Called whenever a player ATTEMPTS to heal another player or monster
(so, they could be healing for 0.0 health, or trying to heal an enemy)
"isplayer" is 1 if the healed entity is a player, 0 if a monster
"isally" is 1 if the healed entity is an ally, 0 if an enemy
*/
forward sc_client_heal(healer, healed, Float:amount, isplayer, isally);

View File

@ -1,98 +0,0 @@
/* Sven Co-op functions
*
* (c) 2007, XxAvalanchexX
* This file is provided as is (no warranties).
*/
#if defined _svencoop_const_included
#endinput
#endif
#define _svencoop_const_included
/* SvenCoop weapons */
enum
{
SCW_CROWBAR = 1,
SCW_9MMHANDGUN = 2, // ammo_9mmAR, ammo_9mmbox, ammo_9mmclip, ammo_glockclip, ammo_mp5clip
SCW_357 = 3, // ammo_357
SCW_9MMAR = 4, // ammo_9mmAR, ammo_9mmbox, ammo_9mmclip, ammo_glockclip, ammo_mp5clip,
SCW_CROSSBOW = 6, // ammo_crossbow
SCW_SHOTGUN = 7, // ammo_buckshot
SCW_RPG = 8, // ammo_rpgclip
SCW_GAUSS = 9, // ammo_egonclip, ammo_gaussclip
SCW_EGON = 10, // ammo_egonclip, ammo_gaussclip
SCW_HORNETGUN = 11,
SCW_HANDGRENADE = 12,
SCW_TRIPMINE = 13,
SCW_SATCHEL = 14,
SCW_SNARK = 15,
SCW_UZIAKIMBO = 16, // ammo_9mmAR, ammo_9mmbox, ammo_9mmclip, ammo_glockclip, ammo_mp5clip
SCW_UZI = 17, // ammo_9mmAR, ammo_9mmbox, ammo_9mmclip, ammo_glockclip, ammo_mp5clip
SCW_MEDKIT = 18,
SCW_CROWBAR_ELECTRIC = 19, // item_battery
SCW_PIPEWRENCH = 20,
SCW_MINIGUN = 21, // ammo_556
SCW_GRAPPLE = 22,
SCW_SNIPERRIFLE = 23, // ammo_762
// USE ONLY FOR sc_*et_user_bpammo NATIVES!
SCW_ARGRENADE = 24 // ammo_ARgrenades, ammo_mp5grenades
};
stock const SCW_MAX_CLIP[25] =
{
-1, // NONE = 0
0, // SCW_CROWBAR = 1
17, // SCW_9MMHANDGUN = 2
6, // SCW_357 = 3
50, // SCW_9MMAR = 4
-1, // NONE = 5
5, // SCW_CROSSBOW = 6
8, // SCW_SHOTGUN = 7
1, // SCW_RPG = 8
0, // SCW_GAUSS = 9
0, // SCW_EGON = 10
0, // SCW_HORNETGUN = 11
0, // SCW_HANDGRENADE = 12
0, // SCW_TRIPMINE = 13
0, // SCW_SATCHEL = 14
0, // SCW_SNARK = 15
32, // SCW_UZIAKIMBO = 16
32, // SCW_UZI = 17
0, // SCW_MEDKIT = 18
0, // SCW_CROWBAR_ELECTRIC = 19
0, // SCW_PIPEWRENCH = 20
0, // SCW_MINIGUN = 21
0, // SCW_GRAPPLE = 22
5, // SCW_SNIPERRIFLE = 23
0 // SCW_ARGRENADE = 24
}
stock const SCW_MAX_AMMO[25] =
{
-1, // NONE = 0
0, // SCW_CROWBAR = 1
250, // SCW_9MMHANDGUN = 2
36, // SCW_357 = 3
250, // SCW_9MMAR = 4
-1, // NONE = 5
50, // SCW_CROSSBOW = 6
125, // SCW_SHOTGUN = 7
5, // SCW_RPG = 8
100, // SCW_GAUSS = 9
100, // SCW_EGON = 10
8, // SCW_HORNETGUN = 11
10, // SCW_HANDGRENADE = 12
5, // SCW_TRIPMINE = 13
5, // SCW_SATCHEL = 14
15, // SCW_SNARK = 15
250, // SCW_UZIAKIMBO = 16
250, // SCW_UZI = 17
100, // SCW_MEDKIT = 18
0, // SCW_CROWBAR_ELECTRIC = 19
0, // SCW_PIPEWRENCH = 20
999, // SCW_MINIGUN = 21
0, // SCW_GRAPPLE = 22
15, // SCW_SNIPERRIFLE = 23
10 // SCW_ARGRENADE = 24
}