Quantcast

Jump to content

» «
Photo

Other way to check of the actor is firing

12 replies to this topic
Junior_Djjr
  • Junior_Djjr

    Living in Modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#1

Posted 10 February 2014 - 02:35 AM Edited by Junior_Djjr, 10 February 2014 - 02:37 AM.

I'm creating a mod to make new functions for weapons, cars, objects and actors... (yes, like imvehft)
I'm starting, and the second function of i created is this:

(you can download the mod here, and the weapon here)
works for me and some others, but, some(much) peoples don't works in a modified game, only in unmodf game...
i tested some scripts with my friend, and i discover of the problem is the "check" of the firing, in most games, don't returns true...

i tried to check with:
opcode 02E0: (actor firing)
WeaponSlot - DWORD state // + 4 (0 idle, 1 firing, 2 reloading)
0000046C pedFlags dd ? (checking the 16° bit)


all of this works for me, but don't works for some others peoples! don't returns true, don't change the value etc...

anyone know what is the mod of maked this bug and know other metod to check if the actor is firing?
(i need this to works in any weapon, and no, don't say to me use key press :p )


ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#2

Posted 10 February 2014 - 06:15 PM Edited by ZAZ, 10 February 2014 - 06:16 PM.

works for me and some others, but, some(much) peoples don't works in a modified game, only in unmodf game...

that happens often because some users have running anything else, bad scripted scripts or any plugin
why should you fix your code if the problem is caused by another mod? are you Jesus?

The reason  for the problem must be fixed, not your code

Example, I found a betatester for my mod two weeks a ago.

He reported

Sometimes I'm having trouble when I get to the heli zone, the pilot is out and walks away from heli. From here the script will be bugged. The heli will fly without pilot

and later
 

Good news with your TakeMoneyRun script.

I removed the line:

"039E: set_actor 1@ locked 1 while_in_car

i answered

 

Unbelievable, it never happens for me that the pilot leaves the heli and set_actor 1@ locked 1 avoids highjacking

Are you shure that you don't have another cleoscript that have effect to peds?

then he answered

I never believed that IMFX (16sept2013 plugin.dll version) could be the issue.  My bad...

 

If you still want to solve it, then you must find out what cause the side effect

But you can't be shure that another problem occur because of other mods


Junior_Djjr
  • Junior_Djjr

    Living in Modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#3

Posted 10 February 2014 - 07:57 PM

omg........ and i don't discovered yet what mod make this

 

but anyone know other way to check the firing of actor? :c  (if i discover the mod of cause this bug i warning here ok)


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#4

Posted 10 February 2014 - 08:53 PM Edited by Wesser, 10 February 2014 - 08:57 PM.

The script delay might cause the bug for some users, because the firing state changes almost instantly. Tomorrow I will show you how to inject useful assembly code at 0x007429F2 to try bypassing this inconvenience.

Junior_Djjr
  • Junior_Djjr

    Living in Modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#5

Posted 10 February 2014 - 10:12 PM

The script delay might cause the bug for some users, because the firing state changes almost instantly. Tomorrow I will show you how to inject useful assembly code at 0x007429F2 to try bypassing this inconvenience.

make sense!

very good, this will fix some other mods too


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]

#6

Posted 10 February 2014 - 11:05 PM

Maybe checking
CWeapon +0x4 m_dwState // 1 = firing
or
0x600F70 CTaskSimpleUseGun *__thiscall CPedIntelligence::GetTaskUseGun(CPedIntelligence *this)
CTaskSimpleUseGun +0x10 m_nState // 0 - 4, maybe some of them
Also, why do you hate IVF so much?

Junior_Djjr
  • Junior_Djjr

    Living in Modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#7

Posted 10 February 2014 - 11:18 PM

Maybe checking

CWeapon +0x4 m_dwState // 1 = firing
or
0x600F70 CTaskSimpleUseGun *__thiscall CPedIntelligence::GetTaskUseGun(CPedIntelligence *this)
CTaskSimpleUseGun +0x10 m_nState // 0 - 4, maybe some of them

the first isn't the same of weapon slot state? ...but i think of the second will work


