[solved] help for making the numbers of strikes depends on hitpoints
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
[solved] help for making the numbers of strikes depends on hitpoints
Hello
To add some realism and changing a little the gameplay (and for fun), i'm looking for a way to make a hits/hitpoints relatives, like in Advance Wars (the more a trop is weakened, the less it will do damage or have men inside holding a weapon)
(i will call each "hit attempt" "strikes" to be more clear),
To be clear I was that units, during a fight, can't do all theirs strikes if they don't have all theirs hitpoints
Exemple :
an unit having 22/44 HP, attacking (or defeding) with a weapon having attack stats like 5x4, will in fact due 5x2. And if that unit heal at like 33/44 HP, it will do 5x3 strikes.
Maybe a formula will make it more clear (or not, lol)
For now I want JUST the strikes being relative to HP, not the attack damages. For both engaged units. For normal and specials attacks.
I see 3 ways to do it
- precalculating the number of strikes of each unit in the beginning of a fight
- or ajusting it on each strikes, depends how go the HP.
- storing a "max_strikes" and "current_strikes" foreach weapons, and recalculating it every side turn, and using the "current_strikes" for fights / simulations
current_count_strikes = math.ceil( base_count_strikes x current_hp/ max_hp )
The second solution will be the best, but it implies keeping track of the number of strikes already done and I don't see an event name like "attack strike" (attack" is triggered only in the begining of a fight, isn'it ?). So except if someone have the keys, I'm seeking help to code the 1st solution.
I was figuring out a way in LUA using wesnoth.wml_actions.event {}
But I guess it's more "clean" to do that with WML events in a .cfg
Is there a way to, change the number or strikes the unit will do, depending of the current HP, then re-store the initial values ? I don't want to permanently change the weapon stats, no keep track of the "max strikes" available.
Maybe there is a proper way to do it, to also display the correct information in battle simulation and not tricking the AI that if it go to attack with a almost dead unit, again a weaker-but-full-HP one, he will not have a chance to win
Thanks a lot for your help
PS : This is my first post \o/
Ruvaak.
To add some realism and changing a little the gameplay (and for fun), i'm looking for a way to make a hits/hitpoints relatives, like in Advance Wars (the more a trop is weakened, the less it will do damage or have men inside holding a weapon)
(i will call each "hit attempt" "strikes" to be more clear),
To be clear I was that units, during a fight, can't do all theirs strikes if they don't have all theirs hitpoints
Exemple :
an unit having 22/44 HP, attacking (or defeding) with a weapon having attack stats like 5x4, will in fact due 5x2. And if that unit heal at like 33/44 HP, it will do 5x3 strikes.
Maybe a formula will make it more clear (or not, lol)
For now I want JUST the strikes being relative to HP, not the attack damages. For both engaged units. For normal and specials attacks.
I see 3 ways to do it
- precalculating the number of strikes of each unit in the beginning of a fight
- or ajusting it on each strikes, depends how go the HP.
- storing a "max_strikes" and "current_strikes" foreach weapons, and recalculating it every side turn, and using the "current_strikes" for fights / simulations
current_count_strikes = math.ceil( base_count_strikes x current_hp/ max_hp )
The second solution will be the best, but it implies keeping track of the number of strikes already done and I don't see an event name like "attack strike" (attack" is triggered only in the begining of a fight, isn'it ?). So except if someone have the keys, I'm seeking help to code the 1st solution.
I was figuring out a way in LUA using wesnoth.wml_actions.event {}
But I guess it's more "clean" to do that with WML events in a .cfg
Is there a way to, change the number or strikes the unit will do, depending of the current HP, then re-store the initial values ? I don't want to permanently change the weapon stats, no keep track of the "max strikes" available.
Maybe there is a proper way to do it, to also display the correct information in battle simulation and not tricking the AI that if it go to attack with a almost dead unit, again a weaker-but-full-HP one, he will not have a chance to win
Thanks a lot for your help
PS : This is my first post \o/
Ruvaak.
Last edited by Ruvaak on March 8th, 2019, 9:10 pm, edited 1 time in total.
Creator of Advance Wesnoth Wars mod
Re: help for making the numbers of strikes depends on hitpoints
Isn't that the same as "swarm"?
Re: help for making the numbers of strikes depends on hitpoints
Swarm provides simple linear relation, if you want something else, then it can also be done as different weapon special that instead uses formula. Events should not be needed, other than unit placed to apply special to units.
Re: help for making the numbers of strikes depends on hitpoints
I didn't knew that "swarm" effect. In fact it can do it for a first version, what to you mean by "simple linear relation" ?
The thing is, can a weapon have many specials ? each specials will apply for all attacks ?
Thanks for your help
BTW, Since I progressed a lot on others aspect of my mod, I published it and opened a proper topic decicated for the global mod.
The thing is, can a weapon have many specials ? each specials will apply for all attacks ?
Thanks for your help
BTW, Since I progressed a lot on others aspect of my mod, I published it and opened a proper topic decicated for the global mod.
Creator of Advance Wesnoth Wars mod
Re: help for making the numbers of strikes depends on hitpoints
For example relation from hp to strike % of
100 -> 120
80 -> 100
...
20 -> 40
0 -> 20 is difficult to do with swarm alone, unless the goal is also to prevent upgrading strikes. What default swarm can do is consider something between 0 and max strikes as the lower bound - for example 20 strike attacking only going down to 10 strikes at 0% hp.
Each attack has separate specials.
100 -> 120
80 -> 100
...
20 -> 40
0 -> 20 is difficult to do with swarm alone, unless the goal is also to prevent upgrading strikes. What default swarm can do is consider something between 0 and max strikes as the lower bound - for example 20 strike attacking only going down to 10 strikes at 0% hp.
Each attack has separate specials.
Re: help for making the numbers of strikes depends on hitpoints
Without changing all weapons to add "swarm", which can have too much side effects, I think for now I will work on that code : code
wich manage to get attacker datas, like "damage" and "specials", like from line 55 :
I think I can extract current HP & max HP, and hit number, hidden somewhere in this "attacker_data" variable.
For that, I will need to print/log/debug the LUA variables to see in which index they are stored (and I don't find the structure in BfW source code). Do you know how can I work on debugging this ?
wich manage to get attacker datas, like "damage" and "specials", like from line 55 :
Code: Select all
local attacker_data = attacker.__cfg
...
if attacker_data[i][1] == "attack" then
table.insert(attacker_data[variables_pos][2][backup_pos][2], wesnoth.deepcopy(attacker_data[i]) )
local has_specials=false
for j=1,#attacker_data[i][2] do
if attacker_data[i][2][j][1] == "specials" then
I think I can extract current HP & max HP, and hit number, hidden somewhere in this "attacker_data" variable.
For that, I will need to print/log/debug the LUA variables to see in which index they are stored (and I don't find the structure in BfW source code). Do you know how can I work on debugging this ?
Creator of Advance Wesnoth Wars mod
Re: help for making the numbers of strikes depends on hitpoints
I only found a way with wesnoth.message() who can't handle array, but from I will get informations from proper object.
Else using swarm or creating a weapon ability, and applying it on all weapons automatically (and maybe so, don't display it on the interface to improve readability) is also a good plan B
Else using swarm or creating a weapon ability, and applying it on all weapons automatically (and maybe so, don't display it on the interface to improve readability) is also a good plan B
Creator of Advance Wesnoth Wars mod
Re: help for making the numbers of strikes depends on hitpoints
From what I have seen, everyone writes their own function to stringify Lua tables. There is function for wml tables, but not for normal tables.
Some versions I know
https://github.com/vgaming/CreepWars/bl ... encode.lua
https://github.com/ProditorMagnus/Oroci ... ctions.lua
Some versions I know
https://github.com/vgaming/CreepWars/bl ... encode.lua
https://github.com/ProditorMagnus/Oroci ... ctions.lua
Re: help for making the numbers of strikes depends on hitpoints
Thanks for the links !
After some though, I came at the conclusion than basing attack numbers of HP can be more way avantagous for units having few strikes with big damages than othes having lot of strikes with moderates damages, so for now I applied to modifications only to damage. I will see if I get some feedback from my module (12 downloads in 2 days, hope it will continue) before going deeper on the subject.
BTW I checked the Ageless Era mod you maintain, and wow, I was not guessing it would imply so much modifications for unifying era mods. Great job
After some though, I came at the conclusion than basing attack numbers of HP can be more way avantagous for units having few strikes with big damages than othes having lot of strikes with moderates damages, so for now I applied to modifications only to damage. I will see if I get some feedback from my module (12 downloads in 2 days, hope it will continue) before going deeper on the subject.
BTW I checked the Ageless Era mod you maintain, and wow, I was not guessing it would imply so much modifications for unifying era mods. Great job
Creator of Advance Wesnoth Wars mod
Re: help for making the numbers of strikes depends on hitpoints
I found a way to find strik number with that debugging options. Was "number"
I updated my module to make this. thanks you !
I updated my module to make this. thanks you !
Creator of Advance Wesnoth Wars mod
Re: help for making the numbers of strikes depends on hitpoints
Not sure if you are aware of Lua console.
Re: help for making the numbers of strikes depends on hitpoints
Nope, I saw it but I didn'took yet read how to use it yet. It's worse the time ?
Creator of Advance Wesnoth Wars mod
Re: help for making the numbers of strikes depends on hitpoints
It is just REPL, nothing to learn about it.