-
Notifications
You must be signed in to change notification settings - Fork 72
/
SC2_MemoryAndGeneralFunctions.ahk
3907 lines (3388 loc) · 150 KB
/
SC2_MemoryAndGeneralFunctions.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;lets make all of the offsets super global (cant be fucked putting them in
; a global memory address array)
Global B_LocalCharacterNameID
, B_LocalPlayerSlot
, B_pStructure
, S_pStructure
, O_pStatus
, O_pXcam
, O_pCamDistance
, O_pCamAngle
, O_pCamRotation
, O_pYcam
, O_pTeam
, O_pType
, O_pVictoryStatus
, O_pName
, O_pRacePointer
, O_pColour
, O_pAccountID
, O_pAPM
, O_pEPM
, O_pWorkerCount
, O_pWorkersBuilt
, O_pHighestWorkerCount
, O_pBaseCount
, O_pSupplyCap
, O_pSupply
, O_pMinerals
, O_pGas
, O_pArmySupply
, O_pMineralIncome
, O_pGasIncome
, O_pArmyMineralSize
, O_pArmyGasSize
, P_IdleWorker
, O1_IdleWorker
, O2_IdleWorker
, B_Timer
, B_rStructure
, S_rStructure
, P_ChatFocus
, O1_ChatFocus
, O2_ChatFocus
, P_MenuFocus
, O1_MenuFocus
, P_SocialMenu
, B_uCount
, B_uHighestIndex
, B_uStructure
, S_uStructure
, O_uModelPointer
, O_uTargetFilter
, O_uBuildStatus
, O_XelNagaActive
, O_uOwner
, O_uX
, O_uY
, O_uZ
, O_uDestinationX
, O_uDestinationY
, O_P_uCmdQueuePointer
, O_P_uAbilityPointer
, O_uChronoState
, O_uInjectState
, O_uHpDamage
, O_uShieldDamage
, O_uEnergy
, O_uTimer
, O_cqState
, O_mUnitID
, O_mSubgroupPriority
, O_mMiniMapSize
, B_SelectionStructure
, B_CtrlGroupOneStructure
, S_CtrlGroup
, S_scStructure
, O_scTypeCount
, O_scTypeHighlighted
, O_scUnitIndex
, B_localArmyUnitCount
, O1_localArmyUnitCount
, O2_localArmyUnitCount
, B_TeamColours
, P_SelectionPage
, O1_SelectionPage
, O2_SelectionPage
, O3_SelectionPage
, DeadFilterFlag
, BuriedFilterFlag
, B_MapStruct
, O_mLeft
, O_mBottom
, O_mRight
, O_mTop
, aUnitMoveStates
, B_UnitCursor
, O1_UnitCursor
, O2_UnitCursor
, P_IsUserPerformingAction
, O1_IsUserPerformingAction
, P_IsBuildCardDisplayed
, 01_IsBuildCardDisplayed
, 02_IsBuildCardDisplayed
, 03_IsBuildCardDisplayed
, P_ChatInput
, O1_ChatInput
, O2_ChatInput
, O3_ChatInput
, O4_ChatInput
, B_CameraDragScroll
, B_InputStructure
, B_iMouseButtons
, B_iSpace
, B_iNums
, B_iChars
, B_iTilda
, B_iNonAlphNumChars
, B_iNonCharKeys
, B_iFkeys
, B_iModifiers
, B_CameraMovingViaMouseAtScreenEdge
, 01_CameraMovingViaMouseAtScreenEdge
, 02_CameraMovingViaMouseAtScreenEdge
, 03_CameraMovingViaMouseAtScreenEdge
, B_IsGamePaused
, B_FramesPerSecond
, B_Gamespeed
, B_ReplayFolder
, B_HorizontalResolution
, B_VerticalResolution
global aUnitModel := []
, aStringTable := []
, aMiniMapUnits := []
/*
O_pTimeSupplyCapped := 0x840
O_pActionsPerformed := 0x5A0 ; accumulative user commands
*/
loadMemoryAddresses(base, version := "")
{
if (version = "2.1.0.28667")
{
versionMatch := "2.1.0.28667"
#include %A_ScriptDir%\Included Files\oldOffsets\2.1.0.28667.ahk
}
else
{
if (version = "2.1.1.29261" || !version) ; !version encase the findVersion function stuffs up and returns 0/blank, thereby just assume match with latest offsets
versionMatch := "2.1.1.29261"
; [Memory Addresses]
B_LocalCharacterNameID := base + 0x04F15C14 ; stored as string Name#123
B_LocalPlayerSlot := base + 0x112E5F0 ; note 1byte and has a second 'copy' (ReplayWatchedPlayer) just after +1byte eg LS =16d=10h, hex 1010 (2bytes) & LS =01d = hex 0101
B_ReplayWatchedPlayer := B_LocalPlayerSlot + 0x1
B_pStructure := base + 0x35F55A8
S_pStructure := 0xE10
O_pStatus := 0x0
O_pXcam := 0x8
O_pYcam := 0xC
O_pCamDistance := 0x10 ; 0xA - Dont know if this is correct - E
O_pCamAngle := 0x14
O_pCamRotation := 0x18
O_pTeam := 0x1C
O_pType := 0x1D ;
O_pVictoryStatus := 0x1E
O_pName := 0x60 ;+8
O_pRacePointer := 0x158
O_pColour := 0x1B0
O_pAccountID := 0x1C0 ; ????
O_pAPM := 0x5E8 ; 0x598
O_pEPM := 0x5D8 ; ?????
O_pWorkerCount := 0x7D8 ; **Care dont confuse this with HighestWorkerCount
O_pTotalUnitsBuilt := 0x658 ; eg numbers of units made (includes 6 starting scvs)
O_pWorkersBuilt := 0x7E8 ; number of workers made (includes the 6 at the start of the game)
O_pHighestWorkerCount := 0x800 ; the current highest worker account achieved
O_pBaseCount := 0x848
O_pSupplyCap := 0x898
O_pSupply := 0x8B0 ;+ 12
O_pMinerals := 0x8F0 ;+18
O_pGas := 0x8F8
O_pArmySupply := 0x8D0
O_pMineralIncome := 0x970
O_pGasIncome := 0x978
O_pArmyMineralSize := 0xC58 ; there are two (identical?) values for minerals/gas
O_pArmyGasSize := 0xC80 ; ** care dont use max army gas/mineral size!
P_IdleWorker := base + 0x03114D30
O1_IdleWorker := 0x358
O2_IdleWorker := 0x244 ; tends to always end with this offset if finding via pointer scan
; This can be found via three methods, pattern scan:
; C1 EA 0A B9 00 01 00 00 01 0D ?? ?? ?? ?? F6 D2 A3 ?? ?? ?? ?? F6 C2 01 74 06 01 0D ?? ?? ?? ?? 83 3D ?? ?? ?? ?? 00 56 BE FF FF FF 7F
; Timer Address = readMemory(patternAddress + 0x1C)
; It can also be found as there are two (identical?) 4-byte timers next to each other.
; So do the usual search between times to find the timer value, then search for an 8 byte representation of
; two timers which have the same value. GameGetMissionTime() refers to the second (+0x4) of these two timers.
; And via IDA (Function: GameGetMissionTime) (-0x800000 from IDA address)
B_Timer := base + 0x35428DC ; 0x353C41C
B_rStructure := base + 0x02F6C850 ; ?? Havent updated as dont use this
S_rStructure := 0x10
P_ChatFocus := base + 0x03114D30 ;Just when chat box is in focus ; value = True if open
O1_ChatFocus := 0x394
O2_ChatFocus := 0x174 ; tends to end with this offset
P_MenuFocus := base + 0x04FFA324 ;this is all menus and includes chat box when in focus ; old 0x3F04C04
O1_MenuFocus := 0x17C ; tends to end with this offse
P_SocialMenu := base + 0x0409B098 ; ???? Havent updated as dont use it
B_uCount := base + 0x3672FA8 ; or 0x2F75568 ; This is the units alive (and includes missiles)
; There are two of these values and they only differ the instant a unit dies esp with missle fire (ive used the higher value) - perhaps one updates slightly quicker - dont think i use this offset anymore
B_uHighestIndex := base + 0x3672FC0 ; this is actually the highest currently alive unit (includes missiles while alive) and starts at 1 NOT 0! i.e. 1 unit alive = 1
B_uStructure := base + 0x3673000
S_uStructure := 0x1C0
O_uModelPointer := 0x8
O_uTargetFilter := 0x14
O_uBuildStatus := 0x18 ; buildstatus is really part of the 8 bit targ filter!
O_XelNagaActive := 0x34 ; dont use as doesnt work all the time
; something added in here in vr 2.10
O_uOwner := 0x41 ; this and the rest below +4
O_uX := 0x4C
O_uY := 0x50
O_uZ := 0x54
O_uDestinationX := 0x80
O_uDestinationY := 0x84
O_P_uCmdQueuePointer := 0xD4 ;+4
O_P_uAbilityPointer := 0xDC
; there are other offsets which can be used for chrono/inject state
O_uChronoState := 0xE6 ; pre 210 chrono and inject offsets were the same
O_uInjectState := 0xE7 ; +5 Weird this was 5 not 4 (and its values changed) chrono state just +4
O_uHpDamage := 0x114
O_uShieldDamage := 0x118
O_uEnergy := 0x11c
O_uTimer := 0x16C ;+4
;CommandQueue ; separate structure
O_cqState := 0x40
; Unit Model Structure
O_mUnitID := 0x6
O_mSubgroupPriority := 0x3A8 ;0x398
O_mMiniMapSize := 0x3AC ;0x39C
; selection and ctrl groups
B_SelectionStructure := base + 0x31D8508
; Note: This is actually the second control group in the group structure.
; The structure begins with ctrl group 0, then goes to 1, But i used ctrl group 1 as base for simplicity
; when getting info for group 1, the negative offset will work fine
B_CtrlGroupOneStructure := base + 0x31DD730
S_CtrlGroup := 0x1B60
S_scStructure := 0x4 ; Unit Selection & Ctrl Group Structures
O_scTypeCount := 0x2
O_scTypeHighlighted := 0x4
O_scUnitIndex := 0x8
; P_PlayerColours := base + 0x03D28A84 ; 0 when enemies red 1 when player colours
; O1_PlayerColours := 0x4
; O2_PlayerColours := 0x17c
; give the army unit count (i.e. same as in the select army icon) - unit count not supply
; dont confuse with similar one which includes army unit counts in production
B_localArmyUnitCount := base + 0x03114D30
O1_localArmyUnitCount := 0x354
O2_localArmyUnitCount := 0x248
B_TeamColours := base + 0x3115E7C ; 2 when team colours is on, else 0
; another one at + 0x4FBCB98
P_SelectionPage := base + 0x03114D30 ; ***theres one other 3 lvl pointer but for a split second (every second or so) it points to
O1_SelectionPage := 0x320 ; the wrong address! You need to increase CE timer resolution to see this happening! Check it!
O2_SelectionPage := 0x15C ;this is for the currently selected unit portrait page ie 1-6 in game (really starts at 0-5)
O3_SelectionPage := 0x14C ;might actually be a 2 or 1 byte value....but works fine as 4
DeadFilterFlag := 0x0000000200000000
BuriedFilterFlag := 0x0000000010000000
B_MapStruct := base + 0x3542874 ;0x353C3B4 ;0x3534EDC ; 0X024C9E7C
O_mLeft := B_MapStruct + 0xDC
O_mBottom := B_MapStruct + 0xE0
O_mRight := B_MapStruct + 0xE4 ; MapRight 157.999756 (akilon wastes) after dividing 4096 (647167 before)
O_mTop := B_MapStruct + 0xE8 ; MapTop: 622591 (akilon wastes) before dividing 4096
aUnitMoveStates := { Idle: -1 ; ** Note this isn't actually a read in game type/value its just what my funtion will return if it is idle
, Amove: 0
, Patrol: 1
, HoldPosition: 2
, Move: 256
, Follow: 512
, FollowNoAttack: 515} ; This is used by unit spell casters such as infestors and High temps which dont have a real attack
; note I have Converted these hex numbers from their true decimal conversion
B_UnitCursor := base + 0x03114D30
O1_UnitCursor := 0x2C0
O2_UnitCursor := 0x21C
; If used as 4byte value, will return 256 there are 2 of these memory addresses
P_IsUserPerformingAction := base + 0x03114D30 ; This is a 1byte value and return 1 when user is casting or in is rallying a hatch via gather/rally or is in middle of issuing Amove/patrol command but
O1_IsUserPerformingAction := 0x230 ; if youre searching for a 4byte value in CE offset will be at 0x254 (but really if using it as 1 byte it is 0x255) - but im lazy and use it as a 4byte with my pointer command
; also 1 when placing a structure (after structure is selected) or trying to land rax to make a addon Also gives 1 when trying to burrow spore/spine
; When searching for 4 byte value this offset will be 0x254
; this address is really really useful!
; it is even 0 with a burrowed swarm host selected (unless user click 'y' for rally which is even better)
/* Not Currently Used
P_IsUserBuildingWithWorker := base + 0x0209C3C8 ; this is like the one but will give 1 even when all structure are greyed out (eg lair tech having advanced mutations up)
01_IsUserBuildingWithWorker := 0x364 ; works for workers of all races
02_IsUserBuildingWithWorker := 0x17C ; even during constructing SVC will give 0 - give 1 when selection card is up :)
03_IsUserBuildingWithWorker := 0x3A8 ; also displays 1 when the toss hallucination card is displayed
04_IsUserBuildingWithWorker := 0x168 ; BUT will also give 1 when a hatch is selected!!!
*/
P_IsBuildCardDisplayed := base + 0x0312872C ; this displays 1 (swarm host) or 0 with units selected - displays 7 when targeting reticle displayed/or placing a building (same thing)
01_IsBuildCardDisplayed := 0x7C ; **but when either build card is displayed it displays 6 (even when all advanced structures are greyed out)!!!!
02_IsBuildCardDisplayed := 0x74 ; also displays 6 when the toss hallucination card is displayed
03_IsBuildCardDisplayed := 0x398 ; could use this in place of the current 'is user performing action offset'
; Note: There is another address which has the same info, but when placing a building it will swap between 6 & 7 (not stay at 7)!
; There are two chat buffers - One blanks after you press return (to send chat)
; while the other one keeps the text even after the chat is sent/closed
; this is the latter
; note there are two of these so make sure pick the right one as there addresses
; can go from high to low so the one at the top of CE scan might not be the same one
; that was at the top last time!
P_ChatInput := base + 0x0310EDEC ; ?????? not updated/used currently
O1_ChatInput := 0x16C
O2_ChatInput := 0xC
O3_ChatInput := 0x278
O4_ChatInput := 0x0
/*
Around this modifier area are other values which contain the logical states
SC2.exe+1FDF7C6 is a 2byte value which contains the state of the numbers 0-9
SC2.exe+1FDF7D0 contains the state F-keys as well as keys like tab, backspace, Ins, left, right etc
SC2.exe+1FDF7C8 (8 bytes) contains the state of most keys eg a-z etc
*/
; there are two of these the later 1 is actually the one that affects the game
; Also the 1st one, if u hold down a modifier then go out of the game (small window mode)
; it will remain 1 even when back in and shift isn't down as moving a unit wont be shift-commanded! so dont use that one
;shift = 1, ctrl = 2, alt = 4 (and add them together)
B_CameraDragScroll := base + 0x3057DB0 ; 1 byte Returns 1 when user is moving camera via DragScroll i.e. mmouse button the main map But not when on the minimap (or if mbutton is held down on the unit panel)
B_InputStructure := base + 0x30580C0
B_iMouseButtons := B_InputStructure + 0x0 ; 1 Byte MouseButton state 1 for Lbutton, 2 for middle mouse, 4 for rbutton
B_iSpace := B_iMouseButtons + 0x8 ; 1 Bytes
B_iNums := B_iSpace + 0x2 ; 2 Bytes
B_iChars := B_iNums + 0x2 ; 4 Bytes
B_iTilda := B_iChars + 0x4 ; 1 Byte (could be 2 bytes)
B_iNonAlphNumChars := B_iTilda + 0x2 ; 2 Bytes - keys: [];',./ Esc Entr \
B_iNonCharKeys := B_iNonAlphNumChars + 0x2 ; 2 Bytes - keys: BS Up Down Left Right Ins Del Hom etc scrl lock pause caps + tab
B_iFkeys := B_iNonCharKeys + 0x2 ; 2 bytes
B_iModifiers := B_iFkeys + 0x6 ; 1 Byte
B_CameraMovingViaMouseAtScreenEdge := base + 0x03114D30 ; Really a 1 byte value value indicates which direction screen will scroll due to mouse at edge of screen
01_CameraMovingViaMouseAtScreenEdge := 0x2C0 ; 1 = Diagonal Left/Top 4 = Left Edge
02_CameraMovingViaMouseAtScreenEdge := 0x20C ; 2 = Top 5 = Right Edge
03_CameraMovingViaMouseAtScreenEdge := 0x5A4 ; 3 = Diagonal Right/Top 6 = Diagonal Left/ Bot
; 7 = Bottom Edge 8 = Diagonal Right/Bot
; Note need to do a pointer scan with max offset > 1200d!
B_IsGamePaused := base + 0x31FEF1D
B_FramesPerSecond := base + 0x04FBD484
B_Gamespeed := base + 0x4EFE5E8
; example: D:\My Computer\My Documents\StarCraft II\Accounts\56021244\6-S2-1-34722\Replays\
; this works for En, Fr, and Kr languages
B_ReplayFolder := base + 0x4F7B228 ;0x04F701F8
; Horizontal resolution ; 4 bytes
; vertical resolution ; The next 4 bytes immediately after the Horizontal resolution
; cheat and search for 8 bytes 4638564681600 (1920 1080)
; There will be 3 green static addresses (+many non-statics) One of them will change depending on resolution
; Can resize in window mode and it will change too
B_HorizontalResolution := base + 0x4FF9DD8
B_VerticalResolution := B_HorizontalResolution + 0x4
/*
; There is value reached via a pointer which will change the rendered resolution (even in widowed mode)
P_HorizontalResolutionReal := base + 0x01106654
01_HorizontalResolutionReal := 0x90
P_VerticalResolutionReal := base + 0x01106654
01_VerticalResolutionReal := 0x94
*/
; The below offsets are not Currently used but are current for 2.0.8
/*
P_IsUserCasting := base + 0x0209C3C8 ; this is probably something to do with the control card
O1_IsUserCasting := 0x364 ; 1 indicates user is casting a spell e.g. fungal, snipe, or is trying to place a structure
O2_IsUserCasting := 0x19C ; auto casting e.g. swarm host displays 1 always
O3_IsUserCasting := 0x228
O4_IsUserCasting := 0x168
P_IsCursorReticleBurrowedInfestor:= base + 0x021857EC ; 1 byte ;seems to return 1 when cursors is reticle but not for inject larva on queen
O1_IsCursorReticleBurrowedInfestor := 0x1C ; also retursn 1 for burrowed swarm hosts though - auto cast? (and fungal - but reticle present for fungal)
O2_IsCursorReticleBurrowedInfestor := 0x14 ; 0 when placing a building
P_IsUserBuildingWithDrone := base + 0x0209C3C8 ; gives 1 when drone has basic mutation or advance mutaion/ open
01_IsUserBuildingWithDrone := 0x364 ; Note: If still on hatch tech and all advanced building 'greyed out' will give 0!!!!!
02_IsUserBuildingWithDrone := 0x17C ; also gives 1 when actually attempting to place building
03_IsUserBuildingWithDrone := 0x228
04_IsUserBuildingWithDrone := 0x168
*/
/* Not Currently used
B_CameraBounds := base + 0x209A094
O_x0Bound := 0x0
O_XmBound := 0x8
O_Y0Bound := 0x04
O_YmBound := 0x0C
B_CurrentBaseCam := 0x017AB3C8 ;not current
P1_CurrentBaseCam := 0x25C ;not current
*/
}
return versionMatch
}
getMapLeft()
{ global
return ReadMemory(O_mLeft, GameIdentifier) / 4096
}
getMapBottom()
{ global
return ReadMemory(O_mBottom, GameIdentifier) / 4096
}
getMapRight()
{ global
return ReadMemory(O_mRight, GameIdentifier) / 4096
}
getMapTop()
{ global
return ReadMemory(O_mTop, GameIdentifier) / 4096
}
IsInControlGroup(group, unitIndex)
{
count := getControlGroupCount(Group)
ReadRawMemory(B_CtrlGroupOneStructure + S_CtrlGroup * (group - 1), GameIdentifier, Memory, O_scUnitIndex + count * S_scStructure)
loop, % count
{
if (unitIndex = (NumGet(Memory, O_scUnitIndex + (A_Index - 1) * S_scStructure, "UInt") >> 18))
Return 1
}
Return 0
}
/*
isInControlGroup(group, unit)
{ ; group# = 1, 2,3-0
global
loop, % getControlGroupCount(Group)
if (unit = getCtrlGroupedUnitIndex(Group, A_Index - 1))
Return 1 ;the unit is in this control group
Return 0
} ; ctrl_unit_number := ReadMemory(B_CtrlGroupOneStructure + S_CtrlGroup * (group - 1) + O_scUnitIndex +(A_Index - 1) * S_scStructure, GameIdentifier, 2)/4
*/
getCtrlGroupedUnitIndex(group, i=0)
{ global
Return ReadMemory(B_CtrlGroupOneStructure + S_CtrlGroup * (group - 1) + O_scUnitIndex + i * S_scStructure, GameIdentifier) >> 18
}
getControlGroupCount(Group)
{ global
Return ReadMemory(B_CtrlGroupOneStructure + S_CtrlGroup * (Group - 1), GameIdentifier, 2)
}
getTime()
{ global
Return Round(ReadMemory(B_Timer, GameIdentifier)/4096, 1)
}
getGameTickCount()
{ global
Return ReadMemory(B_Timer, GameIdentifier)
}
ReadRawUnit(unit, ByRef Memory) ; dumps the raw memory for one unit
{ GLOBAL
ReadRawMemory(B_uStructure + unit * S_uStructure, GameIdentifier, Memory, S_uStructure)
return
}
getSelectedUnitIndex(i=0) ;IF Blank just return the first selected unit (at position 0)
{ global
Return ReadMemory(B_SelectionStructure + O_scUnitIndex + i * S_scStructure, GameIdentifier) >> 18 ;how the game does it
; returns the same thing ; Return ReadMemory(B_SelectionStructure + O_scUnitIndex + i * S_scStructure, GameIdentifier, 2) /4
}
getSelectionTypeCount() ; begins at 1
{ global
Return ReadMemory(B_SelectionStructure + O_scTypeCount, GameIdentifier, 2)
}
getSelectionHighlightedGroup() ; begins at 0
{ global
Return ReadMemory(B_SelectionStructure + O_scTypeHighlighted, GameIdentifier, 2)
}
getSelectionCount()
{ global
Return ReadMemory(B_SelectionStructure, GameIdentifier, 2)
}
getIdleWorkers()
{ global
return pointer(GameIdentifier, P_IdleWorker, O1_IdleWorker, O2_IdleWorker)
}
getPlayerSupply(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return round(ReadMemory(((B_pStructure + O_pSupply) + (player-1)*S_pStructure), GameIdentifier) / 4096)
; Round Returns 0 when memory returns Fail
}
getPlayerSupplyCap(player="")
{ Local SupplyCap
If (player = "")
player := aLocalPlayer["Slot"]
SupplyCap := round(ReadMemory(((B_pStructure + O_pSupplyCap) + (player-1)*S_pStructure), GameIdentifier) / 4096)
if (SupplyCap > 200) ; as this will actually report the amount of supply built i.e. can be more than 200
return 200
else return SupplyCap
}
getPlayerSupplyCapTotal(player="")
{ GLOBAL
If (player = "")
player := aLocalPlayer["Slot"]
Return round(ReadMemory(((B_pStructure + O_pSupplyCap) + (player-1)*S_pStructure), GameIdentifier) / 4096)
}
getPlayerWorkerCount(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(((B_pStructure + O_pWorkerCount) + (player-1)*S_pStructure), GameIdentifier)
}
; Number of workers made (includes the 6 at the start of the game)
; eg have 12 workers, but 2 get killed, and then you make one more
; this value will be 13.
getPlayerWorkersBuilt(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(((B_pStructure + O_pWorkersBuilt) + (player-1)*S_pStructure), GameIdentifier)
}
getPlayerWorkersLost(player="")
{ global aLocalPlayer
If (player = "")
player := aLocalPlayer["Slot"]
return getPlayerWorkersBuilt() - getPlayerWorkerCount()
}
getPlayerHighestWorkerCount(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pHighestWorkerCount + (player-1)*S_pStructure, GameIdentifier)
}
getUnitType(Unit) ;starts @ 0 i.e. first unit at 0
{ global
LOCAL pUnitModel := ReadMemory(B_uStructure + (Unit * S_uStructure) + O_uModelPointer, GameIdentifier) ; note - this isnt really the correct pointer still have to << 5
if !aUnitModel[pUnitModel]
getUnitModelInfo(pUnitModel)
return aUnitModel[pUnitModel].Type
; Return ReadMemory(((ReadMemory(B_uStructure + (Unit * S_uStructure)
; + O_uModelPointer, GameIdentifier)) << 5) + O_mUnitID, GameIdentifier, 2) ; note the pointer is 4byte, but the unit type is 2byte/word
}
getUnitName2(unit)
{ global
Return substr(ReadMemory_Str(ReadMemory(ReadMemory(((ReadMemory(B_uStructure + (Unit * S_uStructure)
+ O_uModelPointer, GameIdentifier)) << 5) + 0xC, GameIdentifier), GameIdentifier) + 0x29, GameIdentifier), 6)
; pNameDataAddress := ReadMemory(unit_type + 0x6C, "StarCraft II")
; NameDataAddress := ReadMemory(pNameDataAddress, "StarCraft II") + 0x29
; Name := ReadMemory_Str(NameDataAddress, , "StarCraft II")
; NameLength := ReadMemory(NameDataAddress, "StarCraft II")
}
getUnitName(unit)
{
mp := ReadMemory(B_uStructure + Unit * S_uStructure + O_uModelPointer, GameIdentifier) << 5 ;
pNameDataAddress := ReadMemory(mp + 0xC, GameIdentifier) ; mp + pName_address
pNameDataAddress := ReadMemory(pNameDataAddress, GameIdentifier)
NameDataAddress := ReadMemory(pNameDataAddress, GameIdentifier)
return substr(ReadMemory_Str(NameDataAddress + 0x20, GameIdentifier), 11) ; trim name/unit/
}
getUnitOwner(Unit) ;starts @ 0 i.e. first unit at 0 - 2.0.4 starts at 1?
{ global
Return ReadMemory((B_uStructure + (Unit * S_uStructure)) + O_uOwner, GameIdentifier, 1) ; note the 1 to read 1 byte
}
getMiniMapRadius(Unit)
{
LOCAL pUnitModel := ReadMemory(B_uStructure + (Unit * S_uStructure) + O_uModelPointer, GameIdentifier) ; note - this isnt really the correct pointer still have to << 5
if !aUnitModel[pUnitModel]
getUnitModelInfo(pUnitModel)
return aUnitModel[pUnitModel].MiniMapRadius
;Return ReadMemory(((ReadMemory(B_uStructure + (unit * S_uStructure) + O_uModelPointer, GameIdentifier) << 5) & 0xFFFFFFFF) + O_mMiniMapSize, GameIdentifier) /4096
}
getUnitCount()
{ global
return ReadMemory(B_uCount, GameIdentifier)
}
getHighestUnitIndex() ; this is the highest alive units index - note its out by 1 - ie it starts at 1
{ global ; if 1 unit is alive it will return 1 (NOT 0)
Return ReadMemory(B_uHighestIndex, GameIdentifier)
}
getPlayerName(i) ; start at 0
{ global
Return ReadMemory_Str(B_pStructure + O_pName + (i-1) * S_pStructure, GameIdentifier)
}
getPlayerRace(i) ; start at 0
{ global
local Race
; Race := ReadMemory_Str((B_rStructure + (i-1) * S_rStructure), ,GameIdentifier) ;old easy way
Race := ReadMemory_Str(ReadMemory(ReadMemory(B_pStructure + O_pRacePointer + (i-1)*S_pStructure, GameIdentifier) + 4, GameIdentifier), GameIdentifier)
If (Race == "Terr")
Race := "Terran"
Else if (Race == "Prot")
Race := "Protoss"
Else If (Race == "Zerg")
Race := "Zerg"
Else If (Race == "Neut")
Race := "Neutral"
Else
Race := "Race Error" ; so if it ever gets read out in speech, easily know its just from here and not some other error
Return Race
}
getPlayerType(i)
{ global
static oPlayerType := { 0: "None"
, 1: "User" ; I believe all human players in a game have this type regardless if ally or on enemy team
, 2: "Computer"
, 3: "Neutral"
, 4: "Hostile"
, 5: "Referee"
, 6: "Spectator" }
Return oPlayerType[ ReadMemory((B_pStructure + O_pType) + (i-1) * S_pStructure, GameIdentifier, 1) ]
}
getPlayerVictoryStatus(i)
{ global
static oPlayerStatus := { 0: "Playing"
, 1: "Victorious"
, 2: "Defeated"
, 3: "Tied" }
Return oPlayerStatus[ ReadMemory((B_pStructure + O_pVictoryStatus) + (i-1) * S_pStructure, GameIdentifier, 1) ]
}
/*
Nuke's Enum
oPlayerStatus := { 0: "Unused"
, 1: "Active"
, 2: "Left"
, 3: "Tied"
, 5: "Win"
, 7: "SeeBuildings"
, 9: "Active9"
, 17: "Active14"
, 24: "Left"
, 25: "Active25" }
all of these values occured while player was still 'active'
; all are diviseable by 4 after subtracting 1
;5 ;9 ;13 ;17 ;33 ;65 ;73 ;81 ;129 ;133 ;137 ;145 ;161 ;193 ;209
unused when a plyer leaves on the replay
I wonder if the structure is more is just active and left
getPlayerActiveStatus(i)
{ global
static oPlayerStatus := { 0: "Unused"
, 1: "Active"
, 2: "Left"
, 3: "Tied" } ; wonder if there is no tied
Return oPlayerStatus[ mod(ReadMemory((B_pStructure + O_pStatus) + (i-1) * S_pStructure, GameIdentifier, 1), 4) ]
}
*/
isPlayerActive(player)
{
Return (ReadMemory((B_pStructure + O_pStatus) + (player-1) * S_pStructure, GameIdentifier, 1) & 1)
}
getPlayerTeam(player="") ;team begins at 0
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory((B_pStructure + O_pTeam) + (player-1) * S_pStructure, GameIdentifier, 1)
}
getPlayerColour(i)
{ static aPlayerColour
if !isObject(aPlayerColour)
{
aPlayerColour := []
Colour_List := "White|Red|Blue|Teal|Purple|Yellow|Orange|Green|Light Pink|Violet|Light Grey|Dark Green|Brown|Light Green|Dark Grey|Pink"
Loop, Parse, Colour_List, |
aPlayerColour[a_index - 1] := A_LoopField
}
Return aPlayerColour[ReadMemory((B_pStructure + O_pColour) + (i-1) * S_pStructure, GameIdentifier)]
}
getLocalPlayerNumber() ;starts @ 1
{ global
Return ReadMemory(B_LocalPlayerSlot, GameIdentifier, 1) ;Local player slot is 1 Byte!!
}
getBaseCameraCount(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory((B_pStructure + O_pBaseCount) + (player-1) * S_pStructure, GameIdentifier)
}
getPlayerMineralIncome(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pMineralIncome + (player-1) * S_pStructure, GameIdentifier)
}
getPlayerGasIncome(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pGasIncome + (player-1) * S_pStructure, GameIdentifier)
}
getPlayerArmySupply(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pArmySupply + (player-1) * S_pStructure, GameIdentifier) / 4096
}
getPlayerArmySizeMinerals(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pArmyMineralSize + (player-1) * S_pStructure, GameIdentifier)
}
getPlayerArmySizeGas(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pArmyGasSize + (player-1) * S_pStructure, GameIdentifier)
}
getPlayerMinerals(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pMinerals + (player-1) * S_pStructure, GameIdentifier)
}
getPlayerGas(player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + O_pGas + (player-1) * S_pStructure, GameIdentifier)
}
getPlayerCameraPositionX(Player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + (Player - 1)*S_pStructure + O_pXcam, GameIdentifier) / 4096
}
getPlayerCameraPositionY(Player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + (Player - 1)*S_pStructure + O_pYcam, GameIdentifier) / 4096
}
getPlayerCameraDistance(Player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + (Player - 1)*S_pStructure + O_pCamDistance, GameIdentifier) / 4096
}
getPlayerCameraAngle(Player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + (Player - 1)*S_pStructure + O_pCamAngle, GameIdentifier) / 4096
}
getPlayerCameraRotation(Player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + (Player - 1)*S_pStructure + O_pCamRotation, GameIdentifier) / 4096
}
; Note if in game without other players (get instant victory)
; then this value will remain zero
; I think it might get frozen after a real game finishes
; but user decides to remain in the game
getPlayerCurrentAPM(Player="")
{ global
If (player = "")
player := aLocalPlayer["Slot"]
Return ReadMemory(B_pStructure + (Player - 1)*S_pStructure + O_pAPM, GameIdentifier)
}
isUnderConstruction(building) ; starts @ 0 and only for BUILDINGS!
{ global ; 0 means its completed
; Return ReadMemory(B_uStructure + (building * S_uStructure) + O_uBuildStatus, GameIdentifier) ;- worked fine
return getUnitTargetFilterFast(building) & aUnitTargetFilter.UnderConstruction
}
isUnitAStructure(unit)
{ GLOBAL
return getUnitTargetFilterFast(unit) & aUnitTargetFilter.Structure
}
getUnitEnergy(unit)
{ global
Return Floor(ReadMemory(B_uStructure + (unit * S_uStructure) + O_uEnergy, GameIdentifier) / 4096)
}
numgetUnitEnergy(ByRef unitDump, unit)
{ global
Return Floor(numget(unitDump, unit * S_uStructure + O_uEnergy, "Uint") / 4096)
}
; Damage which has been delt to the unit
; need to substract max hp in unit to find actual health value/percentage
getUnitHpDamage(unit)
{ global
Return Floor(ReadMemory(B_uStructure + (unit * S_uStructure) + O_uHpDamage, GameIdentifier) / 4096)
}
getUnitShieldDamage(unit)
{ global
Return Floor(ReadMemory(B_uStructure + (unit * S_uStructure) + O_uShieldDamage, GameIdentifier) / 4096)
}
getUnitPositionX(unit)
{ global
Return ReadMemory(B_uStructure + (unit * S_uStructure) + O_uX, GameIdentifier) /4096
}
getUnitPositionY(unit)
{ global
Return ReadMemory(B_uStructure + (unit * S_uStructure) + O_uY, GameIdentifier) /4096
}
getUnitPositionZ(unit)
{ global
Return ReadMemory(B_uStructure + (unit * S_uStructure) + O_uZ, GameIdentifier) /4096
}
/*
Move Structure
+0x0 next Command ptr either (& -2) or (& 0xFFFFFFFE)
+0x4 unit Structure Address
+08 Some ptr - maybe ability
When at the last command, the Command ptr & 0xFFFFFFFE
will = the adress of the first command
also, the last bit of the Command ptr (pre &) will be set to 1
; O_cqState := 0x40
<Struct Name="QueuedCommand" Size="-1">
<Member Name="pNextCommand" Type="Unsigned" Size="4" Offset="0"/>
<!--
A Struct very similar to Command starts here. It is a bit different though.
-->
<Member Name="AbilityPointer" Type="Unsigned" Size="4" Offset="pNextCommand+0x18" AbsoluteOffset="0x18"/>
<Member Name="TargetUnitID" Type="Unsigned" Size="4" Offset="AbilityPointer+8" AbsoluteOffset="0x20"/>
<Member Name="TargetUnitModelPtr" Type="Unsigned" Size="4" Offset="TargetUnitID+4" AbsoluteOffset="0x24"/>
<Member Name="TargetX" Type="Fixed" Size="4" Offset="TargetUnitModelPtr+4" AbsoluteOffset="0x28"/>
<Member Name="TargetY" Type="Fixed" Size="4" Offset="TargetX+4" AbsoluteOffset="0x2C"/>
<Member Name="TargetZ" Type="Fixed" Size="4" Offset="TargetY+4" AbsoluteOffset="0x30"/>
<Member Name="Unknown" Type="Unsigned" Size="4" Offset="TargetZ+4" AbsoluteOffset="0x34"/>
<Member Name="TargetFlags" Type="Unsigned" Size="4" Offset="Unknown+4" AbsoluteOffset="0x38"/>
<Member Name="Flags" Type="Unsigned" Size="4" Offset="TargetFlags+4" AbsoluteOffset="0x3C"/>
<Member Name="AbilityCommand" Type="Unsigned" Size="1" Offset="Flags+4" AbsoluteOffset="0x40"/>
<Member Name="Player" Type="Unsigned" Size="1" Offset="AbilityCommand+2" AbsoluteOffset="0x42"/>
</Struct>
*/
; Check if a medivac, prism or overlord has a drop queued up
; unload command movestate = 2
; target flag = 15 for drop and for movement
; target flag = 7 for hold position but movestate is the same
isTransportDropQueued(transportIndex)
{
getUnitQueuedCommands(transportIndex, aCommands)
for i, command in aCommands
{
if (command.ability = "MedivacTransport"
|| command.ability = "WarpPrismTransport"
|| command.ability = "OverlordTransport")
return i
}
return 0
}
getUnitQueuedCommands(unit, byRef aQueuedMovements)
{
static aTargetFlags := { "overrideUnitPositon": 0x1
, "unknown02": 0x2
, "unknown04": 0x4
, "targetIsPoint": 0x8
, "targetIsUnit": 0x10
, "useUnitPosition": 0x20 }
aQueuedMovements := []
if (CmdQueue := ReadMemory(B_uStructure + unit * S_uStructure + O_P_uCmdQueuePointer, GameIdentifier)) ; points if currently has a command - 0 otherwise
{
pNextCmd := ReadMemory(CmdQueue, GameIdentifier) ; If & -2 this is really the first command ie = BaseCmdQueStruct
loop
{
ReadRawMemory(pNextCmd & -2, GameIdentifier, cmdDump, 0x42)
targetFlag := numget(cmdDump, 0x38, "UInt")
if !aStringTable.hasKey(pString := numget(cmdDump, 0x18, "UInt"))
aStringTable[pString] := ReadMemory_Str(readMemory(pString + 0x4, GameIdentifier), GameIdentifier)
state := numget(cmdDump, O_cqState, "Short")
aQueuedMovements.insert({ "targetX": targetX := numget(cmdDump, 0x28, "Int") / 4096
, "targetY": numget(cmdDump, 0x2C, "Int") / 4096
, "targetZ": numget(cmdDump, 0x30, "Int") / 4096
, "ability": aStringTable[pString]
; , "flag" : targetFlag
, "state": state })
if (A_Index > 20 || !(targetFlag & aTargetFlags.targetIsPoint || targetFlag & aTargetFlags.targetIsUnit || targetFlag = 7))
{
; something went wrong or target isnt a point/unit and the targ flag isnt 7 either
aQueuedMovements := []
return 0
}
} Until (1 & pNextCmd := numget(cmdDump, 0, "Int")) ; loop until the last/first bit of pNextCmd is set to 1
return aQueuedMovements.MaxIndex() ; interstingly after -2 & pNextCmd (the last one) it should = the first address
}
else return 0
}
/*
QueenBuild = make creepTumour (or on way to making it) - state = 0
Transfusion - state = 0
*/
getUnitQueuedCommandString(aQueuedCommandsOrUnitIndex)
{
if !isObject(aQueuedCommandsOrUnitIndex)
{
unitIndex := aQueuedCommandsOrUnitIndex ; safer to do this
aQueuedCommandsOrUnitIndex := [] ; as AHK has a weird thing where variables in functions can alter themselves strangely
getUnitQueuedCommands(unitIndex, aQueuedCommandsOrUnitIndex)
}
for i, command in aQueuedCommandsOrUnitIndex