Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 165 166 [167] 168 169 ... 360

Author Topic: DFHack 0.43.03-r1  (Read 1087462 times)

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2490 on: April 16, 2015, 11:29:56 pm »

Oh man Lua is fast.

Like, way faster than I thought. This code is causing 0 FPS hit (70 before, 70 after) in a fortress of 103:

Code: [Select]
onUnitAction=dfhack.event.new()

local actions_already_checked=actions_already_checked or {}

local function action_already_checked(unit_id,action_id)
    local unit_action_checked=actions_already_checked[unit_id]
    if unit_action_checked then
        return unit_action_checked[action_id]
    end
end

onUnitAction.print=function(unit,action)
    print('Unit #'..unit.id..' is using action of type '..df.unit_action_type[action.type])
end

function checkForActions()
    for k,v in ipairs(df.global.world.units.active) do
        for _,action in ipairs(v.actions) do
            if not action_already_checked(v.id,action.id) then
                onUnitAction(v,action)
                actions_already_checked[v.id]=actions_already_checked[v.id] or {}
                actions_already_checked[v.id][action.id]=true
            end
        end
    end
end

require('repeat-util').scheduleEvery('onAction',1,'ticks',checkForActions)

It's going through the entire active units vector every tick. I'm impressed.

And I'm going to exploit this so hard.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2491 on: April 17, 2015, 06:26:30 am »

That's part of why I first suggested Rumrusher use the actions list to try to get jump working, inserting a new (2)Jump action with the desired coordinates before I figured out what he was doing to make it adventurer mode usable. I didn't even think about how complex some of the checks are. Hell, gm-editor is like that too isn't it? You can pull up some of the lists like the full global events and it only barely hesitates.

Also, I'm... kinda aroused by you talking about hard code exploitation, why is this?
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2492 on: April 17, 2015, 12:57:13 pm »

Oh man Lua is fast.

Like, way faster than I thought. This code is causing 0 FPS hit (70 before, 70 after) in a fortress of 103:

Code: [Select]
onUnitAction=dfhack.event.new()

local actions_already_checked=actions_already_checked or {}

local function action_already_checked(unit_id,action_id)
    local unit_action_checked=actions_already_checked[unit_id]
    if unit_action_checked then
        return unit_action_checked[action_id]
    end
end

onUnitAction.print=function(unit,action)
    print('Unit #'..unit.id..' is using action of type '..df.unit_action_type[action.type])
end

function checkForActions()
    for k,v in ipairs(df.global.world.units.active) do
        for _,action in ipairs(v.actions) do
            if not action_already_checked(v.id,action.id) then
                onUnitAction(v,action)
                actions_already_checked[v.id]=actions_already_checked[v.id] or {}
                actions_already_checked[v.id][action.id]=true
            end
        end
    end
end

require('repeat-util').scheduleEvery('onAction',1,'ticks',checkForActions)

It's going through the entire active units vector every tick. I'm impressed.

And I'm going to exploit this so hard.

Hmm, I wonder if it would be possible make "mines" where you store a location in a persistent variable, and every tick you check if anyone is on that location. Then if there is you trigger a script and remove the location from persistent storage (or not, depending on if you want the mine to trigger more than once)

EDIT: Does anyone have any experience with calling frames? What I mean is, I want my custom unit frame to be able to link directly to the units health screen.
« Last Edit: April 17, 2015, 01:02:44 pm by Roses »
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2493 on: April 17, 2015, 01:08:47 pm »

