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

Prototype Groundspike Graveyard


Post New Thread Reply   
 
Thread Tools Display Modes
Kidev
Veteran Member
Join Date: Jun 2010
Location: France
Old 01-05-2011 , 10:47   Re: Prototype Groundspike Graveyard
Reply With Quote #21

Quote:
Originally Posted by Arkshine View Post
It's fixed for the next version, but do that :

search set_pdata_int( player, m_iClientHideHUD, 0 );

replace with set_pdata_int( player, m_iClientHideHUD, -1 );
Ok, thanks.

EDIT: Doesn't work :'( This is the code:
PHP Code:
/* - - - - - - - - - - -

    AMX Mod X script.

    ¦ Author  : Andrade, Arkshine
    ¦ Plugin  : Prototype Groundspike Graveyard
    ¦ Version : v1.0.0

    (¡) Support : http://forums.alliedmods.net/showthread.php?t=146984

    This plugin is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation; either version 2 of the License, or (at
    your option) any later version.

    This plugin is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


    Description
    ─ ─ ─ ─ ─ ─
        This plugin features a special attack borrowed from the game Prototype now in Counter-Strike style.
        Instead of explaining by words, check yourself by viewing this video.

    Requirements
    ─ ─ ─ ─ ─ ─ ─
        CS 1.6, CZ.
        AMX Mod X 1.8.x or higher.

    Commands
    ─ ─ ─ ─ ─
        * protospike : Start the protospike attack.
        * protospike_help : Show the plugin help.

    Credits
    ─ ─ ─ ─
        * joaquimandrade : Original author.
        * Tirant         : Spike model.

- - - - - - - - - - - */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>
#include <hamsandwich>
#include <xs>
#include <cstrike>


new const Plugin [] = "Prototype Groundspike Graveyard";
new const 
Author [] = "Andrade, Arkshine";
new const 
Version[] = "1.0";


/*
[ PLAYER ]

    ├ GENERAL CONSTANT
*/
        
const MaxSlots 32;
/*
    ├ PRIVATE DATA OFFSETS
*/
        
const m_iHideHUD          361;
        const 
m_iClientHideHUD    362;
        const 
m_pClientActiveItem 374;
        const 
m_fInitHUD          348;
/*
    ├ PLAYER HANDLING
*/
        
const ViewmodelMaxLen     150;
        const 
Float:BloodInterval 1.5;
    
        new 
bool:PlayerIsUsingAttack  MaxSlots ];
        new 
bool:PlayerPreventCorpse  MaxSlots ];
        new 
PlayerLookalike           MaxSlots ];

        new 
PlayerOriginalFlags       MaxSlots ];
        new 
Float:PlayerOriginalAnglesMaxSlots ][ ];
        new 
Float:PlayerOriginalOriginMaxSlots ][ ];
        new 
PlayerOriginalViewmodel   MaxSlots ][ ViewmodelMaxLen ];
        new 
PlayerOriginalActiveItem  MaxSlots ];
/*
    ├ CAMERA HANDLING
*/
        
const Float:FramesPerCameraRotation 300.0;
        const 
Float:RotationDegrees         160.0;
        const 
Float:RotationRadius          100.0;

        new 
Float:DegreeIncreasePerFrame;

        new Array:
PlayerCameraOriginQueueMaxSlots ];
        new Array:
PlayerCameraAnglesQueueMaxSlots ];
/*
    ├ CLIENT CVARS PERMISSION
*/
        
new bool:AskPermission MaxSlots ];
        new 
bool:CommandAllowedMaxSlots ];

        new 
Trie:TrieAuthIdCache;
        new 
PermissionMenu512 ];

/*
[ SPIKE ]

    ├ ENTITY CONSTANTS
*/
        
new const SpikeModel[] = "models/spike.mdl";

        new const 
SpikeEmergeSound  [] = "weapons/hegrenade-1.wav";
        new const 
SpikeUnemergeSound[] = "ImpaleLaunch1.wav";

        new const 
SpikeClassname[] = "protospike";
/*
    ├ ANIMATION HANDLING
*/
        
enum Animation
        
{
            
Summon,
        };

        
enum AnimationProperty
        
{
            
Sequence,
            
FirstFrame,
            
FinalFrame,
            
FramesPerServerFrame,
        };

        new 
AnimationsDataAnimation ][ AnimationProperty ] =
        {
            {
                
29,
                
115,
                
30,
                
2
            
}
        };

        new Array:
AnimationsPackedAnimation ];

        
enum _:EntityAnimation
        
{
            
EntityID,
            Array:
AnimationPack,
            
CallbackFuncID
        
};
        
        new 
PlayerAnimationQueueMaxSlots ][ EntityAnimation ];
/*
    ├ DATAS
*/
        
const SpikesNumber 9;

        const 
Float:SpikeCalcRadiusStart     50.0;
        const 
Float:SpikeCalcRadiusIncrement 10.0;

        const 
