mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 05:45:36 +03:00
phew... updated to include old tsfun stuffs
This commit is contained in:
parent
d9f9c5256a
commit
b968f437ca
@ -36,13 +36,15 @@
|
||||
// class CPlayer
|
||||
// *****************************************************
|
||||
|
||||
void CPlayer::Disconnect(){
|
||||
void CPlayer::Disconnect()
|
||||
{
|
||||
if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused
|
||||
return;
|
||||
rank->updatePosition( &life );
|
||||
ingame = false;
|
||||
}
|
||||
void CPlayer::PutInServer(){
|
||||
void CPlayer::PutInServer()
|
||||
{
|
||||
restartStats();
|
||||
ingame = true;
|
||||
|
||||
@ -74,7 +76,8 @@ void CPlayer::PutInServer(){
|
||||
if ( ( rank = g_rank.findEntryInRank( unique , name ) ) == 0 )
|
||||
ingame = false;
|
||||
}
|
||||
void CPlayer::Connect( const char* ippp ){
|
||||
void CPlayer::Connect(const char* ippp)
|
||||
{
|
||||
strcpy(ip,ippp);
|
||||
}
|
||||
|
||||
@ -96,7 +99,8 @@ void CPlayer::Init( int pi, edict_t* pe )
|
||||
ingame = false;
|
||||
}
|
||||
|
||||
void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
|
||||
void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk)
|
||||
{
|
||||
|
||||
if ( ignoreBots(pEdict,pVictim->pEdict) )
|
||||
return;
|
||||
@ -144,7 +148,8 @@ void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
|
||||
life.tks += ttk;
|
||||
}
|
||||
|
||||
void CPlayer::saveHit(CPlayer* pVictim, int wweapon, int ddamage, int bbody){
|
||||
void CPlayer::saveHit(CPlayer* pVictim, int wweapon, int ddamage, int bbody)
|
||||
{
|
||||
|
||||
if ( ignoreBots(pEdict,pVictim->pEdict) )
|
||||
return;
|
||||
@ -183,7 +188,8 @@ void CPlayer::saveHit(CPlayer* pVictim, int wweapon, int ddamage, int bbody){
|
||||
life.bodyHits[bbody]++;
|
||||
}
|
||||
|
||||
void CPlayer::saveShot(int weapon){
|
||||
void CPlayer::saveShot(int weapon)
|
||||
{
|
||||
|
||||
if ( ignoreBots(pEdict) )
|
||||
return;
|
||||
@ -196,3 +202,44 @@ void CPlayer::saveShot(int weapon){
|
||||
weaponsRnd[0].shots++; // DEC-Weapon (round) stats
|
||||
}
|
||||
|
||||
void CPlayer::SetOffsetF(int offs, float val)
|
||||
{
|
||||
*((float *)pEdict->pvPrivateData + offs) = val;
|
||||
}
|
||||
|
||||
void CPlayer::SetOffset(int offs, int val)
|
||||
{
|
||||
*((int *)pEdict->pvPrivateData + offs) = val;
|
||||
}
|
||||
|
||||
float CPlayer::GetOffsetF(int offs)
|
||||
{
|
||||
return *((float *)pEdict->pvPrivateData + offs);
|
||||
}
|
||||
|
||||
int CPlayer::GetOffset(int offs)
|
||||
{
|
||||
return *((int *)pEdict->pvPrivateData + offs);
|
||||
}
|
||||
|
||||
float CPlayer::GetTime()
|
||||
{
|
||||
return GetOffsetF(TSX_TIME_OFFSET);
|
||||
}
|
||||
|
||||
void CPlayer::SetMoney(int money)
|
||||
{
|
||||
SetOffset(TSX_MONEY_OFFSET, money);
|
||||
}
|
||||
|
||||
void CPlayer::SetSlots(int slots)
|
||||
{
|
||||
SetOffset(TSX_SLOTS_OFFSET, slots);
|
||||
}
|
||||
|
||||
int CPlayer::GetSlots()
|
||||
{
|
||||
return GetOffset(TSX_SLOTS_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +52,26 @@
|
||||
#define TSPWUP_DFIRERATE 16
|
||||
#define TSPWUP_SJUMP 256
|
||||
|
||||
#if defined __linux__
|
||||
#define EXTRAOFFSET 5
|
||||
#else
|
||||
#define EXTRAOFFSET 0
|
||||
#endif
|
||||
|
||||
#define TSX_SDUCK_OFFSET (27+EXTRAOFFSET)
|
||||
#define TSX_SPEED1_OFFSET (85+EXTRAOFFSET)
|
||||
#define TSX_PHYSICS_OFFSET (86+EXTRAOFFSET)
|
||||
#define TSX_BTRAIL_OFFSET (87+EXTRAOFFSET)
|
||||
#define TSX_ISSLO_OFFSET (89+EXTRAOFFSET)
|
||||
#define TSX_SPEED2_OFFSET (90+EXTRAOFFSET)
|
||||
#define TSX_SROLL_OFFSET (158+EXTRAOFFSET)
|
||||
#define TSX_MONEY_OFFSET (301+EXTRAOFFSET)
|
||||
#define TSX_SLOTS_OFFSET (304+EXTRAOFFSET)
|
||||
#define TSX_SLOMO1_OFFSET (423+EXTRAOFFSET)
|
||||
#define TSX_SLOMO2_OFFSET (425+EXTRAOFFSET)
|
||||
#define TSX_MSG_OFFSET (433+EXTRAOFFSET)
|
||||
#define TSX_TIME_OFFSET (444+EXTRAOFFSET)
|
||||
|
||||
#define TSITEM_KUNGFU 1<<0
|
||||
#define TSITEM_SUPERJUMP 1<<1
|
||||
|
||||
@ -91,6 +111,10 @@ struct CPlayer {
|
||||
|
||||
bool ingame;
|
||||
float clearStats;
|
||||
|
||||
int checkstate;
|
||||
int state;
|
||||
int oldstate;
|
||||
|
||||
struct PlayerWeapon : public Stats {
|
||||
char* name;
|
||||
@ -116,6 +140,14 @@ struct CPlayer {
|
||||
void saveHit(CPlayer* pVictim, int weapon, int damage, int aiming);
|
||||
void saveShot(int weapon);
|
||||
void restartStats(bool all = true);
|
||||
void SetMoney(int money);
|
||||
void SetSlots(int slots);
|
||||
int GetSlots();
|
||||
void SetOffset(int offs, int val);
|
||||
int GetOffset(int offs);
|
||||
void SetOffsetF(int offs, float val);
|
||||
float GetOffsetF(int offs);
|
||||
float GetTime();
|
||||
|
||||
inline bool IsBot(){
|
||||
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);
|
||||
|
@ -137,7 +137,118 @@ static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_user_cash(AMX *amx, cell *params){
|
||||
#define BEGIN_USER_FUNC(__name) \
|
||||
static cell AMX_NATIVE_CALL __name(AMX *amx, cell *params) { \
|
||||
int id = params[1]; \
|
||||
if (id<1 || id>gpGlobals->maxClients) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id); \
|
||||
return 0; } \
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); \
|
||||
if (!pPlayer->ingame) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not ingame", id); \
|
||||
}
|
||||
#define END_USER_FUNC() \
|
||||
}
|
||||
|
||||
BEGIN_USER_FUNC(get_user_slots)
|
||||
return pPlayer->GetSlots();
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(set_user_slots)
|
||||
pPlayer->SetSlots(params[2]);
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(get_user_state)
|
||||
return pPlayer->state;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(get_user_message)
|
||||
int val = pPlayer->GetOffset(TSX_MSG_OFFSET);
|
||||
return (val & 15);
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(set_user_message)
|
||||
int message = params[2];
|
||||
if (message < 1 || message > 16)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message id: %d", message);
|
||||
return 0;
|
||||
}
|
||||
int val = pPlayer->GetOffset(TSX_MSG_OFFSET);
|
||||
pPlayer->SetOffset(TSX_MSG_OFFSET, (val & ~15)^message);
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(set_bullettrail)
|
||||
int bullettrail = params[2] * 256;
|
||||
pPlayer->SetOffset(TSX_BTRAIL_OFFSET, bullettrail);
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(set_fake_slowmo)
|
||||
float time = amx_ctof(params[2]);
|
||||
pPlayer->SetOffset(TSX_SLOMO1_OFFSET, TSPWUP_SLOWMO);
|
||||
float prev = pPlayer->GetTime();
|
||||
pPlayer->SetOffsetF(TSX_SLOMO2_OFFSET, prev+time);
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(set_fake_slowpause)
|
||||
float time = amx_ctof(params[2]);
|
||||
pPlayer->SetOffset(TSX_SLOMO1_OFFSET, TSPWUP_SLOWPAUSE);
|
||||
float prev = pPlayer->GetTime();
|
||||
pPlayer->SetOffsetF(TSX_SLOMO2_OFFSET, prev+time);
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(is_in_slowmo)
|
||||
if (pPlayer->GetOffsetF(TSX_ISSLO_OFFSET))
|
||||
return pPlayer->GetOffsetF(TSX_SLOMO2_OFFSET);
|
||||
return 0;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(set_speed)
|
||||
pPlayer->SetOffsetF(TSX_ISSLO_OFFSET, amx_ctof(params[2]));
|
||||
pPlayer->SetOffsetF(TSX_SPEED2_OFFSET, amx_ctof(params[3]));
|
||||
pPlayer->SetOffsetF(TSX_SPEED1_OFFSET, amx_ctof(params[3]));
|
||||
pPlayer->SetOffsetF(TSX_SLOMO2_OFFSET, amx_ctof(params[4]));
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(set_physics_speed)
|
||||
pPlayer->SetOffsetF(TSX_PHYSICS_OFFSET, amx_ctof(params[2]));
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(is_running_powerup)
|
||||
return pPlayer->GetOffset(TSX_SLOMO1_OFFSET);
|
||||
END_USER_FUNC()
|
||||
|
||||
BEGIN_USER_FUNC(force_powerup_run)
|
||||
pPlayer->SetOffset(TSX_SLOMO1_OFFSET, params[2]);
|
||||
return 1;
|
||||
END_USER_FUNC()
|
||||
|
||||
static cell AMX_NATIVE_CALL set_user_cash(AMX *amx, cell *params)
|
||||
{
|
||||
int id = params[1];
|
||||
if (id<1 || id>gpGlobals->maxClients)
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", id);
|
||||
return 0;
|
||||
}
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
|
||||
if (pPlayer->ingame)
|
||||
{
|
||||
pPlayer->SetMoney(params[2]);
|
||||
pPlayer->money = params[2];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_user_cash(AMX *amx, cell *params)
|
||||
{
|
||||
int id = params[1];
|
||||
if (id<1 || id>gpGlobals->maxClients)
|
||||
{
|
||||
@ -442,20 +553,37 @@ AMX_NATIVE_INFO base_Natives[] = {
|
||||
|
||||
{ "ts_getuserwpn", ts_get_user_weapon },
|
||||
{ "ts_getusercash", get_user_cash },
|
||||
{ "ts_setusercash", set_user_cash },
|
||||
{ "ts_getuserspace", get_user_space },
|
||||
{ "ts_getuserpwup",get_user_pwup },
|
||||
{ "ts_getuseritems",get_user_items },
|
||||
{ "ts_getkillingstreak",get_killingStreak },
|
||||
{ "ts_getuserlastfrag",get_lastFrag },
|
||||
{ "ts_getuserkillflags",get_killflags },
|
||||
{ "ts_getuserpwup", get_user_pwup },
|
||||
{ "ts_getuseritems", get_user_items },
|
||||
{ "ts_getkillingstreak", get_killingStreak },
|
||||
{ "ts_getuserlastfrag", get_lastFrag },
|
||||
{ "ts_getuserkillflags", get_killflags },
|
||||
{ "ts_getuserslots", get_user_slots },
|
||||
{" ts_setuserslots", set_user_slots },
|
||||
|
||||
{ "ts_getuserstate", get_user_state },
|
||||
|
||||
{ "ts_giveweapon",give_weapon },
|
||||
{ "ts_createpwup",create_pwup },
|
||||
{ "ts_givepwup",give_pwup },
|
||||
|
||||
{ "ts_set_message", set_user_message },
|
||||
{ "ts_get_message", get_user_message },
|
||||
|
||||
{ "ts_setpddata",ts_setup },
|
||||
|
||||
{ "register_statsfwd",register_forward },
|
||||
{ "register_statsfwd", register_forward },
|
||||
|
||||
{ "ts_set_bullettrail",set_bullettrail },
|
||||
{ "ts_set_fakeslowmo",set_fake_slowmo },
|
||||
{ "ts_set_fakeslowpause",set_fake_slowpause },
|
||||
{ "ts_is_in_slowmo",is_in_slowmo },
|
||||
{ "ts_set_speed",set_speed },
|
||||
{ "ts_set_physics_speed",set_physics_speed },
|
||||
{ "ts_is_running_powerup",is_running_powerup},
|
||||
{ "ts_force_run_powerup",force_powerup_run},
|
||||
|
||||
//****************************************
|
||||
{ "get_weaponname", get_weapon_name },
|
||||
|
@ -53,6 +53,7 @@ int gmsgWeaponInfo;
|
||||
int gmsgClipInfo;
|
||||
int gmsgScoreInfo;
|
||||
int gmsgTSHealth;
|
||||
int gmsgTSState;
|
||||
|
||||
int gmsgWStatus;
|
||||
int gmsgTSCash;
|
||||
@ -85,7 +86,7 @@ struct sUserMsg
|
||||
{ "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 },
|
||||
{ "TSCash",&gmsgTSCash,Client_TSCash,false },
|
||||
{ "TSSpace",&gmsgTSSpace,Client_TSSpace,false },
|
||||
@ -122,6 +123,28 @@ int RegUserMsg_Post(const char *pszName, int iSize)
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
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->GetOffset(TSX_SROLL_OFFSET) == 1) stunttype = STUNT_ROLL;
|
||||
else if( pPlayer->GetOffset(TSX_SDUCK_OFFSET) == 1 ) stunttype = STUNT_DUCK;
|
||||
else stunttype = STUNT_FLIP;
|
||||
|
||||
pPlayer->checkstate = 0;
|
||||
|
||||
//MF_ExecuteForward(Stunt,pPlayer->index,stunttype);
|
||||
}
|
||||
|
||||
void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax )
|
||||
{
|
||||
|
||||
@ -139,14 +162,18 @@ void PlayerPreThink_Post( edict_t *pEntity )
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
|
||||
check_stunts(pEntity);
|
||||
|
||||
if ( !isModuleActive() ) // stats only
|
||||
return;
|
||||
|
||||
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame){
|
||||
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame)
|
||||
{
|
||||
pPlayer->clearStats = 0.0f;
|
||||
pPlayer->rank->updatePosition( &pPlayer->life );
|
||||
pPlayer->restartStats(false);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
@ -264,12 +264,6 @@
|
||||
<File
|
||||
RelativePath="..\moduleconfig.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\MsgFunc.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\StatsNatives.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\tsx.h">
|
||||
</File>
|
||||
|
@ -45,6 +45,13 @@
|
||||
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
|
||||
#endif
|
||||
|
||||
#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 AMX_NATIVE_INFO stats_Natives[];
|
||||
extern AMX_NATIVE_INFO base_Natives[];
|
||||
|
||||
@ -53,6 +60,7 @@ extern int gmsgWeaponInfo;
|
||||
extern int gmsgClipInfo;
|
||||
extern int gmsgScoreInfo;
|
||||
extern int gmsgTSHealth;
|
||||
extern int gmsgTSState;
|
||||
|
||||
extern int gmsgWStatus;
|
||||
extern int gmsgTSCash;
|
||||
@ -64,7 +72,7 @@ void Client_WeaponInfo(void*);
|
||||
void Client_ClipInfo(void*);
|
||||
void Client_ScoreInfo(void*);
|
||||
void Client_TSHealth_End(void*);
|
||||
|
||||
void Client_TSState(void*);
|
||||
void Client_WStatus(void* mValue);
|
||||
void Client_TSCash(void* mValue);
|
||||
void Client_TSSpace(void* mValue);
|
||||
|
@ -33,7 +33,8 @@
|
||||
#include "tsx.h"
|
||||
|
||||
|
||||
void Client_ResetHUD_End(void* mValue){
|
||||
void Client_ResetHUD_End(void* mValue)
|
||||
{
|
||||
if ( mPlayer->IsAlive() ){ // ostatni przed spawn'em
|
||||
mPlayer->clearStats = gpGlobals->time + 0.25f; // teraz czysc statystyki
|
||||
}
|
||||
@ -50,7 +51,8 @@ void Client_ResetHUD_End(void* mValue){
|
||||
}
|
||||
}
|
||||
|
||||
void Client_ScoreInfo(void* mValue){
|
||||
void Client_ScoreInfo(void* mValue)
|
||||
{
|
||||
static int iId;
|
||||
switch(mState++){
|
||||
case 0:
|
||||
@ -64,7 +66,8 @@ void Client_ScoreInfo(void* mValue){
|
||||
}
|
||||
}
|
||||
|
||||
void Client_WeaponInfo(void* mValue){
|
||||
void Client_WeaponInfo(void* mValue)
|
||||
{
|
||||
static int wpn;
|
||||
switch(mState++){
|
||||
case 0:
|
||||
@ -87,7 +90,8 @@ void Client_WeaponInfo(void* mValue){
|
||||
}
|
||||
}
|
||||
|
||||
void Client_ClipInfo(void* mValue){
|
||||
void Client_ClipInfo(void* mValue)
|
||||
{
|
||||
int iValue = *(int*)mValue;
|
||||
if ( iValue < mPlayer->weapons[mPlayer->current].clip ) {
|
||||
mPlayer->saveShot(mPlayer->current);
|
||||
@ -234,7 +238,15 @@ void Client_TSHealth_End(void* mValue){
|
||||
(cell)TA);
|
||||
}
|
||||
|
||||
void Client_WStatus(void* mValue){
|
||||
void Client_TSState(void* mValue)
|
||||
{
|
||||
mPlayer->oldstate = mPlayer->state;
|
||||
mPlayer->checkstate = 1;
|
||||
mPlayer->state = *(int*)mValue;
|
||||
}
|
||||
|
||||
void Client_WStatus(void* mValue)
|
||||
{
|
||||
switch(mState++){
|
||||
case 1:
|
||||
if ( !*(int*)mValue ){
|
||||
@ -244,15 +256,18 @@ void Client_WStatus(void* mValue){
|
||||
}
|
||||
}
|
||||
|
||||
void Client_TSCash(void* mValue){
|
||||
void Client_TSCash(void* mValue)
|
||||
{
|
||||
mPlayer->money = *(int*)mValue;
|
||||
}
|
||||
|
||||
void Client_TSSpace(void* mValue){
|
||||
void Client_TSSpace(void* mValue)
|
||||
{
|
||||
mPlayer->space = *(int*)mValue;
|
||||
}
|
||||
|
||||
void Client_PwUp(void* mValue){
|
||||
void Client_PwUp(void* mValue)
|
||||
{
|
||||
static int iPwType;
|
||||
switch(mState++){
|
||||
case 0:
|
||||
|
Loading…
Reference in New Issue
Block a user