Raised This Month: $ Target: $400
 0% 

Removing grappling hook


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 03-25-2009 , 01:01   Removing grappling hook
Reply With Quote #1

I've made my own grappling hook which pulls people towards me. I'm just having problems removing the hook once the person is right next to me or touches me when they are still hooked...

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>

new model[] =  "models/crossbow_bolt.mdl"
new sprite
new boolg_hooked[33]

public 
plugin_init() 
{
    
register_plugin("Hook grab","1.0","Mazza")
    
    
register_forward(FM_Touch"fw_Touch")
}

public 
client_putinserver(id)
{
    
g_hooked[id] = false
}

public 
plugin_precache()
{
    
engfunc(EngFunc_PrecacheModelmodel);
    
sprite precache_model("sprites/zbeam4.spr");
}

public 
client_impulse(idimpulse)
{        
    if(
impulse == 100)
    {
        
create_hook(id)
        return 
PLUGIN_HANDLED_MAIN
    
}

    return 
PLUGIN_CONTINUE
}

public 
create_hook(id)
{
    if (!
is_user_alive(id))
        return

    static 
FloatOrigin[3], FloatVelocity[3], MinBox[3], MaxBox[3]
    
pev(idpev_originOrigin)
    
pev(idpev_velocityVelocity)

    static 
ent ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
        
    
set_pev(entpev_classname"ent")
    
engfunc(EngFunc_SetModelentmodel)
    
MinBox = { -1.900000, -0.140000, -1.910000 }
    
MaxBox = { 1.90000025.0000001.910000 }
    
    
engfunc(EngFunc_SetSizeentMinBoxMaxBox)
    
engfunc(EngFunc_SetOriginentOrigin)
    
set_pev(entpev_movetypeMOVETYPE_FLY)
    
set_pev(entpev_solidSOLID_TRIGGER)
    
set_pev(entpev_ownerid)
    
    
velocity_by_aim(id1500Velocity)
    
set_pev(entpev_velocityVelocity)
    
    
// Create a beam between two entities
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_BEAMENTS)
    
write_short(id 0x1000)
    
write_short(ent)
    
write_short(sprite)    // sprite index
    
write_byte(0)        // start frame
    
write_byte(0)        // framerate
    
write_byte(200)    // life
    
write_byte(7)        // width
    
write_byte(1)        // noise
    
write_byte(50)    // r, g, b
    
write_byte(50)    // r, g, b
    
write_byte(50)        // r, g, b
    
write_byte(100)    // brightness
    
write_byte(10)        // speed
    
message_end()
}

public 
fw_Touch(pToucherpTouched)
{
    if ( 
pev_valid(pToucher))
    {
        static 
className[32], className2[32], attacker
        pev
(pToucherpev_classnameclassName31)
        if ( 
pev_valid(pTouched)) pev(pTouchedpev_classnameclassName231)
        
attacker pev(pToucherpev_owner)
        
        if ( 
equal(className"ent"))
        {            
            if ( 
pev_valid(pTouched))
            {
                if ( 
equal(className2"player") && is_user_connected(pTouched))
                {
                    static 
Float:fl_Velocity[3]
                    static 
attacker_origin[3], victim_origin[3]
                    
get_user_origin(attackerattacker_origin)
                    
get_user_origin(pTouchedvictim_origin)
                    
                    static 
CsTeams:team[2]
                    
team[0] = cs_get_user_team(pTouched), team[1] = cs_get_user_team(attacker)
                    
                    if (
attacker == pTouched)
                        return 
FMRES_SUPERCEDE
                    
                    
if (!get_cvar_num("mp_friendlyfire") && team[0] == team[1]) 
                        return 
FMRES_SUPERCEDE
                        
                    set_pev
(pToucherpev_aimentpTouched)
                    
set_pev(pToucherpev_movetypeMOVETYPE_FOLLOW)
                    
                    
g_hooked[pTouched] = true
                        
                    
static distance 
                    distance 
get_distance(attacker_originvictim_origin)

                    if ( 
distance 
                    {
                        new 
Float:fl_Time distance 2000.0

                        fl_Velocity
[0] = (attacker_origin[0] - victim_origin[0]) / fl_Time
                        fl_Velocity
[1] = (attacker_origin[1] - victim_origin[1]) / fl_Time
                        fl_Velocity
[2] = (attacker_origin[2] - victim_origin[2]) / fl_Time
                    
}
                    else 
                    {
                        
fl_Velocity[0] = 0.0
                        fl_Velocity
[1] = 0.0
                        fl_Velocity
[2] = 0.0
                    
}

                    
set_pev(pTouchedpev_velocityfl_Velocity)
                }
                else
                    
remove_hook(pToucher)
            }
            else
                
remove_hook(pToucher)
        }
        
    }
    
    return 
FMRES_IGNORED
}  

remove_hook(index)
{
    
engfunc(EngFunc_RemoveEntityindex)
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_KILLBEAM)    
    
write_short(index)
    
message_end()

__________________
It's a mystery.
Mini_Midget is offline
 



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 08:49.


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