Raised This Month: $ Target: $400
 0% 

[Help] Tracking projectiles (TF2)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Inhib
Member
Join Date: Oct 2014
Old 11-29-2014 , 10:42   [Help] Tracking projectiles (TF2)
Reply With Quote #1

I'm writing a plugin, and I need to be able to track the projectiles fired by a specific player, and I currently have no idea how to do this. By track, I mean to identify so I can remove it or other stuff. One of the problems with other methods is that there might be multiple of a particular type of projectile. So if possible, I would like to find the 'newest' projectile fired by a certain player.

Would appreciate any help
Inhib is offline
turtsmcgurts
SourceMod Donor
Join Date: Jul 2011
Old 11-29-2014 , 15:57   Re: [Help] Tracking projectiles (TF2)
Reply With Quote #2

PHP Code:
#define rocket_name "tf_projectile_rocket"
new players_rocket[MAXPLAYERS+1]; //this only tracks the latest rocket fired by each client

public OnEntityCreated (entity, const String:classname[]) {
    if(
StrEqual(classnamerocket_name)) //search for rocket projectile model
    
{
        new 
entity_owner;
        
entity_ownerGetEntPropEnt(entityProp_Data"m_hOwnerEntity"); // retrieves the client who owns the entity
        
players_rocket[entity_owner] = entity;
        
        
SDKHook(entitySDKHook_TouchOn_Projectile_Touch); //this means the rocket has exploded. set players_rocket[entity_owner] = 0 here
    
}

turtsmcgurts is offline
Inhib
Member
Join Date: Oct 2014
Old 11-30-2014 , 00:17   Re: [Help] Tracking projectiles (TF2)
Reply With Quote #3

what would the classname be for a demoman pipe, or say a sandvich? is there any index for all these?
Inhib is offline
turtsmcgurts
SourceMod Donor
Join Date: Jul 2011
Old 11-30-2014 , 00:57   Re: [Help] Tracking projectiles (TF2)
Reply With Quote #4

You should be able to use GetEdictClassName.

Add that into OnEntityCreated and have it print the classname out, then fire the pipe.
turtsmcgurts is offline
Inhib
Member
Join Date: Oct 2014
Old 11-30-2014 , 01:27   Re: [Help] Tracking projectiles (TF2)
Reply With Quote #5

What datatype does
"entity_owner= GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");"
return?
I'm guessing it's an integer, for the clients entity id, but when I print it to the server, it returns -1, this causes all following operations to break.

Here's the portion of it in my code:
new playerpipe[MAXPLAYERS+1]
public OnEntityCreated (entity, const String:classname[])
{
if(StrEqual(classname, "tf_projectile_pipe"))
{
PrintToServer("Found Pipe");
new String:pipeowner;
new String:pipeownerstring[10];
new Float:pipevelocity[3];
pipeowner= GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
//Format(pipeownerstring, sizeof(pipeownerstring), "%d", pipeowner);
//PrintToServer(pipeownerstring);
if(pipeowner==-1)
{
PrintToServer("-1");
}
playerpipe[pipeowner] = entity;
GetEntPropVector(playerpipe[pipeowner], Prop_Data, "m_vecVelocity", pipevelocity);
TeleportEntity(pipeowner, NULL_VECTOR, NULL_VECTOR, pipevelocity);
RemoveEdict(entity);

//SDKHook(entity, SDKHook_Touch, On_Projectile_Touch); this means the rocket has exploded. set players_rocket[entity_owner] = 0 here
}
return Plugin_Continue
} <------Line 105

sourcemod compiler returns "/groups/sourcemod/upload_tmp/textBAkXp5.sp(105) : warning 213: tag mismatch" and I have no idea why.
Inhib is offline
turtsmcgurts
SourceMod Donor
Join Date: Jul 2011
Old 11-30-2014 , 04:54   Re: [Help] Tracking projectiles (TF2)
Reply With Quote #6

I imagine that tf_projectile_pipe doesn't use "m_hOwnerEntity".

Using the sm_dump_datamaps command and searching for "tf_projectile_pipe", I found this.

Try replacing "m_hOwnerEntity" with "m_hThrower".
turtsmcgurts is offline
Inhib
Member
Join Date: Oct 2014
Old 11-30-2014 , 05:04   Re: [Help] Tracking projectiles (TF2)
Reply With Quote #7

the reason the output was -1 is because at (OnEntityCreated), the owner has not been assigned, avoided this by using SDKHook to hook that projectile and assign the owner when (SDKHook_Spawn).

So yes, it does use m_hOwnerEntity.

BTW whats that link abt? It looks really interesting, might be useful for future reference.
Inhib is offline
turtsmcgurts
SourceMod Donor
Join Date: Jul 2011
Old 11-30-2014 , 05:53   Re: [Help] Tracking projectiles (TF2)
Reply With Quote #8

It shows the different properties for the entity. It's useful for a lot of different situations.

PHP Code:
SpawnRocket()
{
    
rocket_entity CreateEntityByName(rocket_entity_name); //creates a new "tf_projectile_rocket" entity 
    
    
TeleportEntity(rocket_entityoriginanglesvelocity); //sets the position, angle and velocity of the rocket so it flies to where you want.
    
    
SetEntPropEnt(rocket_entityProp_Send"m_hOwnerEntity"client); //sets the owner of the rocket
    
SetEntData(rocket_entityFindSendPropInfo(rocket_class_name"m_iTeamNum"), teamtrue); //sets the team value of the rocket
    
SetEntDataFloat(rocket_entityFindSendPropInfo(rocket_class_name"m_iDeflected") + 4100.0true); //not sure why, but this is required in order for it to do damage.
    
SetEntData(rocket_entityFindSendPropInfo(rocket_class_name"m_bCritical"), 11true); //set it to be critical
    
    
DispatchSpawn(rocket_entity); //spawns the rocket
}

Ammo(clientamount)
{
    new 
weapon GetEntPropEnt(idProp_Send"m_hActiveWeapon"); //this allow us to read or manipulate properties of the clients active weapon
    
if(IsValidEntity(weapon))
    {
        new 
ammo_in_clip GetEntProp(weaponProp_Send"m_iClip1"); // this would retrieve how much ammo is in the persons clip.
        
        
SetEntProp(weaponProp_Data"m_iClip1"amount); //this would set the amount of ammo in the persons clip to 'amount'
    
}
}

//if you need to get the position or angles of an entity instead of client (GetClientAbsOrigin only works on clients), you would do something like this.
Get_Entity_Position(entity)
{
    new 
Floatorigin[3];
    new 
Floatangles[3];
    
GetEntPropVector(entityProp_Send"m_vecOrigin"origin);
    
GetEntPropVector(entityProp_Data"m_angRotation"angles);

These were all found using the output of the various "sm_dump_*" commands.

sm_dump_datamaps datamaps.txt
sm_dump_classes classes.txt
sm_dump_netprops netprops.txt

should be all you really need, I think.

Last edited by turtsmcgurts; 11-30-2014 at 05:58.
turtsmcgurts 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 19:11.


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