Author Topic: [Kit] Fancy Damage Systems (OSP)  (Read 15676 times)

0 Members and 1 Guest are viewing this topic.

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
[Kit] Fancy Damage Systems (OSP)
« on: December 31, 2010, 05:48:22 PM »
This is pretty basic and crude, but I thought I'd post it and get this ball rolling.

In version 1.134 of the Warband engine, the trigger condition ti_on_agent_hit was introduced.  This is a very big deal; it means that we can pretty much design whatever damage systems we'd like, making really huge changes to combat systems.  For example, if you want to do an ultra-detailed damage sim for a really hardcore historical mod, including critical hits, weapons breaking (this trigger is the most efficient way to handle that) and special damage for special situations (like, say, slipping a dagger through some poor knight's visor while he's prone, or, for that matter, knocking people prone or stunned occasionally, like how I did it with the Shield Bash code) well, this is by far the way to do these things.

In short, this is a Big Deal :-)

I'll certainly be back to this and exploring how fancy I can make it without it performing really badly when I'm back around again.  It's one of the things that I really wanted to play with when Blood and Steel's core combat balance was designed, and now that it exists, I think that everybody should look at it.  It will allow people to customize combat in ways that simply weren't possible before.

So, here's some very basic code to get people's brains moving.  I haven't had time to flesh this out with a lot of details yet, but it's functional and it demonstrates some basic uses of this- a "natural soak" or "toughness" stat (as opposed to armor soak) and an "auto-dodge" (critical hits could use the same idea but with the opposite treatment of damage, obviously).


In module_mission_templates:

Code: [Select]
#Damage simulation code example by xenoargh
#Makes Ironflesh reduce damage (i.e., it's actually worth putting points into in SP)
#Makes Athletics also give an 'auto-dodge' or 'roll with punch' that reduces damage to a minimum
common_damage_system = (ti_on_agent_hit, 0, 0, [],
[
(store_trigger_param_1, ":agent"),
(store_trigger_param_2, ":attacker"),
(store_trigger_param_3, ":damage"),
(store_trigger_param_3, ":orig_damage"),
(agent_get_troop_id, ":troop", ":agent"),
(agent_get_troop_id, ":attacker_troop", ":attacker"),
(store_skill_level, ":ironflesh",  "skl_ironflesh", ":troop"),
(store_skill_level, ":athletics",  "skl_athletics", ":troop"),
#Damage is lowered 5% per point of Ironflesh.
(try_begin),
(gt, ":ironflesh", 0),
(val_mul, ":ironflesh", 5),
(assign, ":mod_damage", ":damage"),
(val_mul, ":mod_damage", ":ironflesh"),
(val_div, ":mod_damage", 100),#Rounded here, but whatever.
(val_sub, ":damage", ":mod_damage"),
(try_end),
#Damage is avoided 5% per point of Athletics
(try_begin),
(gt, ":athletics", 0),
(val_mul, ":athletics", 5),
(store_random_in_range, ":random_no", 1, 100),
(try_begin),
(le, ":random_no", ":athletics"),
(assign, ":damage", 1),
(try_begin),
(eq, ":troop", "trp_player"),
(display_message, "@You dodge the attack!"),
(else_try),
(eq, ":attacker_troop", "trp_player"),
(display_message, "@{He/She} dodges the attack!"),
(try_end),
(try_end),
(try_end),

(store_sub, ":diff_damage", ":damage", ":orig_damage"),
(val_mul, ":diff_damage", -1),
(store_agent_hit_points, ":hitpoints" , ":agent", 1),
(val_add, ":hitpoints", ":diff_damage"),
(agent_set_hit_points,":agent",":hitpoints",1),
])

