Raised This Month: $51 Target: $400
 12% 

Spawn Entity Is transparent


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AzulFlamaWallon
Junior Member
Join Date: Jan 2017
Location: Korea
Old 02-09-2020 , 06:13   Spawn Entity Is transparent
Reply With Quote #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_RoundActiveEventHookMode_PostNoCopy);
    
HookEvent("arena_round_start"Event_RoundActiveEventHookMode_PostNoCopy);
    
    
HookEvent("teamplay_round_win"Event_RoundEndEventHookMode_PostNoCopy);
}

public 
OnMapStart()
{
    
PrecacheModel(S_HAMMER_PATHtrue); 
    
PrecacheSound(S_HAMMER_SOUND_PATHtrue);
}

public 
void Event_RoundActive(Event _Event, const char[] _Namebool _DontBroadcast)
{
    if (
FF2_HasAbility(0this_plugin_nameSKILL_NAME)) 
    {
        
int client GetClientOfUserId(FF2_GetBossUserId(0)); 
        if (
client && IsClientInGame(client) && IsPlayerAlive(client)) 
        {
            
int boss FF2_GetBossIndex(client);
            
            
g_RageTime FF2_GetAbilityArgumentFloat(bossthis_plugin_nameSKILL_NAME1RAGE_TIME);
            
FF2_SetBossCharge(boss0100.0); // this... Debug
            
        
}
    }
}

public 
void Event_RoundEnd(Event _Event, const char[] _Namebool _DontBroadcast)
{
    
g_RageTime 0.0;
}

