AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: Rage (https://forums.alliedmods.net/showthread.php?t=179706)

joaquimandrade 03-04-2012 13:26

Module: Rage
 
2 Attachment(s)

Rage
Beta 3, released March 21th, 2012

So, me and Arkshine decided to create a new module with the purpose of lifting orpheu restrictions by providing unrestricted interaction
with the engine. This time, we made a module called Rage that is a bit harder to use but it's more solid and supports sub-modules so
it should be the final solution for giving the answer to questions like "can I do this ?".

It works as follow :

Let's say we want to use a function that we can't use no matter what with amxx by itself :
First, we need to create a component called handler in C++ that is like a module but its purpose its to handle the management
of the hooking and calling of the function by plugins and rage modules alike. Basically, it links plugins and rage modules
to the function. They are relatively easy to create since we can use one already made as skeleton to create other one.
There must be one per function header. For example:
int CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry )
It returns an int, its a member function of class CBasePlayerWeapon, and its arguments types are int char* int int.
So, we would need an handler for it that would take this into account and then we can use the same handler for :
int CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry )
Since it has the same header. The function in this case wouldn't need to be exactly a member of CBasePlayerWeapon since all entities are
supposed to be handled the same way.
This way is more painful than in orpheu but it was a must for rage because having no restrictions was a must.
We well give examples for some cases and help you if you need.
Now assuming we have an handler to the function we want to hook we would need to create a file like in orpheu for it.
I will talk about those files in a specific thread so, for now, check in examples to see how they look.

Now assuming we have an handler and a file for the function we can from now call it and hook it in amxx plugins and rage modules with
the natives that rage provides.
At the end, you have this flow :

http://dl.dropbox.com/u/27827560/Dessin7.png


Notes :
- We are releasing this as BETA because we want to have sure that its API is ok to start to create handlers without having to worry
because of future updates that rage might have to take so we would ask for people to try to start creating handlers and sub modules
to test the API and features it might need to get added.

- Rage doesn't have the restriction that made orpheu unable to get to the amxmodx tree so hopefully it can be integrated in amxmodx.
We are open to change it's code to make it fit for it if someone thinks is ok to.

- If you are more into making plugins and not much into C++ you better wait for people creating sub modules that provide functionality directly
to plugins instead of trying to use rage.

- Rage won't come directly with natives for memory patching but it makes it easy to create a module like this http://forums.alliedmods.net/showthread.php?t=23152
as submodule and with support to signatures.
So this is it for now. Expect threads in Code Snippets/Tutorials from now on on teaching how to use this module for specific tasks step by step.


Update:

Beta 2 Changelog:
Added alias handling (now czero uses cstrike files)
Added some functions to FunctionForModule
Fixed some stuff
Beta 3 Changelog:
Fixed problem with long handler filename. (buffer related)
Fixed bug with a hook could not be removed.

joaquimandrade 03-04-2012 13:26

Re: Module: Rage
 
Reserved for later possible use.

Arkshine 03-04-2012 13:27

Re: Module: Rage
 
Rules for naming handlers

You should use this rules if you are creating a handler that you want to distribute and if it handles everything one is supposed to do.
They are normative so if you are testing or just doing for yourself do as you wish.

[[thiscall|stdcall]__]returnType__argType1_argType2_[...]

Notes :
thiscall is a compiler convention for calling functions that are members of a class. The purpose its to call those functions in the context of an object.
stdcall is a convention that makes the function called responsible for cleaning the stack so in relation to cdecl it makes the code more compact because the code to clean the stack isnt spread around in each calling function
No return, use Void.
Special types :
Code:

edict_s*      : Edict
entvars_s*    : Entvars
char*        : String
CBaseEntity*  : CBaseEntity
CBase[...]*  : CBaseEntity

Normal types :
Code:

bool    : Bool
int    : Int
float  : Float
Vector  : Vector
int&    : Int-ref
[...]&  : [...]-ref
Void*  : ptr
Int*    : Int-ptr
[...]*  : [...]-ptr

Examples :

Code:

