Page 1 of 1
Checking targets casting time?
Posted: Thu Nov 01, 2012 5:49 am
by gloover
Hey experts.
I'm trying to make a script with a part checking the remaining time of targets cast?
To be exact, I want to check the cast of mechanical bug in ToSH, so if its spawning the small bugs, my mage should react with "Discharge". Has someone any idea?
Re: Checking targets casting time?
Posted: Thu Nov 01, 2012 7:25 am
by rock5
The only information we collect is whether the mob is casting or not. If you want to know how much time is remaining on their cast then you will have to read memory. I happen to know the offsets needed. Something like this should do it.
Code: Select all
casttime = memoryReadRepeat("float", getProc(), target.Address + 0x260)
elapsedtime = memoryReadRepeat("float", getProc(), target.Address + 0x264)
remaining = casttime-elapsedtime
Re: Checking targets casting time?
Posted: Thu Nov 01, 2012 8:23 am
by Ego95
so if its spawning the small bugs, my mage should react with "Discharge". Has someone any idea?
Do you want to farm tp with the bot? oO
Re: Checking targets casting time?
Posted: Thu Nov 01, 2012 12:02 pm
by gloover
@ Ego, yes, that was my intention.
@ rock, your sugested code seems not to be working on the simple code
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
changeProfileOption("MAX_TARGET_DIST", 400);
player:target(106355)
while (true) do
casttime = memoryReadRepeat("float", getProc(), target.Address + 0x260)
elapsedtime = memoryReadRepeat("float", getProc(), target.Address + 0x264)
remaining = casttime-elapsedtime
printf(remaining)
printf("\n")
end
</onLoad>
</waypoints>
got this error
5:57pm - scripts\rom/bot.lua:505: onLoad error: [string "..."]:7: attempt to index global 'target' (a nil value)
have also try to read a "floatptr" instead of "float" - same errror

Re: Checking targets casting time?
Posted: Thu Nov 01, 2012 1:26 pm
by rock5
That's because you don't define 'target'. Try
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
changeProfileOption("MAX_TARGET_DIST", 400);
local target = player:findNearestNameOrId(106355)
if target then
player:target(target)
while player:hasTarget() do
casttime = memoryReadRepeat("float", getProc(), target.Address + 0x260)
elapsedtime = memoryReadRepeat("float", getProc(), target.Address + 0x264)
remaining = casttime-elapsedtime
printf(remaining)
printf("\n")
end
end
</onLoad>
</waypoints>