public 
Action FF2_OnAbility2(int _Index, const char[] _Plugin_name, const char[] _Ability_nameint _Action)
{
    
int client GetClientOfUserId(FF2_GetBossUserId(_Index));
    if (!
strcmp(_Ability_nameSKILL_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(_ClientChkPos);
    
GetEntPropVector(HammerProp_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(_ClientTFCond_FireImmuneg_RageTime);
    
    
CreateTimer(g_RageTimeTimer_DestroyHammerHammerTIMER_FLAG_NO_MAPCHANGE);
}

public 
Action Timer_DestroyHammer(Handle _Timerany _Hammer)
{
    if (
IsValidEntity(_Hammer))
    {
        
AcceptEntityInput(_Hammer"Kill");
    }
}

public 
int CreateV_SpinHammer(int _Player)
{
    
int Hammer CreateEntityByName("prop_physics_multiplayer");
        
    
SetEntPropEnt(HammerProp_Send"m_hOwnerEntity"_Player);
    
SetEntProp(HammerProp_Send"m_iTeamNum"FF2_GetBossTeam());
    
SetEntProp(HammerProp_Data"m_iInitialTeamNum"FF2_GetBossTeam()); 
    
    
DispatchKeyValue(Hammer"model"S_HAMMER_PATH);
    
DispatchKeyValue(Hammer"nodamageforces""true");
    
DispatchKeyValue(Hammer"rendermode""0");
    
DispatchKeyValue(Hammer"renderamt""255");
    
    
SetEntProp(HammerProp_Send"m_usSolidFlags"0x0008);
    
SetEntProp(HammerProp_Data"m_nSolidType"6);
    
SetEntProp(HammerProp_Send"m_CollisionGroup"1);
    
    
AcceptEntityInput(Hammer"EnableMotion");
            
    
float fCharaPos[3];

    
GetClientEyePosition(_PlayerfCharaPos);
    
    
DispatchSpawn(Hammer);
    
    
TeleportEntity(HammerfCharaPosNULL_VECTORNULL_VECTOR);
        
    
HookEntityOutput("trigger_multiple""OnStartTouch"OnStartTouch);
    
EmitSoundToClient(_PlayerS_HAMMER_SOUND_PATHHammer);
    
    return 
Hammer;
}

public 
void SetEntParent(int _ChildEntint _ParentEnt, const char[] _AttachMentName)
{
    
SetVariantString("!activator");
    
AcceptEntityInput(_ChildEnt"SetParent"_ParentEnt_ChildEnt0);
    if (
StrEqual(_AttachMentName""false))
    {
        
SetVariantString(_AttachMentName);
        
AcceptEntityInput(_ChildEnt"SetParentAttachment"_ChildEnt_ChildEnt0);
    }
}

// OnTouch the Hammers.
public void OnStartTouch(const char[] _OutPutint _Callerint _Activatorfloat _Delay)
{
    
int boss GetClientOfUserId(FF2_GetBossUserId(0));
    
float fEnemyPos[3];
    
GetClientAbsOrigin(_ActivatorfEnemyPos);
    
    
float fHammerPos[3];
    
float fDistance;
    
    if (
IsClientInGame(_Activator) && IsPlayerAlive(_Activator))
    {
        
GetClientAbsOrigin(_ActivatorfHammerPos);
        
fDistance GetVectorDistance(fHammerPosfEnemyPosfalse);
        
float fMaxDistance 10.0;
        if (
fDistance <= fMaxDistance)
        {
            
SDKHooks_TakeDamage(_Activatorbossboss25.0DMG_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!)
AzulFlamaWallon is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 02-10-2020 , 07:15   Re: Spawn Entity Is transparent
Reply With Quote #2

Use ActivateEntity (in this case after TeleportEntity) if your prop has animations. Also try to not use public keyword for your own functions because any function with public works as callback.

Also you should use SDKHook for StartTouch events instead of hooking output because in some cases outputs won't be called.
__________________
MAGNAT2645 is offline
AzulFlamaWallon
Junior Member
Join Date: Jan 2017
Location: Korea
Old 02-10-2020 , 23:25   Re: Spawn Entity Is transparent
Reply With Quote #3

Quote:
Originally Posted by MAGNAT2645 View Post
Use ActivateEntity (in this case after TeleportEntity) if your prop has animations. Also try to not use public keyword for your own functions because any function with public works as callback.

Also you should use SDKHook for StartTouch events instead of hooking output because in some cases outputs won't be called.
I tried as you said!
Animation issues, fixed issues fixed!
However, after Use "SetParent", the model is still transparent.
AzulFlamaWallon is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 02-11-2020 , 13:49   Re: Spawn Entity Is transparent
Reply With Quote #4

Code:
void SetEntParent(int _ChildEnt, int _ParentEnt, const char[] _AttachMentName)
{
    SetVariantString("!activator");
    AcceptEntityInput(_ChildEnt, "SetParent", _ParentEnt, _ChildEnt, 0);
    if (_AttachMentName[0] != '\0')
    {
        SetVariantString(_AttachMentName);
        AcceptEntityInput(_ChildEnt, "SetParentAttachment");
    }
}
Try this (a little optimized for you).
__________________
MAGNAT2645 is offline
AzulFlamaWallon
Junior Member
Join Date: Jan 2017
Location: Korea
Old 02-12-2020 , 06:54   Re: Spawn Entity Is transparent
Reply With Quote #5

Quote:
Originally Posted by MAGNAT2645 View Post
Code:
void SetEntParent(int _ChildEnt, int _ParentEnt, const char[] _AttachMentName)
{
    SetVariantString("!activator");
    AcceptEntityInput(_ChildEnt, "SetParent", _ParentEnt, _ChildEnt, 0);
    if (_AttachMentName[0] != '\0')
    {
        SetVariantString(_AttachMentName);
        AcceptEntityInput(_ChildEnt, "SetParentAttachment");
    }
}
Try this (a little optimized for you).
I tried to fix it immediately, but it didn't work.
AzulFlamaWallon is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 02-12-2020 , 07:33   Re: Spawn Entity Is transparent
Reply With Quote #6

Try to make it simple for tests,

Just set the entity model, activate and set the parent attachment.

Or just try to comment this lines
DispatchKeyValue(Hammer, "rendermode", "0");
DispatchKeyValue(Hammer, "renderamt", "255");
And check if the results are different, I already had problems with rendermode and renderamt parameters.
__________________
Marttt is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 02-12-2020 , 13:42   Re: Spawn Entity Is transparent
Reply With Quote #7

Try to do what Marttt said (or use SetEntityRenderMode & SetEntityRenderColor instead).
If this won't help then it might a problem with the attachment itself.
__________________
MAGNAT2645 is offline
AzulFlamaWallon
Junior Member
Join Date: Jan 2017
Location: Korea
Old 02-13-2020 , 05:16   Re: Spawn Entity Is transparent
Reply With Quote #8

Code:
stock void CreateV_Hammers(int _Player)
{
	int Hammer = CreateEntityByName("prop_physics_multiplayer");
	
	char targetName[64];
	Format(targetName, sizeof(targetName), "Entity%i", Hammer);
	DispatchKeyValue(Hammer, "targetname", targetName);
	DispatchKeyValue(Hammer, "parentname", targetName);
	DispatchKeyValue(Hammer, "model", S_HAMMER_PATH);
	DispatchKeyValue(Hammer, "angles", "0 0 0");
	
	float charaPos[3], charaAng[3];
	
	GetClientAbsOrigin(_Player, charaPos);
	GetClientAbsAngles(_Player, charaAng);
	
	if (DispatchSpawn(Hammer))
	{	
		TeleportEntity(Hammer, charaPos, charaAng, NULL_VECTOR);
		ActivateEntity(Hammer);
		SetEntParent(Hammer, _Player, "");
		SetEntAnim(Hammer, "spin");
		EmitSoundToClient(_Player, S_HAMMER_SOUND_PATH, Hammer);
		
		g_Hammer = Hammer;
	}
	else
	{
		PrintToChatAll("Failed Create Hammer!");
		return;
	}
}

void SetEntAnim(int _Entity, const char[] _AnimName)
{
	SetVariantString(_AnimName);
	AcceptEntityInput(_Entity, "SetAnimation");
	AcceptEntityInput(_Entity, "Enable");
	AcceptEntityInput(_Entity, "EnableMotion");
}

void SetEntParent(int _ChildEnt, int _ParentEnt, const char[] _AttachMentName)
{
	SetVariantString("!activator");
	AcceptEntityInput(_ChildEnt, "SetParent", _ParentEnt, _ChildEnt, 0);
	if (_AttachMentName[0] != '\0')
	{
		SetVariantString(_AttachMentName);
		AcceptEntityInput(_ChildEnt, "SetParentAttachment");
	}
}
Thank you very much for your help!
I listened to your advice step by step and modified it.
I set up the model, enabled it, and set parents.
Then, I deleted the Render part.
however, before setting up a parent, the model will not be transparent and will be output normally. But setting up a parent after model transparent. but the results still don't change.
AzulFlamaWallon is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 02-13-2020 , 05:34   Re: Spawn Entity Is transparent
Reply With Quote #9

I see that in your last example you didn't specify any attachment place on _AttachMentName var.

Try to add one, like "head" or "forward".

And what do you mean by transparent, is really transparent like low alpha, or is it invisible?
__________________

Last edited by Marttt; 02-13-2020 at 05:34.
Marttt is offline
AzulFlamaWallon
Junior Member
Join Date: Jan 2017
Location: Korea
Old 02-13-2020 , 05:57   Re: Spawn Entity Is transparent
Reply With Quote #10

Quote:
Originally Posted by Marttt View Post
I see that in your last example you didn't specify any attachment place on _AttachMentName var.

Try to add one, like "head" or "forward".

And what do you mean by transparent, is really transparent like low alpha, or is it invisible?
It means invisible!

--20.02.13. Edit.

As you said, I've set the attachment name.
However, it's attached correctly, but the shadow of the summoned model is visible, but the model is invisible!

Last edited by AzulFlamaWallon; 02-13-2020 at 06:16.
AzulFlamaWallon is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode