Raised This Month: $32 Target: $400
 8% 

Module: Parachute (not fake)


Post New Thread Reply   
 
Thread Tools Display Modes
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 07-10-2012 , 03:32   Re: Module: Parachute (not fake)
Reply With Quote #21

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
Maybe you can add a cvar to open (or not) the parachute after jump...
This is a great ideea.
DjOptimuS is offline
Old 07-17-2012, 09:51
vladhks
This message has been deleted by YamiKaitou. Reason: spam
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 08-05-2012 , 15:33   Re: Module: Parachute (not fake)
Reply With Quote #22

Bump.
Can you make only 1sec?
I don't know how to compile modules.
guipatinador is offline
PandaDnB
Senior Member
Join Date: Jan 2012
Old 09-28-2012 , 15:13   Re: Module: Parachute (not fake)
Reply With Quote #23

Please fix the delay
PandaDnB is offline
Pastout
Senior Member
Join Date: Dec 2010
Location: 1337 Street LeetTown
Old 04-04-2013 , 15:40   Re: Module: Parachute (not fake)
Reply With Quote #24

I was doing some testing cause some people have ask me about this and I found a way without hooking client_prethink. I am also using gravity cause its really smooth and acts more realistic. Would be nice to see this in a module coded like this.

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < fun >
#include < orpheu >
#include < orpheu_stocks >
 
new OrpheuStruct:g_ppmove;
 
#define PLUGIN        "Parachute"
#define VERSION        "1.0"
#define AUTHOR        ""
 
#define PARACHUTE_MODEL "models/parachute.mdl"
 
#define MAX_PLAYERS    32
 
#define MarkUserHasParachute(%0)    g_bitHasParachute |= (1<<(%0&31))
#define ClearUserHasParachute(%0)    g_bitHasParachute &= ~(1<<(%0&31))
#define HasUserParachute(%0)        g_bitHasParachute & (1<<(%0&31))
 
#define MarkUserUsingParachute(%0)    g_bitUsingParachute |= (1<<(%0&31))
#define ClearUserUsingParachute(%0)    g_bitUsingParachute &= ~(1<<(%0&31))
#define HasUserUsingParachute(%0)    g_bitUsingParachute & (1<<(%0&31))
 
#define MarkUserAliveParachute(%0)    g_bitAlive |= (1<<(%0&31))
#define ClearUserAliveParachute(%0)    g_bitAlive &= ~(1<<(%0&31))
#define HasUserAliveParachute(%0)    g_bitAlive & (1<<(%0&31))
 
new g_bitAlive
new g_bitUsingParachute
new g_bitHasParachute 
 
new g_iUserParachute[MAX_PLAYERS+1]
new 
Float:g_flEntityFrame[MAX_PLAYERS+1]
 
new 
g_iModelIndex
new g_pCvarFallSpeed
 
new const PARACHUTE_CLASS[] = "parachute"
 
enum {
    
deploy,
    
idle,
    
detach
}
 
public 
plugin_init() {
    
register_plugin(_PLUGIN_VERSION_AUTHOR)
    
g_pCvarFallSpeed register_cvar("parachute_fallspeed""0.0001")
 
    
RegisterHam(Ham_Spawn"player""Ham_CBasePlayer_Spawn_Post"1)
    
RegisterHam(Ham_Killed"player""Ham_CBasePlayer_Killed_Post"1)
 
    
OrpheuRegisterHookOrpheuGetDLLFunction"pfnPM_Move""PM_Move" ), "PM_Move" );
    
OrpheuRegisterHookOrpheuGetFunction"PM_FlyMove" ), "PM_FlyMove" );
    
OrpheuRegisterHookOrpheuGetFunction"PM_PlayStepSound" ), "PM_PlayStepSound" );
}
 
public 
plugin_precache() {
    
g_iModelIndex precache_model(PARACHUTE_MODEL)
}
 
public 
client_putinserver(id) {
    if( 
HasUserParachute(id) ) {
        new 
iEnt g_iUserParachute[id]
        if( 
iEnt ) {
            
RemoveUserParachute(idiEnt)
        }
        
ClearUserHasParachute(id)
 
    }
    
ClearUserAliveParachute(id)
}
 
