AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   detecting impact on world (https://forums.alliedmods.net/showthread.php?t=93575)

moosewanted 05-30-2009 16:24

detecting impact on world
 
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

EvolDay 05-30-2009 16:45

Re: detecting impact on world
 
register_touch("player", "worldspawn", "Touched")

stupok 05-30-2009 22:10

Re: detecting impact on world
 
What's the situation?

You can also check its velocity.

moosewanted 05-31-2009 08:05

Re: detecting impact on world
 
It's a rocket which is to explode on impact. I think register_touch is the best method.
Thanks EvolDay

Arkshine 05-31-2009 08:42

Re: detecting impact on world
 
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.

moosewanted 05-31-2009 09:22

Re: detecting impact on world
 
Quote:

Originally Posted by arkshine (Post 838771)
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 05-31-2009 09:38

Re: detecting impact on world
 
Quote:

Originally Posted by moosewanted (Post 838791)
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 05-31-2009 11:01

Re: detecting impact on world
 
Nevermind, equali. I always forget :)

Arkshine 05-31-2009 11:38

Re: detecting impact on world
 
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 )

moosewanted 05-31-2009 11:47

Re: detecting impact on world
 
Quote:

Originally Posted by arkshine (Post 838875)
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?


All times are GMT -4. The time now is 13:56.

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