SpikesFirstCircle       5;
        const 
SpikesPerCircleIncrease 4;
        const 
SpikesCircles           3;

        const 
Float:SpikesMaxHeightMax 130.0;
        const 
Float:SpikesMaxHeightMin 90.0;

        const 
Float:SpikeMinHeight 10.0;

        const 
Float:SpikeHeightIncrementPerFrame 6.0;
        const 
Float:SpikeHeightDecrementPerFrame 1.5;

        const 
SpikeFramesIdle 400;

        
enum _:PlayerSpikeData
        
{
            
SpikeID,
            Array:
SpikeOrigins
        
}

        
enum _:PlayerSpikeOriginQueueData
        
{
            Array:
Queue,
            
SpikeCallbackFuncID,
            
UnemergeFramesMissing
        
}

        new 
PlayerSpikeOriginQueueMaxSlots ][ PlayerSpikeOriginQueueData ];


public 
plugin_precache()
{
    
precache_modelSpikeModel );
    
precache_soundSpikeEmergeSound );
    
precache_soundSpikeUnemergeSound );
}

public 
plugin_init()
{
    
register_pluginPluginVersionAuthor );

    
register_clcmd"protospike""ClientCommand_Protospike" );
    
register_clcmd"protospike_help""ClientCommand_ProtospikeHelp" );

    
register_touch"player"SpikeClassname"Spike_PlayerTouch" );
    
RegisterHamHam_Spawn"player""CBasePlayer_Spawn" );

    
register_messageget_user_msgid"ClCorpse" ), "Event_ClCorpse" );

    
handlePermissionMenu();
}

public 
plugin_cfg()
{
    
packAnimations();

    
DegreeIncreasePerFrame RotationDegrees FramesPerCameraRotation;
}


/*
    ┌──────────────────┐
    │  GENERAL PLAYER  │
    └──────────────────┘

        → client_authorized()
        → client_disconnect()
            └ protospikeFinish()
        → CBasePlayer_Spawn()
            └ protospikeFinish()
        → Event_ClCorpse()
        → handlePermissionMenu()
        → MenuPermissionHandler()
*/

public client_authorizedclient )
{
    static 
authId34 ];
    
get_user_authidclientauthIdcharsmaxauthId ) );

    if( !
TrieKeyExistsTrieAuthIdCacheauthId ) )
    {
        
TrieSetCellTrieAuthIdCacheauthIdtrue );
        
AskPermissionclient ] = true;
    }
}

public 
client_disconnectclient )
{
    
AskPermissionclient ] = false;

    if( 
PlayerIsUsingAttackclient ] )
    {
        
protospikeFinishclient, .fixPosition false, .fixAngles false, .fixHud false );
    }
}

public 
CBasePlayer_Spawn( const player )
{
    if( 
PlayerIsUsingAttackplayer ] )
    {
        
protospikeFinishplayer, .fixPosition false, .fixAngles false, .fixHud true );
    }
    else if( 
AskPermissionplayer ] )
    {
        
show_menuplayerMENU_KEY_1 MENU_KEY_0PermissionMenu, .title "PlayerPermissionMenu" );
    }
}

public 
Event_ClCorpse()
{
    new 
player get_msg_arg_int12 );

    if( 
PlayerPreventCorpseplayer ] )
    {
        
PlayerPreventCorpseplayer ] = false;
        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}

handlePermissionMenu()
{
    
TrieAuthIdCache TrieCreate();
    
register_menu"PlayerPermissionMenu"0x3FF"MenuPermissionHandler" );

    new 
len formatexPermissionMenucharsmaxPermissionMenu ), "\rProtospike Attack^n^n" );

    
len += formatexPermissionMenulen ], charsmaxPermissionMenu ) - len"\wThis server features a special attack borrowed from the game Prototype^n" );
    
len += formatexPermissionMenulen ], charsmaxPermissionMenu ) - len"now in Counter-Strike style.^n^nTo launch it use the console command ^"\dprotospike\w^".^n^n" );
    
len += formatexPermissionMenulen ], charsmaxPermissionMenu ) - len"Beware that it modifies settings of your configuration It restores them when^n" );
    
len += formatexPermissionMenulen ], charsmaxPermissionMenu ) - len"the attack is finished. If you leave the game meanwhile you will have to^n" );
    
len += formatexPermissionMenulen ], charsmaxPermissionMenu ) - len"restore them yourself. Use the command ^"\dprotospike_help\w^" to view^n" );
    
len += formatexPermissionMenulen ], charsmaxPermissionMenu ) - len"the settings that are modified and their current values.^n^n" );

    
formatexPermissionMenulen ], charsmaxPermissionMenu ) - len"\r1.\w Ok^n^n^n\r0.\w Cancel" );
}

public 
MenuPermissionHandler( const player, const key )
{
    
CommandAllowedplayer ] = bool:( key );
    return 
PLUGIN_HANDLED;
}

