Jump to content
The Dark Mod Forums

Damage Stims


Springheel

Recommended Posts

What variables determine how much damage a damage stim does? Is it sr_magnitude? Currently I have that set to 20, and it causes instant death. Changing it to 10 doesn't seem to change anything, however.

Link to comment
Share on other sites

What variables determine how much damage a damage stim does? Is it sr_magnitude? Currently I have that set to 20, and it causes instant death. Changing it to 10 doesn't seem to change anything, however.

The actual damage depends on distance, the stim's magnitude, the "damage" value in the damage def and the fire interval of the stim.

 

It works like this (wow, it's been a while since I set that up):

 

An entity has a STIM_DAMAGE with a magnitude of 100 and a linear falloff (1). The further you're away from the stim origin, the smaller the magnitude gets.

 

Once an entity with a response to STIM_DAMAGE comes into range and the stim fires, the magnitude is passed on to the response entity. The response entity needs to have a response effect defined for the DAMAGE stim, which tells the code which damage entityDef (e.g. atdm:damage_simple) it should use and which entity should be damaged (this should be _SELF by default).

 

So, an example response setup can be found on the player:

 

// The damage response

"sr_class_3" "R"

"sr_type_3" "STIM_DAMAGE"

"sr_state_3" "1"

"sr_effect_3_1" "effect_damage"

"sr_effect_3_1_arg1" "_SELF"

"sr_effect_3_1_arg2" "atdm:damage_simple"

 

As soon as the player comes into the range of a damage stim, the distance-based magnitude is passed over and the code multiplies this magnitude with the "damage" value defined in atdm:damage_simple. E.g. if a magnitude of 30 is passed, the atdm:damage_simple's value of 10 ends up at 300 => insta-death.

 

If you want to have a constant magnitude which is not depending on the distance, you need to define a 0 falloff on the stim.

  • Like 1
Link to comment
Share on other sites

Ok, thanks for the thorough info. :) I'll add that to the wiki as well.

 

I've got a pretty cool ball and chain trap almost done. There's an md5mesh chain that moves quite believably with a spiked ball bound to the end of it. The ball has a damage stim, and it's also a movable, so the player can actually frob the ball, pull it backwards and let go, sending the ball swinging the other way--and you can even use that technique to catch AI in the trap! I just need to adjust the damage so that it doesn't kill you instantly if you bump into it.

Link to comment
Share on other sites

Ok, there are a lot of variables to play around with here. :wacko:

 

What I'd like to do is have a slight falloff of damage, so that a player who edges past the spiked ball might get pricked for a little bit of damage (5 hp), but nothing serious. Someone who collides with the ball will take full damage (50 hp), on the other hand.

 

I'm not even sure that's possible, however. I assume I want a high falloff rate?

 

If I set sr_falloffexponent_1 to 2, that will make the falloff faster, correct?

 

A magnitude of 5 means that the damage will be 5 x "damage_simple" = 50 at the origin of the stim?

Link to comment
Share on other sites

Ok, there are a lot of variables to play around with here. :wacko:

Yes, I went for flexibility and this is often not the same as easy. :)

 

If I set sr_falloffexponent_1 to 2, that will make the falloff faster, correct?

Yes, 1 is a linear falloff, an exponent of 2 will mean quadratic falloff, 3 cubic etc.

 

A magnitude of 5 means that the damage will be 5 x "damage_simple" = 50 at the origin of the stim?

Yes.

Link to comment
Share on other sites

Yes, 1 is a linear falloff, an exponent of 2 will mean quadratic falloff, 3 cubic etc.

 

For non-math folks, what does that mean exactly? If my radius is 10, and I have a magnitude of 5, would a falloff of 1 mean the magnitude drops by .5 every unit you move away from the origin? And a falloff of 2 would mean it is halved every unit?

 

The values I tried last night resulted in the ball not doing any damage at all. And oddly I could walk right through it. That might be a consequence of being content_corpse, and I didn't notice before because touching it killed me.

Link to comment
Share on other sites

