AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity bounce (https://forums.alliedmods.net/showthread.php?t=168788)

Spriite 10-04-2011 00:17

Entity bounce
 
how to do a object(entity) bounce, when touch wall or floor?

Sorry for my bad english.:oops:

Flipper_SPb 10-04-2011 01:30

Re: Entity bounce
 
set_pev(entid, pev_movetype, MOVETYPE_BOUNCE)

Spriite 10-04-2011 09:48

Re: Entity bounce
 
Yeah, but my idea would the object always flying, and bounce only when touches something.

Flipper_SPb 10-04-2011 10:21

Re: Entity bounce
 
PHP Code:

set_pev(entidpev_gravity0.0)     
set_pev(entidpev_movetypeMOVETYPE_BOUNCE


Spriite 10-04-2011 14:13

Re: Entity bounce
 
Yeah, works thx.

But now, I have prolem to detect when his entity touches some player, I'm using:

RegisterHam(Ham_Touch, "info_target", "ent_touch");

But not works, someone can help me?

Hunter-Digital 10-04-2011 14:26

Re: Entity bounce
 
Use engine's register_touch:
Code:

register_touch("YourClassname", "player", "ent_touch")

Spriite 10-04-2011 14:35

Re: Entity bounce
 
Quote:

Originally Posted by Hunter-Digital (Post 1568411)
Use engine's register_touch:
Code:

register_touch("YourClassname", "player", "ent_touch")

I tryed this too, but not works, maybe I'm making something wrong, can you give me some more detailed example?

Xellath 10-04-2011 15:07

Re: Entity bounce
 
Are you assigning a classname for your entity? If so, registering "info_target" along with the touch hook will not trigger the function when your entity touches something. You need to hook touch with the correct entity classname in order for it to work correctly.

Emp` 10-04-2011 15:13

Re: Entity bounce
 
Make sure you set a solid type too:
Code:

// pev(entity, pev_solid) values
// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves
// SOLID only effects OTHER entities colliding with this one when they move - UGH!
#define        SOLID_NOT                      0          // No interaction with other objects
#define        SOLID_TRIGGER                  1          // Touch on edge, but not blocking
#define        SOLID_BBOX                      2          // Touch on edge, block
#define        SOLID_SLIDEBOX                  3          // Touch on edge, but not an onground
#define        SOLID_BSP                      4          // BSP clip, touch on edge, block


Spriite 10-04-2011 15:26

Re: Entity bounce
 
Ok, here is my code:

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
 
new ent_name[] = "new_ent";
 
public 
plugin_init()
{
 
register_clcmd("create""create");
 
 
RegisterHam(Ham_Touch"player""ent_touch");
 
//register_touch(ent_name, "player", "ent_touch")
}
 
public 
plugin_precache()
 
precache_model("some model.mdl");
 
public 
create(id)
{
 new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"info_target"));
 new 
Float:StartOrigin[3], Float:Angle[3];
 
 
pev(idpev_originStartOrigin);
 
pev(idpev_anglesAngle);
 
 
set_pev(entpev_classnameent_name);
 
set_pev(entpev_mins, {-1.0, -1.0, -1.0});
 
set_pev(entpev_maxs, {1.01.01.0});
 
//set_pev(entid, pev_gravity, 0.0)     
 //set_pev(entid, pev_movetype, MOVETYPE_BOUNCE)
 
set_pev(entpev_movetypeMOVETYPE_BOUNCEMISSILE);
 
set_pev(entpev_solidSOLID_BBOX);
 
set_pev(entpev_ownerid);
 
engfunc(EngFunc_SetOriginentStartOrigin);
 
engfunc(EngFunc_SetModelent"some model.mdl");
 
 new 
Float:nVelocity[3];
 
velocity_by_aim(id10nVelocity); 
 
set_pev(entpev_velocitynVelocity);
}
 
public 
ent_touch(playerent)
{
 if(!
pev_valid(ent) || !pev_valid(player))
  return 
HAM_IGNORED;
 
 new 
ent_class[33];
 
pev(entpev_classname,  ent_class32)
 
 if(
equali(ent_classent_name))
  
client_print(0print_chat"Someone touches my entity")
 return 
HAM_IGNORED


What's wrong?


All times are GMT -4. The time now is 19:42.

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