/*
    ┌───────────────────┐
    │  CLIENT COMMANDS  │
    └───────────────────┘

        → ClientCommand_Protospike()
        → ClientCommand_ProtospikeHelp()
*/

public ClientCommand_Protospike( const player )
{
    if( !
CommandAllowedplayer ] )
    {
        
client_printplayerprint_chat"The command is disabled for you." );
    }
    else if( !
is_user_aliveplayer ) )
    {
        
client_printplayerprint_chat"You have to be alive to launch the attack" );
    }
    else if( 
PlayerIsUsingAttackplayer ] )
    {
        
client_printplayerprint_chat"You are already using the attack" );
    }
    else if( ~
pevplayerpev_flags ) & FL_ONGROUND )
    {
        
client_printplayerprint_chat"You have to be on ground to launch the attack" );
    }
    else
    {
        
protospikeStartplayer );
    }

    return 
PLUGIN_HANDLED
}

public 
ClientCommand_ProtospikeHelp( const client )
{
    
console_printclient" --- " );
    
console_printclient"This server features a special attack borrowed from the game Prototype now in Counter-Strike style." );
    
console_printclient"To launch it use the console command ^"protospike^"^n" );
    
console_printclient"Beware that it modifies settings of your configuration It restores them when the attack is finished." );
    
console_printclient"If you leave the game meanwhile you will have to restore them yourself.^n" );
    
console_printclient"Here a list of settings that are modified with their default value :" );
    
console_printclient"cl_vsmoothing 0.05^ncl_nosmooth 0^ncl_smoothtime 0.1" );
    
console_printclient" --- " );

    return 
PLUGIN_HANDLED;
}


/*
    ┌───────────────────────┐
    │  PROTOSPIKE HANDLING  │
    └───────────────────────┘

        → protospikeStart()
            ├ getLookalike()
            ├ getAnimationPack()
            ├ calculatePlayerCameraData()
            └ removeClientPrediction()
        → protospikeFinish()
            ├ restoreClientPrediction()
            ├ tryDeletePlayerCameraData()
            ├ tryDeleteSpikesData()
            └ tryDeleteAnimationData()
        → client_PreThink()
            └ makeBloodAt()
*/

protospikeStart( const player )
{
    
set_pevplayerpev_effects,pevplayerpev_effects) | EF_NODRAW );

    new 
Float:angles];
    new 
Float:origin];

    
pevplayerpev_anglesangles );
    
pevplayer,pev_origin,origin );

    
xs_vec_copyanglesPlayerOriginalAnglesplayer ] );
    
xs_vec_copyoriginPlayerOriginalOriginplayer ] );

    
angles] = 0.0;

    
set_pevplayerpev_angles,angles );
    
set_pevplayerpev_v_angle,angles );
    
set_pevplayerpev_fixangle);

    
set_pevplayerpev_movetypeMOVETYPE_NOCLIP );
    
set_pevplayerpev_solidSOLID_NOT );

    new 
lookalike getLookalikeplayer );
    
PlayerLookalikeplayer ] = lookalike;

    
entity_set_originlookalikePlayerOriginalOriginplayer ] );

    
set_pevlookalikepev_anglesPlayerOriginalAnglesplayer ] );
    
set_pevlookalikepev_sequenceAnimationsDataSummon ][ Sequence ] );

    
fm_set_user_renderinglookalikekRenderFxGlowShell, .amount 30, .50, .50, .50 );

    
PlayerAnimationQueueplayer ][ EntityID ] = lookalike
    PlayerAnimationQueue
player ][ AnimationPack ] = _:getAnimationPackSummon );
    
PlayerAnimationQueueplayer ][ CallbackFuncID ] = get_func_id"finishSummoningAnimation" );

    
PlayerOriginalActiveItemplayer ] = get_pdata_cbaseplayerm_pClientActiveItem );

    
set_pdata_intplayerm_iHideHUD, ~);
//    set_pdata_int( player, m_iClientHideHUD, 0 );
    
set_pdata_intplayerm_iClientHideHUD, -);
    
set_pdata_cbaseplayerm_pClientActiveItemFM_NULLENT );

    
client_cmdplayer"stopsound" );

    
pevplayerpev_viewmodelPlayerOriginalViewmodelplayer ], ViewmodelMaxLen );
    
set_pevplayerpev_viewmodel"" );

    
calculatePlayerCameraDataplayeroriginangles );

    
set_pevplayerpev_flags, ( PlayerOriginalFlagsplayer ] = pevplayerpev_flags ) ) | FL_FLY FL_FROZEN FL_GODMODE & ~FL_ONGROUND )

    
PlayerIsUsingAttackplayer ] = true;

    
removeClientPredictionplayer );
}

getLookalike( const player )
{
    new 
entity create_entity"info_target" );

    
set_peventitypev_movetypeMOVETYPE_NONE );
    
set_peventitypev_ownerplayer );
    
set_peventitypev_framerate0.0 );

    static 