public 
client_disconnect(id) {
    if( 
HasUserParachute(id) ) {
        new 
iEnt g_iUserParachute[id]
        if( 
iEnt ) {
            
RemoveUserParachute(idiEnt)
        }
        
ClearUserHasParachute(id)
    }
    
ClearUserAliveParachute(id)
}
 
public 
Ham_CBasePlayer_Killed_Postid ) {
    if( 
HasUserParachute(id) ) {
        new 
iEnt g_iUserParachute[id]
        if( 
iEnt ) {
            
RemoveUserParachute(idiEnt)
        }
        
ClearUserHasParachute(id)
    }
    
ClearUserAliveParachute(id)
}
 
new 
Float:get_userGravity33 ]
new 
Float:get_cvar
 
public Ham_CBasePlayer_Spawn_Post(id) {
    if( 
is_user_alive(id) ) {
        
get_cvar get_pcvar_float(g_pCvarFallSpeed)
        
get_userGravityid ] = get_user_gravity(id)
        if( 
HasUserParachute(id) ) {
            new 
iEnt g_iUserParachute[id]
            if( 
iEnt ) {
                
RemoveUserParachute(idiEnt)
            }
        }
        
MarkUserHasParachute(id)
        
MarkUserAliveParachute(id)
    }
}
 
RemoveUserParachute(idiEnt) {
    
engfunc(EngFunc_RemoveEntityiEnt)
    
g_iUserParachute[id] = 0
    set_user_gravity
(idget_userGravityid ])
    
ClearUserUsingParachute(id)
}
 
CreateParachute(id) {
    static 
iszInfoTarget
    
if( !iszInfoTarget ) {
        
iszInfoTarget engfunc(EngFunc_AllocString"info_target")
    }
    new 
iEnt engfunc(EngFunc_CreateNamedEntityiszInfoTarget)
    if( 
iEnt 0) {
        static 
iszClass 0
        
if( !iszClass ) {
            
iszClass engfunc(EngFunc_AllocStringPARACHUTE_CLASS)
        }
        
set_pev_string(iEntpev_classnameiszClass)
        
set_pev(iEntpev_aimentid)
        
set_pev(iEntpev_ownerid)
        
set_pev(iEntpev_movetypeMOVETYPE_FOLLOW)
        static 
iszModel 0
        
if( !iszModel ) {
            
iszModel engfunc(EngFunc_AllocStringPARACHUTE_MODEL)
        }
        
set_pev_string(iEntpev_modeliszModel)
        
set_pev(iEntpev_modelindexg_iModelIndex)
        
set_pev(iEntpev_sequencedeploy)
        
set_pev(iEntpev_gaitsequence1)
        
set_pev(iEntpev_frame0.0)
 
        
set_pev(iEntpev_rendermodepev(idpev_rendermode));
        
set_pev(iEntpev_renderfxpev(idpev_renderfx));
        new 
Float:f_renderamt;
        
pev(idpev_renderamtf_renderamt);
        
set_pev(iEntpev_renderamtf_renderamt);
 
        
g_flEntityFrame[id] = 0.0
        g_iUserParachute
[id] = iEnt
        MarkUserHasParachute
(id)
        new 
Float:fVecOrigin[3]
        
pev(idpev_originfVecOrigin)
 
        return 
iEnt
    
}
    return 
0
}
 
public 
OrpheuHookReturn:PM_MoveOrpheuStruct:ppmoveserver )
{
    
g_ppmove ppmove;
 
    return 
OrpheuIgnored;
}
 
public 
OrpheuHookReturn:PM_PlayStepSound( )
{
    new 
id OrpheuGetStructMemberg_ppmove"player_index" ) + 1;
 
    if( ~
HasUserParachute(id) && ~HasUserAliveParachute(id)) {
        return 
OrpheuIgnored;
    }
    new 
iEnt g_iUserParachute[id]
    if(
iEnt && HasUserUsingParachute(id) ) {
 
        
RemoveUserParachute(idiEnt)
    }
 
    return 
OrpheuIgnored;
}
 
public 
OrpheuHookReturn:PM_FlyMove( )
{
    new 
id OrpheuGetStructMemberg_ppmove"player_index" ) + 1;
    new 
Float:flFrame
    