Hmm, I wonder if it would be possible make "mines" where you store a location in a persistent variable, and every tick you check if anyone is on that location. Then if there is you trigger a script and remove the location from persistent storage (or not, depending on if you want the mine to trigger more than once)
I had a similar idea that I wanted to watch all of the unmined bits of specific stones (should be manageable since they're single-tile-clusters).  The backstory of the mod implies that interesting things ought to happen if one of those tiles comes in contact with magma.  My thinking was that I'd need a plug-in for this, setting up a data structure for each type of stone-of-interest with a linked list of coordinates, and checking them every hundred ticks or so (spacing out the different types of tiles to prevent FPS stutters).

But if Lua is that fast, I might not need a plug-in and be able to check them every tick.  Then I can get rid of the boil-away-stone inhaled syndrome dependency and spawn Awakened Stones directly.  It would help if I could figure out who had just mined the tile.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2494 on: April 17, 2015, 03:39:12 pm »

Note that that is going through every unit, which is still, oh, an order of magnitude smaller than every tile. I wouldn't recommend pushing it, but you could always try.

However, Roses: oh, yes, very much. The fact that the move action contains where they're moving to means that you can even use the onAction event.

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2495 on: April 17, 2015, 04:14:33 pm »

Note that that is going through every unit, which is still, oh, an order of magnitude smaller than every tile. I wouldn't recommend pushing it, but you could always try.
The idea was to scan the tiles on load and build the lists to check periodically.  Essentially running prospect all every tick isn't the path to high FPS!  My whole concept depends on what kind of persistent data is available to Lua.  I could encode the "linked list" in a string, but a real Lua list would be much better.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2496 on: April 17, 2015, 05:18:36 pm »

Putnam: if you monitor the announcements event you might be able to do most of what that script does using only eventful.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2497 on: April 17, 2015, 05:20:55 pm »

Yeah, except for exactly what I want to do, heh (which is modify attacks and movement before they actually go through)

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2498 on: April 17, 2015, 05:29:25 pm »

Yeah, except for exactly what I want to do, heh (which is modify attacks and movement before they actually go through)

Hmm...there should probably be an event for that. There isn't but there should be. Action initiated or something.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2499 on: April 17, 2015, 05:41:15 pm »

Yeah, except for exactly what I want to do, heh (which is modify attacks and movement before they actually go through)

Hmm...there should probably be an event for that. There isn't but there should be. Action initiated or something.

Speaking of which, I would love for there to be options for parry's and dodges and such.

And on another note, I figured out how to get all of the information from the Thoughts and Preferences screen without actually being in that screen. Which means it is possible to use that information in custom gui.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2500 on: April 17, 2015, 05:42:03 pm »

Parrys and dodges can be deduced from announcement events but you have to filter it yourself.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2501 on: April 18, 2015, 09:43:05 pm »

Anyone know why this isn't working?

Code: [Select]
modtools/interaction-trigger -suppressAttack -onAttackStr "test for super saiyan" -command [ dragonball/super_saiyan_trigger -unit \\ATTACKER_ID ]
It's suppressing the attack perfectly, but the command isn't going at all.

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2502 on: April 19, 2015, 06:40:29 am »

I don't know how I did it but
Spoiler (click to show/hide)
there's now a directional Aim for throwing folks now.

also learn a valuable lesson on don't try to get a dragon to mount a Roc, dragons will use their fire and burn everyone riding even the mount.
kinda wonder if community arena going to be adding mounts to the options?
« Last Edit: April 19, 2015, 10:47:00 pm by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2503 on: April 19, 2015, 02:41:59 pm »

[Phil Ken Sebben]Ha ha ha, dorf tossing![/Phil Ken Sebben]

I hereby propose the script be called launch btw.


I'm uh, not ready to deal with Rocs being mounted by Dragons given your tendencies to produce horrifying hybrid crimes against nature.
« Last Edit: April 19, 2015, 02:43:30 pm by Max™ »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2504 on: April 20, 2015, 08:46:24 pm »

Question. I have been using dfhack.screen._doSimulateInput() but can only seem to get it to simulate pressing Enter (i.e. dfhack.screen._doSimulateInput(screen,{1}) ). For some reason whenever I try to get a different button press simulated it does nothing, in this case trying to get 'r' pressed, which is supposidly represented by 18. Any thoughts? Maybe the function dfhack.screen.getKeyDisplay() is just not giving me the right information?
Logged
Pages: 1 ... 165 166 [167] 168 169 ... 360