77-- * Provide a copy of or a link to the original license (GPL-3.0 or later); see LICENSE.md or <https://www.gnu.org/licenses/>.
88
99
10+ local SGSL = require (" includes.services.SGSL" )
11+ local secondary_targets = { " CASH" , " WEED" , " COKE" , " GOLD" }
12+
1013--- @class HeistStat
1114--- @field public name string
1215--- @field public val integer
2427--- @field public coords vec3
2528
2629--- @class AgencyProperty : GenericProperty
30+ --- @class FacilityProperty : GenericProperty
2731--- @class FieldHangarProperty : GenericProperty
2832--- @class SubmarineProperty : GenericProperty
33+ --- @field public heading float
2934
3035--- @alias HEIST_TYPES table<integer , HeistInfo>
3136
32- --- @class YimHeists
37+ --- @class Mastermind
3338--- @field private m_raw_data RawBusinessData
34- --- @field private m_properties { agency : AgencyProperty , hangar : FieldHangarProperty , submarine : SubmarineProperty }
39+ --- @field private m_properties { agency : AgencyProperty , hangar : FieldHangarProperty , facility : FacilityProperty , submarine : SubmarineProperty }
3540--- @field m_tab Tab
36- local YimHeists = { m_raw_data = require (" includes.data.yrv3_data" ) }
37- YimHeists .__index = YimHeists
41+ local Mastermind = { m_raw_data = require (" includes.data.yrv3_data" ) }
42+ Mastermind .__index = Mastermind
43+ Mastermind .__label = " Mastermind"
3844
39- --- @return YimHeists
40- function YimHeists :init ()
45+ --- @return Mastermind
46+ function Mastermind :init ()
4147 local instance = setmetatable ({
4248 m_properties = {}
4349 }, self )
4450
4551 if (Game .IsOnline ()) then
46- ThreadManager :Run (function ()
47- instance :ReadPropertyData ()
48- end )
52+ instance :ReadPropertyData ()
4953 end
5054
5155 Backend :RegisterEventCallback (Enums .eBackendEvent .SESSION_SWITCH , function ()
5862--- @param statName string
5963--- @param statVal integer
6064--- @param notifTitle string
61- function YimHeists :SkipPrep (statName , statVal , notifTitle )
65+ function Mastermind :SkipPrep (statName , statVal , notifTitle )
6266 stats .set_int (statName , statVal )
6367 Notifier :ShowSuccess (notifTitle , _T (" YH_PREP_SKIP_NOTIF" ))
6468end
6569
66- -- https://www.unknowncheats.me/forum/4489469-post16.html EXCEPT setting values as that's greater risk
67- --- @param type string I or C
70+ -- https://www.unknowncheats.me/forum/4489469-post16.html
71+ --- @param type string
6872--- @param index integer
69- function YimHeists :SetSecondaryTargets (type , index )
70- local secondary_targets = { " CASH" , " WEED" , " COKE" , " GOLD" }
73+ function Mastermind :SetCayoSecTargets (type , index )
7174 local targets = { 0 , 0 , 0 , 0 }
7275 targets [index ] = - 1
7376
74- for st = 1 , # secondary_targets do
77+ for st = 1 , 4 do
7578 local stat_name = _F (" MPX_H4LOOT_%s_%s" , secondary_targets [st ], type )
7679 stats .set_int (stat_name , targets [st ])
77- stats .set_int (stat_name .. " _SCOPED " , targets [st ])
80+ stats .set_int (_F ( " %s_SCOPED " , stat_name ) , targets [st ])
7881 end
7982
8083 stats .set_int (" MPX_H4LOOT_PAINT" , - 1 ) -- Not really any reason to have an option for paintings
8184 stats .set_int (" MPX_H4LOOT_PAINT_SCOPED" , - 1 )
8285end
8386
8487--- @return integer , integer
85- function YimHeists :GetSecondaryTargets ()
86- local secondary_targets = { " CASH" , " WEED" , " COKE" , " GOLD" }
87- local return_i
88- local return_c
88+ function Mastermind :GetCayoSecTargets ()
89+ local loot_i , loot_c
8990
90- for st = 1 , # secondary_targets do
91+ for st = 1 , 4 do
9192 local stat_name = _F (" MPX_H4LOOT_%s" , secondary_targets [st ])
92- if (stats .get_int (stat_name .. " _I " ) == - 1 ) then
93- return_i = st - 1 -- ImGui indexes by 0
93+ if (stats .get_int (_F ( " %s_I " , stat_name ) ) == - 1 ) then
94+ loot_i = st - 1 -- ImGui indexes by 0
9495 end
95- if (stats .get_int (stat_name .. " _C " ) == - 1 ) then
96- return_c = st - 1
96+ if (stats .get_int (_F ( " %s_C " , stat_name ) ) == - 1 ) then
97+ loot_c = st - 1
9798 end
9899 end
99100
100- return return_i or - 1 , return_c or - 1
101+ return loot_i or - 1 , loot_c or - 1
102+ end
103+
104+ --- @return ScriptGlobal
105+ local function GetSubCoordsGlobal ()
106+ local coords_global = SGSL :Get (SGSL .data .submarine_global )
107+ local pid_size = coords_global :GetOffset (1 )
108+ local offset2 = coords_global :GetOffset (2 )
109+ local vec_offset = 286 -- magic
110+
111+ return coords_global :AsGlobal ()
112+ :At (LocalPlayer :GetPlayerID (), pid_size )
113+ :At (offset2 )
114+ :At (vec_offset )
101115end
102116
103- function YimHeists :ReadPropertyData ()
117+ function Mastermind :ReadPropertyData ()
104118 ThreadManager :Run (function ()
105- -- a better approach to this would be to read transition state.
106- -- I forgot how to do that so this will do.
107- while (script .is_active (" maintransition" )) do
119+ while (Game .IsInTransition ()) do
108120 yield ()
109121 end
110122
@@ -123,35 +135,56 @@ function YimHeists:ReadPropertyData()
123135 end
124136
125137 local hangar_idx = stats .get_int (" MPX_MCKENZIE_HANGAR_OWNED" )
126- if (YRV3 : IsPropertyIndexValid ( hangar_idx ) ) then
138+ if (hangar_idx > 0 ) then
127139 local hangar_ref = self .m_raw_data .FieldHangar [1 ]
128140 self .m_properties .hangar = {
129141 name = Game .GetGXTLabel (hangar_ref .gxt ),
130142 coords = hangar_ref .coords
131143 }
132144 end
133145
146+ local facility_idx = stats .get_int (" MPX_DBASE_OWNED" )
147+ if (facility_idx > 0 ) then
148+ local facility_ref = self .m_raw_data .Facilities [facility_idx ]
149+ self .m_properties .facility = {
150+ name = Game .GetGXTLabel (facility_ref .gxt ),
151+ coords = facility_ref .coords
152+ }
153+ end
154+
134155 local sub_hash = stats .get_int (" MPX_IH_SUB_OWNED" )
135156 if (sub_hash == _J (" kosatka" )) then
157+ local global = GetSubCoordsGlobal ()
136158 self .m_properties .submarine = {
137- name = Game .GetGXTLabel (" CELL_SUBMARINE" ),
138- -- TODO: I have no idea how to properly get the location of player Kosatka
139- --
140- -- It's an index in some global which also has offsets to show if its currently requested or not
141- -- I attempted to do the same for the acid lab truck but quickly got irritated
142- coords = Game .Ensure3DCoords (760 ) or vec3 :zero ()
159+ name = Game .GetGXTLabel (" CELL_SUBMARINE" ),
160+ coords = global :ReadVec3 (),
161+ heading = global :At (3 ):ReadFloat ()
143162 }
144163 end
145164 end )
146165end
147166
167+ --- @return vec3
168+ function Mastermind :GetAviLocation ()
169+ local stat = stats .get_int (" MPX_M25_AVI_MISSION_CURRENT" )
170+ local blip = HUD .GET_FIRST_BLIP_INFO_ID (76 )
171+ if (blip and stat ~= 4 ) then
172+ local blip_coords = HUD .GET_BLIP_INFO_ID_COORD (blip )
173+ local forward_angle = math.rad (HUD .GET_BLIP_ROTATION (blip ) + 90 )
174+ local offset = vec3 :new (math.cos (forward_angle ), math.sin (forward_angle ), 0 ) -- front of payphone
175+ return blip_coords + offset
176+ end
177+
178+ return vec3 :new (42.82 , - 1599.19 , 29.60 ) -- final payphone
179+ end
180+
148181--- @return AgencyProperty ?
149- function YimHeists :GetAgencyProperty ()
182+ function Mastermind :GetAgencyProperty ()
150183 return self .m_properties .agency
151184end
152185
153186--- @return vec3 ?
154- function YimHeists :GetAgencyLocation ()
187+ function Mastermind :GetAgencyLocation ()
155188 local agency = self :GetAgencyProperty ()
156189 if (not agency ) then
157190 return
@@ -161,12 +194,12 @@ function YimHeists:GetAgencyLocation()
161194end
162195
163196--- @return FieldHangarProperty ?
164- function YimHeists :GetFieldHangarProperty ()
197+ function Mastermind :GetFieldHangarProperty ()
165198 return self .m_properties .hangar
166199end
167200
168201--- @return vec3 ?
169- function YimHeists :GetFieldHangarLocation ()
202+ function Mastermind :GetFieldHangarLocation ()
170203 local hangar = self :GetFieldHangarProperty ()
171204 if (not hangar ) then
172205 return
@@ -175,20 +208,32 @@ function YimHeists:GetFieldHangarLocation()
175208 return hangar .coords
176209end
177210
178- --- @return SubmarineProperty ?
179- function YimHeists : HasSubmarine ()
180- return self .m_properties .submarine
211+ --- @return FacilityProperty ?
212+ function Mastermind : GetFacilityProperty ()
213+ return self .m_properties .facility
181214end
182215
183- -- ---@return vec3?
184- -- function YimHeists:GetSubmarineLocation()
185- -- local sub = self:HasSubmarine()
186- -- if (not sub) then
187- -- return
188- -- end
216+ --- @return vec3 ?
217+ function Mastermind :GetFacilityLocation ()
218+ local facility = self :GetFacilityProperty ()
219+ if (not facility ) then
220+ return
221+ end
222+
223+ return facility .coords
224+ end
189225
190- -- sub.coords = Game.Ensure3DCoords(760)
191- -- return sub.coords
192- -- end
226+ --- @return SubmarineProperty ?
227+ function Mastermind :GetSubmarine ()
228+ local sub = self .m_properties .submarine
229+ if (not sub ) then
230+ return
231+ end
232+
233+ local sub_global = GetSubCoordsGlobal ()
234+ sub .coords = sub_global :ReadVec3 ()
235+ sub .heading = sub_global :At (3 ):ReadFloat ()
236+ return sub
237+ end
193238
194- return YimHeists
239+ return Mastermind
0 commit comments