new iEnt g_iUserParachute[id]
    if( 
pev(idpev_button) & IN_USE ) {
        new 
Float:fVecVelocity[3], Float:fVelocity_z
        pev
(idpev_velocityfVecVelocity)
        
fVelocity_z fVecVelocity[2]
        if( 
fVelocity_z 0.0 ) {
            if(
iEnt <= 0) {
                
iEnt CreateParachute(id)
            }
            
//fVelocity_z = floatmin(fVelocity_z + 14.0, -get_pcvar_float(g_pCvarFallSpeed))
            //fVecVelocity[2] = fVelocity_z
            //set_pev(id, pev_velocity, fVecVelocity)
 
            
MarkUserUsingParachute(id)
            
set_user_gravity(id, (get_userGravityid ]/4)+get_cvar)
            if( 
pev(iEntpev_sequence) == deploy ) {
                
flFrame g_flEntityFrame[id]++
                if( 
flFrame 100.0 ) {
                    
set_pev(iEntpev_animtime0.0)
                    
set_pev(iEntpev_framerate0.4)
                    
set_pev(iEntpev_sequenceidle)
                    
set_pev(iEntpev_gaitsequence1)
                    
set_pev(iEntpev_frame0.0)
                    
g_flEntityFrame[id] = 0.0
                
}
                else {
                    
set_pev(iEntpev_frameflFrame)
                }
            }
        }
        else if(
iEnt 0) {
            
RemoveUserParachute(idiEnt)
        }
    }
    else if( 
iEnt && pev(idpev_oldbuttons) & IN_USE ) {
        
RemoveUserParachute(idiEnt)
    }
 
    return 
OrpheuIgnored;

Pastout is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-04-2013 , 16:36   Re: Module: Parachute (not fake)
Reply With Quote #25

PM_Move is not better than prethink ;)
And hook prethink in a module is not a problem.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Pastout
Senior Member
Join Date: Dec 2010
Location: 1337 Street LeetTown
Old 04-05-2013 , 17:59   Re: Module: Parachute (not fake)
Reply With Quote #26

Ok made a new. Really i think this is the best way to do this. Its the most realistic and best performance I think. Please give me feedback on this.

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < engine >
#include < hamsandwich >
#include < fun >
 
new g_szPluginInfo[3][10] = { "Parachute""1.0""Pastout" }
 
#define PARACHUTE_MODEL "models/angel2.mdl"
#define MAX_PLAYERS    32
 
#define MarkUserHasParachute(%0)    g_bitHasParachute |= (1<<(%0&31))
#define ClearUserHasParachute(%0)   g_bitHasParachute &= ~(1<<(%0&31))
#define HasUserParachute(%0)        g_bitHasParachute & (1<<(%0&31))
 
#define MarkUserAlive(%0)       g_bitAlive |= (1<<(%0&31))
#define ClearUserAlive(%0)      g_bitAlive &= ~(1<<(%0&31))
#define GetUserAlive(%0)        g_bitAlive & (1<<(%0&31))
 
#define MarkUserButton(%0)      g_bitButton |= (1<<(%0&31))
#define ClearUserButton(%0)     g_bitButton &= ~(1<<(%0&31))
#define GetUserButton(%0)       g_bitButton & (1<<(%0&31))
 
new g_bitAlive
new g_bitHasParachute 
new g_bitButton
 
new g_iUserParachute[MAX_PLAYERS+1]
new 
Float:g_flEntityFrame[MAX_PLAYERS+1]
new 
Float:get_userGravity[MAX_PLAYERS+1]
 
new 
g_iModelIndex
 
new g_pCvarFallSpeedg_pCvarDeploySpeed
 
//const m_afButtonPressed = 246
const m_afButtonReleased 247
new const PARACHUTE_CLASS[] = "parachute"
 
new Float:get_cvar[2]
 
enum {
    
PARA_FALLSPEED,
    
PARA_DEPLOYSPEED
}
 
enum {
    
deploy,
    
idle,
    
detach
}
 