model20 ];
    static 
modelPath100 ];

    
cs_get_user_modelplayermodelcharsmaxmodel ) );
    
formatexmodelPathcharsmaxmodelPath ), "models/player/%s/%s.mdl"modelmodel );

    
entity_set_modelentitymodelPath );

    return 
entity;
}

protospikeFinish( const playerfixPosition truefixAngles truefixHud true )
{
    
set_pevplayerpev_effectspevplayerpev_effects ) & ~EF_NODRAW );

    if( 
fixAngles )
    {
        
set_pevplayerpev_anglesPlayerOriginalAnglesplayer ] )
        
set_pevplayerpev_v_anglePlayerOriginalAnglesplayer ] )
        
set_pevplayerpev_fixangle,);
    }

    
set_pevplayerpev_movetypeMOVETYPE_WALK );
    
set_pevplayerpev_solidSOLID_SLIDEBOX );

    if( 
fixPosition )
    {
        
entity_set_originplayerPlayerOriginalOriginplayer ] );
    }

    
remove_entityPlayerLookalikeplayer ] );

    if( 
fixHud )
    {
        
set_pdata_intplayerm_iHideHUD);
        
set_pdata_intplayerm_iClientHideHUD);
        
set_pdata_cbaseplayerm_pClientActiveItemPlayerOriginalActiveItemplayer ] );
        
set_pdata_intplayerm_fInitHUD);

        static 
msgIdCrosshair;

        if( 
msgIdCrosshair || ( msgIdCrosshair get_user_msgid"Crosshair" ) ) )
        {
            
message_beginMSG_ONE_UNRELIABLEmsgIdCrosshair, .player player );
            
write_byte);
            
message_end();
        }

        
set_pevplayerpev_weaponmodelPlayerOriginalViewmodelplayer ] );

        new 
weaponID get_pdata_cbaseplayerm_pClientActiveItem );

        if( 
weaponID )
        {
            
ExecuteHamHam_Item_DeployweaponID );
        }
    }

    
set_pevplayerpev_flagsPlayerOriginalFlagsplayer ] );

    
PlayerIsUsingAttackplayer ] = false;

    
restoreClientPredictionplayer );

    
tryDeletePlayerCameraDataplayer );
    
tryDeleteSpikesDataplayer );
    
tryDeleteAnimationDataplayer );
}

tryDeletePlayerCameraData( const player )
{
    if( 
PlayerCameraOriginQueueplayer ] )
    {
        
ArrayDestroyPlayerCameraOriginQueueplayer ] );
        
ArrayDestroyPlayerCameraAnglesQueueplayer ] );

        
PlayerCameraOriginQueueplayer ] = Array:0;
        
PlayerCameraAnglesQueueplayer ] = Array:0;
    }
}

tryDeleteSpikesData( const player )
{
    new Array:
playerSpikeOriginQueue PlayerSpikeOriginQueueplayer ][ Queue ];

    if( 
playerSpikeOriginQueue )
    {
        new 
playerSpikeDataPlayerSpikeData ];

        new Array:
bodies;
        new 
spike;

        new 
queueSize ArraySizeplayerSpikeOriginQueue );

        for( new 
0jbodiesSizequeueSizei++ )
        {
            
ArrayGetArrayplayerSpikeOriginQueueiplayerSpikeData );

            
spike playerSpikeDataSpikeID ];

            
bodies = Array:pevspikepev_iuser1 );

            if( 
bodies )
            {
                
bodiesSize ArraySizebodies );

                for( 
0bodiesSizej++ )
                {
                    
remove_entityArrayGetCellbodies) );
                }
            }

            
remove_entityspike );
        }

        
ArrayDestroyplayerSpikeOriginQueue );
        
PlayerSpikeOriginQueueplayer ][ Queue ] = 0;
    }
}

tryDeleteAnimationData( const player )
{
    new 
animatingEntity PlayerAnimationQueueplayer ][ EntityID ];

    if( 
animatingEntity )
    {
        
ArrayDestroyPlayerAnimationQueueplayer ][AnimationPack] );
        
PlayerAnimationQueueplayer ][ EntityID ] = 0;
    }
}

public 
client_PreThinkplayer )
{
    static 
Float:origin];
    static 
Float:angles];

    if( 
PlayerCameraOriginQueueplayer ] )
    {
        new Array:
cameraOrigins PlayerCameraOriginQueueplayer ];
        new Array:
cameraAngles PlayerCameraAnglesQueueplayer ];

        
ArrayGetArraycameraOrigins0origin );
        
ArrayGetArraycameraAngles0angles );

        
entity_set_originplayerorigin );

        
set_pevplayerpev_anglesangles );
        
set_pevplayerpev_v_angleangles );
        
set_pevplayerpev_fixangle);

        if( 
ArraySizecameraOrigins ) > )
        {
            
ArrayDeleteItemcameraOrigins);
            
ArrayDeleteItemcameraAngles);
        }
    }
    
    new Array:
playerSpikeOriginQueue PlayerSpikeOriginQueueplayer ][ Queue ];

    if( 
playerSpikeOriginQueue )
    {
        static 
playerSpikeDataPlayerSpikeData ];
        static 
Float:lastTimeMadeBlood;
        static 
Float:currentTime;
        static Array:
spikesOrigins;
        static Array:
bodies;
        static 
spike;
        static 
bodiesSize;
        static 
body;

        for( new 
0jkArraySizeplayerSpikeOriginQueue ); i++ )
        {
            
ArrayGetArrayplayerSpikeOriginQueueiplayerSpikeData );

            
spike playerSpikeDataSpikeID ];
            
spikesOrigins playerSpikeDataSpikeOrigins ];

            if( 
ArraySizespikesOrigins ) > )
            {
                
ArrayGetArrayspikesOrigins0origin );

                
bodies = Array:pevspikepev_iuser1 );

                if( 
bodies )
                {
                    static 
Float:oldOrigin];
                    static 
Float:originDiff];
                    static 
Float:bodyOrigin];

                    
pevspikepev_originoldOrigin );
                    
xs_vec_suboriginoldOriginoriginDiff );

                    
bodiesSize ArraySizebodies );

                    for( 
0bodiesSizej++ )
                    {
                        
body ArrayGetCellbodies);

                        
pevbodypev_originbodyOrigin );
                        
pevbodypev_fuser1lastTimeMadeBlood );

                        
xs_vec_addbodyOriginoriginDiffbodyOrigin );
                        
entity_set_originbodybodyOrigin );

                        
currentTime get_gametime();

                        if( ( 
lastTimeMadeBlood BloodInterval random_float( -1.01.0 ) ) <= currentTime )
                        {
                            
set_pevbodypev_fuser1currentTime );
                            
makeBloodAtbodyOrigin );
                        }
                    }
                }

                
entity_set_originspikeorigin );

                
ArrayDeleteItemspikesOrigins);

                if( !
ArraySizespikesOrigins ) )
                {
                    
ArrayDeleteItemplayerSpikeOriginQueuei-- );
                    
remove_entityspike );

                    if( 
bodies )
                    {
                        for( 
0ArraySizebodies ); k++ )
                        {
                            
remove_entityArrayGetCellbodies) );
                        }
                    }
                }
            }
        }

        if( --
PlayerSpikeOriginQueueplayer ][ UnemergeFramesMissing ] == )
        {
            
pevPlayerLookalikeplayer ], pev_originorigin );
            
engfuncEngFunc_EmitAmbientSound0originSpikeUnemergeSoundVOL_NORMATTN_NORM0PITCH_NORM );
        }

        if( !
ArraySizeplayerSpikeOriginQueue ) )
        {
            
PlayerSpikeOriginQueueplayer ][ Queue ] = 0;

            new 
callbackFuncID PlayerSpikeOriginQueueplayer ][ SpikeCallbackFuncID ];

            if( 
callbackFuncID )
            {
                
callfunc_begin_icallbackFuncID );
                
callfunc_push_intplayer );
                
callfunc_end();
            }
        }
    }

    new 
animatingEntity PlayerAnimationQueueplayer ][ EntityID ];

    if( 
animatingEntity )
    {
        new Array:
animationPack = Array:PlayerAnimationQueueplayer ][ AnimationPack ];
        new 
frame ArrayGetCellanimationPack);

        
set_pevanimatingEntitypev_frameframe );

        
ArrayDeleteItemanimationPack);

        if( !
ArraySizeanimationPack ) )
        {
            
PlayerAnimationQueueplayer ][ EntityID ] = 0;

            new 
callbackFuncID PlayerAnimationQueueplayer ][ CallbackFuncID ];

            if( 
callbackFuncID )
            {
                
callfunc_begin_icallbackFuncID );
                
callfunc_push_intanimatingEntity );
                
callfunc_end();
            }
        }
    }
}

makeBloodAt( const Float:origin] )
{
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_BLOODSTREAM );
    
engfuncEngFunc_WriteCoordorigin] );
    
engfuncEngFunc_WriteCoordorigin] );
    
engfuncEngFunc_WriteCoordorigin] );
    
write_coordrandom_num( -360360 ) );
    
write_coordrandom_num( -360360 ) );
    
write_coordrandom_num180360 ) );
    
write_byte70 );
    
write_byte100 );
    
message_end();
}


/*
    ┌───────────────────┐
    │  CAMERA HANDLING  │
    └───────────────────┘

        → calculatePlayerCameraData()
*/
calculatePlayerCameraData( const playerFloat:origin], Float:angles] )
{
    new Array:
cameraOrigins ArrayCreate);
    new Array:
cameraAngles ArrayCreate);

    new 
Float:dislocationVector];
    new 
Float:dislocation];
    new 
