Raised This Month: $12 Target: $400
 3% 

Orpheu: Engine PM Functions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-11-2010 , 10:30   Orpheu: Engine PM Functions
Reply With Quote #1

In half life engine there is a part of the code where the physic calculations to player movement happen (jumping, ducking, moving on water, no clipping, etc). It is unexplored in scripting because those functions are not acessible normally. With orpheu you can use them.

The entry point for the calculations is the function PM_Move, that has the following header:

PHP Code:
PM_Move struct playermove_s *ppmoveint server 
The first argument is a structure (a group of data belonging to a player) that is saved when PM_Move is called and then used in other PM functions.

You can see the structure data here:

http://metamod.org/sdk/dox/pm__defs_8h-source.html

When using Orpheu to hook PM functions the way of accessing the ppmove structure varies from PM_Move to other functions.

In PM_Move you can use it directly:
PHP Code:
public PM_Move(ppmove,server)
{
    new 
Float:gravity Float:OrpheuGetParamStructMember(1,"gravity")

In other functions you have to get ppmove from memory and use it after.
We need to declare in a file how to obtain it from memory but that part is already made by me so you just have to care with using it:

PHP Code:
OrpheuStruct:get_ppmove()
{        
    return 
OrpheuGetStructFromAddress(OrpheuStructPlayerMove,OrpheuMemoryGet("ppmove"))
}
   
public 
PM_Duck()
{
    new 
OrpheuStruct:ppmove get_ppmove()
        
    new 
gravity OrpheuGetStructMember(ppmove,"gravity")

To retrieve the id of a player you should use the member of ppmove called "player_index":

PHP Code:
new id OrpheuGetStructMember(ppmove,"player_index") + 
A full example on blocking duck for non bot players:


PHP Code:

#include <amxmodx>
#include <orpheu>
#include <orpheu_advanced>
#include <orpheu_memory>
    
public plugin_init()
{        
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Duck"),"OnPM_Duck")
}

public 
OrpheuHookReturn:OnPM_Duck()
{
    new 
OrpheuStruct:ppmove get_ppmove()
    
    new 
id OrpheuGetStructMember(ppmove,"player_index") + 1
    
    
if(is_user_bot(id))
    {
        return 
OrpheuSupercede
    
}
    
    return 
OrpheuIgnored
}

OrpheuStruct:get_ppmove()
{        
    return 
OrpheuGetStructFromAddress(OrpheuStructPlayerMove,OrpheuMemoryGet("ppmove"))

Before using these functions do some research about how they work.
Download hlsdk

And check multiplayer/pm_shared/pm_shared.cpp

As attachment I will provide an example script and files to use those functions out of the box:
Code:
PM_Init
PM_Move
PM_PlayerMove
PM_Jump
PM_PlayStepSound
PM_CatagorizeTextureType
PM_FlyMove
PM_UpdateStepSound
PM_CheckVelocity
PM_WaterMove
PM_CheckWater
PM_SpectatorMove
PM_LadderMove
PM_Physics_Toss
PM_CheckWaterJump
PM_CheckFalling
PM_ReduceTimers
PM_CreateStuckTable
Note that these files are meant to be used for your experiments and thus I did not took the time to create signatures but instead providing their offsets. This means that you should use them for testing only. If you want to release plugins with it make signatures or ask here.

On a last note, PM functions occur in parallel in the server and the client and because of client prediction there are functions that are useless to block since they will occur in the client anyway or at least don't act exactly as expected.
Attached Files
File Type: zip pm_pack.zip (7.5 KB, 944 views)
__________________

Last edited by joaquimandrade; 02-11-2010 at 10:45. Reason: last note
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-11-2010 , 10:50   Re: Orpheu: Engine PM Functions
Reply With Quote #2

Quote:
On a last note, PM functions occur in parallel in the server and the client and because of client prediction there are functions that are useless to block since they will occur in the client anyway or at least don't act exactly as expected.
Like things related to the sounds. Wanted to try to block the jump sound, it's always played by the client.
__________________
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 02-11-2010 , 11:43   Re: Orpheu: Engine PM Functions
Reply With Quote #3

Omg, this module rocks

You can force players to duck? D:
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-11-2010 , 11:50   Re: Orpheu: Engine PM Functions
Reply With Quote #4

Quote:
Originally Posted by meTaLiCroSS View Post
Omg, this module rocks

You can force players to duck? D:
I guess so.

A simple plugin example of multijump

PHP Code:

#include <amxmodx>
#include <orpheu>
#include <orpheu_advanced>
#include <orpheu_memory>
#include <fakemeta>
    
public plugin_init()
{            
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"),"OnPM_Jump")
}

public 
OrpheuHookReturn:OnPM_Jump()
{    
    new 
OrpheuStruct:ppmove get_ppmove()
    
    if(~
OrpheuGetStructMember(ppmove,"oldbuttons") & IN_JUMP)
    {
        
OrpheuSetStructMember(ppmove,"oldbuttons",OrpheuGetStructMember(ppmove,"oldbuttons") & ~IN_JUMP)    
        
OrpheuSetStructMember(ppmove,"onground",1)    
    }    
}

OrpheuStruct:get_ppmove()
{        
    return 
OrpheuGetStructFromAddress(OrpheuStructPlayerMove,OrpheuMemoryGet("ppmove"))

__________________
joaquimandrade is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 02-11-2010 , 12:58   Re: Orpheu: Engine PM Functions
Reply With Quote #5

Quote:
Originally Posted by meTaLiCroSS View Post
Omg, this module rocks

You can force players to duck? D:
This is not exactly what you asked but check if its ok for what you want:

PHP Code:

#include <amxmodx>
#include <orpheu>

public plugin_init()
{            
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Duck"),"OnPM_Duck")
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Move"),"OnPM_Move")
}

public 
OnPM_Move(ppmove,server)
{
    
OrpheuSetParamStructMember(1,"usehull",2)    
}

public 
OrpheuHookReturn:OnPM_Duck()
{    
    return 
OrpheuSupercede

__________________
joaquimandrade is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 02-11-2010 , 17:53   Re: Orpheu: Engine PM Functions
Reply With Quote #6

What about changing player size?
01101101 is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 02-12-2010 , 12:40   Re: Orpheu: Engine PM Functions
Reply With Quote #7

Quote:
Originally Posted by 01101101 View Post
What about changing player size?
It's strange, i've tried to hook FM_SetSize to check when it's called: Every frame when is ducking (tested with a message). I have tried to change her size, and nothings changes o.O, and the most strange thing is, SetSize forward is not called and stills with the default size.

Sorry for my bad english
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 02-12-2010 , 21:24   Re: Orpheu: Engine PM Functions
Reply With Quote #8

With PM_* hooks it's possible to make func_ladder entities work when spawned from a plugin
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Lt.RAT
Member
Join Date: Sep 2008
Location: Russia Yekaterinburg
Old 04-19-2010 , 12:02   Re: Orpheu: Engine PM Functions
Reply With Quote #9

I`ve perform decompile of pm_shared.c CS functions with windows library.

Amazing change CTEXTURESMAX to 1024, but whole rest code still with 512

All my comments with triple slash, when its possible i`d try to keep HLSDK code, for compare simplification. Also provided Length of functions, if developers changed something - it will be much easier to find.


@Arkshine Please, add it to CSSDK
Attached Files
File Type: zip pm_shared.zip (32.3 KB, 447 views)
Lt.RAT is offline
Send a message via ICQ to Lt.RAT
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-19-2010 , 13:04   Re: Orpheu: Engine PM Functions
Reply With Quote #10

Thanks you for your contribution, I will add it soon.
__________________
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 12:49.


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