Example of use (for people who aren't familiar with using custom triggers):
(click to show/hide)
« Last Edit: January 01, 2011, 02:08:03 AM by xenoargh »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Fancy Damage Systems (OSP)
« Reply #1 on: December 31, 2010, 06:59:25 PM »
Here's a fancier version, with random knockback / knockdown, critical hits for missiles.  It has been tested, and works.

This is more advanced stuff, please read the comments before attempting to copy-pasta this code, it has a dependency.

(click to show/hide)

Oh, and one other thing:  agent_deliver_damage_to_agent triggers this code.  That has some pretty cool implications.
« Last Edit: January 01, 2011, 02:08:58 AM by xenoargh »

Theoris

  • Guest
Re: Fancy Damage Systems (OSP)
« Reply #2 on: December 31, 2010, 07:09:24 PM »
Nice.. this gives me a few ideas for more advanced combat mechanics.

For example: give the player a X% chance (dependant on weapon, using item slots) to deflect/parry a blow when a key is held down (e.g is readying attack and X key is pressed). This move could also disarm the enemy agent. Hmm.  :P

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Fancy Damage Systems (OSP)
« Reply #3 on: December 31, 2010, 07:14:48 PM »
Right- amongst other things, this makes implementing sword-breakers and such a snap. 

Oh, wait, and bucklers can actually do their RL jobs, instead of being functionally useless in this engine. 

Oh, and spears can suddenly do a lot more damage to horses, so phalanxes and pikemen will suddenly work, without tricks.

And... heh.  Basically, this is one of the biggest things to happen to combat mechanics since Warband's release, frankly.

Theoris

  • Guest
Re: Fancy Damage Systems (OSP)
« Reply #4 on: December 31, 2010, 07:29:50 PM »
Yeah. The Barfight mod can now actually put those stools (among other things) to proper use with stuns etc, lol  :P

blitzking

  • Squire
  • *
  • The beast is coming
    • View Profile
  • Faction: Nord
  • MP nick: H├ímundr inn Vindr
  • WB
Re: Fancy Damage Systems (OSP)
« Reply #5 on: December 31, 2010, 07:40:33 PM »
This could also make Athletics very ovepowered :shock:

Edit: That's not a bad thing.

Lumos

  • Probably Not a Help Desk
  • Grandmaster Knight
  • *
  • Mens INsana in corpore sano
    • YouTube - LumosX
    • View Profile
  • Faction: Nord
  • M&BWBWF&SNW
Re: Fancy Damage Systems (OSP)
« Reply #6 on: December 31, 2010, 07:41:10 PM »
Nice. Since I started playing Oblivion (one-two weeks ago) I hate how I need 50 arrows and/or 50 melee hits to kill someone. I've never wanted to mod Oblivion to fix this. But I got an idea from that game; I liked the methods of skill increasing (which I'll implement in TBS for Warband - doing something a lot makes your skill increase) and also I want to have "talents" for every weapon type (in Warband, that is). The weapon proficiencies exist, but with this trigger one could make the damage increase a bit with higher weapon proficiencies.

