Registered Users
  • Content count

  • Joined

  • Last visited

Community Reputation

13 Good

About DGM

  • Rank
    Junior Member

Recent Profile Visitors

394 profile views
  1. Nevermind. I moved the call to oldEndTurn from the beginning of the function to the end and it seems to be acting properly now. I still don't fully understand how the timing is working here - I expected upkeep to be checked when the player ended his turn - but it's finally doing what I want so I'm not going to complain. Thanks yet again, guys.
  2. >> "So implicit arg "self" should be your sim." That works, thanks. Unfortunately, I was right about the timing. Tags are still reporting the guard paths before getting destroyed. EDIT: Before anyone suggests it, I tried setting patrolObserved to false right after removing the tag. Doesn't work.
  3. I'm trying to implement this, but there's a complication. I need the sim object and it isn't passed to the simengine:endTurn function through the parameters. I'm trying to get at it like so: function simengine:endTurn() oldEndTurn( self ) local playerUnits = simplayer._units local sim = playerUnits[1].getSim() . . . end ...But I'm getting a crash on the "local sim" line: Jul 29 17:06:11 -- Sim returned: BrokenStrats/tag_changes.lua:37: attempt to index local 'playerUnits' (a nil value) stack traceback: BrokenStrats/tag_changes.lua:37 in function 'endTurn' game/sim/simactions.lua:474 in function '?' game/sim/engine.lua:2100 in function 'applyAction' game/client/states/state-game.lua:362 in function <game/client/states/state-game.lua:359> The term "sim" is used in so many places that even a grep tool isn't helping me find an easier way to do this.
  4. Sorry for the delayed reply, but I've been sick. >> "if you replace simengine.endTurn instead you can make endTurn and thus the trigger be called before your code." Wouldn't that cause the upkeep to be checked AFTER the tags have already revealed the guard paths? The idea is to check after things like generator programs and portable servers go off, but before the tags perform their function.
  5. >> "Use a for loop like in your original post and replace simplayer.onStartTurn instead of simunit.onStartTurn." And with that (and a little debugging) it's finally working. Yeesh. That took way longer than I was expecting, but at least I know how to set up once-per-turn effects now. Thanks for your patience, guys. One more question. Testing revealed that the upkeep was being paid before Power Drip kicked in, resulting in tags being lost unnecessarily at low power. I should probably address this, which means I need to learn how the engine handles the ordering of such things. What section(s) of the code deal with this?
  6. Yeah, I just posted about that (probably while you were responding). It doesn't work. The upkeep check is being skipped entirely now, presumably because it thinks I'm asking for the controller of the current unit rather than the active player. Here's the current code: local oldOnStartTurn = simunit.onStartTurn local tagUpkeepCost = .5 function simunit:onStartTurn( sim ) local player = sim:getCurrentPlayer() if player:isPC() and self:getTraits().isGuard and self:getTraits().tagged then if player:getCpus() >= tagUpkeepCost then player:addCPUs(-tagUpkeepCost) else self:setTagged("dissable") end end oldOnStartTurn( self, sim ) end
  7. Never mind. I just remembered that the isPC and isNPC functions do that. EDIT: No, wait, that doesn't work. That just checks who's controlling the unit being checked at the time, which no longer works now that I'm not using the for loop any more. @#$%. Is there a function that does this, or do I need to jury rig something?
  8. Sounds about right, but I still need a way to ask the engine which side's turn it is and I haven't found it yet. Without that it'll be checking for upkeep on both turns instead of just the agency's.
  9. I figured it out. For some reason I thought the code would only work once at the start of the agency's turn instead of once per agency unit. And agency units meant not only my agents but every device I had captured. I had a high upkeep cost for testing purposes and kept paying it over and over until I couldn't afford the tag any more. Is there a function for doing something once at the start of a given side's turn?
  10. [facepalm] How did I miss THAT? Okay, fixed. Thanks. But now I'm getting a different problem. Power is being deducted appropriately, only when the agency has enough to spare. But the tag is removed every turn even when the upkeep is payed. Apparently the else clause is triggering when it isn't supposed to.
  11. Just realized I stuck a semicolon at the end of the addCpus line. Damned muscle memory. However, the line still crashes the game even after removing that (and making no other changes). New log, in case it matters: invisibleinc.txt
  12. I'm trying to give tags a small per-turn upkeep cost by modifying the simunit.onStartTurn function, like so: local oldOnStartTurn = simunit.onStartTurn local tagUpkeepCost = 5 function simunit:onStartTurn( sim ) local tagUpkeepCost = 5 local player = sim:getCurrentPlayer() if player:isPC() then for _, unit in pairs( sim:getAllUnits() ) do if unit:getTraits().isGuard and unit:getTraits().tagged then if player:getCpus( ) >= tagUpkeepCost then player:addCpus(-tagUpkeepCost); else unit:setTagged(true) end end end end oldOnStartTurn( self, sim ) end At the start of each agency turn this checks all guards for tags. For each tagged guard it checks to see if the agency can pay the upkeep, then takes the PWR if it can or destroys the tag if it can't. This is MOSTLY working - tags are removed properly - but the game keeps crashing whenever the addCpus function is called: Jul 23 20:04:24 -- Sim returned: BrokenStrats/tag_upkeep.lua:33: attempt to call method 'addCpus' (a nil value) stack traceback: BrokenStrats/tag_upkeep.lua:33 in function 'onStartTurn' game/sim/simplayer.lua:510 in function 'onStartTurn' game/sim/pcplayer.lua:174 in function 'onStartTurn' game/sim/engine.lua:2068 in function 'endTurn' game/sim/aiplayer.lua:448 in function 'thinkHard' game/sim/engine.lua:2109 in function 'applyAction' game/client/states/state-game.lua:362 in function <game/client/states/state-game.lua:359> Jul 23 20:04:24 -- PerformSync() - unverified build. Jul 23 20:04:24 -- [LUA] HTTP 0: 0 bytes (Unspecified error.) Jul 23 20:04:32 -- TEXTURE: '+' 20628 = 408.91MB < It seems to like the getCpus function just fine, though, so I'm not sure what's going on. Any ideas? invisibleinc.txt tag_upkeep.lua
  13. Nothing else with interfaces, for the moment. But I'm sure I'll want to eventually and I was wondering if Sim Constructor could make it easier next time.
  14. >> "return hudObject" And that just about did it. The game was griping because I also needed to include simdefs, but that was easy to catch and fix. And now it's working. Many thanks, both of you. Cyberboy, I notice that the Sim Constructor mod can change the interface. Does that only apply to graphical elements, or can it handle text elements like the power and credit readouts?
  15. Okay, you know how I said I threw the new hud_changes script into an old mod? And how I've been away from this for months and might have forgotten something basic? Yeah, turns out I forgot to add hud_changes to modinit.lua! Sigh. That said, now that the new script is actually being loaded I'm still having problems. The previous version was causing a crash on launch. Including "hud/hud" and "client_util" instead lets the game work up until I start a mission, but as soon as I try to beam in I crash to desktop. Here's what kills the game according to the log: Jul 22 07:22:56 -- ### ABORTING: FATAL SCRIPT ERROR ### game/client/states/state-game.lua:880: attempt to index field 'hud' (a nil value) stack traceback: [C] in function 'traceback' game/client/state-manager.lua:31 in function <game/client/state-manager.lua:30> game/client/states/state-game.lua:880 in function 'updateSound' game/client/states/state-game.lua:925 in function 'onUpdate' game/client/states/state-campaigngame.lua:93 in function 'onUpdate' game/client/state-manager.lua:40 in function <game/client/state-manager.lua:35> [C] in function 'xpcall' game/client/state-manager.lua:69 in function <game/client/state-manager.lua:62> Here are the relevant files: invisibleinc.txt hud_changes.lua modinit.lua