Raised This Month: $ Target: $400
 0% 

detecting impact on world


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
moosewanted
Member
Join Date: May 2009
Old 05-30-2009 , 16:24   detecting impact on world
Reply With Quote #1

How would I detect an impact of a moving entity with the world, not another entitiy.

Or!

Does the world count as an entitiy(0)? In which case I cacn register FM_Touch

Or!

Using maths I can work out the ETA of the moving entity and the world and use a set_task to make it explode - and then FM_Touch in case it hits an entity such as a player which would block the path to the wall
moosewanted is offline
EvolDay
Senior Member
Join Date: Apr 2008
Location: Canada
Old 05-30-2009 , 16:45   Re: detecting impact on world
Reply With Quote #2

register_touch("player", "worldspawn", "Touched")
__________________
EvolDay is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 05-30-2009 , 22:10   Re: detecting impact on world
Reply With Quote #3

What's the situation?

You can also check its velocity.
__________________
stupok is offline
moosewanted
Member
Join Date: May 2009
Old 05-31-2009 , 08:05   Re: detecting impact on world
Reply With Quote #4

It's a rocket which is to explode on impact. I think register_touch is the best method.
Thanks EvolDay
moosewanted is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-31-2009 , 08:42   Re: detecting impact on world
Reply With Quote #5

Yeah but in your case, don't forget to write the rocket classname, also use "*" as classname ( touched ) to detect whatever worldspawn, player or entity.
__________________
Arkshine is offline
moosewanted
Member
Join Date: May 2009
Old 05-31-2009 , 09:22   Re: detecting impact on world
Reply With Quote #6

Quote:
Originally Posted by arkshine View Post
Yeah but in your case, don't forget to write the rocket classname, also use "*" as classname ( touched ) to detect whatever worldspawn, player or entity.

Coolio, heres the code I will probably use:
PHP Code:
    register_touch(APACHE_ROCKET_CLASSNAME"*""fw_rocket_touch")
    
register_touch("*"APACHE_ROCKET_CLASSNAME"fw_rocket_touch"
PHP Code:
public fw_rocket_touch(touchertouched)
{
    if((
pev(toucherpev_classname)) == APACHE_ROCKET_CLASSNAME)
    {
        
fm_explosion(toucher)
        
fm_remove_rocket(toucher)
    }
    if((
pev(touchedpev_classname)) == APACHE_ROCKET_CLASSNAME)
    {
        
fm_explosion(touched)
        
fm_remove_rocket(touched)
    }
    return 
PLUGIN_HANDLED

Although it probably won't work knowing me :p Also does it matter what I pass here: fm_explosion(IN HERE) if my stock looks like this:

PHP Code:
stock fm_explosion(id)
{
    new 
Float:explosion[3]
    
pev(idpev_originexplosion)
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(3)
    
write_coord(floatround(explosion[0]))
    
write_coord(floatround(explosion[1]))
    
write_coord(floatround(explosion[2]))
    
write_short(boom)
    
write_byte(50)
    
write_byte(15)
    
write_byte(0)
    
message_end()

Or does "IN HERE" have to be "id"?
moosewanted is offline
moosewanted
Member
Join Date: May 2009
Old 05-31-2009 , 09:38   Re: detecting impact on world
Reply With Quote #7

Quote:
Originally Posted by moosewanted View Post
Coolio, heres the code I will probably use:
PHP Code:
    register_touch(APACHE_ROCKET_CLASSNAME"*""fw_rocket_touch")
    
register_touch("*"APACHE_ROCKET_CLASSNAME"fw_rocket_touch"
PHP Code:
public fw_rocket_touch(touchertouched)
{
    if((
pev(toucherpev_classname)) == APACHE_ROCKET_CLASSNAME)
    {
        
fm_explosion(toucher)
        
fm_remove_rocket(toucher)
    }
    if((
pev(touchedpev_classname)) == APACHE_ROCKET_CLASSNAME)
    {
        
fm_explosion(touched)
        
fm_remove_rocket(touched)
    }
    return 
PLUGIN_HANDLED

Gives errors:
/home/groups/amxmodx/tmp3/texto8Ozhk.sma(97) : error 033: array must be indexed (variable "-unknown-")
/home/groups/amxmodx/tmp3/texto8Ozhk.sma(102) : error 033: array must be indexed (variable "-unknown-")
moosewanted is offline
moosewanted
Member
Join Date: May 2009
Old 05-31-2009 , 11:01   Re: detecting impact on world
Reply With Quote #8

Nevermind, equali. I always forget
moosewanted is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-31-2009 , 11:38   Re: detecting impact on world
Reply With Quote #9

The first register_touch() is enough and in fw_rocket_touch(), you just need the 2 fm_* function. You can remove what is left. ( both if() + return )
__________________
Arkshine is offline
moosewanted
Member
Join Date: May 2009
Old 05-31-2009 , 11:47   Re: detecting impact on world
Reply With Quote #10

Quote:
Originally Posted by arkshine View Post
The first register_touch() is enough and in fw_rocket_touch(), you just need the 2 fm_* function. You can remove what is left. ( both if() + return )
So the guy commenting here: http://www.amxmodx.org/funcwiki.php?go=func&id=463 was wrong?

Also what decides who the toucher and the touched is?
Also what would happen if two rockets collided?
moosewanted 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 13:56.


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