Also, why do you hate IVF so much?

lol :lol:
i'm not trying a competition with your mod, i will only create functions for weapons (and others like objects or actors) ...and others new functions for vehicles, like roof folding and electric windows from my old car (307cc BMS Edition) :p

DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]

#8

Posted 10 February 2014 - 11:56 PM

but i think of the second will work

You may try this
0A96: 0@ = actor $PLAYER_ACTOR struct
0@ += 0x47C
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
0AA8: call_function_method 0x600F70 struct 0@ num_params 0 pop 0 0@
if
    0@ <> 0
then
    0@ += 0x10
    0A8D: 0@ = read_memory 0@ size 1 virtual_protect 0
    0AD1: show_formatted_text_highpriority "%d" time 100 0@
end

Junior_Djjr
  • Junior_Djjr

    Living in Modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#9

Posted 11 February 2014 - 12:19 AM Edited by Junior_Djjr, 11 February 2014 - 12:23 AM.

yeah... i already tried with my ugly script

{$CLEO}
0000:

while true
    wait 0
    player.Defined($player_char)
    jf continue
    0A96: 0@ = actor $PLAYER_ACTOR struct
    0@ += 0x47C //CPedIntelligence
    0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
    0AA8: call_function_method 0x600F70 struct 0@ num_params 0 pop 0  1@ //CTaskSimpleUseGun
    1@ > 0
    jf continue
    
    1@ += 0x10
    0A8D: 1@ = read_memory 1@ size 1 virtual_protect 0
    
    0AD1: show_formatted_text_highpriority "%i" time 200 1@
end

the problem is, don't returns the exact time of the fire, is only "is firing? isn't firing?" and i think of will be impossible to get the exactly time when this bug is here
is better to wait the Wesser fix this bug? this fix may be implanted in new version of cleo library too? :p

 

edit: I could check the decrease of the am...ok no...


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]

#10

Posted 11 February 2014 - 12:26 AM

Firing time must be here
CWeapon +0x10

Junior_Djjr
  • Junior_Djjr

    Living in Modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#11

Posted 11 February 2014 - 01:36 AM

Firing time must be here

CWeapon +0x10

