MBX

Mount&Blade Expansion => Mod Graveyard => Discussion => Topic started by: Ron Losey on November 16, 2008, 03:37:32 AM

Title: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 16, 2008, 03:37:32 AM
I was thinking ... and I know, I shouldn't do that ... when I start thinking, insurance companies go bankrupt.

But seriously, I was thinking, because I need to finish up the RCM/Native package, and I wondered if anybody had done any experiments with a bleeding damage model, and/or if anybody would care to.

It wouldn't need to be complex.  Just a simple "x-2 points/unit time bleeding" added along with "x points damage".  (I say x-2, in that very minor wounds should not bleed significantly.  About two points of slack should cover the ability of blood to clot in a shallow wound, while arterial bleeding would not be so cooperative.)  The net effect being that a character hit by a weapon would eventually go down, as continued attempts to stay in the fight with an arrow sticking out of you would cause blood loss.  To really make it elaborate, have them first flag as unconscious, and then only flag as dead if the fight goes on for a while.  It cannot, however, just check current health - that would result in exponential decay (the more blood they lost, the faster they would bleed), and cause everyone to go down from a scratch.

I thought of that while looking at a scar on my thumb - shop accident a few years ago, cut it nearly off on a bit of sheet metal - and remembering that a cut maybe an inch and a half long was completely debilitating ... not because the cut was serious, but because I lost about a pint of blood over the next five minutes, while trying to stop the bleeding with direct pressure.  If I had tried to stay in a fight, I would have been effective for about four minutes before going down from blood loss.  Even blunt trauma causes blood loss, although it is often internal - medical texts even list common volumes of expected blood loss from various broken bones, assuming reasonable emergency procedures, and the numbers are often several pints for a major broken bone.  Then I compared that to M&B, where a badly wounded character can still run around for an hour as long as nobody catches him.  It's rather hard to balance things for realism with this obvious flaw ... simply increasing damage to account for expected shock and bleeding doesn't really get the effect.

If anybody cares to run a test on this, and/or thinks they could program it ... speak up.  (Note - it has to run the check in very little code.  If the game pauses every ten seconds to run the bleeding calculation, people will notice.)  I'll try to come up with the appropriate numbers to plug into a formula, if somebody with programming skill can create the formula.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: KON_Air on November 16, 2008, 05:10:16 AM
It really doesn't need experimenting just tweaking, the sole problem is detecting "a critical hit" that would cause that serious bleeding to worth bleeding in gameplay mechanics,

work flow is like that;

hit detection: trickiest part as players may get themselves into positions that they can take damage in every step (ie. frame, milisecond). And there is no possibilty of detecting what kind of damage they are taking. The only way to do it, is to contiuniously compare their health to their health in previous check and store how much damage they took in between.What can be done as far as I know is making bleeding as a result of a "critical hit" and decide what to do according to the severity of the hit.

execution: if bleeding deliver blunt damage, if battle goes on longer then survival time limit kill that agent.

Or at least that's what I'm going to do Modplosion, only for player and won't kill anyone (that is expect player :P).
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 16, 2008, 05:21:16 AM
There isn't really such a thing as a "non-critical" hit ... if it does more than two or three points of damage, it's critical in the sense of being medically significant.  How critical it is ... that will be roughly equivalent to the number of points of damage in the first place.  No need to repeat that calculation, just re-use the "damage taken" number.

But having it only affect the player would be pointless.  I was just looking for a way to make it where guys who take an arrow don't either completely shrug it off or completely go down ... something in the middle, where they take an arrow and go down from bleeding in about two minutes, but in two minutes they can still knock you in the head with a mace.  (This is the biggest problem with handgun wounds in modern police work - too much time between when the wound is inflicted and the time blood loss becomes debilitating.)

So no, that's not what I was looking for.  Not at all.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Fisheye on November 16, 2008, 05:54:41 AM
KON's method works for all troops, he was just using the player as an example.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: KON_Air on November 16, 2008, 07:12:51 AM
Some times I wonder why do I even bother...
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 16, 2008, 07:54:14 AM
KON's method works for all troops, he was just using the player as an example.

OK, well ... that was not specified.  In fact, the opposite was specified.  I couldn't really imagine why the opposite was specified, but I figured somebody knew more about this than me, so I just accepted that the code in question was specifically for the player.

--------------------------------------

Still, I don't follow that whole "critical hit" logic.  I mean, small wounds bleed little.  Larger wounds bleed more.  Huge wounds just pour blood.  Points damage taken (above a minimum - anything more than one or two points) equals points bleeding (times some constant) per unit time (whatever unit of time).

Unless you mean that "bleeding" only happens sometimes, only on certain hits... but that seems bizarre.  I mean, oil leaks on automobiles would only occur from certain hits, but humans have arteries running to every major body part and so pretty much bleed no matter where you cut them (relative more to the length and depth of the injury than the location).
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: KON_Air on November 16, 2008, 08:07:19 AM
Because it is a "game" not a simulation of "Ron Losey's bizzare world in which you can die due to blood loss by cutting your finger".
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 16, 2008, 09:03:28 AM
Because it is a "game" not a simulation of "Ron Losey's bizzare world in which you can die due to blood loss by cutting your finger".

More specifically, you could pass out from blood loss by cutting your finger mostly off and then trying to fight for thirty minutes (instead of getting out of the fight and trying to stop the bleeding, like a sane person would do) ... but that distinction is irrelevant at the moment, since such details would have to be worked out after the code was in place.

What is relevant is that a number of people ask me for realistic damage modeling.  The delay between serious wounding and the time that this wounding becomes debilitating from blood loss is a real and significant factor (that has been much studied and discussed in the last 30 years or so, particularly in the area of law enforcement shootings).  It is also a logical factor when considering the apparently massive overkill required to stop someone quickly, as opposed to the relatively minor damage that will stop them eventually.  I would be interested in setting up a code sequence which could be used to statistically simulate this delay as accurately as is possible, given the (painfully limited) scope of the game engine.

I mean, attempting to make combat in the game as near to realistic simulation as possible IS what I do for the mod community.  And there are a fair number of people who expect that of me.  So the whole "because it's a game" routine may be fine for whatever someone else is building, but it is unacceptable in the desired application.  (The "Realistic Combat Model" fan club would tar and feather me for saying something like that.)



So ... KON_Air, thanks for submitting your suggestions.  However, they do not fit the desired criteria, and I do not feel that my target audience would be satisfied with the results.  Good luck with what you are trying to implement in "Modplosion".


Meanwhile, the original question still stands ... who wants to write code for this, and/or thinks they know how to do it?  Who thinks they can make it work without bogging down the game or crashing something, and get it where it can be tweaked for accuracy (without a major programming feat for every adjustment)?  Thoughts on how to place such a code (as a general check, or a scripted damage on every weapon, or whatever)?  I really am very open to suggestions, as long as they produce the desired result.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: KON_Air on November 16, 2008, 09:53:47 AM
Why don't you just do us a favour, learn python and just stop bothering us with impossible requests?
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Winter on November 16, 2008, 10:51:34 AM
1. It's unnecessary.

2. It's a stupidly clunky concept to create with the module system.

3. It's unnecessary.

4. ???

5. It's unnecessary.

Seriously, Ron, if somebody with absolutely no programming background and a terrible aversion to code (i.e. me) can learn how to mod in M&Bscript, you have no excuse for making posts like this.

