Raised This Month: $ Target: $400
 0% 

Rocket smoke poof trail.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
urban_ninja
Senior Member
Join Date: Feb 2009
Old 05-07-2012 , 20:29   Rocket smoke poof trail.
Reply With Quote #1

Im trying to make a plugin that adds a trail of individual animated smoke poofs. But here's the problem, find_ent_by_class only returns 1 entity match per execution and fm_find_ent_by_class doesn't work worth a damn. I also can't multi-task origins in the same code execution. Everything has to be able to handle multiple indexes at the same time to work the way I want it. But as it is now, it can only handle 1 rocket at a time.

For loop doesn't do any good. It just loops over the same entity if there's only 1 causing redundant sprite overlapping.

PHP Code:
new Ent[33]
new 
Float:Origin[3]
new 
iOrigin[3]
public 
RocketTrail(id)
{
    
    
Ent[id] = find_ent_by_class(-1"tf_rpg_rocket")
    
//fm_find_ent_by_class(Ent, "tf_rpg_rocket")
    //get_user_origin(id, Origin)
    
entity_get_vector(Ent[id], EV_VEC_origin,Origin);
    
//Origin = pev(Ent,pev_origin)
    
iOrigin[0] = floatround(Origin[0])
    
iOrigin[1] = floatround(Origin[1])
    
iOrigin[2] = floatround(Origin[2])
    
client_print(id,print_chat"Entity: %d (%d)",EntiOrigin[0])
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(17);
    
write_coord(iOrigin[0]);
    
write_coord(iOrigin[1]);
    
write_coord(iOrigin[2]);
    
write_short(DustSpr)
    
write_byte(0.5);
    
write_byte(250);
    
message_end(); 
Here's the problem trying to have multiple origin indexs at the same time.
PHP Code:
new Ent[33]
new 
Float:Origin[3][33]
new 
iOrigin[3][33]
public 
RocketTrail(id)
{
    
    
Ent[id] = find_ent_by_class(-1"tf_rpg_rocket")
    
//fm_find_ent_by_class(Ent, "tf_rpg_rocket")

    
entity_get_vector(Ent[id], EV_VEC_origin,Origin[id]); // This line here it won't allow multi-origin array. Origin[id] gets a compiler error because the [id] is interpreted as part of the x,y,z array yet cant have Origin[0][id] either. This has run me into a dead end for multi-origin indexing.
    //Origin = pev(Ent,pev_origin)
    
iOrigin[0][id] = floatround(Origin[0][id])
    
iOrigin[1][id] = floatround(Origin[1][id])
    
iOrigin[2][id] = floatround(Origin[2][id])
    
client_print(id,print_chat"Entity: %d (%d)",EntiOrigin[0][id])
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(17);
    
write_coord(iOrigin[0][id]);
    
write_coord(iOrigin[1][id]);
    
write_coord(iOrigin[2][id]);
    
write_short(DustSpr)
    
write_byte(0.5);
    
write_byte(250);
    
message_end(); 
__________________
urban_ninja is offline
fearAR
Veteran Member
Join Date: Oct 2010
Old 05-07-2012 , 22:35   Re: Rocket smoke poof trail.
Reply With Quote #2

And, Why didn't define the first dimension like MAX_PLAYERS?

PHP Code:
#define MAX_PLAYERS 32

enum _:C_VECTOR
{
       
0,
       
Y,
       
Z
};

new 
Float:fOrigin[MAX_PLAYERS+1][C_VECTOR]; 
If you do this, It'll allow you to call the right cells inside the functions' parameters.
__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]

Last edited by fearAR; 05-07-2012 at 22:37.
fearAR is offline
Send a message via MSN to fearAR
urban_ninja
Senior Member
Join Date: Feb 2009
Old 05-08-2012 , 19:52   Re: Rocket smoke poof trail.
Reply With Quote #3

Fails to properly store coordinates. Only returns 0.

I don't think I'm clearing understanding what I'm supposed to do.
PHP Code:
#define MAX_PLAYERS 32

enum _:C_VECTOR
{
       
0,
       
Y,
       
Z
};

new 
Float:Origin[MAX_PLAYERS+1][C_VECTOR];
new 
iOrigin[MAX_PLAYERS+1][C_VECTOR];
//new Float:Origin[][3]
//new iOrigin[3]
public RocketTrail(id)
{
    
    
Ent[id] = find_ent_by_class(-1"ntf_squeak")
    
//fm_find_ent_by_class(Ent, "tf_rpg_rocket")
    //get_user_origin(id, Origin)
    
entity_get_vector(Ent[id], EV_VEC_origin,Origin[MAX_PLAYERS]);
    
//Origin = pev(Ent,pev_origin)
    
iOrigin[MAX_PLAYERS][0] = floatround(Origin[MAX_PLAYERS][0])
    
iOrigin[MAX_PLAYERS][1] = floatround(Origin[MAX_PLAYERS][1])
    
iOrigin[MAX_PLAYERS][2] = floatround(Origin[MAX_PLAYERS][2])
    
client_print(id,print_chat"Entity: %d (%d)",EntiOrigin[0])
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(17);
    
write_coord(iOrigin[MAX_PLAYERS][0]);
    
write_coord(iOrigin[MAX_PLAYERS][1]);
    
write_coord(iOrigin[MAX_PLAYERS][2]);
    
write_short(DustSpr)
    
write_byte(0.5);
    
write_byte(250);
    
message_end();

__________________
urban_ninja is offline
fearAR
Veteran Member
Join Date: Oct 2010
Old 05-08-2012 , 21:43   Re: Rocket smoke poof trail.
Reply With Quote #4

PHP Code:
client_print(id,print_chat"Entity: %d (%d)",EntiOrigin[0]) 
-------->

PHP Code:
client_print(id,print_chat"Entity: %d (%d)",EntiOrigin[id][X]) 
It will return show you only the X coordinate.

Wait... Why do you called the directive MAX_PLAYERS like a player index?

You aren't understanding how it works...

I'll give you an example.

PHP Code:
entity_get_vector(Ent[id], EV_VEC_origin,Origin[MAX_PLAYERS]); 
----->

PHP Code:
entity_get_vector(Ent[id], EV_VEC_origin,Origin[id]); 
Do the same thing for the next lines.

Question: Will you use the origin variables for other reasons?, Else, you haven't to create it like a global variable and with a dimension more than the origin cells.

PHP Code:
#define MAX_PLAYERS 32

enum _:C_VECTOR
{
       
0,
       
Y,
       
Z
};

new 
Float:fOrigin[MAX_PLAYERS+1][C_VECTOR];
new 
iOrigin[MAX_PLAYERS+1][C_VECTOR];

public 
RocketTrail(id)
{
    
    
Ent[id] = find_ent_by_class(-1"ntf_squeak")
    
    
entity_get_vector(Ent[id], EV_VEC_origin,fOrigin[id]);
    
    
iOrigin[id][X] = floatround(fOrigin[id][X])
    
iOrigin[id][Y] = floatround(fOrigin[id][Y])
    
iOrigin[id][Z] = floatround(fOrigin[id][Z])
 
    
client_print(id,print_chat"Entity: %d (%d; %d; %d)",EntiOrigin[id][X], iOrigin[id][Y], iOrigin[id][Z])
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(17);
    
write_coord(iOrigin[id][X]);
    
write_coord(iOrigin[id][Y]);
    
write_coord(iOrigin[id][Z]);
    
write_short(DustSpr)
    
write_byte(0.5);
    
write_byte(250);
    
message_end();

__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]

Last edited by fearAR; 05-08-2012 at 22:03.
fearAR is offline
Send a message via MSN to fearAR
urban_ninja
Senior Member
Join Date: Feb 2009
Old 05-09-2012 , 02:12   Re: Rocket smoke poof trail.
Reply With Quote #5

Ok, I did exactly as you instructed in your full example but still was only adding the trail 1 rocket at a time. How do I use find ent by class to return a fill list of matches instead if just 1 entity per execution? After all the entity index number if the entity matches should be what I need for the array.

Something like?
PHP Code:
Ent find_ent_by_class(-1"tf_rpg_rocket")

entity_get_vector(Ent[Ent], EV_VEC_origin,Origin[Ent]); 
__________________
urban_ninja 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 00:20.


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