Vector CBaseEntity::FireBullets3( Vector source, Vector dirShooting, float spread, Float distance, int penetration, int bulletType, int damage, float rangerModifier, entvars_s *pevAttacker, bool isPistol, int sharedRand );
int CBaseAnimating::ExtractBbox( int sequence, float *mins, float *maxs );
int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask );
CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius );

->
Code:

thiscall_Vector__CBaseEntity_Vector_Vector_Float_Float_Int_Int_Int_Float_Entvars_Bool_Int
thiscall_Int__CBaseEntity_Int_Float-ptr_Float-ptr
Int__CBaseEntity-ptr-ptr_Int_Vector-ref_Vector-ref_Int
CBaseEntity__CBaseEntity_Vector-ref_Float




joaquimandrade 03-04-2012 13:27

Re: Module: Rage
 
5 Attachment(s)
This is an example of a handler + module + plugin using the virtual function TakeDamage

Arkshine 03-04-2012 13:29

Re: Module: Rage
 
5 Attachment(s)
This is an example of a handler + module + plugin using the function CBaseEntity::FireBullets3().

joropito 03-04-2012 13:42

Re: Module: Rage
 
Finally released!

ConnorMcLeod 03-04-2012 14:02

Re: Module: Rage
 
This module doesn't serve any purpose, unapproved.

DarkGod 03-04-2012 17:42

Re: Module: Rage
 
So this is what you were doing :p

joaquimandrade 03-04-2012 22:13

Re: Module: Rage
 
3 Attachment(s)
One more example :twisted:

Bonus question:
what does this do?
PHP Code:

RageHookReturn OnRestartRound(void*& multiplay,intret)
{
#ifdef __linux__
    
int offset 200;
#else
    
int offset 208;
#endif

    
intval = *(int*)(&(((char*)multiplay)[offset]));

    if(
val == 0)
        
val 1;

    return 
RageHookHandled;
}

void OnLoadFunction(FunctionForModule* function)
{
    if(!
strcmp(function->get_name(),"CHalfLifeMultiplay::RestartRound"))
    {
        function->
add_module_hook((void*)&OnRestartRound,RageHookPre);
    }



ConnorMcLeod 03-05-2012 00:54

Re: Module: Rage
 
Module name is too much explicit, it sets some multiplay private data that will prevent players from Rage and write "teams !" in chat :)

Nice.

Arkshine 03-05-2012 04:24

Re: Module: Rage
 
Yes, kind of obvious, but here a small explanation.
By setting m_iUnBalancedRounds to 1, it forces to call BalanceTeams().

PHP Code:

    [...]
    
int autoTeamBalance CVAR_GET_FLOAT"mp_autoteambalance" );
    
    if ( 
autoTeamBalance != && m_iUnBalancedRounds )
    {
        
BalanceTeams();
    }
    
    if ( 
m_iNumCT m_iNumTerrorist >= || m_iNumTerrorist m_iNumCT >= )
    {
        
m_iUnBalancedRounds++;
    }
    else
    {
        
m_iUnBalancedRounds 0;
    }
    
    if ( 
autoTeamBalance != && m_iUnBalancedRounds == )
    {
        
UTIL_ClientPrintAllprint_center"#Auto_Team_Balance_Next_Round" );
    }
    [...] 



But I'm not sure it's good idea, because I remember calling directly BalanceTeams() with orpheu when #Auto_Team_Balance_Next_Round is trieggered and it was not working properly.

micapat 03-05-2012 12:43

Re: Module: Rage
 
Hello Sir !

1 )

I have some errors when i try to install it with TakeDamage / FireBullet3.

HTML Code:

L 03/05/2012 - 18:19:38: Start of error session.
L 03/05/2012 - 18:19:38: Info (map "de_nuke") (file "addons/amxmodx/logs/error_20120305.log")
L 03/05/2012 - 18:19:38: [RAGE] Virtual function TakeDamage not registered
L 03/05/2012 - 18:19:38: [AMXX] Displaying debug trace (plugin "takedamage.amxx")
L 03/05/2012 - 18:19:38: [AMXX] Run time error 10: native error (native "RageGetFunctionFromClass")
L 03/05/2012 - 18:19:38: [AMXX]    [0] take_damage_example.sma::plugin_precache (line 13)
L 03/05/2012 - 18:19:40: [RAGE] Function "CBaseEntity::FireBullets3" not found in rage
L 03/05/2012 - 18:19:40: [AMXX] Displaying debug trace (plugin "firebullets.amxx")
L 03/05/2012 - 18:19:40: [AMXX] Run time error 10: native error (native "RageGetFunction")
L 03/05/2012 - 18:19:40: [AMXX]    [0] Untitled.sma::plugin_init (line 7)

