Junior Member
Join Date: Jan 2017
Location: Korea
|
02-09-2020
, 06:13
Spawn Entity Is transparent
|
#1
|
PHP Code:
#pragma semicolon 1
/*
HEADER LINE
*/
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <tf2items>
#include <tf2attributes>
#include <tf2>
#include <tf2_stocks>
#include <freak_fortress_2>
#include <freak_fortress_2_subplugin>
/*
DEFINE LINE
*/
#define RAGE_TIME 10.0
#define SKILL_NAME "V_SpinHammer"
#define S_HAMMER_PATH "models/V_SpinHammer.mdl"
#define S_HAMMER_SOUND_PATH "sounds/SpinHammers.wav"
/*
GLOBAL VARIABLE LINE
*/
float g_RageTime;
public void OnPluginStart2()
{
HookEvent("teamplay_round_active", Event_RoundActive, EventHookMode_PostNoCopy);
HookEvent("arena_round_start", Event_RoundActive, EventHookMode_PostNoCopy);
HookEvent("teamplay_round_win", Event_RoundEnd, EventHookMode_PostNoCopy);
}
public OnMapStart()
{
PrecacheModel(S_HAMMER_PATH, true);
PrecacheSound(S_HAMMER_SOUND_PATH, true);
}
public void Event_RoundActive(Event _Event, const char[] _Name, bool _DontBroadcast)
{
if (FF2_HasAbility(0, this_plugin_name, SKILL_NAME))
{
int client = GetClientOfUserId(FF2_GetBossUserId(0));
if (client && IsClientInGame(client) && IsPlayerAlive(client))
{
int boss = FF2_GetBossIndex(client);
g_RageTime = FF2_GetAbilityArgumentFloat(boss, this_plugin_name, SKILL_NAME, 1, RAGE_TIME);
FF2_SetBossCharge(boss, 0, 100.0); // this... Debug
}
}
}
public void Event_RoundEnd(Event _Event, const char[] _Name, bool _DontBroadcast)
{
g_RageTime = 0.0;
}
public Action FF2_OnAbility2(int _Index, const char[] _Plugin_name, const char[] _Ability_name, int _Action)
{
int client = GetClientOfUserId(FF2_GetBossUserId(_Index));
if (!strcmp(_Ability_name, SKILL_NAME))
{
V_SpinHammer(client);
}
return Plugin_Continue;
}
public Action V_SpinHammer(int _Client)
{
int Hammer = CreateV_SpinHammer(_Client);
if(Hammer == -1)
{
PrintToChatAll("Error : Failed Spawn Hammers");
}
float ChkPos[3], ChkHamPos[3];
GetClientEyePosition(_Client, ChkPos);
GetEntPropVector(Hammer, Prop_Send, "m_vecOrigin", ChkHamPos);
PrintToChatAll("Player Pos : %f %f %f", ChkPos[0], ChkPos[1], ChkPos[2]);
PrintToChatAll("Hammer Pos : %f %f %f", ChkHamPos[0], ChkHamPos[1], ChkHamPos[2]);
SetEntParent(Hammer, _Client, "v_pelvis"); // Spin in V's Center.
TF2_AddCondition(_Client, TFCond_FireImmune, g_RageTime);
CreateTimer(g_RageTime, Timer_DestroyHammer, Hammer, TIMER_FLAG_NO_MAPCHANGE);
}
public Action Timer_DestroyHammer(Handle _Timer, any _Hammer)
{
if (IsValidEntity(_Hammer))
{
AcceptEntityInput(_Hammer, "Kill");
}
}
public int CreateV_SpinHammer(int _Player)
{
int Hammer = CreateEntityByName("prop_physics_multiplayer");
SetEntPropEnt(Hammer, Prop_Send, "m_hOwnerEntity", _Player);
SetEntProp(Hammer, Prop_Send, "m_iTeamNum", FF2_GetBossTeam());
SetEntProp(Hammer, Prop_Data, "m_iInitialTeamNum", FF2_GetBossTeam());
DispatchKeyValue(Hammer, "model", S_HAMMER_PATH);
DispatchKeyValue(Hammer, "nodamageforces", "true");
DispatchKeyValue(Hammer, "rendermode", "0");
DispatchKeyValue(Hammer, "renderamt", "255");
SetEntProp(Hammer, Prop_Send, "m_usSolidFlags", 0x0008);
SetEntProp(Hammer, Prop_Data, "m_nSolidType", 6);
SetEntProp(Hammer, Prop_Send, "m_CollisionGroup", 1);
AcceptEntityInput(Hammer, "EnableMotion");
float fCharaPos[3];
GetClientEyePosition(_Player, fCharaPos);
DispatchSpawn(Hammer);
TeleportEntity(Hammer, fCharaPos, NULL_VECTOR, NULL_VECTOR);
HookEntityOutput("trigger_multiple", "OnStartTouch", OnStartTouch);
EmitSoundToClient(_Player, S_HAMMER_SOUND_PATH, Hammer);
return Hammer;
}
public void SetEntParent(int _ChildEnt, int _ParentEnt, const char[] _AttachMentName)
{
SetVariantString("!activator");
AcceptEntityInput(_ChildEnt, "SetParent", _ParentEnt, _ChildEnt, 0);
if (StrEqual(_AttachMentName, "", false))
{
SetVariantString(_AttachMentName);
AcceptEntityInput(_ChildEnt, "SetParentAttachment", _ChildEnt, _ChildEnt, 0);
}
}
// OnTouch the Hammers.
public void OnStartTouch(const char[] _OutPut, int _Caller, int _Activator, float _Delay)
{
int boss = GetClientOfUserId(FF2_GetBossUserId(0));
float fEnemyPos[3];
GetClientAbsOrigin(_Activator, fEnemyPos);
float fHammerPos[3];
float fDistance;
if (IsClientInGame(_Activator) && IsPlayerAlive(_Activator))
{
GetClientAbsOrigin(_Activator, fHammerPos);
fDistance = GetVectorDistance(fHammerPos, fEnemyPos, false);
float fMaxDistance = 10.0;
if (fDistance <= fMaxDistance)
{
SDKHooks_TakeDamage(_Activator, boss, boss, 25.0, DMG_GENERIC);
}
}
}
Hello! I'm a sourcemod beginner. and making "Spin hammer".
I was going to make it a medic shield of MVM,
But hammer's animation won't play, it's not centered on the player,
I building a spin hammer by implementing the Medic Shield feature.
This is the part that sets the center of the player after creating the hammer.
If this part is wrong, it will be created transparently at creation time.
Fixed animations on the player's head, no animation playback
How can I fix this?
(I'm learning English, so I used Google Translator. Sorry!)
|
|