Float:dislocatedOrigin];

    
angle_vectoranglesANGLEVECTOR_FORWARDdislocationVector );

    
xs_vec_mul_scalardislocationVectorRotationRadiusdislocation );
    
xs_vec_addorigindislocationdislocatedOrigin );

    
angles] -= 180.0;

    new 
Float:point];
    new 
Float:pointOriginDiff];
    new 
Float:cameraAngle];

    for( new 
1<= FramesPerCameraRotationi++ )
    {
        
angle_vectoranglesANGLEVECTOR_FORWARDpoint );

        
xs_vec_mul_scalarpointRotationRadiuspoint );
        
xs_vec_adddislocatedOriginpointpoint );

        
ArrayPushArraycameraOriginspoint );

        
xs_vec_suboriginpointpointOriginDiff );
        
xs_vec_normalizepointOriginDiffpointOriginDiff );

        
vector_to_anglepointOriginDiffcameraAngle );

        
ArrayPushArraycameraAnglescameraAngle );

        
angles] += DegreeIncreasePerFrame;
    }

    
PlayerCameraOriginQueueplayer ] = cameraOrigins;
    
PlayerCameraAnglesQueueplayer ] = cameraAngles;
}

/*
    ┌───────────────────────────┐
    │  PACK ANIMATION HANDLING  │
    └───────────────────────────┘

        → packAnimations()
        → getAnimationPack()
*/

packAnimations()
{
    new Array:
animationPack;
    new 
animationFirstFrame;
    new 
animationFinalFrame;
    new 
animationFramesPerServerFrame;
    new 
increment;

    for( new 
Animation:Animation:0frameframeCopyAnimationi++ )
    {
        
animationPack ArrayCreate()

        
animationFirstFrame AnimationsData][ FirstFrame ];
        
animationFinalFrame AnimationsData][ FinalFrame ];
        
animationFramesPerServerFrame AnimationsData][ FramesPerServerFrame ];

        
increment = ( animationFirstFrame animationFinalFrame ) ? : -1;

        for( 
frame animationFirstFrameframe != animationFinalFrame increment frame += increment )
        {
            for( 
frameCopy 1frameCopy <= animationFramesPerServerFrameframeCopy++ )
            {
                
ArrayPushCellanimationPack ,floatframe ) );
            }
        }

        
AnimationsPacked] = animationPack;
    }
}

Array:
getAnimationPackAnimation:animation )
{
    new Array:
animationPack ArrayCreate();
    new Array:
originalAnimationPack AnimationsPackedanimation ];

    new 
pachSize ArraySizeoriginalAnimationPack );

    for(new 
0pachSizei++)
    {
        
ArrayPushCellanimationPackArrayGetCelloriginalAnimationPack) );
    }

    return 
animationPack;
}


/*
    ┌─────────────────────────┐
    │  CLIENT CVARS HANDLING  │
    └─────────────────────────┘

        → removeClientPrediction()
        → restoreClientPrediction()
*/

removeClientPrediction( const player )
{
    
client_cmdplayer"cl_vsmoothing 0" );
    
client_cmdplayer"cl_nosmooth 1" );
    
client_cmdplayer"cl_smoothtime 0" );
}

restoreClientPrediction( const player )
{
    
client_cmdplayer"cl_vsmoothing 0.05" );
    
client_cmdplayer"cl_nosmooth 0" );
    
client_cmdplayer"cl_smoothtime 0.1" );
}


/*
    ┌──────────────────┐
    │  SPIKE HANDLING  │
    └──────────────────┘

        → Spike_PlayerTouch()
            └ attachToSpike()
                └ createBody()
        → finishSummoningAnimation()
            └ calculateSpikesData()
                └ getSpike()
        → finishSpikeMovement()
            └ protospikeFinish()
*/

public Spike_PlayerTouch( const player, const spike )
{
    if( 
is_user_aliveplayer ) )
    {
        
attachToSpikespikecreateBodyplayerspike ) );

        
ExecuteHam (Ham_Killedplayerpevspikepev_owner ), );
        
set_pevplayerpev_effectspevplayerpev_effects ) | EF_NODRAW );

        
PlayerPreventCorpseplayer ] = true;
    }
}

attachToSpike( const spike, const body )
{
    new Array:
bodies = Array:pevspikepev_iuser1 );

    if( !
bodies )
    {
        
set_pevspikepev_iuser1bodies ArrayCreate() );
    }

    
ArrayPushCellbodiesbody );
    
fm_set_user_renderingspikekRenderFxGlowShell, .amount 10, .50, .50, .50 );
}

createBody( const player, const spike )
{
    new 
body create_entity"info_target" );

    const 
sequence 8;

    static 
model20 ];
    static 
modelPath100 ];

    
cs_get_user_modelplayermodelcharsmaxmodel ) );
    
formatexmodelPathcharsmaxmodelPath ), "models/player/%s/%s.mdl"modelmodel );

    
set_pevbodypev_framerate0.0 );
    
set_pevbodypev_sequencesequence );
    
