req: dynamic number of children addresses

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
(V)(;,,;)(V)
Expert Cheater
Expert Cheater
Posts: 57
Joined: Sat Aug 18, 2018 8:08 pm
Reputation: 11

req: dynamic number of children addresses

Post by (V)(;,,;)(V) »

First off iv been pouring over these forms for a bit now, but thats gotten me more lost while simplifying my problem also. What you guys do with these scripts is amazing.

So im messing with fighting in tight spaces and found the enemies hp pointers and how they adjust the offset for each additional enemy as they are added to the map.

Im looking to have NPC1 (the first enemy/protection target thats spawned) as my base pointer, with a script that adds children with the adjusted offset (i currently manually add children as +104/+208/ect). With number of children defined by a dropdown or setting a value for another table entry, so it can be added and reduced on the fly as enemies spawn in then reset on the next map. 4 byte if it makes a difference.

Thank for any time you can spare for this. Im sure its actually something incredibly simple, but i definitely dont have enough experience with this stuff yet.

S1N74X
Cheater
Cheater
Posts: 34
Joined: Wed Sep 15, 2021 4:25 pm
Reputation: 4

Re: req: dynamic number of children addresses

Post by S1N74X »

(V)(;,,;)(V) wrote:
Sun Dec 05, 2021 4:34 am
First off iv been pouring over these forms for a bit now, but thats gotten me more lost while simplifying my problem also. What you guys do with these scripts is amazing.

So im messing with fighting in tight spaces and found the enemies hp pointers and how they adjust the offset for each additional enemy as they are added to the map.

Im looking to have NPC1 (the first enemy/protection target thats spawned) as my base pointer, with a script that adds children with the adjusted offset (i currently manually add children as +104/+208/ect). With number of children defined by a dropdown or setting a value for another table entry, so it can be added and reduced on the fly as enemies spawn in then reset on the next map. 4 byte if it makes a difference.

Thank for any time you can spare for this. Im sure its actually something incredibly simple, but i definitely dont have enough experience with this stuff yet.
Hi, i am not sure if i understand your Problem right.
You have a basepointer for one Enemy and offsets for other enemies ?
If so i suggest to use a Table maybe like this
Spoiler

Code: Select all

local base = someAddress
local enemies = {offset1,offset2,offsetN..} --declare table

--create a Timer and in this Context do
for i=1,#enemies do
local res = base .. enemies[i]
-- check if res != nil
-- do something with Value or Address
end

So you can let the script check if the Pointers or Values are valid and do something with them.

User avatar
LeFiXER
LeFixer
LeFixer
Posts: 479
Joined: Wed Mar 24, 2021 9:35 am
Reputation: 242

Re: req: dynamic number of children addresses

Post by LeFiXER »

Just to chime in. Lua syntax for not equal is "~=" instead of "!="

User avatar
(V)(;,,;)(V)
Expert Cheater
Expert Cheater
Posts: 57
Joined: Sat Aug 18, 2018 8:08 pm
Reputation: 11

Re: req: dynamic number of children addresses

Post by (V)(;,,;)(V) »

Ok thank you for the help.

to clarify what im trying to do is:
Spoiler
  • NPCs (the pointer i have)
    • script here that uses the parent address as the base address, and uses another entry as the selector for amout of children addresses to create
      • figured this is the best place for the selector dummy address. Always minimum of 1
        • NPC1 (address/offset +0)
        • NPC2 (+104)
        • NPC3(+208)
        • NPC4(+30C)
        • ect.
Hope for a way to make the script refresh when manually changing the selector amount. Or setting it and disable/re enable to refresh the children count for when moving to a new map
I found a script from zaner from...like 2015 on the original CE fourm that i tried to adapt.
Spoiler

Code: Select all

function addMoreAddresses(baseAddress, num, step)
  local al = getAddressList()

  local base = al.createMemoryRecord()
  base.setAddress(baseAddress)
  base.setDescription("Base Address")
  base.Type = vtString
  base.String.Size = 0

  for i=0, num-1 do
    local rec = al.createMemoryRecord()
    local str = string.format("+%X", i * step)
    rec.setAddress(str)
    rec.setDescription(str)
    rec.appendToEntry(base)
  end
end

addMoreAddresses("002C083C", 10, 4)
I changed the addMoreAddresses line to
("NPCs",5,260)
Used NPCs in hope it would auto refrence the NPCs table entry but ce doesnt work like that unfortunately. And the 260 was trial and error but after i messeged zanzer about the script i realized the 260 was just my 104 offset in HEX.

Thats about as far as i got last night.

S1N74X
Cheater
Cheater
Posts: 34
Joined: Wed Sep 15, 2021 4:25 pm
Reputation: 4

Re: req: dynamic number of children addresses

