added new functions

This commit is contained in:
Lukasz Wlasinksi 2005-05-31 13:56:15 +00:00
parent 959a5b9225
commit 1cc60fc9ad
9 changed files with 759 additions and 41 deletions

View File

@ -78,4 +78,76 @@ void CPlayer::getTeamName(char * szName ){
for (int i=0;i<16;i++){
szName[i] = *( (char*)pEdict->pvPrivateData + STEAM_PDOFFSET_TEAMNAME + i );
}
}
void CObjective::SetKeyValue( int index, char *keyname, char *value ){
KeyValueData pkvd;
pkvd.szClassName = (char *)STRING(obj[index].pEdict->v.classname);
pkvd.szKeyName = keyname; // type
pkvd.szValue = value;
pkvd.fHandled = false;
MDLL_KeyValue(obj[index].pEdict, &pkvd);
}
void CObjective::InitObj(int dest , edict_t* ed ){
MESSAGE_BEGIN( dest, gmsgInitObj,0,ed );
WRITE_BYTE( count );
for ( int i=0; i<count; i++ ){
WRITE_SHORT(ENTINDEX(obj[i].pEdict));
WRITE_BYTE( obj[i].index );
WRITE_BYTE( obj[i].owner );
WRITE_BYTE( obj[i].visible );
WRITE_BYTE( obj[i].icon_neutral );
WRITE_BYTE( obj[i].icon_allies );
WRITE_BYTE( obj[i].icon_axis );
WRITE_COORD( obj[i].origin_x );
WRITE_COORD( obj[i].origin_y );
}
MESSAGE_END();
}
void CObjective::SetObj(int index){
MESSAGE_BEGIN(MSG_ALL,gmsgSetObj);
WRITE_BYTE(obj[index].index);
WRITE_BYTE(obj[index].owner);
WRITE_BYTE(0);
MESSAGE_END();
}
void CObjective::UpdateOwner(int index, int team){
obj[index].owner = team;
GET_CP_PD(obj[index].pEdict).owner = team;
switch ( team ){
case 0:
obj[index].pEdict->v.model = MAKE_STRING( GET_CP_PD(obj[index].pEdict).model_neutral );
obj[index].pEdict->v.body = GET_CP_PD(obj[index].pEdict).model_body_neutral;
break;
case 1:
obj[index].pEdict->v.model = MAKE_STRING( GET_CP_PD(obj[index].pEdict).model_allies );
obj[index].pEdict->v.body = GET_CP_PD(obj[index].pEdict).model_body_allies;
break;
case 2:
obj[index].pEdict->v.model = MAKE_STRING( GET_CP_PD(obj[index].pEdict).model_axis );
obj[index].pEdict->v.body = GET_CP_PD(obj[index].pEdict).model_body_axis;
break;
}
mObjects.SetObj(index);
}
void CObjective::Sort(){
objinfo_t temp;
for (int j=0;j<count-1;j++ ){
for (int i=0;i<count-1;i++ ){
if ( obj[i].index > obj[i+1].index ){
temp = obj[i+1];
obj[i+1] = obj[i];
obj[i] = temp;
}
}
}
}

View File

