Synced to Twilight's stuff

This commit is contained in:
David Anderson 2005-08-25 07:12:52 +00:00
parent a17b879380
commit b271b01b13
6 changed files with 210 additions and 68 deletions

View File

@ -97,6 +97,7 @@ void Client_ClipInfo(void* mValue)
void Client_TSHealth_End(void* mValue) void Client_TSHealth_End(void* mValue)
{ {
edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor; edict_t *enemy = mPlayer->pEdict->v.dmg_inflictor;
int damage = (int)mPlayer->pEdict->v.dmg_take; int damage = (int)mPlayer->pEdict->v.dmg_take;
@ -227,6 +228,15 @@ void Client_TSHealth_End(void* mValue)
pAttacker->killFlags = killFlags; pAttacker->killFlags = killFlags;
} }
void Client_TSState(void* mValue)
{
mPlayer->oldstate = mPlayer->state;
mPlayer->checkstate = 1;
mPlayer->state = *(int*)mValue;
}
void Client_WStatus(void* mValue) void Client_WStatus(void* mValue)
{ {
switch(mState++) switch(mState++)
@ -240,11 +250,6 @@ void Client_WStatus(void* mValue)
} }
} }
void Client_TSSpace(void* mValue)
{
mPlayer->space = *(int*)mValue;
}
void Client_PwUp(void* mValue) void Client_PwUp(void* mValue)
{ {
static int iPwType; static int iPwType;

View File

@ -1,54 +1,5 @@
#include "tsfun.h" #include "tsfun.h"
funEventCall modMsgsEnd[MAX_REG_MSGS];
funEventCall modMsgs[MAX_REG_MSGS];
void (*function)(void*);
void (*endfunction)(void*);
CPlayer* mPlayer;
int mPlayerIndex;
int mState;
CPlayer players[33];
int gKnifeOffset;
int gmsgResetHUD;
int gmsgWeaponInfo;
int gmsgClipInfo;
int gmsgScoreInfo;
int gmsgTSHealth;
int gmsgWStatus;
int gmsgTSCash;
int gmsgTSSpace;
int gmsgPwUp;
struct sUserMsg {
const char* name;
int* id;
funEventCall func;
bool endmsg;
} g_user_msg[] = {
{ "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true },
{ "WeaponInfo",&gmsgWeaponInfo,Client_WeaponInfo,false },
{ "ClipInfo",&gmsgClipInfo,Client_ClipInfo,false },
{ "ScoreInfo",&gmsgScoreInfo,Client_ScoreInfo,false },
{ "TSHealth",&gmsgTSHealth,Client_TSHealth_End,true },
{ "WStatus",&gmsgWStatus,Client_WStatus,false },
{ "TSSpace",&gmsgTSSpace,Client_TSSpace,false },
{ "PwUp",&gmsgPwUp,Client_PwUp,false},
{ 0,0,0,false }
};
const char* get_localinfo( const char* name , const char* def = 0 )
{
const char* b = LOCALINFO( (char*)name );
if (((b==0)||(*b==0)) && def )
SET_LOCALINFO((char*)name,(char*)(b = def) );
return b;
}
weapon_t weaponData[] = { weapon_t weaponData[] = {
{ 1,"Kung Fu","kung_fu",3 }, // id 0 like in WeaponInfo , DeathMsg { 1,"Kung Fu","kung_fu",3 }, // id 0 like in WeaponInfo , DeathMsg
{ 0,"Glock-18","glock-18",1 }, { 0,"Glock-18","glock-18",1 },

View File

@ -153,6 +153,19 @@ static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params)
} }
static cell AMX_NATIVE_CALL get_user_state(AMX *amx, cell *params)
{
int id = params[1];
CHECK_PLAYER(id);
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if(!pPlayer->ingame) return 0;
return pPlayer->state;
}
static cell AMX_NATIVE_CALL set_user_cash(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_user_cash(AMX *amx, cell *params)
{ {
int id = params[1]; int id = params[1];
@ -174,7 +187,6 @@ static cell AMX_NATIVE_CALL get_user_cash(AMX *amx, cell *params)
} }
static cell AMX_NATIVE_CALL set_user_slots(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_user_slots(AMX *amx, cell *params)
{ {
int id = params[1]; int id = params[1];
@ -194,13 +206,6 @@ static cell AMX_NATIVE_CALL get_user_slots(AMX *amx, cell *params)
return pPlayer->GetSlots(); return pPlayer->GetSlots();
} }
static cell AMX_NATIVE_CALL get_user_space(AMX *amx, cell *params){
int id = params[1];
CHECK_PLAYER(id);
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
return pPlayer->space;
}
static cell AMX_NATIVE_CALL get_user_pwup(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_user_pwup(AMX *amx, cell *params)
{ {
@ -493,7 +498,6 @@ static cell AMX_NATIVE_CALL get_consecutive_frags(AMX *amx, cell *params)
CHECK_PLAYER(id); CHECK_PLAYER(id);
return pPlayer->GetOffsetInt(433); return pPlayer->GetOffsetInt(433);
} }
static cell AMX_NATIVE_CALL set_consecutive_frags(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_consecutive_frags(AMX *amx, cell *params)
@ -681,6 +685,8 @@ AMX_NATIVE_INFO base_Natives[] = {
//**************************************** //****************************************
{ "ts_getuserstate", get_user_state },
{ "ts_getusercash", get_user_cash }, { "ts_getusercash", get_user_cash },
{ "ts_setusercash", set_user_cash }, { "ts_setusercash", set_user_cash },
@ -690,7 +696,7 @@ AMX_NATIVE_INFO base_Natives[] = {
{ "ts_getusertime",get_usertime }, { "ts_getusertime",get_usertime },
{ "ts_setusertime",set_usertime}, { "ts_setusertime",set_usertime},
{ "ts_getuserspace", get_user_space }, { "ts_getuserspace", get_user_slots },
{ "ts_getuserpwup",get_user_pwup }, { "ts_getuserpwup",get_user_pwup },
{ "ts_getuseritems",get_user_items }, { "ts_getuseritems",get_user_items },

View File

@ -77,7 +77,9 @@ struct CPlayer {
int aiming; int aiming;
int current; int current;
int space; int checkstate;
int state;
int oldstate;
int PwUp; int PwUp;
int PwUpValue; int PwUpValue;
int items; // "stale" przedmioty , super jump i kung fu bonus int items; // "stale" przedmioty , super jump i kung fu bonus

View File

@ -32,8 +32,61 @@
#include "tsfun.h" #include "tsfun.h"
#include "CNatives.h" #include "CNatives.h"
funEventCall modMsgsEnd[MAX_REG_MSGS];
funEventCall modMsgs[MAX_REG_MSGS];
void (*function)(void*);
void (*endfunction)(void*);
CPlayer* mPlayer;
int mPlayerIndex;
int mState;
CPlayer players[33];
int gKnifeOffset;
int gmsgResetHUD;
int gmsgWeaponInfo;
int gmsgClipInfo;
int gmsgScoreInfo;
int gmsgTSHealth;
int gmsgWStatus;
int gmsgTSCash;
int gmsgTSState;
int gmsgPwUp;
struct sUserMsg {
const char* name;
int* id;
funEventCall func;
bool endmsg;
} g_user_msg[] = {
{ "ResetHUD",&gmsgResetHUD,Client_ResetHUD_End,true },
{ "WeaponInfo",&gmsgWeaponInfo,Client_WeaponInfo,false },
{ "ClipInfo",&gmsgClipInfo,Client_ClipInfo,false },
{ "ScoreInfo",&gmsgScoreInfo,Client_ScoreInfo,false },
{ "TSHealth",&gmsgTSHealth,Client_TSHealth_End,true },
{ "TSState",&gmsgTSState,Client_TSState,false },
{ "WStatus",&gmsgWStatus,Client_WStatus,false },
{ "PwUp",&gmsgPwUp,Client_PwUp,false},
{ 0,0,0,false }
};
const char* get_localinfo( const char* name , const char* def = 0 )
{
const char* b = LOCALINFO( (char*)name );
if (((b==0)||(*b==0)) && def )
SET_LOCALINFO((char*)name,(char*)(b = def) );
return b;
}
int Powerup = -1; int Powerup = -1;
int KungFoo = -1; //-1 is an invalid forward so initiate this to that int KungFoo = -1; //-1 is an invalid forward so initiate this to that
int Death = -1;
int Damage = -1;
int Stunt = -1;
void OnPluginsLoaded() void OnPluginsLoaded()
{ {
@ -42,8 +95,11 @@ void OnPluginsLoaded()
//FP_CELL - first parameter is a normal cell //FP_CELL - first parameter is a normal cell
//FP_CELL - second parameter is a normal cell //FP_CELL - second parameter is a normal cell
//FP_DONE - that's the end of the parameter descriptions //FP_DONE - that's the end of the parameter descriptions
KungFoo = MF_RegisterForward("KungFoo_Attack", ET_STOP, FP_CELL, FP_FLOAT,FP_FLOAT, FP_DONE); KungFoo = MF_RegisterForward("Melee_Attack", ET_STOP, FP_CELL, FP_FLOAT,FP_FLOAT, FP_DONE);
Death = MF_RegisterForward("client_death", ET_IGNORE, FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL, FP_DONE);
Damage = MF_RegisterForward("client_damage", ET_IGNORE, FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL, FP_DONE);
Powerup = MF_RegisterForward("client_powerup", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE); Powerup = MF_RegisterForward("client_powerup", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE);
Stunt = MF_RegisterForward("client_stunt", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE);
} }
void check_powerup(edict_s *player) void check_powerup(edict_s *player)
@ -104,13 +160,125 @@ void check_kungfoo(edict_s *player)
} }
} }
void check_stunts(edict_s *player)
{
CPlayer *pPlayer = GET_PLAYER_POINTER(player);
if(pPlayer->checkstate == 0) return;
int stunttype;
int newstate = pPlayer->state;
int oldstate = pPlayer->oldstate;
if(newstate == 0) stunttype = STUNT_NONE;
else if(newstate == 2) stunttype = STUNT_DIVE;
else if(oldstate == 2) stunttype = STUNT_GETUP;
else if( pPlayer->GetOffsetInt(158) == 1) stunttype = STUNT_ROLL;
else if( pPlayer->GetOffsetInt(27) == 1 ) stunttype = STUNT_DUCK;
else stunttype = STUNT_FLIP;
pPlayer->checkstate = 0;
MF_ExecuteForward(Stunt,pPlayer->index,stunttype);
}
void PlayerPreThink_Post(edict_s *player) void PlayerPreThink_Post(edict_s *player)
{ {
check_powerup(player); check_powerup(player);
check_kungfoo(player); check_kungfoo(player);
check_stunts(player);
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
if (ed)
{
mPlayerIndex = ENTINDEX(ed);
mPlayer = GET_PLAYER_POINTER_I(mPlayerIndex);
}
else
{
mPlayerIndex = 0;
mPlayer = NULL;
}
mState = 0;
if ( msg_type < 0 || msg_type >= MAX_REG_MSGS )
msg_type = 0;
function=modMsgs[msg_type];
endfunction=modMsgsEnd[msg_type];
RETURN_META(MRES_IGNORED);
}
void MessageEnd_Post(void) {
if (endfunction) (*endfunction)(NULL);
RETURN_META(MRES_IGNORED);
}
void WriteByte_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteChar_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteShort_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteLong_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteAngle_Post(float flValue) {
if (function) (*function)((void *)&flValue);
RETURN_META(MRES_IGNORED);
}
void WriteCoord_Post(float flValue) {
if (function) (*function)((void *)&flValue);
RETURN_META(MRES_IGNORED);
}
void WriteString_Post(const char *sz) {
if (function) (*function)((void *)sz);
RETURN_META(MRES_IGNORED);
}
void WriteEntity_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
int RegUserMsg_Post(const char *pszName, int iSize)
{
for (int i = 0; g_user_msg[ i ].name; ++i )
{
if ( !*g_user_msg[i].id && strcmp( g_user_msg[ i ].name , pszName ) == 0 )
{
int id = META_RESULT_ORIG_RET( int );
*g_user_msg[ i ].id = id;
if ( g_user_msg[ i ].endmsg )
modMsgsEnd[ id ] = g_user_msg[ i ].func;
else
modMsgs[ id ] = g_user_msg[ i ].func;
break;
}
}
RETURN_META_VALUE(MRES_IGNORED, 0);
}
void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ) void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax )
{ {
for( int i = 1; i <= gpGlobals->maxClients; ++i ) for( int i = 1; i <= gpGlobals->maxClients; ++i )

View File

@ -33,6 +33,16 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include "CPlayer.h" #include "CPlayer.h"
#define STUNT_NONE 0
#define STUNT_DUCK 1
#define STUNT_ROLL 2
#define STUNT_DIVE 3
#define STUNT_GETUP 4
#define STUNT_FLIP 5
extern int Death;
extern int Damage;
#define GET_PLAYER_POINTER(e) (&players[ENTINDEX(e)]) #define GET_PLAYER_POINTER(e) (&players[ENTINDEX(e)])
#define GET_PLAYER_POINTER_I(i) (&players[i]) #define GET_PLAYER_POINTER_I(i) (&players[i])
@ -47,7 +57,7 @@ extern int gmsgScoreInfo;
extern int gmsgTSHealth; extern int gmsgTSHealth;
extern int gmsgWStatus; extern int gmsgWStatus;
extern int gmsgTSSpace; extern int gmsgTSState;
extern int gmsgPwUp; extern int gmsgPwUp;
void Client_ResetHUD_End(void*); void Client_ResetHUD_End(void*);
@ -58,7 +68,7 @@ void Client_TSHealth_End(void*);
void Client_WStatus(void* mValue); void Client_WStatus(void* mValue);
void Client_TSCash(void* mValue); void Client_TSCash(void* mValue);
void Client_TSSpace(void* mValue); void Client_TSState(void* mValue);
void Client_PwUp(void* mValue); void Client_PwUp(void* mValue);
typedef void (*funEventCall)(void*); typedef void (*funEventCall)(void*);