get inflicted damage of attack before strike in WML

The place to post your WML questions and answers.

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.
Post Reply
lea
Posts: 301
Joined: October 1st, 2016, 7:25 pm

get inflicted damage of attack before strike in WML

Post by lea »

is there any way to get (for example store in variable) amount of damage that will be actually inflicted when/if next strike connects?
apart from calculating it by starting with weapon's base damage and "manually" applying modificators from resistance, weapon specials and other sources one by one

same value as in damage_inflicted variable automatically set for attacker_hits and defender_hits events but before this damage is actually inflicted, for example in attack event.
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: get inflicted damage of attack before strike in WML

Post by zookeeper »

No, doesn't seem possible.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: get inflicted damage of attack before strike in WML

Post by Sapient »

lea wrote:is there any way to get (for example store in variable) amount of damage that will be actually inflicted when/if next strike connects?
There is [harm_unit], which would allow you to factor in the unit type damage resistances and time-of-day alignment bonus. But that's not going to cover every possibility.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
lea
Posts: 301
Joined: October 1st, 2016, 7:25 pm

Re: get inflicted damage of attack before strike in WML

Post by lea »

Sapient wrote:There is [harm_unit], which would allow you to factor in the unit type damage resistances and time-of-day alignment bonus. But that's not going to cover every possibility.
that's how I tried to do it but it is impractical when there are too many possibilities to cover.

my goal is/was to make a "nonlethal" attack special (attack that cannot kill, somewhat like poison but with instant one-time effect). I tried to reset unit's HP to 1 whenever it fell below 1 but it prevents remaining strikes of current combat encounter from happening.

my current solution is to add a big number (much bigger than damage from single combat encounter can ever be, like 1000) to current hitpoints in attack event and subtract same number in attack end event (or set HP to 1 if remaining hitpoints are less than the number I used). I should "automatically" account for every possibility except effects that vary depending on HP.
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
Post Reply