Meta List

HTML Code:

[ 1] AMX Mod X        RUN  -    amxmodx_mm.dll    v1.8.1.3  ini  Start ANY 
 [ 2] Fun              RUN  -    fun_amxx.dll      v1.8.1.3  pl1  ANY  ANY 
 [ 3] CStrike          RUN  -    cstrike_amxx.dll  v1.8.1.3  pl1  ANY  ANY 
 [ 4] CSX              RUN  -    csx_amxx.dll      v1.8.1.3  pl1  ANY  ANY 
 [ 5] Rage            RUN  -    rage_amxx.dll    vBETA 1  pl1  ANY  ANY 
 [ 6] thiscall_Int__C  RUN  -    thiscall_int__cb  v1.0      pl5  ANY  ANY 
 [ 7] thiscall_Vector  RUN  -    thiscall_vector_  v1.0      pl5  ANY  ANY 
 [ 8] FakeMeta        RUN  -    fakemeta_amxx.dl  v1.8.1.3  pl1  ANY  ANY 
 [ 9] Engine          RUN  -    engine_amxx.dll  v1.8.1.3  pl1  ANY  ANY 
9 plugins, 9 running

Handlers are installed ( addons/rage/handlers )
TakeDamage is installed ( addons/rage/virtual_functions/mod )
CBaseEntity_FireBullets3 is installed ( addons/rage/functions/mod )

;rage is declared ( addons/amxmodx/configs/modules.ini ) ( useless ? )

2 )

Quote:

Originally Posted by Arkshine
Special types :
Code:
edict_s* : Edict
entvars_s* : Entvars
CBaseEntity* : CBaseEntity
CBase[...]* : CBaseEntity

And what about the structure "TraceResult" .. ? :3

"CBaseEntity" can be used instead of "CAK47" ? Just a confirmation.

3 ) Great Job Sir :D and i'm not gay :nono:

joaquimandrade 03-05-2012 12:48

Re: Module: Rage
 
1 ) Post:

rage errors
rage functions
rage modules
rage handlers

2 ) TraceResult is handled as a pointer if I remember correctly so do like if it were void*.

3) Thanks :twisted: and well you are French so you are at least 50%

Edit:

Quote:

"CBaseEntity" can be used instead of "CAK47" ? Just a confirmation.
Not only can but also should

Exolent[jNr] 03-05-2012 12:59

Re: Module: Rage
 
Another module I will not have the time to fully understand. *sigh*

On another note, looks great and good job.

micapat 03-05-2012 13:26

Re: Module: Rage
 
Ok I have some informations :U

I forgot to say that but it's a local server ( -> Windows ) on Czero.

rage errors

Errors:

Unable to get vtable information for 'CBaseEntity'
Unable to get vtable information for 'CGameRules'
Function 'CBaseEntity_FireBullets3' doesn't have identifiers for your mod
Virtual function 'TakeDamage' doesn't have offsets for your mod

rage functions and rage modules :

Nothing.

rage handlers :

Crash czero ..

I think that we localised the problem :C

joaquimandrade 03-05-2012 13:48

Re: Module: Rage
 
Quote:

Originally Posted by Exolent[jNr] (Post 1663209)
Another module I will not have the time to fully understand. *sigh*

On another note, looks great and good job.

Thanks fellow

Quote:

Originally Posted by micapat (Post 1663234)
Ok I have some informations :U

I forgot to say that but it's a local server ( -> Windows ) on Czero.

rage errors

Errors:

