diff --git a/dlls/esforces/esfmod/esf_avatars.cpp b/dlls/esforces/esfmod/esf_avatars.cpp new file mode 100755 index 00000000..6a6cd390 --- /dev/null +++ b/dlls/esforces/esfmod/esf_avatars.cpp @@ -0,0 +1,119 @@ +#include +#include +#include +#include +#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}, +}; \ No newline at end of file diff --git a/dlls/esforces/esfmod/esf_effects.cpp b/dlls/esforces/esfmod/esf_effects.cpp index 56a27ce9..65313938 100755 --- a/dlls/esforces/esfmod/esf_effects.cpp +++ b/dlls/esforces/esfmod/esf_effects.cpp @@ -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}, }; diff --git a/dlls/esforces/esfmod/esfmod.vcproj b/dlls/esforces/esfmod/esfmod.vcproj index a7e48d2d..c6b54d63 100755 --- a/dlls/esforces/esfmod/esfmod.vcproj +++ b/dlls/esforces/esfmod/esfmod.vcproj @@ -117,6 +117,9 @@ + + diff --git a/dlls/esforces/esfmod/esforces.cpp b/dlls/esforces/esfmod/esforces.cpp index e48b4321..82e051b1 100755 --- a/dlls/esforces/esfmod/esforces.cpp +++ b/dlls/esforces/esfmod/esforces.cpp @@ -6,4 +6,5 @@ void OnAmxxAttach() MF_AddNatives(g_PdataNatives); MF_AddNatives(g_EffectsNatives); MF_AddNatives(g_BaseNatives); + MF_AddNatives(g_AvatarNatives); } diff --git a/dlls/esforces/esfmod/esforces.h b/dlls/esforces/esfmod/esforces.h index 4fa20cd9..5409f6ae 100755 --- a/dlls/esforces/esfmod/esforces.h +++ b/dlls/esforces/esfmod/esforces.h @@ -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