Hi all,
I'm trying to read the cooldown time on active spells from memory. I'm doing this with Delphi, no injection.
I tried to convert the following code to Delphi. Im using 0x4F943A as offset to get the cooldowns 0xCFF49C(localplayer) for baseaddress,
Unfortunately I can't seem to find out how to read the spells.
My questions:
- Am I using the correct offset?
- Can anyone tell me the general idea of reading cooldowns?
NOTE: I tried the search functions, read several posts, but not one pointed me in the correct direction
Code:
1. public class SpellHistory {
2.
3. private static final int SPELL_COOLDOWN = 0xACD714; // 4.3.4.15595
4. private static final int TIMESTAMP_OFFSET = 0x9C0C7C; // 4.3.4.15595
5.
6. private static SpellHistory instance;
7.
8. private static class Spell {
9.
10. private int spellId; // ID of the spell
11. private int itemId; // 0 for most spells, for trinket spells or engineer enchants, contains the item ID of the item that casted it
12. private int startTime; // time the cooldown started, sometimes zero for profession cooldowns that end at midnight (in which case shared CD is used)
13. private int spellCD; // length of the spell cooldown, can be zero or negative if the spell has or a shared/global CD only
14. private int sharedId; // ID of the shared cooldown, a unique number for most spells, but many spells do actually have overlapping shared cooldowns
15. private int otherTime; // the start time of the shared cooldown, always nonzero
16. private int sharedCD; // length of the shared cooldown
17. private int globalCD; // length of the global cooldown, 0 for spells with no globel cooldown
18. }
19.
20. private final ArrayList<Spell> spells;
21. private final MemoryReader r;
22. private int now;
23.
24. private SpellHistory(MemoryReader r) {
25.
26. this.r = r;
27. spells = new ArrayList<Spell>();
28. }
29.
30. public static void createSpellHistory(MemoryReader r) {
31.
32. instance = new SpellHistory(r);
33. }
34.
35. public static SpellHistory getSpellHistory() {
36.
37. return instance;
38. }
39.
40. public void update() {
41.
42. spells.clear();
43. int current = r.readInt(r.getBaseAddress() + SPELL_COOLDOWN + 0x08);
44. int[] fields = new int[12];
45. while (0 != current && 0 == (current & 3)) {
46. r.readArray(current, fields);
47. Spell spell = new Spell();
48. int prev = fields[0];
49. int next = fields[1];
50. spell.spellId = fields[2];
51. spell.itemId = fields[3];
52. spell.startTime = fields[4];
53. spell.spellCD = fields[5];
54. spell.sharedId = fields[6];
55. spell.otherTime = fields[7];
56. spell.sharedCD = fields[8];
57. int unk1 = fields[9]; // always zero
58. int unk2 = fields[10]; // 0x85 when GCD, otherwise 0
59. spell.globalCD = fields[11];
60. spells.add(spell);
61. current = next;
62. }
63. now = r.readInt(r.getBaseAddress() + TIMESTAMP_OFFSET);
64. }