Can someone please explain to me how Energy works?
Moderator: Moderator
Can someone please explain to me how Energy works?
I'm trying to make a mod that has an Action Points based turns system, similar to Fallout. I've been playing around with the code, and cannot for the life of me figure out how to make it work the way I want it to. If I knew more about how the energy based system works it would probably be of great help.
-
- Uruivellas
- Posts: 762
- Joined: Sun Nov 03, 2013 12:14 am
Re: Can someone please explain to me how Energy works?
I'll be honest with you, I'm not a resident expert on those background things.
However, this topic here might have something of value. It's concerned with game mechanics for combat in general.
However, this topic here might have something of value. It's concerned with game mechanics for combat in general.
Re: Can someone please explain to me how Energy works?
GameEnergyBased:tick handles energy.
I'm most familiar with how energy works for actors. Non-actor entities (objects, etc.) can get turns too, but their behavior may be different.
- The game is organized into game turns (sometimes called ticks).
- Each entity has an energy value.
- Every game turn (every tick), each entity gains a certain amount of energy (called energy_per_tick).
- Once an entity's energy is at least energy_to_act, the entity gets to act: the player gets to input a command, an NPC's AI picks an action, etc. The act method can also perform any per-turn updates (cooldowns, status effects wearing off, etc. - but see below).
- After finishing the action, the act method calls useEnergy.
- Entities' speed can affect how quickly they gain energy, allowing some characters to be faster than others. (Check energy.mod and global_speed in GameEnergyBased:tick.)
- useEnergy defaults to subtracting energy_to_act, but it can take a parameter to allow some actions to cost more energy than others. (For example, ToME has speed modifiers for movement, combat, and spells, so it multiplies energy_to_act by the appropriate modifier for each action.)
- Along with tracking energy and calling act, T-Engine tracks energyBase and calls actBase. These function the same as energy and act but are unmodified by entities' speed. ToME uses these so that cooldowns and status effects occur by strict game turns instead of faster characters getting faster cooldowns.
- If you set energy_to_act to 1 and set energy_per_tick to 5, then characters will get 5 actions per turn.
- If you set energy_to_act to 1 and energy_per_tick to 1 but set each entity's energy.mod to 5-10, then characters get 5-10 action points per turn, and calling useEnergy with different values can make different actions require different numbers of action points. I think this is what you want.
I'm most familiar with how energy works for actors. Non-actor entities (objects, etc.) can get turns too, but their behavior may be different.