Raised This Month: $ Target: $400
 0% 

How to set enitity's body


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-27-2010 , 20:52   How to set enitity's body
Reply With Quote #1

Code:
public set_mine(id) {
  new Float:StartOrigin[3]

 
  new PlayerOrigin[3]
  get_user_origin(id, PlayerOrigin, 1)

  StartOrigin[0] = float(PlayerOrigin[0])
  StartOrigin[1] = float(PlayerOrigin[1])
  StartOrigin[2] = float(PlayerOrigin[2]-60)

  new MineEnt = create_entity("info_target")
  
  entity_set_string(MineEnt, EV_SZ_classname, "landmine")
  entity_set_model(MineEnt, "models/w_landmine_zlw.mdl")
  entity_set_origin(MineEnt, StartOrigin)

  entity_set_int(MineEnt, EV_INT_solid, 2)
  entity_set_edict(MineEnt, EV_ENT_owner, id)


}
For some reasons it doesn't react for:

Code:
public pfn_touch(ptr, ptd) {
new ClassName[32]



if(!pev_valid(ptr))
	return FMRES_IGNORED;

if ((ptr > 0) && is_valid_ent(ptr))
    entity_get_string(ptr, EV_SZ_classname, ClassName, 31)
  

static toucherClass[32];
pev(ptd, pev_classname, toucherClass, 31);
if(equal(ClassName, "landmine") && equal(toucherClass, "player"))
{

client_print(0,print_chat,"Umba umba!")
remove_entity(ptr)

}
It seems like the mine has no body, I wonder how could I fix it? How can i make the mine "touchable"?
Gadzislaw007 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 07-28-2010 , 01:53   Re: How to set enitity's body
Reply With Quote #2

You need to set the size after setting the solid type.

Code:
/* Set entity bounds. */
native entity_set_size(index, const Float:mins[3], const Float:maxs[3]);
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-28-2010 , 06:16   Re: How to set enitity's body
Reply With Quote #3

Code:
public set_mine(id) {
  new Float:StartOrigin[3]

 
  new PlayerOrigin[3]
  get_user_origin(id, PlayerOrigin, 1)

  StartOrigin[0] = float(PlayerOrigin[0])
  StartOrigin[1] = float(PlayerOrigin[1])
  StartOrigin[2] = float(PlayerOrigin[2]-53)

  new MineEnt = create_entity("info_target")
  
  entity_set_string(MineEnt, EV_SZ_classname, "landmine")
  entity_set_model(MineEnt, "models/w_landmine_zlw.mdl")
  entity_set_origin(MineEnt, StartOrigin)

  new Float:MinBox[3] = {-3.0, -3.0, -1.0}
  new Float:MaxBox[3] = {3.0, 3.0, 1.0}
  entity_set_size(MineEnt, MinBox, MaxBox);
  entity_set_vector(MineEnt, EV_VEC_mins, MinBox)
  entity_set_vector(MineEnt, EV_VEC_maxs, MaxBox)

  entity_set_int(MineEnt, EV_INT_solid, 2)
  entity_set_int(MineEnt, EV_INT_movetype, 5)
  entity_set_edict(MineEnt, EV_ENT_owner, id)

  new Float:Velocity[3]
  VelocityByAim(id, 0, Velocity)
  entity_set_vector(MineEnt, EV_VEC_velocity, Velocity)
  
  

   

}
Still doesn't working. :/
Gadzislaw007 is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-28-2010 , 08:25   Re: How to set enitity's body
Reply With Quote #4

And you must spawn it.

Made a few adjustments:
Code:
public set_mine(id) {
  new Float:StartOrigin[3]
 
  new PlayerOrigin[3]
  get_user_origin(id, PlayerOrigin, 1)

  StartOrigin[0] = PlayerOrigin[0] + 0.0
  StartOrigin[1] = PlayerOrigin[1] + 0.0
  StartOrigin[2] = PlayerOrigin[2] - 53.0

  new MineEnt = create_entity("info_target")

  entity_set_string(MineEnt, EV_SZ_classname, "landmine")
  entity_set_model(MineEnt, "models/w_landmine_zlw.mdl")
  entity_set_edict(MineEnt, EV_ENT_owner, id)

  DispatchSpawn(MineEnt)

  entity_set_origin(MineEnt, StartOrigin)
  entity_set_size(MineEnt, Float:{-3.0, -3.0, -1.0}, Float:{3.0, 3.0, 1.0})
  entity_set_int(MineEnt, EV_INT_solid, 2) /* for readability, use the HLSDK defines... SOLID_* and MOVETYPE_*. */
  entity_set_int(MineEnt, EV_INT_movetype, 5)

  new Float:Velocity[3]
  VelocityByAim(id, 0, Velocity) /* what's the point of setting velocity 0 towards nothing ? */
  entity_set_vector(MineEnt, EV_VEC_velocity, Velocity)
}
Btw, be careful when spawning the mine while player is ducking.

You could easily make one variable, use entity_get_vector(id, EV_VEC_origin, fOrigin) and use -32 or -16 if player is ducking.
__________________

Last edited by Hunter-Digital; 07-28-2010 at 08:31.
Hunter-Digital is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-28-2010 , 08:46   Re: How to set enitity's body
Reply With Quote #5

Thanks' for the 'ducking' tip.

Quote:
* what's the point of setting velocity 0 towards nothing ? */
Just forgot to erease that . So movetype is needen no more too?

Even so, code still isn't working properly. Nothing's happening when mine is touched by a player.
Gadzislaw007 is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-28-2010 , 09:25   Re: How to set enitity's body
Reply With Quote #6

I see you use MOVETYPE_FLY... I recommend using MOVETYPE_TOSS or something, so that the mine falls on it's own.

How do you hook the touch, register_touch() ?
See that you don't mix up variables in the function, first it's the ent then the ent touching it and also, see that the classname in the register_touch() is "landmine".
__________________
Hunter-Digital is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-28-2010 , 09:28   Re: How to set enitity's body
Reply With Quote #7

Well, touch is working for other entities, like rpgrocket, or something (cause I have mixed rpg in it). Only landmine isn't working.

I realized that the condition of my pfn_touch is bad.
Code:
if(equal(ClassName, "landmine") && equal(toucherClass, "player"))
It just doesn't work.

If i set just:

Code:
if(equal(ClassName, "landmine"))
Mine explodes after it touches the ground. I want to make it explode after touching player, what's wrong in my method (first post)?

Last edited by Gadzislaw007; 07-28-2010 at 10:30.
Gadzislaw007 is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 07-28-2010 , 11:22   Re: How to set enitity's body
Reply With Quote #8

Maybe try to use register_touch from engine
Code:
register_touch( your_mine_classname, "player", "fn_MineTouch" )

...

public fn_MineTouch( iMine, iOther )
{
     if( !pev_valid( iMine ) )
         return

     Explosion etc...
}
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-28-2010 , 11:38   Re: How to set enitity's body
Reply With Quote #9

Still nothing :/.
I run and jump over the mine, but it's not going to explode anyway.
Gadzislaw007 is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-28-2010 , 11:39   Re: How to set enitity's body
Reply With Quote #10

Still nothing :/.
I run and jump over the mine, but it's not going to explode anyway.
Gadzislaw007 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:15.


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