set_pevbodypev_framerandom_float17.022.0 ) );

    
entity_set_modelbodymodelPath );

    
set_pevbodypev_movetypeMOVETYPE_NONE );
    
set_pevbody ,pev_solidSOLID_NOT );

    static 
Float:origin];
    static 
Float:angles];
    static 
Float:spikeOrigin];

    
pevplayerpev_originorigin );
    
pevplayerpev_anglesangles );

    
set_pevbodypev_anglesangles );
    
set_pevbodypev_fixangle);

    
pevspikepev_originspikeOrigin );

    
engfuncEngFunc_TraceModeloriginspikeOriginHULL_POINTspike);
    
get_tr20TR_vecEndPosorigin );

    
origin] -= random_float30.040.0 );
    
entity_set_originbodyorigin );

    return 
body;
}

public 
finishSummoningAnimation( const entity )
{
    
calculateSpikesDatapeventitypev_owner ) );

    new 
Float:origin];
    
peventitypev_originorigin );

    
engfuncEngFunc_EmitAmbientSound0originSpikeEmergeSoundVOL_NORMATTN_NORM0PITCH_NORM );
}

public 
finishSpikeMovement( const player )
{
    
protospikeFinishplayer );
}

calculateSpikesData( const player )
{
    new 
lookalike PlayerLookalikeplayer ];

    new 
Float:origin];
    new 
Float:angles];
    new 
Float:position];
    new 
Float:positionTrace];

    
pevlookalikepev_originorigin );

    new 
spikesNumber SpikesFirstCircle;

    new 
Float:radius SpikeCalcRadiusStart;
    new 
Float:radiusIncrement SpikeCalcRadiusIncrement;

    new Array:
playerSpikes ArrayCreate_:PlayerSpikeData );
    new Array:
spikesOrigins;

    new 
longerAnimationFrames;
    new 
longerAnimationFramesFramesDown;

    new 
playerSpikeDataPlayerSpikeData ];
    new 
Float:maxHeight;
    new 
Float:anglesIncrement;
    new 
spike;
    new 
framesUp;
    new 
framesDown;
    new 
frames;

    for( new 
0jkSpikesCirclesi++ )
    {
        
angles] = random_float0.0360.0 );

        
anglesIncrement 360.0 spikesNumber;

        for( 
0spikesNumberj++ )
        {
            
angle_vectoranglesANGLEVECTOR_FORWARDposition );

            
xs_vec_mul_scalarpositionradiusposition );
            
xs_vec_addoriginpositionposition );
            
xs_vec_copypositionpositionTrace );

            
positionTrace] = -9999.99;

            
trace_line0positionpositionTraceposition );

            
position] += SpikeMinHeight;

            
spike getSpikeplayer );

            
maxHeight random_floatSpikesMaxHeightMinSpikesMaxHeightMax );

            
framesUp floatround( ( maxHeight floatabsSpikeMinHeight ) ) / SpikeHeightIncrementPerFramefloatround_ceil );
            
framesDown floatround( ( maxHeight floatabsSpikeMinHeight) ) / SpikeHeightDecrementPerFramefloatround_ceil );

            
frames framesUp SpikeFramesIdle framesDown;

            if( 
frames longerAnimationFrames )
            {
                
longerAnimationFrames frames;
                
longerAnimationFramesFramesDown framesDown;
            }

            
spikesOrigins ArrayCreate);

            
ArrayPushArrayspikesOriginsposition );

            for( 
0framesUpk++ )
            {
                
position] += SpikeHeightIncrementPerFrame;
                
ArrayPushArrayspikesOriginsposition );
            }

            for( 
0SpikeFramesIdlek++ )
            {
                
ArrayPushArrayspikesOriginsposition );
            }

            for( 
0framesDownk++ )
            {
                
position] -= SpikeHeightDecrementPerFrame random_float( -1.21.2 );
                
ArrayPushArrayspikesOriginsposition );
            }

            
playerSpikeDataSpikeID ] = spike;
            
playerSpikeDataSpikeOrigins ] = _:spikesOrigins;

            
ArrayPushArrayplayerSpikesplayerSpikeData );

            
radius += radiusIncrement;
            
angles] += anglesIncrement;
        }

        
spikesNumber += SpikesPerCircleIncrease;
    }

    
PlayerSpikeOriginQueueplayer ][ Queue ] = _:playerSpikes
    PlayerSpikeOriginQueue
player ][ SpikeCallbackFuncID ] = get_func_id"finishSpikeMovement" );
    
PlayerSpikeOriginQueueplayer ][ UnemergeFramesMissing ] = longerAnimationFrames floatround( ( floatlongerAnimationFramesFramesDown ) / 1.2 ) );
}

getSpike( const player )
{
    new 
entity create_entity"info_target" );

    
set_peventitypev_ownerplayer );
    
set_peventitypev_classnameSpikeClassname );

    
set_peventitypev_solidSOLID_BBOX );

    
entity_set_modelentitySpikeModel );
    