The values I tried last night resulted in the ball not doing any damage at all. And oddly I could walk right through it. That might be a consequence of being content_corpse, and I didn't notice before because touching it killed me.

 

Perhaps this is what you want (in AF code)?

 contents corpse, monsterclip, playerclip
clipMask solid, corpse
selfCollision 0

You might just want to add monsterclip and playerclip contents only to the ball body to see if you'd prefer letting the player jump through the chain.

yay seuss crease touss dome in ouss nose tair

Link to comment
Share on other sites

For non-math folks, what does that mean exactly? If my radius is 10, and I have a magnitude of 5, would a falloff of 1 mean the magnitude drops by .5 every unit you move away from the origin? And a falloff of 2 would mean it is halved every unit?

For a falloff of 1, you're correct. However, a falloff of 2 doesn't make it halve every step; that would be exponential falloff, not quadratic.

 

I haven't checked exactly how the maths is set up, or I'd do a graph.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Here's a quick capture roughly explaining how it appears to work (through experimentation). The X-axis is player's distance from the stim (if falloff distance is set to 10 units). The Y-axis is damage (damage set to 10). You'll probably have to experiment with high low falloff exponents to see what is fair for the player.

 

post-2515-125981416097_thumb.gif

Linear falloff. 2 units away from the stim, and you'll receive 8 damage.

Y=x+10

 

post-2515-125981414874_thumb.gif

Cubic falloff. 2 units away from the stim, and you'll receive ~9.92 damage.

Y= (.01x^3)+10

  • Like 1

yay seuss crease touss dome in ouss nose tair

Link to comment
Share on other sites

No, the second graph is not correct. The formula is like this:

 

magnitude·(1 - dist/radius)^falloff for dist

 

Be the distance to the stim source 20 units and the stim radius 100 units, the factor in the parentheses ends up to be 0.8 (the stim has 80% of its strength to start, so to say, I call this base). This value is now power'ed by the falloff exponent. A quadratic falloff (2) results in 0.8·0.8 which is smaller than 0.8, hence the magnitude is diminishing faster with increasing distance. The code makes sure that (1-dist/radius) is always in [0..1] so the magnitude can only decrease from its maximum value defined on the stim.

 

For quadratic falloff, the curve will look like a children's slide, it starts steep and becomes more horizontal the further you're away from the stim.

 

Here's the actual code:

// Calculate the magnitude of the stim based on the distance and the falloff model
magnitude = stim->m_Magnitude;
float distance = (owner->GetPhysics()->GetOrigin() - sourceEntity->GetPhysics()->GetOrigin()).LengthFast();

using std::min;
float base = 1 - min(stim->m_Radius, distance) / stim->m_Radius;

// Calculate the falloff value (the magnitude is between [0, magnitude] for positive falloff exponents)
magnitude *= pow(base, stim->m_FallOffExponent);

  • Like 1
Link to comment
Share on other sites

Been busy making a new zombie (and moving the entire contents of my office) but I did get back to play with this briefly. I have changed the radius so that it uses only the bounds of the spiked ball, which means the player can get realistically close to it without getting damaged. However, even when I set the magnitude to 5 (with 0 falloff) it still kills the player instantly on touch. Shouldn't it be doing only 50 damage at that point? Or is that 50 HP every frame the player stays in contact with the stim?

 

I recall seeing something about staggering the stim firing...is that what I need to do here? But I don't want the player to be able to touch the ball without getting hurt, if the ball were to swing in between firings, for example.

 

here it is:

sr_time_interval_N When this stim is active, the firings will be spread out by this many milliseconds. So a stim with sr_time_interval = 500 will fire every half second when active. Used for optimization for stims that don't have to be checked that often.

 

Is there a spawnarg that can basically say, "once stim is received, wait x until new stim can be received"? Or does that have to go on the response?

Link to comment
Share on other sites

I don't think the stim settings themselves 'know' if the stim is 'responded to' so they just keep firing blind. So yes, probably something on the response.

 

Mmm... from memory there is a response effect that can turn a stim