And there could be no more death-from-arrows-in-the-arm in MP. (Yesterday, I got shot by an arrow in the achilles tendon. I lost almost 1/2 of my full life. When in an other respawn I got shot in the right side of the chest, I lost the same amount of health. Is that proper? I don't think so!)

EDIT: I think that the damage reduction % should be decreased a bit, now 10 Ironflesh and 10 Athletics render you invulnerable?

cmpxchg8b

  • Modder++
  • Grandmaster Knight
  • *
  • Master of rglPool
    • View Profile
  • Faction: Vaegir
  • MP nick: cmp
  • M&BWBWF&SNW
Re: Fancy Damage Systems (OSP)
« Reply #7 on: December 31, 2010, 07:41:33 PM »
set_trigger_result shouldn't have any effect whatsoever, the game doesn't check it after executing the trigger.
same goes for pos0.
Warband Script Enhancer v3.2.0 - additional operations, game scripts and triggers for Warband modders

Caba`drin

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&SNW
Re: Fancy Damage Systems (OSP)
« Reply #8 on: December 31, 2010, 07:53:49 PM »
Thanks for the initiative xenoargh...it definitely has the brain juices flowing!

set_trigger_result shouldn't have any effect whatsoever, the game doesn't check it after executing the trigger.
same goes for pos0.
If this is the case and the agent_deliver_damage_to_agent operation triggers the ti_on_agent_hit, wouldn't that then recursively call the trigger if one were to try and increase the damage output of a given hit? (Or am I asking a foolish question and missing something?)

Damage reduction could be handled by giving HP back to the agent, still, though I suppose.



Somebody

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Bandit
  • WBWF&S
Re: Fancy Damage Systems (OSP)
« Reply #9 on: December 31, 2010, 08:22:31 PM »
ti_on_agent_hit is called before the damage is actually incurred to the agent. The damage as a parameter also differs from the in-game damage notification - I suspect one rounds and the other (when passed to the trigger) truncates. In the case of damage increase, I would simply use agent_set_hit_points with reduction based on the actual damage. Also, have you tried using agent_delivered_damage_to_agent with 0 as the last flag? Does that still cause the trigger to fire? If so, is the value of reg0 -1?

dunde

  • Grandmaster Knight
  • *
  • Curious Coder of The Vision
    • View Profile
  • Faction: Swadian
  • WB
Re: Fancy Damage Systems (OSP)
« Reply #10 on: December 31, 2010, 10:40:18 PM »
Great Idea..
I never know before that this trigger have an output to modify the final damage.
BTW, refer to header_operations_py, I thing store_skill_level works to troops, not to agents, so we should use :
(store_skill_level, ":ironflesh",  "skl_ironflesh", ":troop"),
(store_skill_level, ":athletics",  "skl_athletics", ":troop"),

Edit:
The modified damage doesn't work. Even the damage delivered is different from the initial damage taken from trigger param. May be the trigger param is basic damage that 's not modified yet by bonus speed etc. I tried to assign the initial damage to reg2 and modified damage to reg3 and put this debug message at the end :
(display_message, "@DEBUG : Damage delivered to {s1} amount {reg2} and taken as {reg3}"),
The game's damage notification displayed below the debug message even sometime different from reg2, but it's related to reg2 instead of reg3.   
« Last Edit: December 31, 2010, 11:40:54 PM by dunde »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Fancy Damage Systems (OSP)
« Reply #11 on: December 31, 2010, 11:48:50 PM »
D'oh!  My bad about the skill thing.  Corrected  :lol:

Hrmm.  So, how different is the damage input?  I thought the output worked, and mitigation before factoring in speed bonus is still going to cause the total result to get mitigated... and ofc we can turn speed bonus off. 

Guess I'm going to need to test this further and make sure that inputs and outputs make sense.  I know that the stun is working.

Quote
EDIT: I think that the damage reduction % should be decreased a bit, now 10 Ironflesh and 10 Athletics render you invulnerable?
No, one's flat reduction, one's avoidance.  So, at best, you have a 50% chance to avoid all damage and if you do take damage, you take 50% of normal.  It's still one heck of a buff, but you'd have to have 30 AGI and 30 STR, so in most mods, it's not likely to happen a lot, and if somebody wants to ignore INT / CHR, any good mod will punish them there.  Anyhow, it may be horribly OP, but it's OK, it's just an example.

Anyhow, more after I've tested things a bit.  Maybe I need to assign the result to reg0 instead (works that way with a lot of triggers).
« Last Edit: January 01, 2011, 12:00:36 AM by xenoargh »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Fancy Damage Systems (OSP)
« Reply #12 on: January 01, 2011, 01:03:38 AM »
OK, couple of things:

1. set_trigger_result does absolutely nothing.
2.  agent_deliver_damage_to_agent definitely calls this trigger.  Putting it anywhere in the loop causes an endless loop, lol.
3.  Reg0 is also worthless.

Wow.  I feel rather stupid.  Apparently this isn't a function call that expects us to return a value and operates after all the gamecode (which would have been the logical way to do this, imo, given the business case).  Oh well.

We can use agent_set_hit_points to give the difference, which is no big deal.  But the displayed damage for people who leave that (hardcoded) feature on will be fubar'd- you'll take 50 damage, but at 50% reduction, you've been handed 25 hitpoints before the damage actually happens... which is pretty disappointing.

Anyhow, more when I've verified that that approach works.
« Last Edit: January 01, 2011, 01:07:41 AM by xenoargh »

dunde

  • Grandmaster Knight
  • *
  • Curious Coder of The Vision
    • View Profile
  • Faction: Swadian
  • WB
Re: Fancy Damage Systems (OSP)
« Reply #13 on: January 01, 2011, 01:58:54 AM »
I did some tests, focusing on pos0. I found that pos0 is absolute position, not relative position of bodypart of the agent being hit.
Can anybody confirm?

Thanks.

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Fancy Damage Systems (OSP)
« Reply #14 on: January 01, 2011, 02:12:57 AM »
OK, I have verified the set_agent_hit_points method.  The script works as advertised, see changes above.

If you want to verify that it does, indeed, work correctly, add this:

Code: [Select]
(try_begin),
(eq, ":attacker_troop", "trp_player"),
(assign, ":damage", 200),
(try_end),
(try_begin),
(eq, ":troop", "trp_player"),
(val_div, ":damage", 10),
(try_end),

Just before the new ending code:
Code: [Select]
(store_sub, ":diff_damage", ":damage", ":orig_damage"),
(val_mul, ":diff_damage", -1),
(store_agent_hit_points, ":hitpoints" , ":agent", 1),
(val_add, ":hitpoints", ":diff_damage"),
(agent_set_hit_points,":agent",":hitpoints",1),
Voila, your hero can kill fully-armored knights with punches and blows from giant mauls barely do damage (in Blood and Steel, with this and Heroic Health, you become practically invulnerable).  In short... it works.  Finally.

Oh, and yes, pos0 is absolute.  If you were hoping we'd finally get access to hitbox results... sorry.