public 
plugin_init() {
    
register_plugin(g_szPluginInfo[0], g_szPluginInfo[1], g_szPluginInfo[2])
    
g_pCvarFallSpeed register_cvar("p_fallspeed""0.05")
    
g_pCvarDeploySpeed register_cvar("p_deployspeed""0.01")
 
    static 
g_szPlayer[] = "player"
    
RegisterHam(Ham_Spawng_szPlayer"Ham_CBasePlayer_Spawn_Post", .Post true)
    
RegisterHam(Ham_Killedg_szPlayer"Ham_CBasePlayer_Killed_Post", .Post true)
    
RegisterHam(Ham_ObjectCapsg_szPlayer"Ham_CBasePlayer_ObjectCaps", .Post false)
 
    
register_forward(FM_CmdStart"FM_CBasePlayer_CmdStart")
 
    
register_event("HLTV""Event_NewRound""a""1=0""2=0")
 
    
register_think(PARACHUTE_CLASSg_szPluginInfo[0])
}
 
public 
plugin_precache()
    
g_iModelIndex precache_model(PARACHUTE_MODEL)
 
public 
client_putinserver(id
    
ClearUserAlive(id)
 
public 
client_disconnect(id) {
    
SetParachuteSettings(id)
 
    
ClearUserAlive(id)
}
 
public 
Ham_CBasePlayer_Killed_Postid ) {
    
SetParachuteSettings(id)
 
    
ClearUserAlive(id)
}
 
public 
Event_NewRound( ) {
    
get_cvar[0] = get_pcvar_float(g_pCvarFallSpeed)
    
get_cvar[1] = get_pcvar_float(g_pCvarDeploySpeed)
}
 
public 
Ham_CBasePlayer_Spawn_Post(id) {
    if( 
is_user_alive(id) ) {
        
SetParachuteSettings(id)
        
ClearUserButton(id)
        
MarkUserAlive(id)
    }
}
 
SetParachuteSettings(id)
    if( 
HasUserParachute(id) ) 
        
RemoveUserParachute(id)
 
RemoveUserParachute(id) {
    new 
iEnt g_iUserParachute[id]
    if(
iEnt
        
engfunc(EngFunc_RemoveEntityiEnt)
 
    
g_iUserParachute[id] = 0
 
    set_user_gravity
(idget_userGravity[id])
 
    
ClearUserHasParachute(id)
}
 
public 
FM_CBasePlayer_CmdStart(idhandle)
    if(
GetUserAlive(id))
        if( 
entity_get_intidEV_INT_button ) & IN_USE )
            
MarkUserButton(id)
 