Post by S1N74X »

(V)(;,,;)(V) wrote:
Mon Dec 06, 2021 6:37 pm
Ok thank you for the help.

to clarify what im trying to do is:
Spoiler
  • NPCs (the pointer i have)
    • script here that uses the parent address as the base address, and uses another entry as the selector for amout of children addresses to create
      • figured this is the best place for the selector dummy address. Always minimum of 1
        • NPC1 (address/offset +0)
        • NPC2 (+104)
        • NPC3(+208)
        • NPC4(+30C)
        • ect.
Hope for a way to make the script refresh when manually changing the selector amount. Or setting it and disable/re enable to refresh the children count for when moving to a new map
I found a script from zaner from...like 2015 on the original CE fourm that i tried to adapt.
Spoiler

Code: Select all

function addMoreAddresses(baseAddress, num, step)
  local al = getAddressList()

  local base = al.createMemoryRecord()
  base.setAddress(baseAddress)
  base.setDescription("Base Address")
  base.Type = vtString
  base.String.Size = 0

  for i=0, num-1 do
    local rec = al.createMemoryRecord()
    local str = string.format("+%X", i * step)
    rec.setAddress(str)
    rec.setDescription(str)
    rec.appendToEntry(base)
  end
end

addMoreAddresses("002C083C", 10, 4)
I changed the addMoreAddresses line to
("NPCs",5,260)
Used NPCs in hope it would auto refrence the NPCs table entry but ce doesnt work like that unfortunately. And the 260 was trial and error but after i messeged zanzer about the script i realized the 260 was just my 104 offset in HEX.

Thats about as far as i got last night.
Try this -> addMoreAddresses("some fixed Address", 5 Entries or whatever, 260)
104 Hex is 260 in Dec

I personally would just count the Maximum Enemies per Level + some Treshhold and let the script decide what Pointer is valid.
Spoiler

Code: Select all

local bp = '[someBasePointer]+'
local offsets = {}

for i=0, 2600,260 do
table.insert(offsets,bp .. string.format("%x",i))
end

for j=1,#offsets do
print(offsets[j])
end
Will produce the following output :
[someBasePointer]+0
[someBasePointer]+104
[someBasePointer]+208
[someBasePointer]+30c
[someBasePointer]+410
[someBasePointer]+514
[someBasePointer]+618
[someBasePointer]+71c
[someBasePointer]+820
[someBasePointer]+924
[someBasePointer]+a28

User avatar
(V)(;,,;)(V)
Expert Cheater
Expert Cheater
Posts: 57
Joined: Sat Aug 18, 2018 8:08 pm
Reputation: 11

Re: req: dynamic number of children addresses

Post by (V)(;,,;)(V) »

Is there a way for me to change "some fixed address" to look for a table entry with a certain description? Thats the biggest thing im looking for, but i cant find it in the CE lua wiki.

If i can do that, that would make it so i could simplify some other tables iv made also.

Lol this feels like working with circles but without the knowledge of pi. Figue there is a comand i keep over looking on the wiki 😅

User avatar
LeFiXER
LeFixer
LeFixer
Posts: 479
Joined: Wed Mar 24, 2021 9:35 am
Reputation: 242

Re: req: dynamic number of children addresses

Post by LeFiXER »

(V)(;,,;)(V) wrote:
Mon Dec 06, 2021 7:47 pm
Is there a way for me to change "some fixed address" to look for a table entry with a certain description? Thats the biggest thing im looking for, but i cant find it in the CE lua wiki.

If i can do that, that would make it so i could simplify some other tables iv made also.

Lol this feels like working with circles but without the knowledge of pi. Figue there is a comand i keep over looking on the wiki 😅

Code: Select all

local al = getAddressList()
local mr = al.getMemoryRecordByDescription('entry_description_here')

if mr ~= nil then
  -- entry exists
else
  error('The entry doesn\'t exist')
end
There are a host of Lua functions for CE documented [Link]

User avatar
SunBeam
Administration
Administration
Posts: 4704
Joined: Sun Feb 04, 2018 7:16 pm
Reputation: 4287

Re: req: dynamic number of children addresses

Post by SunBeam »

..and you can always check my Horizon Zero Dawn table here: viewtopic.php?t=13317. See '[Existing Inventory] Inventory Editor' script.

User avatar
(V)(;,,;)(V)
Expert Cheater
Expert Cheater
Posts: 57
Joined: Sat Aug 18, 2018 8:08 pm
Reputation: 11

Re: req: dynamic number of children addresses

Post by (V)(;,,;)(V) »

Ah that github page never came up while i was looking around, just from a glance iv already seen some functions/descriptions i didnt see elsewhere. Thanks again for all the help everyone.

Post Reply

Who is online

Users browsing this forum: ireallymeanit