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

Orpheu: iMaxClip and iMaxAmmo1


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-08-2018 , 15:04   Orpheu: iMaxClip and iMaxAmmo1
Reply With Quote #1

Hello, I'm trying to change weapon iMaxClip/iMaxAmmo1, but I'm getting a problem to hook function from class.

Code:
new const g_pszNameGalil[] = "weapon_galil"; public plugin_precache() {     OrpheuRegisterHook(OrpheuGetFunctionFromClass(g_pszNameGalil, "GetItemInfo", "CBasePlayerItem"), "CGalil_GetItemInfo_Post", OrpheuHookPost); } public CGalil_GetItemInfo_Post(this, hItemInfo) {     if (entity_get_int(this, EV_INT_impulse) != 100)         return;     new iMaxClip = get_pcvar_num(g_pCvarGalilMaxClip);     new iMaxAmmo = get_pcvar_num(g_pCvarGalilMaxAmmo);     OrpheuSetParamStructMember(2, "iMaxClip", iMaxClip);     OrpheuSetParamStructMember(2, "iMaxAmmo1", iMaxAmmo); }

Log error
Code:
L 10/08/2018 - 15:47:10: [ORPHEU] Invalid virtual function "CBasePlayerItem::GetItemInfo"
L 10/08/2018 - 15:47:10: [AMXX] Displaying debug trace (plugin "orpheu_galil.amxx", version "unknown")
L 10/08/2018 - 15:47:10: [AMXX] Run time error 10: native error (native "OrpheuGetFunctionFromClass")
L 10/08/2018 - 15:47:10: [AMXX]    [0] orpheu_galil.sma::plugin_precache (line 132)
__________________









Last edited by CrazY.; 10-08-2018 at 22:38.
CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-08-2018 , 16:09   Re: Orpheu (invalid virtual function)
Reply With Quote #2

You are hooking on the wrong class. https://github.com/s1lentq/ReGameDLL..._galil.cpp#L36
__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-08-2018 , 16:29   Re: Orpheu (invalid virtual function)
Reply With Quote #3

Code:
OrpheuRegisterHook(OrpheuGetFunctionFromClass(g_pszNameGalil, "GetItemInfo", "CGalil"), "CGalil_GetItemInfo_Post", OrpheuHookPost);

Same problem. I have no idea how to work with orpheu, by chance I need a signature for CGalil::GetItemInfo? Anyway, I'm trying to change weapon clip but I don't think will be easy with default hlds as an I though.

As an I read here https://forums.alliedmods.net/showthread.php?p=1793160, I will need to recode some parts of the weapon to be able to manage clip. Is there any signature list? Because I'm getting problem to get them with myself due my computer.
__________________








CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-08-2018 , 16:58   Re: Orpheu (invalid virtual function)
Reply With Quote #4