@ -33,19 +33,162 @@
#define CMISC_H
#ifndef __linux__
#define LINUXOFFSET 0
#define LINUXOFFSET 0
#else
#define LINUXOFFSET 5
#define LINUXOFFSET 5
#endif
#define DODFUN_VERSION "0.1"
#define DODFUN_VERSION "1.0.2"
#define STEAM_PDOFFSET_WDEPLOY 229 + LINUXOFFSET // weapon deploy
// DoD Player
#define STEAM_PDOFFSET_WDEPLOY 229 + LINUXOFFSET // weapon deploy
#define STEAM_PDOFFSET_TEAMNAME 1396 + (LINUXOFFSET * sizeof(char)) // team name 349 char[16]
#define STEAM_PDOFFSET_CLASS 366 + LINUXOFFSET // player class
#define STEAM_PDOFFSET_RCLASS 367 + LINUXOFFSET // random class
#define STEAM_PDOFFSET_SCORE 475 + LINUXOFFSET // score
#define STEAM_PDOFFSET_DEATHS 476 + LINUXOFFSET // deaths
#define STEAM_PDOFFSET_TEAMNAME 1396 + LINUXOFFSET // team name
// DoD Control Point
struct pd_dcp {
int iunk_0;
#ifndef __linux__
int iunk_1; // windows only
#endif
int iunk_2; // pointer edict_t*
int iunk_3;
float origin_x;
float origin_y;
float origin_z; // 6
float mins_x;
float mins_y;
float mins_z;
float maxs_x;
float maxs_y;
float maxs_z;
float angles_x;
float angles_y;
float angles_z; // 15
// 19 - spawnflags ?
// 20-int , always 1
int unknown_block1[19];
int iunk_35; // pointer entvars_t*
int iunk_36; // pointer entvars_t*
int unknown_block2[52];
int iunk_89; // pointer entvars_t*
#ifdef __linux__
int iunk_extra1;
int iunk_extra2;
int iunk_extra3;
int iunk_extra4;
#endif
int owner; // 90
int iunk_91;
int iunk_92;
int default_owner; // 93
int flag_id;
int pointvalue;
int points_for_player;
int points_for_team;
float funk_98; // always 1.0
float cap_time;
char win_string[256]; // 100 MAP_PLAYER_CAP , %p player , %n pointname , %t teamname
int iunk_164;
int iunk_165;
char target_allies[256]; // 166
char target_axis[256]; // 230
char target_reset[256];
char model_allies[256]; // 358
char model_axis[256]; // 422
char model_neutral[256]; // 486
int model_body_allies; // 550
int model_body_axis;
int model_body_neutral;
int icon_allies;
int icon_axis;
int icon_neutral;
int can_touch; // flags : 1-allies can't, 256-axis can't , default 0 (all can)
int iunk_557;
int iunk_558; // ? -2 , 4
char pointgroup[256];
int iunk_623;
int iunk_624;
int iunk_625;
};
#define GET_CP_PD( x ) (*(pd_dcp*)x->pvPrivateData)
// DoD Capture Area
struct pd_dca {
int iunk_0;
int iunk_1;
int iunk_2;
#ifndef __linux__
int iunk_3; // if def windows
#endif
float origin_x;
float origin_y;
float origin_z; // 6
float mins_x;
float mins_y;
float mins_z;
float maxs_x;
float maxs_y;
float maxs_z;
float angles_x;
float angles_y;
float angles_z; // 15
// 16-135
#ifndef __linux__
int unknown_block_16[111];
#else
int unknown_block_16[116]; // linux +5 more
#endif
int time_to_cap; // 127
int iunk_128;
int allies_numcap; // 129
int axis_numcap; // 130
int iunk_131;
int iunk_132;
int can_cap; // 133 flags : 1-allies can , 256-axis can, default 257 (all can)
int iunk_134;
int iunk_135;
char allies_endcap[256]; // 136
char axis_endcap[256]; // 200
char allies_startcap[256]; // 264
char axis_startcap[256]; // 328
char allies_breakcap[256]; // 392
char axis_breakcap[256]; // 456
int iunk_520; // -1 allies area, blowable (charlie) ??
char hud_sprite[256]; // 521
// 585 - 649
int unknown_block_585[65];
char object_group[256]; // 650
int iunk_714;
int iunk_715;
int iunk_716;
// 717 size
};
#define GET_CA_PD( x ) (*(pd_dca*)x->pvPrivateData)
/* DoD weapons */
enum {
@ -99,7 +242,7 @@ public:
bool staminaSet;
bool fuseSet;
int fuseType; // 1<<0 - for new , 1<<1 - for catched
int fuseType; // 1<<0 - for new , 1<<1 - for cought
float nadeFuse;
bool ingame;
@ -122,7 +265,84 @@ public:
}
};
typedef struct objinfo_s {
// initobj
edict_t* pEdict;
int index;
int default_owner;
int visible;
int icon_neutral;
int icon_allies;
int icon_axis;
float origin_x;
float origin_y;
// setobj
int owner;
// control area
int areaflags; // 0-need check , 1-no area , 2-found area
edict_t* pAreaEdict;
} objinfo_t;
class CObjective {
public:
int count;
objinfo_t obj[12];
inline void Clear() { count = 0; memset(obj,0,sizeof(objinfo_s)); }
void SetKeyValue( int index, char *keyname, char *value );
void InitObj(int dest = MSG_ALL , edict_t* ed = NULL);
void SetObj(int index);
void UpdateOwner( int index, int team );
void Sort();
};
enum CP_VALUE {
CP_edict = 1,
CP_area,
CP_index,
CP_owner,
CP_default_owner,
CP_visible,
CP_icon_neutral,
CP_icon_allies,
CP_icon_axis,
CP_origin_x,
CP_origin_y,
CP_can_touch,
CP_pointvalue,
CP_points_for_cap,
CP_team_points,
CP_model_body_neutral,
CP_model_body_allies,
CP_model_body_axis,
// strings
CP_name,
CP_reset_capsound,
CP_allies_capsound,
CP_axis_capsound,
CP_targetname,
CP_model_neutral,
CP_model_allies,
CP_model_axis,
};
enum CA_VALUE {
CA_edict = 1,
CA_allies_numcap,
CA_axis_numcap,
CA_timetocap,
CA_can_cap,
// strings
CA_target,
CA_sprite,
};
#endif // CMISC_H

