This commit is contained in:
David Anderson 2005-07-30 17:33:49 +00:00
parent faae071ee8
commit b91cc24d32
5 changed files with 199 additions and 0 deletions

View File

@ -0,0 +1,119 @@
#include <extdll.h>
#include <meta_api.h>
#include <eiface.h>
#include <edict.h>
#include "esforces.h"
int g_Avatars[33] = {0};
static cell AMX_NATIVE_CALL esf_create_avatar(AMX *amx, cell *params)
{
int player = params[1];
CHECKPLAYER(player);
if (g_Avatars[player] == 0)
{
edict_t *pEntity = CREATE_NAMED_ENTITY(MAKE_STRING("env_model"));
if (!pEntity || FNullEnt(pEntity))
return 0;
pEntity->v.movetype = MOVETYPE_FOLLOW;
pEntity->v.aiment = MF_GetPlayerEdict(player);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL esf_remove_avatar(AMX *amx, cell *params)
{
int player = params[1];
CHECKPLAYER(player);
if (g_Avatars[player])
{
edict_t *pEntity = INDEXENT(g_Avatars[player]);
if (!pEntity || FNullEnt(pEntity))
{
g_Avatars[player] = 0;
return 0;
}
REMOVE_ENTITY(pEntity);
g_Avatars[player] = 0;
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL esf_has_avatar(AMX *amx, cell *params)
{
int player = params[1];
CHECKPLAYER(player);
if (g_Avatars[player])
{
edict_t *pEntity = INDEXENT(g_Avatars[player]);
if (!pEntity || FNullEnt(pEntity))
{
g_Avatars[player] = 0;
return 0;
}
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL esf_avatar_getent(AMX *amx, cell *params)
{
int player = params[1];
CHECKPLAYER(player);
if (g_Avatars[player])
{
edict_t *pEntity = INDEXENT(g_Avatars[player]);
if (!pEntity || FNullEnt(pEntity))
{
g_Avatars[player] = 0;
return 0;
}
return g_Avatars[player];
}
return 0;
}
static cell AMX_NATIVE_CALL esf_avatar_setmodel(AMX *amx, cell *params)
{
int player = params[1];
CHECKPLAYER(player);
if (g_Avatars[player])
{
edict_t *pEntity = INDEXENT(g_Avatars[player]);
if (!pEntity || FNullEnt(pEntity))
{
g_Avatars[player] = 0;
return 0;
}
int len;
const char *str = MF_GetAmxString(amx, params[2], 0, &len);
SET_MODEL(player, STRING(ALLOC_STRING(str)));
return 1;
}
return 0;
}
AMX_NATIVE_INFO g_AvatarNatives[] = {
{"esf_create_avatar", esf_create_avatar},
{"esf_remove_avatar", esf_remove_avatar},
{"esf_has_avatar", esf_has_avatar},
{"esf_avatar_getent", esf_avatar_getent},
{"esf_avatar_setmodel", esf_avatar_setmodel},
{NULL, NULL},
};

View File

@ -7,6 +7,8 @@
int g_PowerupMsg = 0;
int g_StopPowerupMsg = 0;
int g_ExplosionMsg = 0;
int g_TransformFX = 0;
int g_StopTransform = 0;
static cell AMX_NATIVE_CALL esf_start_powerup(AMX *amx, cell *params)
{
@ -33,6 +35,76 @@ static cell AMX_NATIVE_CALL esf_start_powerup(AMX *amx, cell *params)
return 1;
}
static cell AMX_NATIVE_CALL esf_transformfx_1(AMX *amx, cell *params)
{
int index = params[1];
CHECKPLAYER(index);
if (!g_TransformFX)
{
g_TransformFX = GET_USER_MSG_ID(PLID, "TransformFX", NULL);
if (!g_TransformFX)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not find TransformFX message!");
return 0;
}
}
MESSAGE_BEGIN(MSG_ALL, g_TransformFX);
WRITE_BYTE(index);
WRITE_BYTE(50);
WRITE_BYTE(75);
MESSAGE_END();
return 1;
}
static cell AMX_NATIVE_CALL esf_transformfx_2(AMX *amx, cell *params)
{
int index = params[1];
CHECKPLAYER(index);
if (!g_TransformFX)
{
g_TransformFX = GET_USER_MSG_ID(PLID, "TransformFX", NULL);
if (!g_TransformFX)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not find TransformFX message!");
return 0;
}
}
MESSAGE_BEGIN(MSG_ALL, g_TransformFX);
WRITE_BYTE(index);
WRITE_BYTE(100);
WRITE_BYTE(75);
MESSAGE_END();
return 1;
}
static cell AMX_NATIVE_CALL esf_transformfx_off(AMX *amx, cell *params)
{
int index = params[1];
CHECKPLAYER(index);
if (!g_StopTransform)
{
g_StopTransform = GET_USER_MSG_ID(PLID, "StopTransFX", NULL);
if (!g_StopTransform)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Could not find StopTransFX message!");
return 0;
}
}
MESSAGE_BEGIN(MSG_ALL, g_StopTransform);
WRITE_BYTE(index);
MESSAGE_END();
return 1;
}
static cell AMX_NATIVE_CALL esf_stop_powerup(AMX *amx, cell *params)
{
int index = params[1];
@ -93,5 +165,8 @@ AMX_NATIVE_INFO g_EffectsNatives[] = {
{"esf_start_powerup", esf_start_powerup},
{"esf_stop_powerup", esf_stop_powerup},
{"esf_explosion", esf_explosion},
{"esf_transformfx_1", esf_transformfx_1},
{"esf_transformfx_2", esf_transformfx_2},
{"esf_transformfx_off", esf_transformfx_off},
{NULL, NULL},
};

View File

@ -117,6 +117,9 @@
<File
RelativePath=".\esf_anim.cpp">
</File>
<File
RelativePath=".\esf_avatars.cpp">
</File>
<File
RelativePath=".\esf_base.cpp">
</File>

View File

@ -6,4 +6,5 @@ void OnAmxxAttach()
MF_AddNatives(g_PdataNatives);
MF_AddNatives(g_EffectsNatives);
MF_AddNatives(g_BaseNatives);
MF_AddNatives(g_AvatarNatives);
}

View File

@ -74,5 +74,6 @@ extern AMX_NATIVE_INFO g_AnimationNatives[];
extern AMX_NATIVE_INFO g_PdataNatives[];
extern AMX_NATIVE_INFO g_EffectsNatives[];
extern AMX_NATIVE_INFO g_BaseNatives[];
extern AMX_NATIVE_INFO g_AvatarNatives[];
#endif //_INCLUDE_ESFORCES_H