i used CWeaponSlot+0x16 (i don't know if is the same) but works perfect! like...

the value is const, and change in each bullet :p then is only to check the change of the value

 

thanks

 

 

 

one doubt, if i'm in twin weapons... i can control each weapon in each hand? or the objects of weapon is "mirrored"?

as one could imagine... the slide cover of each weapon move in same time when fire


Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown
  • Contribution Award [Mods]

#12

Posted 07 August 2014 - 11:10 AM Edited by Wesser, 07 August 2014 - 03:16 PM.

Lately, I read you wish to review your Enhanced Functions script, I believe you do not mind using this code:
{$CLEO}

0000: NOP

const
    _CPed__GetWeaponSkill            = 0x005E3B60
    _CPedIntelligence__GetTaskUseGun = 0x00600F70
    _CWeaponInfo__GetWeaponInfo      = 0x00743C60
end
const
    _HOOK_PTR_005E476B_CPool_CPed_CPed__Delete     = 29@
    _HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed = 28@
    _HOOK_PTR_007428E9_CWeapon__Fire               = 27@
    _CPools__GettPoolPedID                         = 26@
    _CGunFireInfo__ms_aPedGunFireInfo              = 25@
    _CGunFireInfo__AddPedGunFireInfo               = 24@
    _CGunFireInfo__RemovePedGunFireInfo            = 23@
    _CGunFireInfo__GetPedGunFireTime               = 22@
end

0A9F: 31@ = current_thread_pointer
0A8E: 30@ = 31@ + 0x10 // CRunningScript.m_iBaseAddress
0A8D: 30@ = read_memory 30@ size 4 virtual_protect 0
0A8F: _HOOK_PTR_005E476B_CPool_CPed_CPed__Delete = 30@ - @_HOOK_PTR_005E476B_CPool_CPed_CPed__Delete
0A8F: _HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed = 30@ - @_HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed
0A8F: _HOOK_PTR_007428E9_CWeapon__Fire = 30@ - @_HOOK_PTR_007428E9_CWeapon__Fire
0A8F: _CPools__GettPoolPedID = 30@ - @_CPools__GettPoolPedID
0A8F: _CGunFireInfo__ms_aPedGunFireInfo = 30@ - @_CGunFireInfo__ms_aPedGunFireInfo
0A8F: _CGunFireInfo__AddPedGunFireInfo = 30@ - @_CGunFireInfo__AddPedGunFireInfo
0A8F: _CGunFireInfo__RemovePedGunFireInfo = 30@ - @_CGunFireInfo__RemovePedGunFireInfo
0A8F: _CGunFireInfo__GetPedGunFireTime = 30@ - @_CGunFireInfo__GetPedGunFireTime

0A8F: 0@ = _HOOK_PTR_005E476B_CPool_CPed_CPed__Delete - 0x005E4770
0A8C: write_memory 0x005E476B size 1 value 0xE9 virtual_protect 1
0A8C: write_memory 0x005E476C size 4 value 0@ virtual_protect 1
0A8E: 0@ = _HOOK_PTR_005E476B_CPool_CPed_CPed__Delete + 2
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CPools__GettPoolPedID - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0
0A8E: 0@ = _HOOK_PTR_005E476B_CPool_CPed_CPed__Delete + 0x14
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CGunFireInfo__RemovePedGunFireInfo - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0
0A8E: 0@ = _HOOK_PTR_005E476B_CPool_CPed_CPed__Delete + 0x20
0A8E: 1@ = 0@ + 4
0A8F: 2@ = 0x005E4784 - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0

0A8F: 0@ = _HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed - 0x00630738
0A8C: write_memory 0x00630733 size 1 value 0xE9 virtual_protect 1
0A8C: write_memory 0x00630734 size 4 value 0@ virtual_protect 1
0A8E: 0@ = _HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed + 2
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CPools__GettPoolPedID - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0
0A8E: 0@ = _HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed + 8
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CGunFireInfo__RemovePedGunFireInfo - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0
0A8E: 0@ = _HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed + 0x19
0A8E: 1@ = 0@ + 4
0A8F: 2@ = 0x0063073C - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0

0A8F: 0@ = _HOOK_PTR_007428E9_CWeapon__Fire - 0x007428EE
0A8C: write_memory 0x007428E9 size 1 value 0xE9 virtual_protect 1
0A8C: write_memory 0x007428EA size 4 value 0@ virtual_protect 1
0A8E: 0@ = _HOOK_PTR_007428E9_CWeapon__Fire + 2
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CPools__GettPoolPedID - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0
0A8E: 0@ = _HOOK_PTR_007428E9_CWeapon__Fire + 0x13
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CGunFireInfo__AddPedGunFireInfo - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0
0A8E: 0@ = _HOOK_PTR_007428E9_CWeapon__Fire + 0x20
0A8E: 1@ = 0@ + 4
0A8F: 2@ = 0x007428EE - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0

0A8E: 0@ = _CGunFireInfo__AddPedGunFireInfo + 0x10
0A8C: write_memory 0@ size 4 value _CGunFireInfo__ms_aPedGunFireInfo virtual_protect 0
0A8E: 0@ = _CGunFireInfo__AddPedGunFireInfo + 0x1F
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CPedIntelligence__GetTaskUseGun - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0

0A8E: 0@ = _CGunFireInfo__RemovePedGunFireInfo + 0x0B
0A8C: write_memory 0@ size 4 value _CGunFireInfo__ms_aPedGunFireInfo virtual_protect 0

0A8E: 0@ = _CGunFireInfo__GetPedGunFireTime + 0x0D
0A8C: write_memory 0@ size 4 value _CGunFireInfo__ms_aPedGunFireInfo virtual_protect 0
0A8E: 0@ = _CGunFireInfo__GetPedGunFireTime + 0x2D
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CPed__GetWeaponSkill - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0
0A8E: 0@ = _CGunFireInfo__GetPedGunFireTime + 0x34
0A8E: 1@ = 0@ + 4
0A8F: 2@ = _CWeaponInfo__GetWeaponInfo - 1@
0A8C: write_memory 0@ size 4 value 2@ virtual_protect 0

while true
    wait 0
    0A96: 0@ = actor $PLAYER_ACTOR struct
    0AA7: call_function _CPools__GettPoolPedID num_params 1 pop 1 pPed 0@ iPoolID 1@
    0470: 2@ = actor $PLAYER_ACTOR current_weapon
    0AA7: call_function _CGunFireInfo__GetPedGunFireTime num_params 4 pop 4 bTwinPistol false eWeaponType 2@ pPed 0@ iPoolID 1@ uiFireTime 3@
    
    [...]
    
    0AA8: call_function_method _CPed__GetWeaponSkill struct 0@ num_params 1 pop 0 eWeaponType 2@ cWeaponSkill 4@
    0AA7: call_function _CWeaponInfo__GetWeaponInfo num_params 2 pop 2 cWeaponSkill 4@ eWeaponType 2@ weaponInfo 5@
    0A8E: 6@ = 5@ + 0x18 // CWeaponInfo.m_uiFlags
    0A8D: 6@ = read_memory 6@ size 4 virtual_protect 0
    if
    08B7:  test 6@ bit 11 // TWIN_PISTOL
    then
        0AA7: call_function _CGunFireInfo__GetPedGunFireTime num_params 4 pop 4 bTwinPistol true eWeaponType 2@ pPed 0@ iPoolID 1@ uiFireTime 7@
        
        [...]
    end
    //0AA7: call_function _CGunFireInfo__RemovePedGunFireInfo num_params 1 pop 1 iPoolID 1@
end

:_HOOK_PTR_005E476B_CPool_CPed_CPed__Delete
hex
    51               // 00000000 push    ecx
    E8 00000000      // 00000001 call    CPools::GettPoolPedID
    59               // 00000006 pop     ecx
    8BD0             // 00000007 mov     edx, eax
    83B9 30050000 37 // 00000009 cmp     dword ptr [ecx+CPed.m_uiPedState], PEDSTATE_WASTED
    74 07            // 00000010 je      ped_is_wasted
    50               // 00000012 push    eax
    E8 00000000      // 00000013 call    CGunFireInfo::RemovePedGunFireInfo
    5A               // 00000018 pop     edx
                     // 00000019 ped_is_wasted:
    8B4E 04          // 00000019 mov     ecx, [esi+CPool<CPed, CPed>.m_pFlags]
    8D0411           // 0000001C lea     eax, [ecx+edx]
    E9 00000000      // 0000001F jmp     CPool<CPed, CPed>::Delete+24h
end

:_HOOK_PTR_00630733_CTaskSimpleDead__ProcessPed
hex
    56               // 00000000 push    esi
    E8 00000000      // 00000001 call    CPools::GettPoolPedID
    50               // 00000006 push    eax
    E8 00000000      // 00000007 call    CGunFireInfo::RemovePedGunFireInfo
    83C4 08          // 0000000C add     esp, 8
    C686 18070000 00 // 0000000F mov     byte ptr [esi+CPed.m_cWeaponSlot], 0
    8BCE             // 00000016 mov     ecx, esi
    E9 00000000      // 00000018 jmp     CTaskSimpleDead::ProcessPed+13Ch
end

:_HOOK_PTR_007428E9_CWeapon__Fire
hex
    57               // 00000000 push    edi
    E8 00000000      // 00000001 call    CPools::GettPoolPedID
    8B0D 84CBB700    // 00000006 mov     ecx, CTimer.m_snTimeInMilliseconds
    51               // 0000000C push    ecx
    8B16             // 0000000D mov     edx, [esi+CWeapon.m_eWeaponType]
    52               // 0000000F push    edx
    57               // 00000010 push    edi
    50               // 00000011 push    eax
    E8 00000000      // 00000012 call    CGunFireInfo::AddPedGunFireInfo
    83C4 14          // 00000017 add     esp, 14h
    8B46 08          // 0000001A mov     eax, [esi+CWeapon.m_iAmmoInClip]
    85C0             // 0000001D test    eax, eax
    E9 00000000      // 0000001F jmp     CWeapon::Fire+05EEh
end

{
    int CPools::GettPoolPedID(CPed *pPed)
    (
        return ((int)pPed - (int)CPools::ms_pPedPool->m_pObjects) / sizeof(CCopPed);
    )
}
:_CPools__GettPoolPedID
hex
    8B4C24 04        // 00000000 mov     ecx, [esp+pPed]
    8B15 9044B700    // 00000004 mov     edx, CPools.ms_pPedPool
    2B0A             // 0000000A sub     ecx, [edx+CPool<CPed, CPed>.m_pObjects]
    B8 A77CEE41      // 0000000C mov     eax, 41EE7CA7h
    F7E9             // 00000011 imul    ecx
    C1FA 09          // 00000013 sar     edx, 9
    8BC2             // 00000016 mov     eax, edx
    C1E8 1F          // 00000018 shr     eax, 31
    03C2             // 0000001B add     eax, edx
    C3               // 0000001D ret
//  90               // 0000001E nop
//  90               // 0000001F nop
end

{
    class CGunFireInfo
    (
    public:
        struct PedInfo
        (
            eWeaponType m_eWeaponType;
            unsigned int m_uiRGunFireTime;
            unsigned int m_uiLGunFireTime;
        );

        static PedInfo ms_aPedGunFireInfo[140];

    	static void AddPedGunFireInfo(int iPoolID, CPed *pPed, eWeaponType eWeaponType, unsigned int uiFireTime);
        static void RemovePedGunFireInfo(int iPoolID);
    	static unsigned int GetPedGunFireTime(int iPoolID, CPed *pPed, eWeaponType eWeaponType, bool bTwinPistol);
    );
}
:_CGunFireInfo__ms_aPedGunFireInfo
hex
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000000 00000000 00000000
end

{
    void CGunFireInfo::AddPedGunFireInfo(int iPoolID, CPed *pPed, eWeaponType eWeaponType, unsigned int uiFireTime)
    (
        CTaskSimpleUseGun *pTaskSimpleUseGun = pPed->m_pPedIntelligence->GetTaskUseGun();

        if(!pTaskSimpleUseGun || pTaskSimpleUseGun->m_ucGunFlashFlag & GUNFLASH_RHAND)
        (
            ms_aPedGunFireInfo[iPoolID].m_uiRGunFireTime = uiFireTime;

            if(ms_aPedGunFireInfo[iPoolID].m_eWeaponType != eWeaponType)
                ms_aPedGunFireInfo[iPoolID].m_uiLGunFireTime = 0;
        )
        else if(pTaskSimpleUseGun->m_ucGunFlashFlag & GUNFLASH_LHAND)
        (
            if(ms_aPedGunFireInfo[iPoolID].m_eWeaponType != eWeaponType)
                ms_aPedGunFireInfo[iPoolID].m_uiRGunFireTime = 0;

            ms_aPedGunFireInfo[iPoolID].m_uiLGunFireTime = iFireTime;
        )
        else
        (
            ms_aPedGunFireInfo[iPoolID].m_uiRGunFireTime = 0;
            ms_aPedGunFireInfo[iPoolID].m_uiLGunFireTime = 0;
        )

        ms_aPedGunFireInfo[iPoolID].m_eWeaponType = eWeaponType;
    )
}
:_CGunFireInfo__AddPedGunFireInfo
hex
    53               // 00000000 push    ebx
    33DB             // 00000001 xor     ebx, ebx
    56               // 00000003 push    esi
    8B7424 0C        // 00000004 mov     esi, [esp+8+iPoolID]
    8D3476           // 00000008 lea     esi, [esi+esi*2]
    C1E6 02          // 0000000B shl     esi, 2
    81C6 00000000    // 0000000E add     esi, offset CGunFireInfo.ms_aPedGunFireInfo
    8B4424 10        // 00000014 mov     eax, [esp+8+pPed]
    8B88 7C040000    // 00000018 mov     ecx, [eax+CPed.m_pPedIntelligence]
    E8 00000000      // 0000001E call    CPedIntelligence::GetTaskSimpleUseGun
    8B4C24 18        // 00000023 mov     ecx, [esp+8+uiFireTime]
    8B5424 14        // 00000027 mov     edx, [esp+8+eWeaponType]
    85C0             // 0000002B test    eax, eax
    74 07            // 0000002D jz      right_gun_fire_time
    8A40 0D          // 0000002F mov     al, byte ptr [eax+CPedIntelligence.m_ucGunFlashFlag]
    A8 01            // 00000032 test    al, GUNFLASH_RHAND
    74 0C            // 00000034 jz      left_gun_fire_time
                     // 00000036 right_gun_fire_time:
    894E 04          // 00000036 mov     [esi+CGunFireInfo.PedInfo.m_uiRGunFireTime], ecx
    3916             // 00000039 cmp     [esi+CGunFireInfo.PedInfo.m_eWeaponType], edx
    74 03            // 0000003B je      left_gun_fire_no_reset
    895E 08          // 0000003D mov     [esi+CGunFireInfo.PedInfo.m_uiLGunFireTime], ebx
                     // 00000040 left_gun_fire_no_reset:
    EB 16            // 00000040 jmp     epilogue
                     // 00000042 left_gun_fire_time:
    A8 02            // 00000042 test    al, GUNFLASH_LHAND
    74 0C            // 00000044 jz      gun_fire_time_reset
    3916             // 00000046 cmp     [esi+CGunFireInfo.PedInfo.m_eWeaponType], edx
    74 03            // 00000048 je      right_gun_fire_no_reset
    895E 04          // 0000004A mov     [esi+CGunFireInfo.PedInfo.m_uiRGunFireTime], ebx
                     // 0000004D right_gun_fire_no_reset:
    894E 08          // 0000004D mov     [esi+CGunFireInfo.PedInfo.m_uiLGunFireTime], ecx
    EB 06            // 00000050 jmp     epilogue
                     // 00000052 gun_fire_time_reset:
    895E 04          // 00000052 mov     [esi+CGunFireInfo.PedInfo.m_uiRGunFireTime], ebx
    895E 08          // 00000055 mov     [esi+CGunFireInfo.PedInfo.m_uiLGunFireTime], ebx
                     // 00000058 epilogue:
    8916             // 00000058 mov     [esi+CGunFireInfo.PedInfo.m_eWeaponType], edx
    5E               // 0000005A pop     esi
    5B               // 0000005B pop     ebx
    C3               // 0000005C ret
//  90               // 0000005D nop
//  90               // 0000005E nop
//  90               // 0000005F nop
end

{
    void CGunFireInfo::RemovePedGunFireInfo(int iPoolID)
    (
        ms_aPedGunFireInfo[iPoolID].m_eWeaponType = WEAPONTYPE_UNARMED;
        ms_aPedGunFireInfo[iPoolID].m_uiRGunFireTime = 0;
        ms_aPedGunFireInfo[iPoolID].m_uiLGunFireTime = 0;
    )
}
:_CGunFireInfo__RemovePedGunFireInfo
hex
    8B4424 04        // 00000000 mov     eax, [esp+iPoolID]
    8D0440           // 00000004 lea     eax, [eax+eax*2]
    C1E0 02          // 00000007 shl     eax, 2
    05 00000000      // 0000000A add     eax, offset CGunFireInfo.ms_aPedGunFireInfo
    33C9             // 0000000F xor     ecx, ecx
    8908             // 00000011 mov     [eax+CGunFireInfo.PedInfo.m_eWeaponType], ecx
    8948 04          // 00000013 mov     [eax+CGunFireInfo.PedInfo.m_uiRGunFireTime], ecx
    8948 08          // 00000016 mov     [eax+CGunFireInfo.PedInfo.m_uiLGunFireTime], ecx
    C3               // 00000019 ret
//  90               // 0000001A nop
//  90               // 0000001B nop
//  90               // 0000001C nop
//  90               // 0000001D nop
//  90               // 0000001E nop
//  90               // 0000001F nop
end

{
    unsigned int CGunFireInfo::GetPedGunFireTime(int iPoolID, CPed *pPed, eWeaponType eWeaponType, bool bTwinPistol)
    (
        CWeaponInfo *pWeaponInfo;

        if(ms_aPedGunFireInfo[iPoolID].m_eWeaponType == eWeaponType)
        (
            if(!bTwinPistol)
                return ms_aPedGunFireInfo[iPoolID].m_uiRGunFireTime;

            pWeaponInfo = CWeaponInfo::GetWeaponInfo(eWeaponType, pPed->GetWeaponSkill(eWeaponType));

            if(pWeaponInfo->m_uiFlags & TWIN_PISTOL)
                return ms_aPedGunFireInfo[iPoolID].m_uiLGunFireTime;
        )

        return 0;
    )
}
:_CGunFireInfo__GetPedGunFireTime
hex
    53               // 00000000 push    ebx
    8B5C24 08        // 00000001 mov     ebx, [esp+4+iPoolID]
    8D1C5B           // 00000005 lea     ebx, [ebx+ebx*2]
    C1E3 02          // 00000008 shl     ebx, 2
    81C3 00000000    // 0000000B add     ebx, offset CGunFireInfo.ms_aPedGunFireInfo
    56               // 00000011 push    esi
    8B7424 14        // 00000012 mov     esi, [esp+8+eWeaponType]
    3933             // 00000016 cmp     [ebx+CGunFireInfo.PedInfo.m_eWeaponType], esi
    75 2F            // 00000018 jne     no_gun_fire_time
    8B5424 18        // 0000001A mov     edx, [esp+8+bTwinPistol]
    85D2             // 0000001E test    edx, edx
    75 05            // 00000020 jnz     left_gun_fire_time
    8B43 04          // 00000022 mov     eax, [ebx+CGunFireInfo.PedInfo.m_uiRGunFireTime]
    EB 24            // 00000025 jmp     epilogue
                     // 00000027 left_gun_fire_time:
    56               // 00000027 push    esi
    8B4C24 14        // 00000028 mov     ecx, [esp+0Ch+pPed]
    E8 00000000      // 0000002C call    CPed::GetWeaponSkill
    50               // 00000031 push    eax
    56               // 00000032 push    esi
    E8 00000000      // 00000033 call    CWeaponInfo::GetWeaponInfo
    83C4 08          // 00000038 add     esp, 8
    F740 18 00080000 // 0000003B test    dword ptr [eax+CWeaponInfo.m_uiFlags], TWIN_PISTOL
    74 05            // 00000042 jz      no_gun_fire_time
    8B43 08          // 00000044 mov     eax, [ebx+CGunFireInfo.PedInfo.m_uiLGunFireTime]
    EB 02            // 00000047 jmp     epilogue
                     // 00000049 no_gun_fire_time:
    33C0             // 00000049 xor     eax, eax
                     // 0000004B epilogue:
    5E               // 0000004B pop     esi
    5B               // 0000004C pop     ebx
    C3               // 0000004D ret
//  90               // 0000004E nop
//  90               // 0000004F nop
end

one doubt, if i'm in twin weapons... i can control each weapon in each hand? or the objects of weapon is "mirrored"?
as one could imagine... the slide cover of each weapon move in same time when fire

Unfortunately, only a clump is cloned per weapon which is rendered twice, one for each hand.
  • Junior_Djjr likes this

Junior_Djjr
  • Junior_Djjr

    Living in Modding

  • Members
  • Joined: 16 Dec 2011
  • Brazil

#13

Posted 09 September 2014 - 09:29 AM Edited by Junior_Djjr, 09 September 2014 - 09:42 AM.

(only now i view this message, i'm returned in the mod yesterday in a new function)

 

holy sh*t, this is very nice!

 

so, what the vantage use this and not this?:

0A8D: 9@ = read_memory 8@ size 1 vp 0 //8@ = CWeaponSlot+0x16
if 9@ <> 29@
then
    29@ = 9@
    0485:  return_true //fired
else
    059A:  return_false
end
return




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users