Skip to content

Commit 491a9c6

Browse files
committed
miscellaneous
### YimactionsV3: - Add the ability to dynamically register CommandExecutor commands for all animations and scenarios. ### Aircraft/Machine Guns - The feature previously did not work for all aircraft machine guns because it used to iterate through an array of machine gun hashes and compares each one to our currently selected weapon. The array was not well maintained and was missing some hashes. We now read data directly from memory so the feature will work with all aircraft equipped with MGs. ### CommandExecutor - Fix command meta showing translation keys for some commands instead of the translated label. ### Scripts/Translations - Move the hash map file to the Lua source.
1 parent 0cf951b commit 491a9c6

63 files changed

Lines changed: 1159 additions & 369 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ The project is organized by responsibility rather than feature size. Folders def
230230

231231
```bash
232232
├─ includes/
233-
│ ├─ classes/ # Contains reverse-engineered game classes (mostly sourced from Yimura's archived classes repository) and a few Lua-defined classes.
233+
│ ├─ classes/
234+
│ │ └─ gta/ # Contains reverse-engineered game classes mostly sourced from Yimura's archived repository and others I reversed myself using a mix of debuggers, public research, and personal suffering.
234235
│ │
235236
│ ├─ data/ # A place where all raw data is stored.
236237
│ │ ├─ actions/ # Contains YimActions V3 data (animations, scenarios, synchronized scenes, and movement clipsets).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---@diagnostic disable: param-type-mismatch
22

3-
local fwDrawData = require("includes.classes.fwDrawData")
3+
local fwDrawData = require("includes.classes.gta.fwDrawData")
44

55
---@ignore
66
---@class CBaseModelInfo : GenericClass
@@ -28,7 +28,7 @@ local CAttackers = GenericClass
2828
---@field m_hostility pointer<uint8_t> -- 0x018C
2929
---@field m_health pointer<float> -- 0x0280
3030
---@field m_max_health pointer<float> -- 0x0284
31-
---@field m_max_attackers pointer<CAttackers> -- 0x0288
31+
---@field m_attackers pointer<CAttackers> -- 0x0288
3232
---@overload fun(entity: handle): CEntity
3333
local CEntity = Class("CEntity", nil, 0x290)
3434

@@ -53,7 +53,7 @@ function CEntity:init(entity)
5353
instance.m_hostility = ptr:add(0x018C)
5454
instance.m_health = ptr:add(0x0280)
5555
instance.m_max_health = ptr:add(0x0284)
56-
instance.m_max_attackers = ptr:add(0x0288)
56+
instance.m_attackers = ptr:add(0x0288):deref()
5757

5858
return instance
5959
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---@class CFiringPatternAlias
2+
---@field protected m_ptr pointer
3+
---@field m_firing_pattern_hash pointer<joaat_t> // 0x0
4+
---@field m_alias_hash pointer<joaat_t> // 0x4
5+
---@overload fun(ptr: pointer): CFiringPatternAlias
6+
local CFiringPatternAlias = {}
7+
CFiringPatternAlias.__index = CFiringPatternAlias
8+
---@diagnostic disable-next-line: param-type-mismatch
9+
setmetatable(CFiringPatternAlias, {
10+
__call = function(_, ...)
11+
return CFiringPatternAlias.new(...)
12+
end
13+
})
14+
15+
---@param ptr pointer
16+
---@return CFiringPatternAlias
17+
function CFiringPatternAlias.new(ptr)
18+
return setmetatable({
19+
m_firing_pattern_hash = ptr:add(0x0),
20+
m_alias_hash = ptr:add(0x4)
21+
---@diagnostic disable-next-line: param-type-mismatch
22+
}, CFiringPatternAlias)
23+
end
24+
25+
return CFiringPatternAlias
File renamed without changes.
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---@diagnostic disable: param-type-mismatch
22

3-
local CEntity = require("includes.classes.CEntity")
4-
local CPlayerInfo = require("includes.classes.CPlayerInfo")
3+
local CEntity = require("includes.classes.gta.CEntity")
4+
local CPlayerInfo = require("includes.classes.gta.CPlayerInfo")
5+
local CPedWeaponManager = require("includes.classes.gta.CPedWeaponManager")
56

67
---@class CPedIntelligence
78
---@class CPedInventory
8-
---@class CPedWeaponManager
99

1010
--------------------------------------
1111
-- Class: CPed
@@ -15,21 +15,21 @@ local CPlayerInfo = require("includes.classes.CPlayerInfo")
1515
---@field private m_ptr pointer
1616
---@field m_ped_intelligence pointer<CPedIntelligence>
1717
---@field m_ped_inventory pointer<CPedInventory>
18-
---@field m_ped_weapon_mgr pointer<CPedWeaponManager>
18+
---@field m_ped_weapon_mgr CPedWeaponManager
1919
---@field m_player_info? CPlayerInfo
2020
---@field m_velocity pointer<vec3>
2121
---@field m_ped_type pointer<uint8_t>
2222
---@field m_ped_task_flag pointer<uint8_t>
2323
---@field m_seatbelt pointer<uint8_t>
2424
---@field m_armor pointer<float>
2525
---@field m_cash pointer<uint16_t> // 0x1614
26-
---@overload fun(ped: handle): CPed|nil
27-
local CPed = Class("CPed", CEntity, 0x161C)
26+
---@overload fun(ped: handle): CPed
27+
local CPed = Class("CPed", CEntity, 0x161C)
2828

2929
---@param ped handle
3030
---@return CPed
3131
function CPed:init(ped)
32-
if not ENTITY.DOES_ENTITY_EXIST(ped) or not ENTITY.IS_ENTITY_A_PED(ped) then
32+
if (not ENTITY.DOES_ENTITY_EXIST(ped) or not ENTITY.IS_ENTITY_A_PED(ped)) then
3333
error("Invalid entity!")
3434
end
3535

@@ -41,7 +41,7 @@ function CPed:init(ped)
4141
instance.m_ptr = ptr
4242
instance.m_ped_intelligence = ptr:add(0x10A0)
4343
instance.m_ped_inventory = ptr:add(0x10B0)
44-
instance.m_ped_weapon_mgr = ptr:add(0x10B8)
44+
instance.m_ped_weapon_mgr = CPedWeaponManager(ptr:add(0x10B8))
4545
instance.m_velocity = ptr:add(0x0300)
4646
instance.m_ped_type = ptr:add(0x1098)
4747
instance.m_ped_task_flag = ptr:add(0x144B)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
local CWeaponInfo = require("includes.classes.gta.CWeaponInfo")
2+
3+
---@class CPedWeaponManager
4+
---@field protected m_ptr pointer
5+
---@field public m_owner pointer<CPed>
6+
---@field public m_selected_weapon_hash pointer<uint32_t>
7+
---@field public m_weapon_info CWeaponInfo?
8+
---@field public m_vehicle_weapon_info CWeaponInfo?
9+
---@overload fun(ptr: pointer): CPedWeaponManager
10+
local CPedWeaponManager = { m_ptr = nullptr }
11+
CPedWeaponManager.__index = CPedWeaponManager
12+
---@diagnostic disable-next-line: param-type-mismatch
13+
setmetatable(CPedWeaponManager, {
14+
__call = function(_, ...)
15+
return CPedWeaponManager.new(...)
16+
end
17+
})
18+
19+
---@param ptr pointer
20+
---@return CPedWeaponManager?
21+
function CPedWeaponManager.new(ptr)
22+
if (not ptr or ptr:is_null()) then
23+
return
24+
end
25+
26+
ptr = ptr:deref()
27+
return setmetatable({
28+
m_ptr = ptr,
29+
m_owner = ptr:add(0x0010):deref(), -- CPed
30+
m_selected_weapon_hash = ptr:add(0x0018),
31+
m_weapon_info = CWeaponInfo(ptr:add(0x0020):deref()),
32+
m_vehicle_weapon_info = CWeaponInfo(ptr:add(0x0070):deref()),
33+
---@diagnostic disable-next-line: param-type-mismatch
34+
}, CPedWeaponManager)
35+
end
36+
37+
---@return boolean
38+
function CPedWeaponManager:IsValid()
39+
return self.m_ptr and self.m_ptr:is_valid()
40+
end
41+
42+
---@return pointer
43+
function CPedWeaponManager:GetPointer()
44+
return self.m_ptr
45+
end
46+
47+
---@return uint64_t
48+
function CPedWeaponManager:GetAddress()
49+
return self.m_ptr:get_address()
50+
end
51+
52+
return CPedWeaponManager

0 commit comments

Comments
 (0)