Unable to get vtable information for 'CBaseEntity'
Unable to get vtable information for 'CGameRules'
Function 'CBaseEntity_FireBullets3' doesn't have identifiers for your mod
Virtual function 'TakeDamage' doesn't have offsets for your mod

rage functions and rage modules :

Nothing.

rage handlers :

Crash czero ..

I think that we localised the problem :C

Ok good you find this problem. I forgot to create aliast stuff for Vtables.
Do the following:
Go to

"addons\rage\config\vtables"

and each file there called cstrike, clone it, call it czero, open it and rename the entry from czero to cs.

That should make it for the virtual function.
About "CBaseEntity_FireBullets3" arkshine will have to create a new signature.
About doing "rage handlers" crashing try again after having the files.

Edit:

and edit TakeDamage and clone cstrike identifiers and rename it czero. I will fix this for next version.

Arkshine 03-05-2012 14:10

Re: Module: Rage
 
Quote:

About "CBaseEntity_FireBullets3" arkshine will have to create a new signature.
No. Just tried and works fine. But duplicating cstrike identifiers and renaming to cezro, should be done.

micapat 03-05-2012 14:24

Re: Module: Rage
 
News :

rage functions

id: 0 , function 'CBaseEntity::FireBullets3', handler '5:13', library: 'mod' , offset: '0x78170'
id: 1 , virtual function 'TakeDamage', handler 'thiscall_Int__CBaseEntity_Entvars_Entvars_Fl oat_Int', classname 'player', library: 'mod' , offset: '0xa5210

rage errors

0.

rage handlers

Crash :O

--

CBaseEntity::FireBullets3 works nice !
But when I write "mkdir", nothing happens :0

joaquimandrade 03-05-2012 14:28

Re: Module: Rage
 
Quote:

Originally Posted by micapat (Post 1663276)
News :

rage functions

id: 0 , function 'CBaseEntity::FireBullets3', handler '5:13', library: 'mod' , offset: '0x78170'
id: 1 , virtual function 'TakeDamage', handler 'thiscall_Int__CBaseEntity_Entvars_Entvars_Fl oat_Int', classname 'player', library: 'mod' , offset: '0xa5210

rage errors

0.

rage handlers

Crash :O

--

CBaseEntity::FireBullets3 works nice !
But when I write "mkdir", nothing happens :0

I will check later on czero why the crash.
mkdir is not implemented. Try mkdmg

micapat 03-05-2012 14:33

Re: Module: Rage
 
Ok sorry it works too :crab:

Good Job !

joaquimandrade 03-05-2012 14:44

Re: Module: Rage
 
Quote:

Originally Posted by micapat (Post 1663285)
Ok sorry it works too :crab:

Good Job !

Thanks for testing! Despite being french

Arkshine 03-05-2012 14:55

Re: Module: Rage
 
Quote:

Despite being french
Meanwhile, only french are working on it. (Me, Connor and micapat) :mrgreen:

ConnorMcLeod 03-06-2012 00:57

Re: Module: Rage
 
Quote:

Originally Posted by Arkshine (Post 1663294)
Meanwhile, only french are working on it. (Me, Connor and micapat) :mrgreen:

I'm not sure yet i'm able or not to use this stuff, anyway, 2french/2 or 3french/3 == 100% french :)
But you don't see people using this in the darkness :evil::evil:

Starsailor 03-06-2012 18:41

Re: Module: Rage
 
Awesome work!

ConnorMcLeod 03-07-2012 01:50

Re: Module: Rage
 
Quote:

Originally Posted by joaquimandrade (Post 1662850)
One more example :twisted:

Bonus question:
what does this do?
PHP Code:

RageHookReturn OnRestartRound(void*& multiplay,intret)
{
#ifdef __linux__
    
int offset 200;
#else
    
int offset 208;
#endif

    
intval = *(int*)(&(((char*)multiplay)[offset]));

    if(
val == 0)
        
val 1;

    return 
RageHookHandled;
}

