Using HitByWeapon to emulate armor zones?

Using HitByWeapon to emulate armor zones?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Using HitByWeapon to emulate armor zones?

Post by KDR_11k »

Experiments with the counter have shown that most (almost all) of the damage is dealt after HitByWeapon was called, I presume this could be used to set ARMORED depending on the angle of impact so we can have tanks with stronger front armor in mods that want them. Or did everyone but me already know this?

It won't work properly with explosions caused by weapons that didn't hit the unit directly as they don't call HitByWeapon (could be minimized by resetting ARMORED a set amount of time after the impact) and it might break down if a unit takes fire from multiple directions at the same time but it should work well enough I think.

And we really need a dedicated scripting forum, this one seems to be aimed more at mods as a whole.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

Yes it is possible

It is extrmely CPU intensive. In TA it was one of the most expewnsive functions you could use; I dont suspect that SPring will bew any different.
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

Spring doesn't report the angle of the hit in HitByWeapon IIRC, unless they've fixed that recently.

Nemo had a plan for armor zones involving shields a while back, I'll let him elaborate on it if he wants...
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Hm, no, doesn't seem fixed. Damn.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

sounds like something that shouldn't be hitbyweaponangle but hitbyweaponsector...where sectors are front/back/side/side/top/bottom. or just a very inaccurate calculation, assuming you can perform a simplified version without using the exact one...noone would ever want to use angles beyond very simple implementations i'd have thought.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Well, yes, but we're still stuck with hitspheres, with those you can't really test for hit areas.

I think the shield idea might work. You mean adding a shield that only extends past the hit sphere slightly in front of the unit, right? I hope projectile collision handling is accurate enough, that wouldn't work if the projectile can only detonate every n pixels (such behaviour happens with fast shots hitting the ground) and would often end up inside the hit sphere before exploding.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

sounds like something that shouldn't be hitbyweaponangle but hitbyweaponsector...where sectors are front/back/side/side/top/bottom. or just a very inaccurate calculation, assuming you can perform a simplified version without using the exact one...noone would ever want to use angles beyond very simple implementations i'd have thought.
Actually... here's how you can do it...

Use rockunit.h's calculation of the hit... the inverse of the angle generated during rockunit's calculation is your hit angle.

However... there are two problems with all this:

1. You can only do this RETROACTIVELY. Scripts do NOT take precedence of sim-time events such as damage application.

2. Because most hits are actually area-effects being applied, I doubt if this solution would be at all accurate.
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Post by Caydr »

I am totally hip to the max excited about this "Using HitByWeapon to emulate armor zones" mod. When is it going to be released? Do you have any screenshots? It sounds totally wild.
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

I GOT AN IDEA! This would be awesome, my infantry with small arms, can't hurt tanks from the front, but get em slightly okay from the back, better than 0 damage :mrgreen:
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

RETROACTIVE means that it will only change the ARMORED state from TRUE to FALSE ... after the damage has been applied to the unit.
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

After :( Another idea, weapons that weaken armor!
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Argh: Yes but it gets called on the first frame of damage and the expanding explosions mean that the bulk of the damage is dealt on a later frame. Letting the counter display its HEALTH value when HitByWeapon is called makes it show the health it had before it got hit.

RockUnit simply reads the values given to HitByWeapon, the counter displays 0 for them when getting hit.

Sniper: Impossible, there's no way to tell what just hit you.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

@KDR_11k: Hmm. You may be able to trigger a TRUE event from HitByWeapon then... that might make it work OK.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Hm, using shields won't work, the projectiles won't explode on the shield but at the position they have the frame before or after (no idea which) so the damage ends up distributed pretty randomly.
Egarwaen
Posts: 1207
Joined: 27 Feb 2006, 21:19

Post by Egarwaen »

May I offer an alternative suggestion for getting a similar effect (units are easier to kill from behind) with (possibly) less fuss?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Sure.
Egarwaen
Posts: 1207
Joined: 27 Feb 2006, 21:19

Post by Egarwaen »

Turret speed/aiming speed. If the unit can't effectively engage things behind it, it'll take more damage from them because it'll take longer to kill them. For some units, making them simply unable to engage targets behind them might work, especially if they have a slow turn rate. For others, if you can reduce the turret aiming speed against a target in the rear arc, it would have a similar effect.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

I hope I can avoid doing that. The point is to have e.g. infantry kill the tank in one shot when approaching from the side but not from the front. Now the question is if I should assume front or side armor for all hits.

Using beam lasers makes the shields stop the damage, unfortunately they'll stop all of it instead of merely reducing it. I think I'll use those with limited capacity shields for now.
Post Reply

Return to “Game Development”