Regards,
Winter
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Fisheye on November 16, 2008, 11:50:42 AM
FWIW Ron, I believe KON's solution is 99% close to what you had in mind, if you say it's simply just no good then there is basically not much room for further discussion, that's why these guys are being so short and snappy in their responses.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: grailknighthero on November 16, 2008, 12:33:06 PM
I think it would be interesting, and agree with fisheye in that kon_airs way is the way I would do it for all agents.  The severity of the wound would be determined by the amount of damage taken, and values assigned in slots to determine the future blood loss and the current health (so in the next call of the trigger the agent's health can be checked against its past health).  I would work on it, but I am not sure on the impact on performance, because every .1 seconds or so the health of every agent would need to be checked.  This would cause a performance hit, and a performance hit which I cannot afford with my mod.  I also don't have the time because my mod and school work and life is eating up all of my time.  Best of luck though, interesting idea, and perhaps fujiwara would like it in ONR, and perhaps he can do it.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 17, 2008, 12:11:13 AM
Let's see...

"Necessary" is a moot point.  What is "necessary" - oxygen, water, food, sleep, protection from the environment, and minimal interaction with said environment - doesn't really include computer games anyway.  Even sociologists who argue that entertainment is necessary for a society to reduce vandalism would not really claim that it needs to be good quality entertainment - lower-class adolescent teenage males are generally entertained by watching basketball on television, so a well-designed screen saver would probably keep them off the street.  The whole idea of mods for computer games is about an artistic vision for what you would like to see in the game.  In that respect, the quest for realistic detail is one in which a number of people in this mod community have put great interest and tremendous work.  So no, it's not "necessary", but it would be greatly appreciated by a significant number of people (if and only if it could be made to work efficiently).

As for my skills, give me a break.  I only recently picked up 3D graphics.  While my ability to make sense of Python code is slowly growing, consider I am someone with effectively no computer background (beyond just using them).  It's not just an aversion to code - it's zero training in computer programming, except what I just pick up around here.  So don't think of it as whining ... think of it as a compliment to your skill set, that I figure there might be people around here who can do the seemingly impossible, if I will just ask.


And yes, I probably should have just got with Fujiwara and planned this out off-forum, and if and when we had something working, it could have suddenly appeared as a surprise new feature in OnR.  But Fujiwara has been busy, both with the port to 1.0x and some unrelated things ... so I figured I would pass the idea around elsewhere.  Should we get such a model working and accurately reflecting reality to my satisfaction, it would most certainly end up in OnR, among other places.  (I do the combat model for OnR - Fujiwara refers to what I do with the numbers as my "magic".)  But only if it works, and works extremely well.

--------------------------

The basic effect that KON_Air described - running a check to see if a character had been significantly wounded - would, I agree, create an effect similar to what I was describing (plus or minus enough tweaking to get the desired numbers).  And yes, I suspect with relative certainty that running a health check on every character every second is going to create a massive lag.  I figure KON_Air can get away with running that check on only the player, as he described, but I don't really want to think about what it would do to 70 guys on the field at once.  (The morale scripts that do this sort of thing are bad enough.)  Therefore, while I agree that the idea is potentially valid, it's not exactly what I was looking for.  The desired solution is going to have to be a lot lighter.  That's just all there is to it.

A damage script attached to each weapon might be a little better, since the script would only be running on those characters that had been significantly wounded... or it might be worse, since some characters could have several wound scripts running at once.  It would offer the bonus that some weapons could cause more bleeding than others, by running slightly different scripts, and hit detection would not be an issue (since the hit would be what triggered the script).  I doubt my old computer could handle it either way - that's a LOT of code to leave active all the time.  And that lag is likely going to be unacceptable again.  If it was that easy, there would be no need for the question in the first place.

I was hoping that somebody would have a brilliant idea for getting around this, with some slick idea for an uber-efficient way to collect wound data and apply blood-loss damage relative to that, without bogging down the whole game.  But that's going to require more than just basic programming skill - somebody is going to need a strange brand of genius (and/or insanity) to cook up a solution like that.

If it was easy, anybody could do it.  (Heck, if it was easy, even I could do it.)
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: grailknighthero on November 17, 2008, 09:12:56 AM
Can we get the agent who was just wounded by a weapon?  If so, that would be great, not just for this reason.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 17, 2008, 09:49:36 AM
Can we get the agent who was just wounded by a weapon?  If so, that would be great, not just for this reason.

Not that I'm aware of ... except for the long way, as KON_Air was doing.

However, weapons can be flagged to run a script - i.e. do (whatever) to target.  This has been used for special effects in some of the mods using magic effects.  With a little experimentation, it should be possible to modify that to flag a target (for whatever reason).  on hit ... assign whatever to target.  That script should be able to retrieve the data of how many actual points of damage the target just took, if you knew which variable to check.  Tragically, to do this, it would have to be run on literally every weapon and every hit ... which means someone would have to come up with an extremely streamlined script, to prevent this immediately bogging down the game.  (Also true if you were thinking of using this for other functions as well.)

Note that the mods using this effect for magic were all arranged around small fights - you can do a lot of that if there are only a couple of troops on the screen.  It would lag, if not totally crash the system, if you ran those kind of effects on a hundred troops and horses at once.  I'm certainly not the first one to see potential in this trick ... and certainly not the first one to see problems as a result.

Which brings us back to where we started ... what is possible and what is suitably efficient are very different critters.  That's why I couldn't do this myself.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: grailknighthero on November 17, 2008, 10:34:45 AM
That somewhat what I mean, on the attack trigger on the item, does it return the agent for one of the params?  The on init item returns the agent for one of the params, check out the heraldry items.  What I am wondering is if the on attack trigger does the same.  I might mess around with the on attack trigger later, when I get time.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 17, 2008, 09:12:10 PM
The "on hit" function would HAVE to check who or what was getting hit.  Otherwise, it would not be able to flag the right target for the effect.  I don't know how much control you would have over this, however.  That would have to be tested.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: hayate666 on November 19, 2008, 04:06:59 AM
What if bleeding is formulated as a chance that is influenced by the amount of damage a unit receives? Part of body should be left out of the equation, because M&B already counts head shots as pretty much lethal and armour parts like helmets, gauntlets and boots reduce the damage for specific parts. Let's say that any hit doing more than 3-5(?) damage has a chance of starting 1-2 points bleeding damage every 5-10 seconds with a rising chance to close up according to the healing skill. Additional hits should be cumulative. Simulating heavy bleeding shouldn't be necessary, because if you take 30 damage in one blow you're usually going to be dead pretty soon anyway.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 19, 2008, 05:42:30 AM
I was really thinking that we could work on a 1 point damage from weapon equals about one point per minute bleeding damage (for every point over about 3 or 4, to discount shallow wounds where the bleeding would stop itself momentarily).  Depending on how someone figures out how to code it, we might be able to adjust that slightly with different weapons (say, sharp weapons 1 point for 1, non-sharp weapons somewhat less, maybe .7 or .8).  That's a shot-in-the-dark estimate ... it might actually come out 1 point per 2 minutes, or whatever.

Then, adjust the weapon damage to follow ... current RCM numbers were set up to include the possibility of rapid debilitation from massive blood loss, so many of those numbers would have to be lowered.  That would have to be done manually, i.e. by me, and while I'm looking at a stack of medical texts and FBI police shooting reports.

This would result in a model where any moderate to severe injury would result in combat casualty within a few minutes.  That is, you take an arrow in the gut, and the time you can fight like that is not very long.  However, it would not necessarily result in going down immediately either ... especially a particularly tough person could probably still inflict some damage after taking such a wound, at least for a few seconds.

This would have nothing to do with head shots, really ... since a head wound that is not debilitating still bleeds, and that really does not change the probability of a head wound being immediately debilitating (either from direct weapon trauma to the brain or spine, concussion from indirect shock, or the massive pain and psychological shock of face and eye injuries.  Neck hits, which are prone to cause massive bleeding as well as nerve damage and trauma to airway, would respond about right to the data as well.

Since the damage inflicted is already a chance roll within a given parameter, a second probability roll is not really necessary.  More damage equals more bleeding, damage times set constant equals blood loss.

-----------------

But all of this is pure conjecture until somebody constructs an efficient way to collect weapon hit data without having to run health checks on every unit every second.  Otherwise, for programming reasons, this would create such a lag on the system that nothing but the most over-simplified mods could run.  (Repeated health checks might work in an arena, where battles were always less than 10 guys, or if used only on the player like KON_Air was doing, but not on 70 troops.)  So in a word, the exact formula is on hold until the code is in place ... and I can't do the code, that's for sure.  Not anything that will ever run that efficiently.  Somebody (or probably several people, before it's done) is going to have to have a real stroke of genius to think of a way to do that.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Winter on November 19, 2008, 08:49:07 AM
But all of this is pure conjecture until somebody constructs an efficient way to collect weapon hit data without having to run health checks on every unit every second.  Otherwise, for programming reasons, this would create such a lag on the system that nothing but the most over-simplified mods could run.  (Repeated health checks might work in an arena, where battles were always less than 10 guys, or if used only on the player like KON_Air was doing, but not on 70 troops.)  So in a word, the exact formula is on hold until the code is in place ... and I can't do the code, that's for sure.  Not anything that will ever run that efficiently.  Somebody (or probably several people, before it's done) is going to have to have a real stroke of genius to think of a way to do that.

The health checks would run every frame, not every second or even every hundredth of a second. And you have no idea if it would cause any slowdown at all. M&B runs about five or six triggers with every frame, and while they're not nearly as heavy-duty as this, there's no way of verifying if it would actually slow the game down at all without actually doing it. You can run a surprising amount of code in M&B before generating any appreciable slowdown.

Regards,
Winter
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 19, 2008, 09:23:15 AM
Really?

You really mean to tell me that you think it could run a check and compare to last check on EVERY person and horse on the field EVERY frame without utterly grinding the system to a halt?

I ask, because the morale code that Fujiwara put on OnR recently runs a similar (but slightly less heavy-handed) check, only it runs once about every 30 seconds or so ... and it nearly stops my computer every time.  (Granted, my computer is low-spec, but I'm also running very minimal graphics options and don't normally have problems.)  Note that the rest of the script runs cleanly - only the check bogs the system.  (And tolerating it every 30 seconds is one thing, while a two-second delay for every second of game time would be something else.)  If that check is any indicator, then running something like that would be an utter killer on any group more than about ten troops on the field at a time.  This leads me to believe that any such check will have to be written in some very particular (but currently unspecified) way, in order to prevent this.

So my suspicion that this will cause lag is not purely supposition ... I have a good example as evidence of an impending problem.  While that is not proof of anything, it is certainly worthy of attention.

Of course, that was my question to begin with ... does anybody know specifically how to write something along these lines AND actually get away with it (i.e. without crashing anything or grinding the system to a halt)?  So that question still stands ... exactly how do we get away with it?  How can this code be slipped in along with all the other code in a way that doesn't create a massive lag or disrupt anything else?

I mean, I agree that, considering all the stuff running in M&B anyway, there theoretically SHOULD be a way to add one more check, code line, or script like this relatively cleanly.  But how, exactly?  (Mental note: NOT the way that morale check works.)
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Fisheye on November 19, 2008, 10:25:37 AM
If it's a fixed linear thing like 1pt of weapon damage = 1/3 point of bleed per second, then no checks need to take place at all. You just need to keep track of how much bleed damage you applied to the victim and deduct that from the current lack of health to get weapon-inflicted damage.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: grailknighthero on November 19, 2008, 03:20:04 PM
Ron, what I was talking about, was having this run alongside of formation scripts, which is something I am working on, and so I didn't want to work on this, for fear of it, alongside of my formations scripts, would clog the game down.

If you are only running this, then their probably won't be any performance hit at all.  Of course this depends on the machine and other things, like number of troops and models.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 19, 2008, 07:19:39 PM
Well, nothing is going to be "only" running one thing.  Any mod that uses this is going to have to do it alongside whatever other scripts are in place - formations, morale, plus any special functions of that mod.  And I'm certainly not proposing this as a stand-alone mod - the idea was for reworking the RCM, which is in turn used by more different mods than I can count.  So whatever we cook up, it's going to have to run alongside a bunch of random other stuff.

Fisheye:  How would you do that?  Can we test it and find out what it will do to performance?

(I mean, if anybody can come up with efficient ways to do absurd stuff, Fisheye can.)
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: KON_Air on November 19, 2008, 08:04:28 PM
Quote
If it's a fixed linear thing like 1pt of weapon damage = 1/3 point of bleed per second, then no checks need to take place at all. You just need to keep track of how much bleed damage you applied to the victim and deduct that from the current lack of health to get weapon-inflicted damage.

well,

every step/interval
-get agent current health
-get agent max health
--if wounded
-get max - current health
-div result to 3
-apply damage

vs

every step (doesn't even have to be every step, can match interval)
-get agent health
-get agnet max health
--if wounded (lt, agent health, max health)
--get damage from an index according to agent health
-mark agent with wound severity

regular interval
-get agent wound severity
-apply damage
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Fisheye on November 19, 2008, 08:22:55 PM
Each time you want to apply bleed damage (e.g. if you want to apply it every 5 seconds, do this every 5 seconds):

- currhealth <-- agent current health
- totalbleed <-- get agent total bleeding damage applied from slot
- totaldamage <-- maxhealth - currhealth
- weapondamage <-- totaldamage - currentbleed
- this_round_bleed_damage <-- weapondamage / 3
- totalbleed <-- totalbleed + this_round_bleed_damage
- store totalbleed damage in agent slot
- inflict damage to agent (this_round_bleed_damage)
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 19, 2008, 10:45:23 PM
If somebody cares to reformat that into Python, we can plug it in and test it (both for system lag and to tweak the numbers).

(You DON'T want me trying to turn that into Python ... it took me hours to rework the loot code for OnR back in .808, and it didn't have to be efficient.  I can probably adjust numbers once it is in place and I know what I'm looking for, but getting it in there in the first place....)
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Winter on November 20, 2008, 07:24:05 AM
Each time you want to apply bleed damage (e.g. if you want to apply it every 5 seconds, do this every 5 seconds):

- currhealth <-- agent current health
- totalbleed <-- get agent total bleeding damage applied from slot
- totaldamage <-- maxhealth - currhealth
- weapondamage <-- totaldamage - currentbleed
- this_round_bleed_damage <-- weapondamage / 3
- totalbleed <-- totalbleed + this_round_bleed_damage
- store totalbleed damage in agent slot
- inflict damage to agent (this_round_bleed_damage)

Yeah, that'd work, and be easy as anything. Sound thinking.

Regards,
Winter
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on November 21, 2008, 04:05:32 PM
This is not exactly what you where asking for, but back when v0.8x was released I experimented with removing the awful pen-and-paper RPG abstraction called "hitpoints" from M&B.

The idea was to use the same method mentioned by Mr Air above to record the power of any hits taken, reset the hitpoints of the agent to keep it form dying the normal way, and then use an exponential function to calculate a damage value (to make one powerful hit better than several weak ones). This damage value would then be compared to an other value calculated from the agents strength and iron skin stats and various "effects" would be applied to the agent.

A typical effect would be reducing the weapons proficiency to make swings slower and lowering the skill and stat that affects running speed to simulate a wounded agent, and of course simply being knocked out (using agent_deliver_damage, meaning no xp for kills). The damage would be recorded so the next time the agent took a hit the chances of severe effects would go up. Also, the agents would slowly recover some stat-loss during the fight (25% perhaps) to simulate some sort of recovery after the initial shock. This way it is always some chance to kill/knockout in one hit, even with a crappy weapon, especially if the target has little fighting experience (low iron skin) and poor armor.

I never did any experiments with blood loss since I thought it would be frustrating for the player to slowly bleed out without being able to affect it, but in retrospect it was probably a mistake to not even test it before dismissing the idea. I also never did any large scale test, only 4 vs 4 arena fights, but compared to rendering a 3D environment these scripts will most likely not cause any major slowdowns.

This system had many limitations and it I never quite managed to get the right "feel" to it. It was always too much like ordinary hitpoints or it felt too random, but perhaps it would be possible to create something interesting from this if we worked together?
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 21, 2008, 07:35:01 PM
I'm always open to suggestion, especially when it comes to how to code something.  (Because my knowledge of Python code is minimal, to say the least.)

I have no problem with the "hit point" concept - at its source is the simple idea that humans can take a limited degree of damage before being disabled.  And this is a valid point, which various medical texts and just about every study on military and police firearms wounding cases will support.

The problem with most RPG-type hit points is that a person can take way too much damage ("Ha, arrows in my head don't hurt me because I have HIT POINTS!"), and/or the weapons are poorly modeled (How come, in M&B Native, players can swing an axe the size of a stop sign at 90% of the speed they can use a pocketknife?).  That was how the "Realistic Combat Model" was born - correcting these obvious errors.

As for a bleeding model, I think it can be balanced out properly, such that minor wounds only produce minor bleeding (A couple of points over the course of the rest of the fight), while major ones would mean that troops could not keep fighting forever on their last couple of hit points (because blood loss would catch up to them in 30 or 40 seconds).  However, I did notice that the RCM had an issue here - many troops die too fast after being hit.  And that is not realistic... real people keep fighting for their lives even when critically wounded, at least until they go into shock from the injury.  That delay is the difference between hitting someone with a huge sword (which without armor will likely be immediately debilitating, as soon as that thing touches a nerve or tendon) and shooting them with a handgun (which might kill them eventually, but unless it hits brain or spine, odds are they're not going down for a couple of minutes).

Anyway, if you care to write that code (I think I asked earlier if somebody cared to turn that into Python code for me), please do.  We'll test it, and I would love to hear any other thoughts you might have.

Side note, if you are unfamiliar with the "Realistic Combat Model" (RCM) stats, try Onin-no-Ran.  (Most recent version for .90x - won't be ready for 1.0x for a couple of months at best.)  It's proof that hit-points can be made to work, provided you rescale the damage enough.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: grailknighthero on November 21, 2008, 11:56:22 PM
Very interesting Amarillo.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on November 25, 2008, 11:31:25 AM
I tried this as a proof of concept:

* One trigger that checks for damage twenty times per second.
* Tested applying ~33% of the damage to bleeding damage.
* Bleeding damage reduces health by one point every ~2 seconds until consumed.


Results:

* The triggers does not affect frame rates even with 100 agents plus horses in the battle.
* Bleeding has little effect on enemies since they tend to get killed before bleeding out, even in sieges. The player's troops on the other hand, will suffer more casualties since they usually have to withstand several waves of enemies.
* The trigger used to knock out an enemy form blood loss will make the XP award a bit strange since it is impossible to know who is responsible for the kill. It also seems to kill rather than wound the agent 100% of the time.


Discussion:

This is obviously a very primitive implementation that would have to be improved in many ways, but I think it can serve as a base for a discussion about how to proceed. One idea would be to randomise both the total hit points that will be lost from a wound and how fast this loss will be, and combine this with a temporary (current battle only) loss of weapons proficiency and attributes so a wound actually makes a difference. (Or to start work on a hitpointless system.) I can imagine that everyone in this thread has spent some time thinking about the problems with the current damage system while paying and modding M&B, and I would be very intersted to hear your thoughts about this.

Ron Losey: Is this similar to what you had in mind?

Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Foxhound on November 25, 2008, 04:23:06 PM
So are you trying for a reality mod or Dmg over time mod/yay blood >:D aww i died  :'(

My two cents ;)
Yeah so what you were saying with the dmg over time and that you would have to stop to take care of the wound, that then you would have to add the ability to leave the battle or "pull out" bleeding men before they die

you are going to need animations for the blood

Another way of doing this is taking each part of the body and looking at how much you would bleed and what weapon was used, but then you also need to include the skill you have at that weapon(thus increasing the Chance of hitting a vital area)way too much programming and lag  ???

Will there be bleeding off the battle field aka if they are wounded they need to rest(camp or town) and if you don't do this they will die (forever  :'( )
  going with this all men that "die"(or only that "die" of bleeding) on that battle field go into the wounded pile and must be          healed like in the ways listed above above

Then you also can add a "medic class" that can increase or even stop the bleeding of men without camping( :idea: if someone could make a medic animation for carrying and patching people up you could even have him on the battle field mending people that depending on the wound they can be put back in the battle with wounds/HP drop)

You can add a "wounded" animation where they walk slower, and have a slower reactions to things

And there are my 2 cents
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Lord Nalfein on November 25, 2008, 05:00:24 PM
From what i've read, the basic problem you have is wounding. I know you bleed form almost every cut you receive, but there are some you don't. Say you need to take 5 damage to start bleeding, then not every hit makes you bleed. But then you get into arteries. If you get hit in the neck or heart, you should die quickly. The arteries in the legs and arms will kill you a little slower but still rather fast. Getting shot in the calf would make you move slower (don't know if your going for that) and a hit to the arm would likely make you drop your weapon. Arrow wounds would be hard though, as you don't always bleed from one. The arrow might plug the wound, or it might be a glancing blow and make a long gash.

My thoughts are too long to post, but another question is: Would you bleed more from a long gash or from a wound that went to the bone?
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: grailknighthero on November 25, 2008, 07:37:08 PM
Amarillo, the only problem with causing stat losses is that it can only work for named Characters, or troops in which there will only be 1 present on the battlefield.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 25, 2008, 07:58:02 PM
Amarillo:
Yeah, that's exactly what I had in mind.

Write up the code.  I anticipate the numbers to balance out about 0.1 points of bleeding damage per point of weapon damage every ten seconds or so.  (i.e. 20 points - a serious wound - would be 2 points every ten seconds, two to three minutes before you would go down).  But I'll mess with the exact numbers after seeing it in a game.  The trigger should not need to check more than once per second, tops ... could be less often.  (But that comment about ten seconds was math, not programming ... we don't want visible waves of people falling once every ten seconds.)

Try to set it up so that it only counts weapon hits greater than 3 points of damage.  That will eliminate the factor of continuous blood loss from scratches that would clot and stop bleeding on their own.

Also, it would be really nice to rig it so that they are rendered unconscious by blood loss, but then switch to "dead" if they continue to lay there and bleed.  Since a person bleeds a lot less when they are not moving, it should be a lot slower than the initial problem.  Say, if they get to -100 at the previous bleeding rate, they are listed dead. Otherwise, they are wounded.  Not sure if you can do that or not, but it would be a nice touch.

Do make sure it applies to horses too.  That is important.

Foxhound:
I was going to assume that, when the battle ended, somebody would have time to apply some pressure to wounds.  Most blood loss issues can be handled with a little direct pressure, provided you have time to do that (i.e. nobody is trying to kill you).

The idea was just to stop people from fighting at full strength for five minutes on their last two hit points.  That and to work a delay into the effect between wounding and actual disability ... i.e. a wounded person can still get off a couple more shots before going down.

Nalfein:
Generally speaking, the only wounds that don't bleed significantly are very small wounds.  Regardless if the wound is long and shallow or narrow and deep, the odds of hitting a large artery or a series of smaller arteries and veins is about the same.  Really sharp weapons draw more blood than dull ones, but they also do more tissue damage, and so should have higher damage numbers to begin with.

The only time I have ever heard of arrows actually slowing bleeding, it was a simple point (i.e. not a cutting broadhead).  The only thing using those type of tips in M&B are the crossbows, and they are set to pierce damage, and therefore much lower damage numbers overall, to represent their weakness in damaging muscle, nerves, and arteries.  Even then, if the victim moves around at all, bleeding usually resumes immediately.  So the lower overall numbers should cover that effect relatively well.

"Would you bleed more from a long gash or from a wound that went to the bone?" ... actually, a cut from anything larger than a scalpel is probably going to go to the bone on most areas of the body.  I mean, you can cut yourself "to the bone" in an accident with a kitchen knife (done that a few times, and so has every other person who frequently cooks anything more elaborate than macaroni and cheese).  A solid hit with anything machete or larger will go through several bones as well.  The question for our model is, "how long can you keep fighting with your left triceps completely severed just above the elbow, before you go into shock and collapse?" (Answer: about two minutes, likely.)  Even an arrow, with any kind of effective broadhead, makes a hole at least an inch and a half wide - so it is a long, wide tear as well.  The only thing that is going to make any of these better is armor, which might actually prevent the weapon from passing through meat, or at least slow it down a lot.  Methinks you are generally underestimating the kinds of wounds that a weapon leaves.

Then the really amazing part is how much of this kind of damage a person can survive and fully recover from, provided they don't bleed to death first.  I know too many people who crawled out of car crashes or industrial accidents with just awful injuries, and then were back to fully operational in a few weeks.

As for slowing you down or dropping a weapon, I don't think we can get the game to do that.  However, a wound to the leg would likely either completely stop the person (i.e. actually broken bones), or else they probably would not really notice for a couple of minutes.  If they go down completely, well, then they are down - if a person hits the ground with a broken leg, he's probably not going to keep fighting from the ground.  If not, trying to model the effects of adrenalin on pain reception is quite beyond the scope of this project.

Actual damage to the heart usually puts most people into shock immediately.  However, any hit that goes deep into the chest is going to read like 40 points of damage or more ... so the only change this would make is to make sure they go down within a short period of time.  It really doesn't matter if the wound was heart, lung, liver, or major arteries.  Same with neck wounds - they're listed as head, so hits to the neck are double damage anyway.

Side note:
This is intended to be used with Realistic Combat Model (RCM) numbers.  They already do not work like Native, where the player can solo everything.  I make no promises of any of this even appearing sane if applied to a damage model based on M&B Native.  It will, however, put the player under some pressure to end the battle, rather than waiting forever on the last guy on the field... your troops can't just stand there forever, looking casually at the arrows sticking out of their bodies.  It will also get rid of that effect where some guy on a horse with only two points left is running around all over the place and nobody can catch him... his wounds would eventually disable him (or his horse).



Edit:
grailknighthero:  your post while I was writing....

Yeah, I wondered about that, but wasn't going to say anything, because I figured he must have worked it out.  If it's a problem, I'll leave it to you guys who know what you're doing to figure out....
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Foxhound on November 26, 2008, 02:49:45 PM
Yeah but how do you like my other ideas?
and like you were saying about not being able to fight with your last two health, you will have to make a way to pull people out of combat so you don't lose men just because that annoying mounted guy is all the way across the map from you and your men
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 26, 2008, 07:16:15 PM
Yeah but how do you like my other ideas?
and like you were saying about not being able to fight with your last two health, you will have to make a way to pull people out of combat so you don't lose men just because that annoying mounted guy is all the way across the map from you and your men

To be honest, you're getting the cart WAY ahead of the horse.

I figure that all bleeding will get stopped with bandages as soon as the fight is over.

I also figure that, if you really want to pull back and care for your wounded, that's what the "retreat" command is for.  Other than that, part of the point was that you could wound someone and just wait for him to bleed out.  It makes hit-and-run tactics a lot more viable, for both you and them.

The blood animations are already quite enough to deliver the message "this person looks pretty bad."  Since the game doesn't really support animation of blood spots on the ground, we really can't go anywhere with specialized graphics.

For wounded animation, well, to be honest, adrenalin usually keeps people on their feet for a while after they've been hit.  It's quite common for people to feel no pain at all for several seconds after a major injury.  It could get VERY complex to estimate the degree of "acting wounded" that might actually occur.

But all of that is still way ahead of where we are now ... First the code, then the tests, then we worry about stuff like that.

Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Foxhound on November 27, 2008, 02:48:22 AM
don't you lose something if you retreat? and what i had said, why lose to that one guy all the way across the field, but hey i am just thinking out the future  :D
I have new idea i have is assigning a random numbers genorator to each hit depending on the weapon and maybe skill(this is thought out with very little scripting experience ;) ) soo yeah just ideas to help you formulate your own

I also think that this is a very good topic that future games should look at(if we find a way lol), because most games now don't deal with this, because of all the problems we have came up with, while also balancing it so that the entire game doesn't focus on bleeding.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 27, 2008, 03:59:24 AM
Well, "most games" have no regard whatsoever for anything related to realism.  They take their standard from the old D&D pen-and-paper games, where game balance was based on some obscure arbitrary standard that had nothing to do with any standard of physics or biology whatsoever.  Even if they add various things like bleeding or fatigue, it is based on some standard developed by Martians that obviously has nothing to do with how humans (or any other known organism) really react to damage.

M&B started that way (and Native is still somewhat there), but since the early experiments with combat realism in Onin-no-Ran, some of us have managed to get a surprising degree of realism out of the M&B game engine (even if it took some odd games with statistics to get it there).  A few of us had a vision that said real combat is more exciting than cartoon combat, so we should shoot for making the game as close to reality as possible ... and in general, the idea has been a brilliant success - much more so than I ever dreamed, that day that I told Fujiwara to give me the source code and 48 hours, and I would rewrite the bloody thing or die trying.  (Side note - I don't put myself on those kind of schedules any more - too much chance of burnout.  Of course, I don't have anything to prove now ... everybody who hasn't been living under a rock has heard of my "Realistic Combat Model" now.)  We've gone through several versions of M&B since that day, but the dream of realistic combat physics is still very much alive, especially among the historical mods.

So the idea of a blood loss model, and subsequently a delay between wounding and disability, would be a nice touch to add to this model.  Maybe not the most necessary addition, but a good one ... if it can be made to work.  No doubt it will take some detail work, even after the basics are in place.  But I'm not worried - they said somewhat realistic damage numbers would make the game unplayable, and it did exactly the opposite.  I'm sure this sort of thing can be incorporated and balanced as well.

But all of this still hinges on these guys who know what the heck they're doing, assuming they can write and test the code for it.  Me tweaking the numbers, and then everybody chipping in with ideas, all comes after that part.  Tragically, my actual skills at this stuff are a good deal less than what many people assume ... I had effectively zero game mod skills when I first started working with OnR as a historian.  (Now, I do limited things with Python, and my skills with graphics ... well, most of the weapons and helmets in OnR are my work.  But that still doesn't mean I can handle stuff like this.)

So I am still depending on somebody to set up the code ... then we'll see where we can go with it.  One step at a time.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on November 27, 2008, 09:48:55 AM
I think all of the features you requested are possible to add. An agent who bleed to death will always be killed, but I suspect we can calculate how many agents survive and then add this number of wounded troops to the party.

One question: I got the impression form your post that bleeding never should stop (makes sense to me),  is this correct?

Amarillo, the only problem with causing stat losses is that it can only work for named Characters, or troops in which there will only be 1 present on the battlefield.

Thank you for pointing this out, I had completely forgotten. There is still a chance that it is possible to implement but the solution would most likely become quite complicated so lets skip this, for now.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 27, 2008, 05:16:02 PM
Well, stopping blood loss should require some medical attention.  So it should not stop on its own.  We may, later, wish to implement a function where wounded individuals would stop fighting and attempt to control bleeding (and/or others who would help them) ... but that's a thing for what we might want to do later, not an immediate issue.  Even if we do, it can be a function that adds a negative to bleeding damage - we don't need a timer on it, if that's what you're asking.

"killed" as in removed from the field ... we can cook up something so that some of them will only be disabled.  Run it through the same function as the number who survive fatal wounds because of the surgery skill.  That should be simple enough.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Foxhound on November 30, 2008, 07:52:03 PM
Yay you took one of my ideas
here is a new one(i will stop if you ask :() you heal on field if you stand still (with no one trying to kill you) and use a bandage, and make bandages available for purchase(in large bulk) from all towns
maybe also have it equipped as a weapon
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on November 30, 2008, 10:48:37 PM
The bandage idea is not going to work, just because it would apply to all troops, not just the player/named NPC characters.  Therefore, there is no way to count them being used.

As I said, we may later want to add things like doing basic first aid on yourself or others, but that is AFTER the basics are working.  No need in planning that part until the first part is working and thoroughly tested.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on December 06, 2008, 08:51:35 AM
Update: Added some randomization.

The triggers for bloodloss are done. For every HP lost the agent lose one "blood point" every second. When the defined number of blood points are lost the agent lose one hitpoint (defined by blood_per_hp).

Paste this at the very bottom of your module_scripts.py:
Code: [Select]
### constants ###
# Agent slots, make sure these slots are not used for something else
slot_agent_bleed = 8
slot_agent_rate  = 9    # rate of blood loss
slot_agent_hp    = 12

# Various constants
absolute = 1
true     = 1
false    = 0
player   = 0

# Bleeding
blood_per_hp  = 300
dmg_threshold = 3
dmg_low_range = 6
dmg_hi_range  = 12

bloodScripts = [
    ("monitor_health",
    [
        (try_for_agents,":agent_id"),
            (agent_is_alive,":agent_id"),
            (store_agent_hit_points,":current_hp",":agent_id",absolute),
            (agent_get_slot,":old_hp",":agent_id",slot_agent_hp),
            (try_begin),
                (gt,":old_hp",":current_hp"), # Damage taken
                (agent_set_slot,":agent_id",slot_agent_hp,":current_hp"),
                (store_sub,":new_rate",":old_hp",":current_hp"),
                (gt,":new_rate",dmg_threshold),
               
                #debug start
                (str_store_agent_name,s1,":agent_id"),
                (assign,reg1,":new_rate"),
                (try_begin),
                    (agent_is_human,":agent_id"),
                    (display_message,"@{s1} recived {reg1} damage"),
                (else_try),
                    (display_message,"@{s1}s horse recived {reg1} damage"),
                (try_end),
                #debug end
               
                (val_sub,":new_rate",dmg_threshold),
                (store_random_in_range,":mul",dmg_low_range,dmg_hi_range),
                (val_mul,":new_rate",":mul"),
                (val_div,":new_rate",10),
               
                #debug start
                (assign,reg1,":new_rate"),
                (display_message,"@damage reduced to {reg1}"),
                #debug end
               
                (agent_get_slot,":old_rate",":agent_id",slot_agent_rate),
                (val_add,":new_rate",":old_rate"),
                (agent_set_slot,":agent_id",slot_agent_rate,":new_rate"),
            (else_try),
                (eq,":old_hp",0), # Init agent
                (agent_set_slot,":agent_id",slot_agent_hp,":current_hp"),
            (try_end),
        (try_end),
    ]),
   
    ("bleed",
    [
        (try_for_agents,":agent_id"),
            (agent_is_alive,":agent_id"),
            (agent_get_slot,":rate",":agent_id",slot_agent_rate),
            (gt,":rate",0),
            (agent_get_slot,":blood",":agent_id",slot_agent_bleed),
            (val_add,":blood",":rate"),
            (store_div,":hp_loss",":blood",blood_per_hp),
            (try_begin),
                (gt,":hp_loss",0), # the agent has lost enough blood to lose hitpoints
                (store_agent_hit_points,":hp",":agent_id",absolute),
                (val_sub,":hp",":hp_loss"),
               
                #debug start
                (str_store_agent_name,s1,":agent_id"),
                (assign,reg1,":rate"),
                (assign,reg2,":hp"),
                (try_begin),
                    (agent_is_human,":agent_id"),
                    (display_message,"@{s1} is bleeding: rate = {reg1}, HP = {reg2}"),
                (else_try),
                    (display_message,"@{s1}s horse is bleeding: rate = {reg1}, HP = {reg2}"),
                (try_end),
                #debug end
               
                (try_begin),
                    (gt,":hp",0),
                    (agent_set_hit_points,":agent_id",":hp",absolute),
                    (agent_set_slot,":agent_id",slot_agent_hp,":hp"),
                    (store_mul,":tmp",":hp_loss",blood_per_hp),
                    (val_sub,":blood",":tmp"),
                    (agent_set_slot,":agent_id",slot_agent_bleed,":blood"),
                (else_try),
                    (call_script,"script_get_enemy_agent",":agent_id"),
                    (agent_deliver_damage_to_agent,reg0,":agent_id"),
                (try_end),
            (else_try),
                (agent_set_slot,":agent_id",slot_agent_bleed,":blood"),
            (try_end),
        (try_end),
    ]),
   
    ("get_enemy_agent",
    [
        (store_script_param,":target_agent_id",1),
        (try_begin),
            (agent_is_ally,":target_agent_id"),
            (agent_is_human,":target_agent_id"),    # a horse agent can not cause damage
            (assign,reg0,":target_agent_id"),
        (else_try),
            (get_player_agent_no,reg0),
        (try_end),
    ]),
]

scripts.extend(bloodScripts)


Paste this at the very bottom of your module_mission_templates.py:
Code: [Select]
# blood loss
monitor_health = (
    0.05, 0.0, 0.0,
        [],
        [
            (call_script,"script_monitor_health"),
        ])

bleed = (
    1.0, 0.0, 0.0,
        [],
        [
            (call_script,"script_bleed"),
        ])

# add triggers to all mission templates
for template in mission_templates:
    template[-1].append(monitor_health)
    template[-1].append(bleed)
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 06, 2008, 09:22:25 AM
OK ... good show.  I'll plug this into an older version of OnR and test it as soon as I get a chance.

Couple of questions:

1.  Does it flag everybody as wounded?  Everybody as dead?  Or does it wash them through the surgery skill to determine survival rate after collapse from blood loss?  (The latter being the most desirable option.)

2.  Does it work on horses too?  (If not, it needs to.)
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on December 07, 2008, 06:40:13 AM
Consider this a test version for balancing purposes. Agents can only be killed from blood loss at the moment. The agent_set_hit_points command eventually sets the agents hitpoints to zero but this won't actually kill the agent. Thefore we have to use the agent_deliver_damage_to_agent command, which unfortunately seems to kill 100% of the time. This means only surgery can save those who colapse from blood loss at the moment, but I'm pretty sure there is a workaround.

Horses are affected and will have their HP reduced to zero, but only enemy horses will actually be knocked out using the current implementation. This is easy to fix though.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 07, 2008, 07:22:32 AM
Letting the surgery skill settle the problem seems a fair solution to me.

However, I plugged this into an older version of OnR, and tested it ... I couldn't get it to do anything, at least not that I could observe.  Did I do something wrong?  Does it only work in Native at the moment, or only on M&B 1.0x?  (The version of OnR that I used for the test was for .90x.)  I mean, I believe you, that it worked for you ... so now where did I screw up?

(Side note ... that is, where did I screw up in relation to implementing this scrap of code ... not "How did my life come down to this?" ... I already know how I screwed up that part.)

And I'm likely to be busy most of the day tomorrow, so I may not get back to this for just a bit....
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on December 07, 2008, 10:30:43 AM
I'm using the 1.010 module system, but I don't think that should cause any problems. Make sure that  agent slots 8, 9 and 12 are not used for something by OnR. If they are, just change the following lines above the new scripts to some avaliable slots.

Code: [Select]
slot_agent_bleed = 8
slot_agent_rate  = 9    # rate of blood loss
slot_agent_hp    = 12

Also, for debug purposes the code will print a message regularly if an agent is bleeding.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Conners on December 13, 2008, 05:48:46 AM
Bleeding in combat sounds like a really fun addition :D (....unless you are the one bleeding :p)!

Small idea: What if the bleeding was partially random? A wound might gush out blood at first, but then it would supposedly slow down as you had less blood in that area to bleed out (this may not be the best example).
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 13, 2008, 06:52:51 AM
Connors:
Generally blood loss from trauma wounds is pretty consistent.  About the only things that change rate of blood loss are the heart rate/blood pressure of the victim (i.e. lay down and try to be calm to slow bleeding), and first aid procedures (direct pressure on the wound, pressure points on arteries, and/or tourniquet).  Both of these generally require your undivided attention to make them effective, and so aren't going to have much effect as long as there are people on the field trying to kill you.

The human circulatory system is a closed circuit.  As long as the heart is working, blood pressure remains pretty constant across the system until it actually runs out of blood (at which time blood pressure drops very fast, and the victim generally goes into severe hemorrhagic shock more or less immediately).  That drop in blood pressure is generally fatal, at least without the facilities of a modern hospital ... there is certainly not much that could be done on the field before military medics started carrying blood plasma for I.V. transfusion.

Loss of other body fluids would be slightly more random.  For example, hits to the digestive system would cause rapid loss of various fluids, until those organs were drained.  However, no matter how large of a medical complication this might be in two or three days, it's not going to have much effect immediately.  That is, unless you can tear those systems apart badly enough to either cause massive bleeding, or disable from pain, or cripple enough bones, nerves, and muscles to be debilitating.  And in that case, you're back to either bleeding or hit points of damage from the initial wound to simulate that kind of trauma.

So no, I seriously vote against your "small idea" for biological reasons.

---------------------------

However, if we're just testing stuff ... it might be interesting to put a variation on the number.  For example, x points of damage (assuming x to be over the minimum threshold - I think it was 3 in this code, for the time being) produces x plus or minus 5 points of blood loss.  Simulate that slight randomness that results from things like maybe the arrow hit the main artery and maybe it just cut some minor stuff.  That is actually an issue in real incidents - in police shootings, for example, bullets either hitting a nerve, artery, or organ, or missing it by a hair, make the difference between a serious injury and a minor one... even though the wounds look more or less identical from the outside.

Granted, bullets (and practice-tip arrows, and screwdrivers, and other small-diameter puncture wounds) are a lot worse about that randomness than edged weapons.  Also, truncheons tend to be more random about that sort of thing than blades, since the difference between lacerating an artery and just flattening the heck out of it is often pure chance.  But still, if we're not getting much lag from this code, it could help.  Make the ratio between injury and bleeding a little less mechanical, and so a little less predictable ... the illusion of a computation more complex than it is.

----------------------------

Unrelated:  Fujiwara didn't get back with me on which slots were open in OnR, so I couldn't really test it under the conditions I wanted.  However, the word is that we are good for incorporating this into OnR as soon as is feasible.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on December 13, 2008, 04:13:45 PM
You can find out what agent slots are used by looking in the constants file, assuming that Fujiwara uses the same conventions as the native module. Or you could just set the numbers to something really high until he can help you with this.

Perhaps the problem is caused by something different. Have you tried the code with a fresh native module?

I actually considered some sort of randomization but decided against it since the damage is slightly random already, but I like the idea of some small wounds not causing blood loss 100% of the time so I'll probably add it soon.

One more thing; it is possible to find out what kind of armor the agent is carrying. Does anyone have any ideas how to use this information to modify damage/bleeding in any interesting way?
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 13, 2008, 09:02:15 PM
Armor type shouldn't really matter that much.  Either it was effectively penetrated (causing that degree of injury/bleeding), or it was deformed in a way that caused injury (less than the other, likely, but still relative to the damage), or it was effective in preventing injury.  And none of those possibilities really change that much relative to the armor type.

I will try it on .90x RCM-Native, when I get some time.  However, I specifically wanted to balance it on OnR, because I knew the troop types, weapon conventions, and such, and so had a better idea of what I was seeing.  I'll mess with it some more in a little while.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Conners on December 14, 2008, 06:23:24 AM
Connors:
Generally blood loss from trauma wounds is pretty consistent.  About the only things that change rate of blood loss are the heart rate/blood pressure of the victim (i.e. lay down and try to be calm to slow bleeding), and first aid procedures (direct pressure on the wound, pressure points on arteries, and/or tourniquet).  Both of these generally require your undivided attention to make them effective, and so aren't going to have much effect as long as there are people on the field trying to kill you.

The human circulatory system is a closed circuit.  As long as the heart is working, blood pressure remains pretty constant across the system until it actually runs out of blood (at which time blood pressure drops very fast, and the victim generally goes into severe hemorrhagic shock more or less immediately).  That drop in blood pressure is generally fatal, at least without the facilities of a modern hospital ... there is certainly not much that could be done on the field before military medics started carrying blood plasma for I.V. transfusion.

Loss of other body fluids would be slightly more random.  For example, hits to the digestive system would cause rapid loss of various fluids, until those organs were drained.  However, no matter how large of a medical complication this might be in two or three days, it's not going to have much effect immediately.  That is, unless you can tear those systems apart badly enough to either cause massive bleeding, or disable from pain, or cripple enough bones, nerves, and muscles to be debilitating.  And in that case, you're back to either bleeding or hit points of damage from the initial wound to simulate that kind of trauma.

So no, I seriously vote against your "small idea" for biological reasons.

---------------------------

However, if we're just testing stuff ... it might be interesting to put a variation on the number.  For example, x points of damage (assuming x to be over the minimum threshold - I think it was 3 in this code, for the time being) produces x plus or minus 5 points of blood loss.  Simulate that slight randomness that results from things like maybe the arrow hit the main artery and maybe it just cut some minor stuff.  That is actually an issue in real incidents - in police shootings, for example, bullets either hitting a nerve, artery, or organ, or missing it by a hair, make the difference between a serious injury and a minor one... even though the wounds look more or less identical from the outside.

Granted, bullets (and practice-tip arrows, and screwdrivers, and other small-diameter puncture wounds) are a lot worse about that randomness than edged weapons.  Also, truncheons tend to be more random about that sort of thing than blades, since the difference between lacerating an artery and just flattening the heck out of it is often pure chance.  But still, if we're not getting much lag from this code, it could help.  Make the ratio between injury and bleeding a little less mechanical, and so a little less predictable ... the illusion of a computation more complex than it is. You certainly do know your stuff.
I'll have to commit this to memory for the sake of writing... and possibly a situation where I'm actually helping a bleeding person.

Scary o_o.

....Very scary O_O

Sorry :(. My suggestion was uneducated, and based more on RPG systematics than human biology.

---

So my idea is useful :)?

This'll certainly be better than multiple combatants falling unconscious at the exact same moment, I'd guess.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on December 14, 2008, 07:17:28 AM
Fist thing first. If you use a fresh 1.01 module and it still does not work we might be able to figure out what is wrong with the code. If it does work we have to investigate what have changed between v0.9 and v1.0.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 14, 2008, 09:51:45 AM
Wait ... you said it worked for you, right?  Then we know it works on a clean 1.0x module.  The questions involve making it work on one of the versions that use RCM numbers, so I can figure out how we want to tweak it.

Which I will get to, ASAP ... but that may be a while, because I'm going to be excessively busy for about a week.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on December 15, 2008, 10:49:01 AM
I was actually interested in knowing if you were able to correctly insert the code in to the module or not, and that the code had survived the transition form my editor to the forum to your editor. I'm in no hurry to get this done however, so I apologize if you felt like I was trying to rush you about it.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 15, 2008, 07:31:51 PM
Actually, I would love to see it done quickly too.  Tragically, I have a stack of final exams to grade, and more than a couple of minutes over here is hard to justify at the moment.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 25, 2008, 11:49:54 PM
OK, finally got back to this.  Had some errors, but they were my mistake ... I fixed it.  (Amazing how frustrating a little typo can be.)

Anyway, the current data set is brilliant ... but it's at least 3 times too fast.  Set blood points per hp to about 300.  Further tweaks forthcoming - that's just first round rough estimate.

Also, I haven't played with it enough to be sure, but I think that 100% of enemy downed from blood loss are killed.  Should be a way to lower that ... say, if bleeding is less than (x), target is rendered unconscious instead of dead.  (Value of x yet to be determined.  I would start with about 40, if I read the code right.)

Of course, the final version will presumably have the feedback level lowered ... but the extra data is great for tweaking it for now.  That helped a lot, actually.

Anyway, got it working now.  I love it.  It's brilliant.  Absolute masterpiece.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on December 28, 2008, 04:36:54 PM
Glad you like it.

Blood loss rate: This is set under the scripts constants with "blood_per_hp"
Feedback: If you want to remove this now you can comment out the lines between "#debug start" and "#debug end" in the "bleed" script by putting a # first on each line.
Death: The only solution I can think of is adding troops of the same kind that bled to death to the parties after the battle, but I have not been able to figure out how to do this correctly in multiparty battles. I will keep working on it and see if I can find a solution.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on December 28, 2008, 10:56:54 PM
Yeah, I found the "blood_per_hp" flag ... that's what I said, it needs to be set to about 300.

(My Python programming sucks, but I'm not completely illiterate.)

Is there no way to flag the damage as "blunt"/non-fatal?  Or get damage type off of the weapon used?

Another potentially useful thought, along with adding some randomness to the blood loss:  Might be useful if blunt damage caused less bleeding than the other two.  Not sure exactly how much less - broken bones, especially, do cause substantial internal bleeding, but not nearly as fast as if a sharp blade crosses even a minor artery.  Might start with half.

Even without a fix on that, this code is certainly destined to find its way into every one of the RCM mods ... I'll make sure of it.  It does what I couldn't do with stats alone - it makes getting injured a serious problem, even if the injury is relatively light.  Stops players from thinking like "well, I can take x hits...". 
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: mfhberg on January 02, 2009, 02:14:40 PM

Also, I haven't played with it enough to be sure, but I think that 100% of enemy downed from blood loss are killed.  Should be a way to lower that ... say, if bleeding is less than (x), target is rendered unconscious instead of dead.  (Value of x yet to be determined.  I would start with about 40, if I read the code right.)

Death: The only solution I can think of is adding troops of the same kind that bled to death to the parties after the battle, but I have not been able to figure out how to do this correctly in multiparty battles. I will keep working on it and see if I can find a solution.

Ignore this I'm just typing as I ponder.

Death -
Blood loss is killing (if blood loss is the last hp).
Blunt damage is not killing, even for massive head trauma, unless blood loss is the last hit point.
Cutting/piercing is always killing.

I see a problem if using a morale mod, those fleeing with wounds will usually die by blood loss.

Surgery (party skill) reduces (all) death to wounding by percentage. You could increase all parties or the winning parties surgery by one in the death/wounds portion of the code to reduce the number of deaths by blood loss.

To simulate first aid how about reducing blood loss by percentage (or increasing blood hp by percentage) according to troop or party First Aid skill?

mfberg
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on January 02, 2009, 07:47:21 PM
Actually, running from a battle when wounded IS a very likely cause of death by blood loss.  Historically, retreats almost always result in the highest casualties, not just because the enemy can get at your backs, but because the wounded can't be pulled behind your lines to safety - they have to run along with everyone else.  Elevated heart rate and the inability to do anything about injuries (because you're running) is a sure formula for a fatality.  However, it goes both ways - caution on the winning side will also keep them in the battle longer, and therefore prevent their wounded from getting proper care as well.

I was very much figuring that you can't really perform much first aid while people are trying to kill you.  It just doesn't really work that way.  If M&B battles were really large (like, armies of thousands on the field for hours), it would be necessary to set up some kind of "stop fighting and treat injuries" script.  The way they are, I figure that function can be relegated to stuff that happens after the battle ends.

Party skills don't apply unless there is at least one hero character in the party - so the enemy does not generally get surgery skill.  This makes it a pain to take prisoners.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on January 13, 2009, 01:46:25 PM
I added some randomization to the code and updated my post on page three. The bleeding is now calculated (damage-threshold)*random(dmg_low_range,dmg_hi_range)/10 instead of just damage-threshold. dmg_low_range and dmg_hi_range is set to 6 and 12 by default so bleeding range roughly from 60% to 120% of the damage taken. What do you think?

The next thing to fix is stopping agents that bleed out from dying 100% of the time. The only solution I can think of is adding wounded troops to the party after the battle but this might be complicated, especially for multi-party battles. Have you been able to confirm if the surgery skill can stop bleeding agents from dying?

Sadly, there is no way of knowing what kind of damage an agent received. I suppose we could use the agent_get_wielded_item to calculate how many of the enemy agents are using weapons of a certain kind and then calculating the odds of getting hit by e.g. blunt damage. Not a very attractive solution in my opinion.

Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Conners on January 13, 2009, 07:07:35 PM
Would it be possible to replace the last HP(s) of Bleeding Damage with Cut or Pierce Damage? Or perhaps you could actually heal the soldier when they reach 1 or 0 so as to inflict 200 Pierce/Cut damage? That way, the Surgery Skill would kick in as normal, and they have a chance of dying or surviving.

Hope this was helpful.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Ron Losey on January 13, 2009, 08:17:48 PM
Randomization is good.  Good move.

Have not been able to confirm the surgery skill thing ... didn't play it that long.  Been messing with the base RCM code instead, for ASoIaF, among others.

If we can't get them to survive as desired, the game can be balanced around it ... for example, tweaking the loot code so that taking prisoners is not the only way to make money.  So while correcting it is an objective, it is not critical.  Don't do anything really clumsy ... it's not worth it.
Title: Re: Has anyone experimented with a "blood loss" damage model?
Post by: Amarillo on January 15, 2009, 11:21:03 AM
Would it be possible to replace the last HP(s) of Bleeding Damage with Cut or Pierce Damage? Or perhaps you could actually heal the soldier when they reach 1 or 0 so as to inflict 200 Pierce/Cut damage? That way, the Surgery Skill would kick in as normal, and they have a chance of dying or surviving.

Thank you for the input.

I can explain how the blood loss code works. When the agent has accumulated enough "blood points" the hitpoints will be set to a lover value using agent_set_hit_points. When the hitpoints of the agent reach zero the following happens; nothing. The agent will still be alive until receiving some actual damage. The only way of doing damage through a script is the function agent_deliver_damage_to_agent and for some reason this is very lethal.

I will do some experiments with your idea of adding hitpoints right before the killing blow and see if it helps.