Sorry I was talking bullshit, it's okay how you are hooking. Use a signature like this:
PHP Code:
{
     
"name"      "GetItemInfo",
     
"class"     "CBasePlayerItem",
     
"library"   "mod",
     
"arguments" :
     [
         {
             
"type" "ItemInfo *"
         
}
     ],
     
"return" :     
     {
         
"type" "int"
     
},
     
"indexes" :
     [
         {
             
"os"    "windows",
             
"mod"   "cstrike",
             
"value" 61
         
},         
         {
             
"os"    "linux",
             
"mod"   "cstrike",
             
"value" 61
         
}
     ] 

__________________
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-08-2018 , 22:35   Re: Orpheu (invalid virtual function)
Reply With Quote #5

As an expected, now it worked but had no effect. Any idea?

Code:
public plugin_precache() {     OrpheuRegisterHook(OrpheuGetFunctionFromClass(g_pszNameGalil, "GetItemInfo", "CBasePlayerItem"), "CGalil_GetItemInfo_Post", OrpheuHookPost); } public CGalil_GetItemInfo_Post(this, hItemInfo) {     if (!IsMagnumDrill(this))         return;     static iMaxClip, iMaxAmmo;     iMaxClip = get_pcvar_num(g_pCvarDrillMaxClip);     iMaxAmmo = get_pcvar_num(g_pCvarDrillMaxAmmo);     OrpheuSetParamStructMember(2, "iMaxClip", iMaxClip);     OrpheuSetParamStructMember(2, "iMaxAmmo1", iMaxAmmo); }
__________________








CrazY. is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 10-09-2018 , 03:08   Re: Orpheu: iMaxClip and iMaxAmmo1
Reply With Quote #6

Because GetItemInfo is called at server first start instance (UTIL_PrecacheOtherWeapon), and values are cached on CBasePlayerItem::ItemInfoArray array. After that, gamedll uses values from that array. If you want to change those values in mid game, you'll need to hook every function that uses, in this case, iMaxClip and iMaxAmmo1 members from ItemInfoArray.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-09-2018 , 04:10   Re: Orpheu: iMaxClip and iMaxAmmo1
Reply With Quote #7

Quote:
Originally Posted by meTaLiCroSS View Post
Because GetItemInfo is called at server first start instance (UTIL_PrecacheOtherWeapon), and values are cached on CBasePlayerItem::ItemInfoArray array. After that, gamedll uses values from that array. If you want to change those values in mid game, you'll need to hook every function that uses, in this case, iMaxClip and iMaxAmmo1 members from ItemInfoArray.
Or just alter ItemInfoArray directly.
__________________

Last edited by HamletEagle; 10-09-2018 at 04:10.
HamletEagle is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 10-09-2018 , 16:37   Re: Orpheu: iMaxClip and iMaxAmmo1
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
Or just alter ItemInfoArray directly.
Quote:
Originally Posted by meTaLiCroSS View Post
If you want to change those values in mid game, you'll need to hook every function that uses, in this case, iMaxClip and iMaxAmmo1 members from ItemInfoArray.
I assume you understood the context given here. He's trying to make a custom weapon, plus, use a different max clip ammo for itself, without altering original weapon.

PHP Code:
public CGalil_GetItemInfo_Post(thishItemInfo)
{
    if (!
IsMagnumDrill(this))
        return;
    
// ... 
So...

Quote:
you'll need to hook every function that uses, in this case, iMaxClip and iMaxAmmo1 members from ItemInfoArray.
A mix of hooks with AddPrimaryAmmo, DefaultReload, ItemPostFrame, and I guess others. At least I need those for altering max clip without altering default/other (custom or not) weapons.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 10-09-2018 , 18:27   Re: Orpheu: iMaxClip and iMaxAmmo1
Reply With Quote #9

What @meTaLiCroSS said make totally sense, since I did without orpheu and looks working. I needed to "recode":

Code:
CBasePlayerWeapon::DefaultReload
CBasePlayerWeapon::ItemPostFrame
to manage iMaxClip (I didn't even try AddPrimaryAmmo yet). To manage iMaxAmmo1 I'm still getting some trouble in "buy primary ammo" at buy menu.
__________________









Last edited by CrazY.; 10-09-2018 at 18:28.
CrazY. is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 10-10-2018 , 02:49   Re: Orpheu: iMaxClip and iMaxAmmo1
Reply With Quote #10

Quote:
Originally Posted by CrazY. View Post
What @meTaLiCroSS said make totally sense, since I did without orpheu and looks working. I needed to "recode":

Code:
CBasePlayerWeapon::DefaultReload
CBasePlayerWeapon::ItemPostFrame
to manage iMaxClip (I didn't even try AddPrimaryAmmo yet). To manage iMaxAmmo1 I'm still getting some trouble in "buy primary ammo" at buy menu.
AddPrimaryAmmo helps a lot in this case, you'll need Orpheu for it also. Just a parameter changing, same like DefaultReload
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS 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 21:52.


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