bonusShield is dead! Long live flankingBonus!

bonusShield is dead! Long live flankingBonus!

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply

Did you know about this?

Yes.
6
7%
No.
86
93%
 
Total votes: 92

User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

bonusShield is dead! Long live flankingBonus!

Post by lurker »

Editing for anyone coming along: some of what I said early in the thread is wrong. I assumed it followed the unit, rather than the pile of wtf that is its default mode. The original post:

There is a function at the beginning of calculating damage that gives a bonus to flanking. If you attack from the front, an attack does 90% damage, and damage increases as you move around, 140% at the sides, and 190% in back. (It's a little more complicated, with the direction of least damage being able to change if you haven't been attacked in a while, so an attack from the right could make the left the sweet spot.)
This function is alone in Unit.cpp and Unit.h, and no other files make any reference to its variables. It's hardcoded to do this, and my searching has not found any reference on the entire spring site. It's not mentioned in any changelogs, and it's not tied to a single tag.
<tombom> haha
<tombom> it's been there forever
<tombom> all the lines relating to it are revision 2
I've tested it, it works. If you want to see for yourself, have a unit attacked by two units in opposite directions (and don't have it attacked by anything else first). One will do twice the damage.
Near the top of CUnit::DoDamage

Code: Select all

if(attacker){
		SetLastAttacker(attacker);
		float3 adir=attacker->pos-pos;
		adir.Normalize();
		bonusShieldDir+=adir*bonusShieldSaved;		//not the best way to do it(but fast)
		bonusShieldDir.Normalize();
//		logOutput.Print("shield mult %f %f %i %i", 2-adir.dot(bonusShieldDir),bonusShieldSaved,id,attacker->id);
		bonusShieldSaved=0;
		damage*=1.4f-adir.dot(bonusShieldDir)*0.5f;
	}
Last edited by lurker on 16 Nov 2007, 20:46, edited 2 times in total.
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

JESUS TITTY FUCKING CHRIST

:OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO


how the FUCK did anyone not notice this!!

this will revolutionize how people do everything in spring...
Last edited by Dragon45 on 06 Jul 2007, 17:57, edited 1 time in total.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

The "front" is defined as the direction the first shot comes from.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post by lurker »

KDR_11k wrote:The "front" is defined as the direction the first shot comes from.
Yes. I'll explain more.
The variable "bonusShieldSaved" builds up over time, and it is set to a small amount after each attack. The higher "bonusShieldSaved" is, the more the 90% damage direction can move to face incoming attacks. ("bonusShieldSaved" is set to 0 after each attack, so it can only move a lot if there haven't been any attacks in a small while.)
If a unit hasn't been attacked in a while, and you attack from, say, its right, then further shots hitting it on its left side will do extra damage, but the more you attack it in a different direction the more the lessened damage will swing over to face that same way.
Also remember that it is relative to the unit. If a tough units comes to attack your base, and gets hit on one side, then turns to retreat, attacks coming from that same attacker will now do double damage.
Also, it's not where the attack hits, it's where the attacker is. A missile hitting the back of the unit when the attacker is in front will be calculated as a frontal blow.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

This isn't important in spaem gaetor scenarios, but exploiting this would be huge in micro-heavy mods with small amounts of units in play (something like CA Tactics, for example.)
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

It's also important for spaem gater, it means you should surround your enemies.
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Post by BrainDamage »

what about gunships who circles around targets? don't they get too much rewarded?
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post by Neddie »

Brain Damage wrote:what about gunships who circles around targets? don't they get too much rewarded?
Hence why some will have that tag to remain in place.
User avatar
Zpock
Posts: 1218
Joined: 16 Sep 2004, 23:20

Post by Zpock »

I don't get it, has this been on all the time as hardcoded standard stuff? Or is there a tag you can turn on/off to use this?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Seems to be mandatory hardcoded crap.
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post by Neddie »

I just realized that this will make my traditional flanking tactics so much more useful.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post by lurker »

neddiedrow wrote:I just realized that this will make my traditional flanking tactics so much more useful.
Will? It's been there for a long, long time.
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post by Neddie »

Then this explains why Spring is the first RTS engine where flanking has ever offered me any real benefit.
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Post by BrainDamage »

also explains why bombers gets pwned when they get pasts defences/attacking target making the bombing missions almost always kamikaze
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post by Neddie »

Brain Damage wrote:also explains why bombers gets pwned when they get pasts defences/attacking target making the bombing missions almost always kamikaze
Yes, yes it does.

And Micromanagement of Banshees has a benefit! Keep them around the same area, they'll deal more or less depending on where the first shots of EMG fell.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

so this explains why damage is soo wonky.

so lets say I have a unit, a bunch of shots hit this "front" then when something attacks the other side it takes full damage?

that is asinine!
el_matarife
Posts: 933
Joined: 27 Feb 2006, 02:04

Post by el_matarife »

I'm just guessing all this code came from SJ's 19th century RTS Spring was initially based on. Still, it is absolutely mindblowing that 3000+ revisions of the codebase later we just now found this. Anyone want to get in touch with SJ and ask him if there's any other skeletons in the closet we should know about?
Archangel of Death
Posts: 854
Joined: 28 Jan 2005, 18:15

Post by Archangel of Death »

Woah :shock: Mixing this with the damage stuff we were working on would have made for some interesting results.
User avatar
jackalope
Posts: 694
Joined: 18 Jun 2006, 22:43

Post by jackalope »

lol @ spring
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

Does the angle 'swung' around depend on the damage dealt? judging from a quick scan of the code snippet it does...

quick note: this may mean, that, after an assault that has hit the back of your defensive line, it may be advantageous to force-fire at and repair your own defensive line, but from the front, to 'reset' the bonus shield area.
Post Reply

Return to “Engine”