View File

@ -41,7 +41,6 @@ static cell AMX_NATIVE_CALL set_user_class(AMX *amx, cell *params){
if ( !pPlayer->ingame )
return 0;
if (iClass){
*( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_CLASS) = iClass;
*( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_RCLASS) = 0; // disable random class
@ -439,34 +438,294 @@ static cell AMX_NATIVE_CALL get_user_ammo(AMX *amx, cell *params){
return 1;
}
static cell AMX_NATIVE_CALL test_pd(AMX *amx, cell *params){
static cell AMX_NATIVE_CALL objective_set_data(AMX *amx, cell *params){ // index, key, ivalue , szvalue
int index = params[1];
CHECK_PLAYER(index);
int type = params[2];
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->ingame){
int i;
FILE *bp = fopen("pdtest.txt","at");
for ( i=1;i<1000;i++ ){
switch(type){
case 0: fprintf(bp,"%d %d\n",i,*( (int*)pPlayer->pEdict->pvPrivateData + i));
break;
case 1: fprintf(bp,"%d %f\n",i,*( (float*)pPlayer->pEdict->pvPrivateData + i));
break;
case 2:
fprintf(bp,"%d %c\n",i+1000,*( (char*)pPlayer->pEdict->pvPrivateData + i + 1000));
break;
//MF_PrintSrvConsole("",*( (int*)pPlayer->pEdict->pvPrivateData + i) );
}
}
fclose(bp);
if ( index < 0 || index > mObjects.count ){
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", index);
return 0;
}
return 0;
edict_t *pent = mObjects.obj[index].pEdict;
int iLen;
int ivalue = params[3];
char *szValue = MF_GetAmxString(amx, params[4], 0, &iLen);
CP_VALUE key = (CP_VALUE)params[2];
switch ( key ){
case CP_owner :
mObjects.UpdateOwner( index, ivalue );
return 1;
case CP_default_owner :
mObjects.obj[index].default_owner = ivalue;
GET_CP_PD(pent).default_owner = ivalue;
return 1;
case CP_visible :
mObjects.obj[index].visible = ivalue;
mObjects.obj[index].pEdict->v.spawnflags = 1 - ivalue;
return 1;
case CP_icon_neutral :
mObjects.obj[index].icon_neutral = ivalue;
GET_CP_PD(pent).icon_neutral = ivalue;
return 1;
case CP_icon_allies :
mObjects.obj[index].icon_allies = ivalue;
GET_CP_PD(pent).icon_allies = ivalue;
return 1;
case CP_icon_axis :
mObjects.obj[index].icon_axis = ivalue;
GET_CP_PD(pent).icon_axis = ivalue;
return 1;
case CP_origin_x :
mObjects.obj[index].origin_x = (float)ivalue;
// reinit
return 1;
case CP_origin_y :
mObjects.obj[index].origin_y = (float)ivalue;
// reinit
return 1;
case CP_can_touch :
GET_CP_PD(pent).can_touch = ivalue;
return 1;
case CP_pointvalue :
GET_CP_PD(pent).pointvalue = ivalue;
return 1;
case CP_points_for_cap :
GET_CP_PD(pent).points_for_player = ivalue;
return 1;
case CP_team_points :
GET_CP_PD(pent).points_for_team = ivalue;
return 1;
case CP_model_body_neutral :
GET_CP_PD(pent).model_body_neutral = ivalue;
return 1;
case CP_model_body_allies :
GET_CP_PD(pent).model_body_axis = ivalue;
return 1;
case CP_model_body_axis :
GET_CP_PD(pent).model_body_axis = ivalue;
return 1;
// Strings
case CP_name :
mObjects.obj[index].pEdict->v.netname = MAKE_STRING(szValue);
return 1;
case CP_reset_capsound :
mObjects.obj[index].pEdict->v.noise = MAKE_STRING(szValue);
return 1;
case CP_allies_capsound :
mObjects.obj[index].pEdict->v.noise1 = MAKE_STRING(szValue);
return 1;
case CP_axis_capsound :
mObjects.obj[index].pEdict->v.noise2 = MAKE_STRING(szValue);
return 1;
case CP_targetname :
mObjects.obj[index].pEdict->v.targetname = MAKE_STRING(szValue);
return 1;
case CP_model_neutral :
strcpy(GET_CP_PD(pent).model_neutral,szValue);
return 1;
case CP_model_allies :
strcpy(GET_CP_PD(pent).model_allies,szValue);
return 1;
case CP_model_axis :
strcpy(GET_CP_PD(pent).model_axis,szValue);
return 1;
}
return 1;
}
static cell AMX_NATIVE_CALL objective_get_data(AMX *amx, cell *params){ // flagid, key, ivalue szvalue[],len=0
int index = params[1];
if ( index < 0 || index > mObjects.count ){
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", index);
return 0;
}
int len = params[4];
CP_VALUE key = (CP_VALUE)params[2];
switch ( key ){
case CP_edict :
return ENTINDEX(mObjects.obj[index].pEdict);
case CP_area :
GET_CAPTURE_AREA(index)
return mObjects.obj[index].areaflags == 2 ? ENTINDEX(mObjects.obj[index].pAreaEdict) : 0;
case CP_owner :
return mObjects.obj[index].owner;
case CP_default_owner :
return mObjects.obj[index].default_owner;
case CP_visible :
return mObjects.obj[index].visible;
case CP_icon_neutral :
return mObjects.obj[index].icon_neutral;
case CP_icon_allies :
return mObjects.obj[index].icon_allies;
case CP_icon_axis :
return mObjects.obj[index].icon_axis;
case CP_origin_x :
return (int)mObjects.obj[index].origin_x;
case CP_origin_y :
return (int)mObjects.obj[index].origin_y;
case CP_can_touch :
return GET_CP_PD( mObjects.obj[index].pEdict ).can_touch;
case CP_pointvalue :
return GET_CP_PD( mObjects.obj[index].pEdict ).pointvalue;
case CP_points_for_cap :
return GET_CP_PD( mObjects.obj[index].pEdict ).points_for_player;
case CP_team_points :
return GET_CP_PD( mObjects.obj[index].pEdict ).points_for_team;
case CP_model_body_neutral :
return GET_CP_PD(mObjects.obj[index].pEdict).model_body_neutral;
case CP_model_body_allies :
return GET_CP_PD(mObjects.obj[index].pEdict).model_body_allies;
case CP_model_body_axis :
return GET_CP_PD(mObjects.obj[index].pEdict).model_body_axis;
// strings
case CP_name :
if ( len ){
MF_SetAmxString(amx,params[3],STRING(mObjects.obj[index].pEdict->v.netname),len);
}
return 1;
case CP_reset_capsound :
if ( len ){
MF_SetAmxString(amx,params[3],STRING(mObjects.obj[index].pEdict->v.noise),len);
}
return 1;
case CP_allies_capsound :
if ( len ){
MF_SetAmxString(amx,params[3],STRING(mObjects.obj[index].pEdict->v.noise1),len);
}
return 1;
case CP_axis_capsound :
if ( len ){
MF_SetAmxString(amx,params[3],STRING(mObjects.obj[index].pEdict->v.noise2),len);
}
return 1;
case CP_targetname :
if ( len ){
MF_SetAmxString(amx,params[3],STRING(mObjects.obj[index].pEdict->v.targetname),len);
}
return 1;
case CP_model_neutral :
if ( len ){
MF_SetAmxString(amx,params[3],GET_CP_PD(mObjects.obj[index].pEdict).model_neutral,len);
}
return 1;
case CP_model_allies :
if ( len ){
MF_SetAmxString(amx,params[3],GET_CP_PD(mObjects.obj[index].pEdict).model_allies,len);
}
return 1;
case CP_model_axis :
if ( len ){
MF_SetAmxString(amx,params[3],GET_CP_PD(mObjects.obj[index].pEdict).model_axis,len);
}
return 1;
}
return 1;
}
static cell AMX_NATIVE_CALL objectives_get_num(AMX *amx, cell *params){
return mObjects.count;
}
static cell AMX_NATIVE_CALL objectives_reinit(AMX *amx, cell *params){ // index
int player = params[1];
if ( player < 0 || player > gpGlobals->maxClients ){
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", player);
return 0;
}
mObjects.InitObj( player == 0 ? MSG_ALL:MSG_ONE, player == 0 ? NULL:INDEXENT(player) );
return 1;
}
static cell AMX_NATIVE_CALL area_get_data(AMX *amx, cell *params){ // flagid, key, ivalue szvalue[],len=0
int index = params[1];
if ( index < 0 || index > mObjects.count ){
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", index);
return 0;
}
int len = params[4];
CA_VALUE key = (CA_VALUE)params[2];
GET_CAPTURE_AREA(index)
switch ( key ){
case CA_edict :
return ENTINDEX(mObjects.obj[index].pAreaEdict);
case CA_allies_numcap :
return GET_CA_PD( mObjects.obj[index].pAreaEdict ).allies_numcap;
case CA_axis_numcap :
return GET_CA_PD( mObjects.obj[index].pAreaEdict ).axis_numcap;
case CA_timetocap :
return GET_CA_PD( mObjects.obj[index].pAreaEdict ).time_to_cap;
case CA_can_cap :
return GET_CA_PD( mObjects.obj[index].pAreaEdict ).can_cap;
// strings
case CA_target:
if ( len ){
MF_SetAmxString(amx,params[3],STRING(mObjects.obj[index].pAreaEdict->v.target),len);
}
return 1;
case CA_sprite:
if ( len ){
MF_SetAmxString(amx,params[3],GET_CA_PD(mObjects.obj[index].pAreaEdict).hud_sprite,len);
}
return 1;
}
return 1;
}
static cell AMX_NATIVE_CALL area_set_data(AMX *amx, cell *params){ // index, key, ivalue , szvalue
int index = params[1];
if ( index < 0 || index > mObjects.count ){
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", index);
return 0;
}
int iLen;
int ivalue = params[3];
char *szValue = MF_GetAmxString(amx, params[4], 0, &iLen);
CA_VALUE key = (CA_VALUE)params[2];
GET_CAPTURE_AREA(index)
switch ( key ){
case CA_allies_numcap :
GET_CA_PD( mObjects.obj[index].pAreaEdict ).allies_numcap = ivalue;
return 1;
case CA_axis_numcap :
GET_CA_PD( mObjects.obj[index].pAreaEdict ).axis_numcap = ivalue;
return 1;
case CA_timetocap :
GET_CA_PD( mObjects.obj[index].pAreaEdict ).time_to_cap = ivalue;
return 1;
case CA_can_cap :
GET_CA_PD( mObjects.obj[index].pAreaEdict ).can_cap = ivalue;
return 1;
// strings
case CA_target:
mObjects.obj[index].pAreaEdict->v.target = MAKE_STRING(szValue);
return 1;
case CA_sprite:
strcpy(GET_CA_PD( mObjects.obj[index].pAreaEdict ).hud_sprite,szValue);
return 1;
}
return 1;
}
AMX_NATIVE_INFO pd_Natives[] = {
{ "dod_set_user_class", set_user_class },
{ "dod_set_user_team", set_user_team },
{ "dod_get_next_class", get_user_nextclass },
@ -475,16 +734,21 @@ AMX_NATIVE_INFO pd_Natives[] = {
{ "dod_set_pl_deaths", set_user_deaths },
{ "dod_set_user_score", set_user_score },
{ "dod_set_pl_teamname", set_user_teamname },
{ "dod_get_pl_teamname", get_user_teamname },
{ "dod_get_pl_teamname", get_user_teamname },
{ "dod_is_deployed", is_weapon_deployed },
{ "dod_get_user_ammo", get_user_ammo },
{ "dod_set_user_ammo", set_user_ammo },
{ "dod_get_user_ammo", get_user_ammo },
{ "dod_set_user_ammo", set_user_ammo },
{ "dod_get_user_kills", get_user_frags },
{ "dod_set_user_kills", set_user_frags },
{ "dod_test_pd", test_pd },
{ "objective_set_data", objective_set_data },
{ "objective_get_data", objective_get_data },
{ "objectives_get_num", objectives_get_num },
{ "objectives_reinit", objectives_reinit },
{ "area_set_data", area_set_data },
{ "area_get_data", area_get_data },
///*******************
{ NULL, NULL }
};

View File

@ -45,3 +45,4 @@ edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName)
{
return FindEntityByString(pentStart, "classname", szName);
}

View File

@ -42,21 +42,30 @@ extern AMX_NATIVE_INFO base_Natives[];
extern AMX_NATIVE_INFO pd_Natives[];
extern int mState;
extern int mDest;
extern int mPlayerIndex;
void Client_CurWeapon(void*);
void Client_InitObj(void*);
void Client_SetObj(void*);
typedef void (*funEventCall)(void*);
extern int gmsgScoreShort;
extern int gmsgPTeam;
extern int gmsgInitObj;
extern int gmsgSetObj;
extern int iFGrenade;
extern int iFInitCP;
extern CPlayer players[33];
extern CPlayer* mPlayer;
extern CObjective mObjects;
edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
edict_t *FindEntityByString(edict_t *pentStart, const char *szKeyword, const char *szValue);
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
@ -101,6 +110,20 @@ edict_t *FindEntityByClassname(edict_t *pentStart, const char *szName);
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#define GET_CAPTURE_AREA(x) \
if ( mObjects.obj[x].areaflags == 0 ){\
if ( (mObjects.obj[x].pAreaEdict = FindEntityByString(0,"target",STRING(mObjects.obj[x].pEdict->v.targetname)))\
&& (strcmp( STRING(mObjects.obj[x].pAreaEdict->v.classname),"dod_capture_area" )==0) ){\
mObjects.obj[x].areaflags = 2;\
}\
else{\
mObjects.obj[x].areaflags = 1;\
}\
}\
if ( mObjects.obj[x].areaflags == 1 )\
return 0;
#endif // DODFUN_H

View File

@ -39,15 +39,20 @@ void (*endfunction)(void*);
CPlayer* mPlayer;
CPlayer players[33];
CObjective mObjects;
int mState;
int mDest;
int mPlayerIndex;
int iFGrenade;
int iFInitCP;
int gmsgCurWeapon;
int gmsgScoreShort;
int gmsgPTeam;
int gmsgInitObj;
int gmsgSetObj;
struct sUserMsg {
const char* name;
@ -55,13 +60,15 @@ struct sUserMsg {
funEventCall func;
bool endmsg;
} g_user_msg[] = {
{ "InitObj",&gmsgInitObj,Client_InitObj,false},
{ "CurWeapon",&gmsgCurWeapon,Client_CurWeapon,false },
{ "ScoreShort",&gmsgScoreShort,NULL,false },
{ "PTeam",&gmsgPTeam,NULL,false },
{ "SetObj",&gmsgSetObj,Client_SetObj,false },
{ 0,0,0,false }
};
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 ){
@ -148,6 +155,7 @@ void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t
mPlayer = NULL;
}
mState = 0;
mDest = msg_dest;
if ( msg_type < 0 || msg_type >= MAX_REG_MSGS )
msg_type = 0;
function=modMsgs[msg_type];
@ -230,7 +238,7 @@ void SetModel_Post(edict_t *e, const char *m){
e->v.dmgtime += pPlayer->nadeFuse - 5.0;
}
}
else{ // catched
else{ // cought
bool ownNade = ( (pPlayer->pEdict->v.team == 1 && pPlayer->current == 16) || (pPlayer->pEdict->v.team == 2 && pPlayer->current == 15) ) ? true:false;
if ( ownNade ){
float fExp = e->v.dmgtime - gpGlobals->time;
@ -250,4 +258,5 @@ void OnAmxxAttach() {
void OnPluginsLoaded(){
iFGrenade = MF_RegisterForward("grenade_throw",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
iFInitCP = MF_RegisterForward("controlpoints_init",ET_IGNORE,FP_DONE);
}

View File

@ -5,7 +5,7 @@
// Module info
#define MODULE_NAME "DoD Fun"
#define MODULE_VERSION "1.01"
#define MODULE_VERSION "1.02"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "DODFUN"

View File

@ -1,6 +1,6 @@
/*
* dodfun
* Copyright (c) 2004 Lukasz Wlasinski
* DoDFun
* Copyright (c) 2004 £ukasz W³asiñski
*
*
* This program is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
* version.
*
*/
#include "amxxmodule.h"
#include "dodfun.h"
@ -46,4 +47,65 @@ void Client_CurWeapon(void* mValue){
}
}
void Client_InitObj(void* mValue){
static int num;
if ( mDest != MSG_ALL )
return;
switch (mState++){
case 0:
num = 0;
mObjects.count = *(int*)mValue;
if ( mObjects.count == 0 )
mObjects.Clear();
break;
case 1:
mObjects.obj[num].pEdict = INDEXENT(*(int*)mValue);
break;
case 2:
mObjects.obj[num].index = *(int*)mValue;
break;
case 3:
mObjects.obj[num].default_owner = *(int*)mValue;
mObjects.obj[num].owner = mObjects.obj[num].default_owner;
break;
case 4:
mObjects.obj[num].visible = *(int*)mValue;
break;
case 5:
mObjects.obj[num].icon_neutral = *(int*)mValue;
break;
case 6:
mObjects.obj[num].icon_allies = *(int*)mValue;
break;
case 7:
mObjects.obj[num].icon_axis = *(int*)mValue;
break;
case 8:
mObjects.obj[num].origin_x = *(float*)mValue;
break;
case 9: // 8,9 coord
mObjects.obj[num].origin_y = *(float*)mValue;
mState = 1;
num++;
if ( num == mObjects.count ){
mObjects.Sort();
MF_ExecuteForward( iFInitCP );
}
break;
}
}
void Client_SetObj(void* mValue){
static int id;
switch (mState++){
case 0:
id = *(int*)mValue;
break;
case 1:
mObjects.obj[id].owner = *(int*)mValue;
break;
}
}

View File

@ -1,6 +1,6 @@
/* DoDFun functions
*
* (c) 2004, SidLuke
* (c) 2004-2005, SidLuke
* This file is provided as is (no warranties).
*/
@ -65,4 +65,71 @@ native dod_set_user_ammo(index,wid,value);
/*Gets the ammo of the specified weapon entity id */
native dod_get_user_ammo(index,wid);
/* called after first InitObj */
forward controlpoints_init();
enum CP_VALUE {
CP_edict = 1, // read only
CP_area, // read only
CP_index, // read only
CP_owner,
CP_default_owner,
CP_visible, // reinit after change
CP_icon_neutral, // reinit after change
CP_icon_allies, // reinit after change
CP_icon_axis, // reinit after change
CP_origin_x, // reinit after change
CP_origin_y, // reinit after change
CP_can_touch,
CP_pointvalue,
CP_points_for_cap,
CP_team_points,
CP_model_body_neutral,
CP_model_body_allies,
CP_model_body_axis,
// strings
CP_name,
CP_reset_capsound,
CP_allies_capsound,
CP_axis_capsound,
CP_targetname,
CP_model_neutral,
CP_model_allies,
CP_model_axis,
};
/* returns number of objectives */
native objectives_get_num();
/* use this function to update client(s) hud. You need to do this sometimes. Check CP_VALUE comments.
if player is 0 , all clients will get this message */
native objectives_reinit( player=0 );
/* use this function to get info about specified control point */
native objective_get_data( index, CP_VALUE:key, szValue[]="", len=0 );
/* use this function to change control point's data */
native objective_set_data( index, CP_VALUE:key , iValue=-1, szValue[]="" );
enum CA_VALUE {
CA_edict = 1,
CA_allies_numcap,
CA_axis_numcap,
CA_timetocap,
CA_can_cap,
// strings
CA_target,
CA_sprite,
};
/* use this function to get info about specified control point's area */
native area_get_data( index, CP_VALUE:key, szValue[]="", len=0 );
/* use this function to change control point's area data */
native area_set_data( index, CP_VALUE:key , iValue=-1, szValue[]="" );