A question about energy and running

Moderator: Moderator

Post Reply
Message
Author
galaxys
Posts: 4
Joined: Sat May 19, 2012 3:30 pm

A question about energy and running

#1 Post by galaxys »

Hello everyone,

I wanted to make something like in TRPGs, you move and attack in a single turn, and then enemies move & attack.
So I modified GameEnergyBased.lua to make entities recover energy only every 10 game turns, each time recovering 1000 energy. And modified enoughEnergy() and useEnergy() to let actors acts before energy goes down to zero; also made move to cost 300 energy, and attack cost 600 energy.
It worked as expected, mostly. The problem is at player running: Say I have 100 energy left, I can run as normal; but if I have 400 or more energy, I will stop running after 1 step, and then get locked there, still "running", but can't continue moving. Why? :|

Any comment will be appreciated, and also thanks for your attention :wink:

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: A question about energy and running

#2 Post by edge2054 »

If I understand correctly you're asking about 'running' and not moving in which case I ran into the same issue with Fae when I put together an action point system.

The issue was that the game would still be paused and that the runStep function assumes that the first step will consume enough energy to unpause the game for you. So the solution was to manually unpause the game when the player started running.

I put this in the player class.

Code: Select all

-- Superload runStep to drop a game.paused = false in for Action Points to work
local previous_runStep = _M.runStep
function _M:runStep()
    game.paused = false
    return previous_runStep(self)
end
Sorry if it's messy, I'm on my Step Mother's laptop and don't have a text editor in front of me.

*edit* here's the commit and a link to the repo if you want to take a look at some other things I did to deal with an Action Point style system.
https://github.com/edge2054/Fae/commit/ ... 42e06e0a92

galaxys
Posts: 4
Joined: Sat May 19, 2012 3:30 pm

Re: A question about energy and running

#3 Post by galaxys »

edge2054 wrote:The issue was that the game would still be paused and that the runStep function assumes that the first step will consume enough energy to unpause the game for you. So the solution was to manually unpause the game when the player started running.
/ab8df4a98abc2e88b9efc205a5297342e06e0a92
Thank you very much :D The auto-explore part are also very useful, it's so kind of you :)

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: A question about energy and running

#4 Post by edge2054 »

Happy to help :)

Post Reply