entity_set_originentityFloat:{ 0.00.00.0 } );
    
entity_set_sizeentityFloat:{ -5.0, -5.0, -100.0 }, Float:{ 5.05.0100.0 } );

    return 
entity;

__________________

Last edited by Kidev; 01-05-2011 at 10:54.
Kidev is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2011 , 11:21   Re: Prototype Groundspike Graveyard
Reply With Quote #22

Don't put the whole code.

I've tested before posting. It works. Make sure you compile and replace properly, and restart.
__________________
Arkshine is offline
Old 01-05-2011, 12:49
joaquimandrade
This message has been deleted by joaquimandrade.
bibu
Veteran Member
Join Date: Sep 2010
Old 01-05-2011 , 14:06   Re: Prototype Groundspike Graveyard
Reply With Quote #23

Awesome plugin again, thanks quim / arkshine.
bibu is offline
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 01-05-2011 , 16:24   Re: Prototype Groundspike Graveyard
Reply With Quote #24

boludo ; )
__________________
Javivi is offline
The Art of War
Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
Old 01-05-2011 , 18:14   Re: Prototype Groundspike Graveyard
Reply With Quote #25

So, I dont want to look through the entire code, and yes Ive seen the video. Is it like an attack you spawn on keydown or is it an automatic thingy or whatever? :p Thanks.
__________________
The Art of War is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 01-05-2011 , 18:23   Re: Prototype Groundspike Graveyard
Reply With Quote #26

I wonder how many hidden things these moderators
this site has.
I think there are many plugins that were not disclosed.
__________________
rx1983 is offline
Send a message via MSN to rx1983
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 01-05-2011 , 20:27   Re: Prototype Groundspike Graveyard
Reply With Quote #27

I'm curious as to why you create a fake player and then move the actual player around and adjust angles instead of just using attach_view with an entity and adjust the entity instead.

I think it's also a bad habit to do Array:0 as that could potentially be a valid cell array. You should use the constant Invalid_Array and do the corresponding if checks against that instead of the 0 value.

I'd try to stay away from variable names with the exact same spelling to reduce confusion:
Code:
new Array:playerSpikeOriginQueue = PlayerSpikeOriginQueue[ player ][ Queue ];
I would suggest at least adding g to the global's name so you can identify easily that it is the global variable.

Not really sure why you're messing with callfunc_* instead of just doing the function.

Line 307:
Code:
CommandAllowed[ player ] = bool:( key + 1 );
That is setting it to true regardless of what the player selects. bool:0 only returns false.
Instead change it to
Code:
CommandAllowed[ player ] = bool:( key == 0 );
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 01-05-2011 , 20:39   Re: Prototype Groundspike Graveyard
Reply With Quote #28

I'll respond for my part

Quote:
Originally Posted by Emp` View Post
I'm curious as to why you create a fake player and then move the actual player around and adjust angles instead of just using attach_view with an entity and adjust the entity instead.
I haven't thought of that. It sound like an improvement but remaking that part is hard and not worth the effort.

Quote:
Originally Posted by Emp` View Post
I think it's also a bad habit to do Array:0 as that could potentially be a valid cell array. You should use the constant Invalid_Array and do the corresponding if checks against that instead of the 0 value.
Should be changed.

Quote:
Originally Posted by Emp` View Post
I'd try to stay away from variable names with the exact same spelling to reduce confusion:
Code:
new Array:playerSpikeOriginQueue = PlayerSpikeOriginQueue[ player ][ Queue ];
I would suggest at least adding g to the global's name so you can identify easily that it is the global variable.
Our globals start with caps.

About:

PHP Code:
new Array:playerSpikeOriginQueue PlayerSpikeOriginQueueplayer ][ Queue 
I normally (and was meant to be like) do it like:

PHP Code:
new Array:playerSpikeOriginQueue PlayersSpikeOriginQueueplayer ][ Queue 
(Difference in "Players").

Quote:
Originally Posted by Emp` View Post
Not really sure why you're messing with callfunc_* instead of just doing the function.
As with animations, when I made the plugin I had another ideas and that is the explanation for that. Basically support to end the animation with other functions. So it can be changed too.
__________________

Last edited by joaquimandrade; 01-05-2011 at 20:41.
joaquimandrade is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 01-05-2011 , 21:16   Re: Prototype Groundspike Graveyard
Reply With Quote #29

Quote:
Originally Posted by The Art of War View Post
So, I dont want to look through the entire code, and yes Ive seen the video. Is it like an attack you spawn on keydown or is it an automatic thingy or whatever? :p Thanks.
Sorry Art of War, haven't saw your question. Attack on command issue.
__________________
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-06-2011 , 02:19   Re: Prototype Groundspike Graveyard
Reply With Quote #30

Thanks Emp`. Changes are ready for the next update.
__________________
Arkshine is offline
Reply


Thread Tools
Display Modes

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 17:33.


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