public 
Ham_CBasePlayer_ObjectCaps(id) {
    if(
GetUserButton(id))
    {
        new 
flags get_entity_flags(id)
 
        new 
isOnGround flags FL_ONGROUND
        
new isInWater = (pev(idpev_waterlevel) > 0)
        if(~
HasUserParachute(id) && GetUserButton(id)) {
            if( 
isOnGround || isInWater 
                return
 
            
//client_print(id, print_chat, "Created parachute")
            
get_userGravity[id] = get_user_gravity(id)
 
            
CreateParachute(id)
        }
        else if(
HasUserParachute(id) && get_pdata_int(idm_afButtonReleased) & IN_USE) {
            
//client_print(id, print_chat, "You release IN_USE NO more parachute" )
            
RemoveUserParachute(id)
            
ClearUserButton(id)
        }
        if(
HasUserParachute(id) && ( isOnGround || isInWater ) ) {
            
//client_print(id, print_chat, "NO more parachute on ground" )
            
RemoveUserParachute(id)
        }
    }
}
 
CreateParachute(id) {
    static 
iszInfoTarget
    
if( !iszInfoTarget ) {
        
iszInfoTarget engfunc(EngFunc_AllocString"info_target")
    }
    new 
iEnt engfunc(EngFunc_CreateNamedEntityiszInfoTarget)
    if( 
iEnt 0) {
        static 
iszClass 0
        
if( !iszClass ) {
            
iszClass engfunc(EngFunc_AllocStringPARACHUTE_CLASS)
        }
        
set_pev_string(iEntpev_classnameiszClass)
        
set_pev(iEntpev_aimentid)
        
set_pev(iEntpev_ownerid)
        
set_pev(iEntpev_movetypeMOVETYPE_FOLLOW)
        static 
iszModel 0
        
if( !iszModel ) {
            
iszModel engfunc(EngFunc_AllocStringPARACHUTE_MODEL)
        }
        
set_pev_string(iEntpev_modeliszModel)
        
set_pev(iEntpev_modelindexg_iModelIndex)
        
set_pev(iEntpev_sequencedeploy)
        
set_pev(iEntpev_gaitsequence1)
        
set_pev(iEntpev_frame0.0)
 
        
set_pev(iEntpev_rendermodepev(idpev_rendermode))
        
set_pev(iEntpev_renderfxpev(idpev_renderfx))
        new 
Float:f_renderamt
        pev
(idpev_renderamtf_renderamt)
        
set_pev(iEntpev_renderamtf_renderamt)
 
        
g_flEntityFrame[id] = 0.0
        g_iUserParachute
[id] = iEnt
 
        MarkUserHasParachute
(id)
 
        new 
Float:fVecOrigin[3]
        
pev(idpev_originfVecOrigin)
 
        
set_pev(iEntpev_nextthinkget_gametime() + get_cvar[1])
 
        return 
iEnt
    
}
    return 
0
}
 
public 
Parachute(iEnt)
{
    if(!
pev_valid(iEnt))
        return
 
    static 
id
    id 
pev(iEntpev_owner)
    new 
Float:flFrame
    
new iEnt g_iUserParachute[id]
 
    if( 
HasUserParachute(id) ) {
        new 
Float:fVecVelocity[3], Float:fVelocity_z
        pev
(idpev_velocityfVecVelocity)
        
fVelocity_z fVecVelocity[2]
        if( 
fVelocity_z 0.0 ) {
            if(
iEnt <= 0) {
                
iEnt CreateParachute(id)
            }
            
//fVelocity_z = floatmin(fVelocity_z + 14.0, -get_cvar[PARA_FALLSPEED])
            //fVecVelocity[2] = fVelocity_z
            //set_pev(id, pev_velocity, fVecVelocity)
            
set_user_gravity(idget_cvar[0]+get_cvar[0])
            if( 
pev(iEntpev_sequence) == deploy) {
                
flFrame g_flEntityFrame[id]++
                if(
flFrame 100.0) {
                    
set_pev(iEntpev_animtime0.0)
                    
set_pev(iEntpev_framerate0.4)
                    
set_pev(iEntpev_sequenceidle)
                    
set_pev(iEntpev_gaitsequence1)
                    
set_pev(iEntpev_frame0.0)
                    
g_flEntityFrame[id] = 0.0
                
}
                else {
                    
set_pev(iEntpev_frameflFrame)
                }
            }
        }
    }
    
set_pev(iEntpev_nextthinkget_gametime() + 0.01)

Attached Files
File Type: sma Get Plugin or Get Source (parachute.sma - 739 views - 6.1 KB)

Last edited by Pastout; 06-19-2013 at 20:01.
Pastout is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-06-2013 , 05:36   Re: Module: Parachute (not fake)
Reply With Quote #27

Why don't you post in plugin parachute thread ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 04-06-2013 , 08:21   Re: Module: Parachute (not fake)
Reply With Quote #28

Btw, check this Pastout:

http://forums.alliedmods.net/showpos...94&postcount=9
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Pastout
Senior Member
Join Date: Dec 2010
Location: 1337 Street LeetTown
Old 04-06-2013 , 12:31   Re: Module: Parachute (not fake)
Reply With Quote #29

Quote:
Originally Posted by bibu View Post
I know that, but if you read the code it will auto correct itself. Btw the chances of that happening are still very low and even if it does like i said it will auto correct itself.

But im done. This was only to improve the parachute plugin without using prethink or cmdstart

Last edited by Pastout; 04-06-2013 at 12:47.
Pastout is offline
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 07-27-2013 , 14:27   Re: Module: Parachute (not fake)
Reply With Quote #30

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
Maybe you can add a cvar to open (or not) the parachute after jump...
Here is.

Code:
sv_fallspeed 100 // fall speed with parachute
sv_min_fallspeed_to_open 300.0 // minimum fall speed to open the parachute. If you want the parachute to open fast, set a low value
linux version only.
Attached Files
File Type: zip parachute.zip (9.2 KB, 275 views)

Last edited by guipatinador; 07-27-2013 at 14:28.
guipatinador 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:25.


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