on and off on a named entity. So you could have a response with say 3 effects:

 

1. To do whatever response effect you actually want.

2. To turn off the stim

3. To trigger some kind of timer that eventually turns the stim on again. (there may be an another entity to turn stims on and off I'm unsure.)

Link to comment
Share on other sites

I don't think the stim settings themselves 'know' if the stim is 'responded to' so they just keep firing blind. So yes, probably something on the response.

 

Mmm... from memory there is a response effect that can turn a stim

on and off on a named entity. So you could have a response with say 3 effects:

 

1. To do whatever response effect you actually want.

2. To turn off the stim

3. To trigger some kind of timer that eventually turns the stim on again. (there may be an another entity to turn stims on and off I'm unsure.)

 

I think it would be easier (and probably less resource intensiv) to add code support for a response to block itself for X ms after it has fired. (The stim doesn't know which response it effects, it could be a completely different object).

 

As for the spikey ball, wouldn't it be much better if the impulse did hurt the player? That way you can f.i. brush past the hanging ball, but being hit by it would hurt. A S+R system always is artificially creating damage even when the ball doesn't move.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

As for the spikey ball, wouldn't it be much better if the impulse did hurt the player?

 

It would be nice if the impulse had some effect in damage (though brushing up against a spiked ball would certainly hurt). That doesn't seem possible with S/R, however, unless I've missed something.

Link to comment
Share on other sites

It would be nice if the impulse had some effect in damage (though brushing up against a spiked ball would certainly hurt). That doesn't seem possible with S/R, however, unless I've missed something.

 

If the ball is a moveable, then it should be possible to trigger a damage upon impact, or run a script, which does the damage.

 

I am a bit unsure atm how that works, but for instance the arrow hitting the bottles breaks them by imparting an impulse, so the ball could hurt the player (and smash bottles etc).

 

Maybe looking at the arrow entity def would make it more clear?

 

Edit:

Ah, I knew I implemented that already :D

 

http://bloodgate.com/mirrors/tdm/pub/doc/#spawnarg-script_collide

 

The script will be called only every 0.5 seconds (I think, or it is 0.2 or 0.3 seconds, but it definitely only happens a few times a second. Currently you cannot change the time AFAIK, but that could be easily coded in as a new spawnarg).

 

So, basically making a script that hurts the entity that is impacted, and then referencing it in that spawnarg should be enough.

 

I can help you with the script if you want.

 

Edit 2: The script is called at maximum every 300ms. You can set a counter that says called it "X" times (e.g. 1, or 10, or so) or indefinitely often, but in any case it will wait 300ms between each call. Also, the minimum velocity is 5, so brushing against it won't do damage.

 

The script can then scale the damage linar with the speed or whatever.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Hmm, sounds promising. Just browsing atm, but I'll look into this more tonight.

Link to comment
Share on other sites

Hmm, sounds promising. Just browsing atm, but I'll look into this more tonight.

 

I have looked at the C++ code and the script call does not get the entity that is damaged (e.g. the script is called with only one parameter, namely the entity that is the one colliding). So if your script hurts the player, that would only work if the ball collides with the player, if it collides with anything else, it would still hurt the player - oops.

 

Need to revise that code.

 

As for the damage stim, the code says:

 

   if ( canDamage && damage.Length() && gameLocal.time > nextDamageTime )
   {
       if ( ent && v > minDamageVelocity )
       {
           float f = v > maxDamageVelocity ? 1.0f : idMath::Sqrt( v - minDamageVelocity ) * ( 1.0f / idMath::Sqrt( maxDamageVelocity - minDamageVelocity ) );
           idVec3 dir = velocity;
           dir.NormalizeFast();
           ent->Damage( this, GetPhysics()->GetClipModel()->GetOwner(), dir, damage, f, CLIPMODEL_ID_TO_JOINT_HANDLE(collision.c.id), const_cast<trace_t *>(&collision) );
           nextDamageTime = gameLocal.time + 1000;
       }
   }

 

So have you tried simply a "damage" spawnarg on the ball, not using a stim at all? The code above means that damage is applied once a second, so unless the player is touching the ball longer, it would only hurt him once.

 

(Sorry if you already tried that, I didn't read the entire thread)

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

 

 

So have you tried simply a "damage" spawnarg on the ball, not using a stim at all? The code above means that damage is applied once a second, so unless the player is touching the ball longer, it would only hurt him once.

 

 

 

Just tried it, but it appeared to have no effect. The ball just went right through me without doing damage. It didn't appear to damage the AI either.

Link to comment
Share on other sites

Just tried it, but it appeared to have no effect. The ball just went right through me without doing damage. It didn't appear to damage the AI either.

 

Ah, that would of course only happen if the ball collides with the player or the AI. If you set it non-solid (why?), then it won't collide, so it won't trigger a script or do damage :)

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

I didn't set it to nonsolid; it's a consequence of being bound to a ragdoll, I believe. I'll see if I can adjust it.

Link to comment
Share on other sites

I didn't set it to nonsolid; it's a consequence of being bound to a ragdoll, I believe. I'll see if I can adjust it.

 

Ah, shoot, yes, things bound to anything don't collide. I did run into the same problem with the candle flames, only the candle (or the holder) collides with things... (I hate the D3 physics hacks already, so many limitations in every direction *sigh*)

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Hmm, this sounds like what I want if the corpse_ragdoll can be removed. http://wiki.thedarkmod.com/index.php?title=Making_Moveables_Damage_Things

 

I'll have to test it once I get my development rig back.

Link to comment
Share on other sites

Hmm, this sounds like what I want if the corpse_ragdoll can be removed. http://wiki.thedarkmod.com/index.php?title=Making_Moveables_Damage_Things

 

I'll have to test it once I get my development rig back.

 

I think the problem here is essentially that if you have your ball bound to *something*, it will never collide, only the bindmaster will do, so the above won't be triggered. (Which I wrote about in my last post).

 

Workarounds:

 

* make the ball the bindmaster, and bind the chain to it (possible?)

* make the ball "stuck" to a pipe (e.g. create a swinging "halberd") instead of a ball-on-a-chain. This way you only have one rotating object. Not as cool, tho :(

* Throw away D3's idea of a broken physics engine and implement a real one, which can realistically simulate collisions with contraints and bound objects.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

I've gotten this mostly working by setting the stim to fire every second. It's not totally satisfying, however, since the ball can actually swing through the player in less than a second, so he could technically escape damage.

 

I'd like to do the following:

 

Mmm... from memory there is a response effect that can turn a stim

on and off on a named entity. So you could have a response with say 3 effects:

 

1. To do whatever response effect you actually want.

2. To turn off the stim

3. To trigger some kind of timer that eventually turns the stim on again. (there may be an another entity to turn stims on and off I'm unsure.)

 

I tried adding:

 

"sr_timer_type_1" "reload"

"sr_timer_time_1" "0:0:1:0"

 

and I thought that would basically mean that when the stim fires, turn it off for 1 second, then turn it on it again. But now I'm back to the player dying instantly, which means it must be firing continuously. What am I missing?

Link to comment
Share on other sites

I've gotten this mostly working by setting the stim to fire every second. The player now only takes a little damage on impact, rather than dying instantly.

 

It's not totally satisfying, however, since the ball can actually swing through the player in less than a second, so he sometimes escapes damage even after being hit.

 

I'd like to do the following:

 

Mmm... from memory there is a response effect that can turn a stim

on and off on a named entity. So you could have a response with say 3 effects:

 

1. To do whatever response effect you actually want.

2. To turn off the stim

3. To trigger some kind of timer that eventually turns the stim on again. (there may be an another entity to turn stims on and off I'm unsure.)

 

I tried adding:

 

"sr_timer_type_1" "reload"

"sr_timer_time_1" "1000"

 

and I thought that would basically mean that when the stim fires, turn it off for 1 second, then activate it again. But now I'm back to the player dying instantly on contact, which means it must be firing continuously. What am I missing?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 3 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
×
×
  • Create New...