Raised This Month: $28 Target: $400
 7% 

[TF2] Custom Projectile


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tetradox
Junior Member
Join Date: Aug 2016
Old 08-02-2017 , 02:24   [TF2] Custom Projectile
Reply With Quote #1

Hello, well, i was trying to spawn an arrow projectile, but i have a problem, it appears to not collide with anything, for some reason, when spawned, it disappears when it is about to hit something. I tried setting "m_CollisionGroup" and "m_usSolidFlags" but the problem persists.

The code i use is this:

Code:
int ShootArrow(int client)
{
	float pos[3], rot[3], vel[3];
	GetEntPropVector(client, Prop_Send, "m_vecOrigin", pos);
	GetClientEyeAngles(client, rot);
	pos[2]+=63;			

	int proj = CreateEntityByName("tf_projectile_arrow");
	SetVariantInt(GetClientTeam(client));
	AcceptEntityInput(proj, "TeamNum", -1, -1, 0);
	SetVariantInt(GetClientTeam(client));
	AcceptEntityInput(proj, "SetTeam", -1, -1, 0); 
	SetEntPropEnt(proj, Prop_Send, "m_hOwnerEntity", client);

	vel[0] = Cosine(DegToRad(rot[0]))*Cosine(DegToRad(rot[1]))*2600.0;
	vel[1] = Cosine(DegToRad(rot[0]))*Sine(DegToRad(rot[1]))*2600.0;
	vel[2] = Sine(DegToRad(rot[0]))*2600.0;
	vel[2]*=-1;

	TeleportEntity(proj, pos, rot, vel);
	DispatchSpawn(proj);
}
What should i add to make it collide with things and do damage?

Last edited by Tetradox; 08-02-2017 at 02:24.
Tetradox is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Middle of Nowhere
Old 08-02-2017 , 18:50   Re: [TF2] Custom Projectile
Reply With Quote #2

With this:
PHP Code:
SDKHook(projSDKHook_OnTouchPostOnArrowTouchPost);

public 
void OnArrowTouchPost(int entity)
{
    
// put the damage code here
    
SDKUnhook(entitySDKHook_OnTouchPostOnArrowTouchPost);
    
    
AcceptEntityInput(entity"Kill");
    
RemoveEdict(entity);

__________________

Last edited by cravenge; 08-02-2017 at 18:50.
cravenge is offline
Reply


Thread Tools
Display Modes

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 19:35.


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