void OnLoadFunction(FunctionForModule* function)
{
    if(!
strcmp(function->get_name(),"CHalfLifeMultiplay::RestartRound"))
    {
        function->
add_module_hook((void*)&OnRestartRound,RageHookPre);
    }



I think you check against wrong params count in rage_call.

zekStein 03-07-2012 12:17

Re: Module: Rage
 
very nice module, i'll be helpfull to my server because i don't have to put the signature like in orpheu !!!

Arkshine 03-07-2012 12:32

Re: Module: Rage
 
You still need signatures. Just with Rage is far more efficient/flexible/powerful than Orpheu and can do sub-modules.

K.K.Lv 03-09-2012 00:09

Re: Module: Rage
 
Quote:

Originally Posted by Arkshine (Post 1664530)
You still need signatures. Just with Rage is far more efficient/flexible/powerful than Orpheu and can do sub-modules.

I think the problem is there are most people don't know how to find the signatures. at least for me ! I think most of people are learn pawn by themselves ! so we need more sample tutors to learn how to use this module ! BTW very very very nice module :mrgreen:

yokomo 03-09-2012 02:03

Re: Module: Rage
 
Hurmm new revolution module has arrived.

@Arkshine
How about to make Custom Knife Range with this module haha.

Alka 03-09-2012 04:17

Re: Module: Rage
 
Oh, good work guys. As i can see it's a nice integration with engine.

BTW: Connor i still hate you!

K.K.Lv 03-09-2012 04:35

Re: Module: Rage
 
I have a suggestion , actually it is a question:
Is it possible to make some natives can use the windows api ?
I think it can be done !

Arkshine 03-09-2012 04:57

Re: Module: Rage
 
Quote:

Originally Posted by K.K.Lv (Post 1665272)
I think the problem is there are most people don't know how to find the signatures. at least for me ! I think most of people are learn pawn by themselves ! so we need more sample tutors to learn how to use this module ! BTW very very very nice module :mrgreen:

There is a tutorial to find a signature. Tutorial for orpheu, but it applies too for Rage.
About tutorial for Rage, Joaquim will do it some when it will have some time.

Quote:

Is it possible to make some natives can use the windows api ?
Sure.

K.K.Lv 03-09-2012 06:24

Re: Module: Rage
 
Quote:

Originally Posted by Arkshine (Post 1665350)
Sure.

will you do it ?

edited:
Will be powerful if you add the windows api(I don't know anything about the linux) in it !

Arkshine 03-09-2012 08:44

Re: Module: Rage
 
Will do it what ? Not sure what you're expecting or requesting. The windows API is like any others API. Natives for what ? Doesn't make much sense what you're saying.

K.K.Lv 03-09-2012 11:25

Re: Module: Rage
 
I say if move the windows API into the module tha we can use it in the game.
eg:
GetProcAddress,
we can make a native like it !

Arkshine 03-09-2012 11:52

Re: Module: Rage
 
Just make a module (Using Rage or not) and use only functions of the API you want (and eventually some natives). Such stuff should be done with C/C++ code and not through pawn plugins, doesn't make sense really. There are already modules here using the windows API, just do another module with the suff you need.

Pastout 03-09-2012 19:00

Re: Module: Rage
 
Nice job! should have named it MonsterAI - Arkshine.

Doc-Holiday 03-09-2012 20:05

Re: Module: Rage
 
So i have no idea how ot use this yet.. but i have a question..

Is using ham to do most of the functions like spawn/touch/death/take damage still better?

Or would using this be more efficient to hook those?

Also Would i run into the same problem hooking cz bots with rage as i do with ham?

joaquimandrade 03-09-2012 20:21

Re: Module: Rage
 
Quote:

Originally Posted by Doc-Holiday (Post 1665743)
So i have no idea how ot use this yet.. but i have a question..

Is using ham to do most of the functions like spawn/touch/death/take damage still better?

Or would using this be more efficient to hook those?

Also Would i run into the same problem hooking cz bots with rage as i do with ham?

It should now be approximatelly the same speed since it basically does the same give or take a call or two so you probably won't get a measurable difference.

What are the problems you have? We might make a module especifically to solve them.

Edit: anyway about the speed since it doesn't matter you should still use Ham.

Doc-Holiday 03-09-2012 20:36

Ham cant hook cz bots using classname player you have to hookem and register from ent.


All times are GMT -4. The time now is 10:18.

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