Page MenuHomeWildfire Games

Allow to apply techs to bonuses
Needs ReviewPublic

Authored by Stan on Fri, Mar 1, 11:13 AM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

Currently you can't change bonuses during the game, like making infantry two times more effective just against cavalry. You can only double their attack which is different. With this patch you can now do that.

In the technology add

	"modifications": [{"value": "Attack/{ATTACK_TYPE}/Bonuses/{BONUS_NAME}/Multiplier", "add": 1.0},
Test Plan

Check that everything works as expected and that it is the best way to do it.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 6940
Build 11359: Vulcan BuildJenkins

Event Timeline

Stan created this revision.Fri, Mar 1, 11:13 AM
Vulcan added a subscriber: Vulcan.Fri, Mar 1, 11:17 AM

Build failure - The Moirai have given mortals hearts that can endure.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|  23|  23| 	let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
|  24|  24| 	let turnLength = cmpTimer.GetLatestTurnLength();
|  25|  25| 	return new Vector3D(
|  26|    |-			(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|    |  26|+		(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|  27|  27| 			0,
|  28|  28| 			(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|  29|  29| };
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|  24|  24| 	let turnLength = cmpTimer.GetLatestTurnLength();
|  25|  25| 	return new Vector3D(
|  26|  26| 			(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|  27|    |-			0,
|    |  27|+		0,
|  28|  28| 			(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|  29|  29| };
|  30|  30| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|  25|  25| 	return new Vector3D(
|  26|  26| 			(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|  27|  27| 			0,
|  28|    |-			(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|    |  28|+		(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|  29|  29| };
|  30|  30| 
|  31|  31| /**
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
| 111| 111| 
| 112| 112| 	// Do this first in case the direct hit kills the target
| 113| 113| 	if (data.isSplash)
| 114|    |-	{
|    | 114|+	
| 115| 115| 		this.CauseSplashDamage({
| 116| 116| 			"attacker": data.attacker,
| 117| 117| 			"origin": Vector2D.from3D(data.position),
| 124| 124| 			"type": data.type,
| 125| 125| 			"attackerOwner": data.attackerOwner
| 126| 126| 		});
| 127|    |-	}
|    | 127|+	
| 128| 128| 
| 129| 129| 	let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager);
| 130| 130| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
| 212| 212| 				damageMultiplier = 0;
| 213| 213| 		}
| 214| 214| 		else // In case someone calls this function with an invalid shape.
| 215|    |-		{
|    | 215|+		
| 216| 216| 			warn("The " + data.shape + " splash damage shape is not implemented!");
| 217|    |-		}
|    | 217|+		
| 218| 218| 
| 219| 219| 		if (data.splashBonus)
| 220| 220| 			damageMultiplier *= GetDamageBonus(ent, data.splashBonus, data.type, data.attacker);
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
| 495| 495| 
| 496| 496| 		let horizSpeed = +this.template[type].ProjectileSpeed;
| 497| 497| 		let gravity = +this.template[type].Gravity;
| 498|    |-		//horizSpeed /= 2; gravity /= 2; // slow it down for testing
|    | 498|+		// horizSpeed /= 2; gravity /= 2; // slow it down for testing
| 499| 499| 
| 500| 500| 		let cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
| 501| 501| 		if (!cmpPosition || !cmpPosition.IsInWorld())
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
| 544| 544| 		let launchPoint = selfPosition.clone();
| 545| 545| 		// TODO: remove this when all the ranged unit templates are updated with Projectile/Launchpoint
| 546| 546| 		launchPoint.y += 3;
| 547|    |-		
|    | 547|+
| 548| 548| 		let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
| 549| 549| 		if (cmpVisual)
| 550| 550| 		{
|    | [NORMAL] ESLintBear (no-multi-spaces):
|    | Multiple spaces found before 'GetDamageBonus'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
| 594| 594| 		if (attackerOwner == INVALID_PLAYER)
| 595| 595| 			return;
| 596| 596| 
| 597|    |-		let multiplier =  GetDamageBonus(target, this.GetBonusTemplate(type), type, this.entity);
|    | 597|+		let multiplier = GetDamageBonus(target, this.GetBonusTemplate(type), type, this.entity);
| 598| 598| 		let cmpHealth = Engine.QueryInterface(target, IID_Health);
| 599| 599| 		if (!cmpHealth || cmpHealth.GetHitpoints() == 0)
| 600| 600| 			return;
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
| 615| 615| 			});
| 616| 616| 	}
| 617| 617| 	else
| 618|    |-	{
|    | 618|+	
| 619| 619| 		// Melee attack - hurt the target immediately
| 620| 620| 		cmpDamage.CauseDamage({
| 621| 621| 			"strengths": this.GetAttackStrengths(type),
| 625| 625| 			"type": type,
| 626| 626| 			"attackerOwner": attackerOwner
| 627| 627| 		});
| 628|    |-	}
|    | 628|+	
| 629| 629| };
| 630| 630| 
| 631| 631| /**

binaries/data/mods/public/simulation/components/Attack.js
| 485| ·»   let·cmpDamage·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_Damage);
|    | [NORMAL] ESLintBear (no-mixed-spaces-and-tabs):
|    | Mixed spaces and tabs.

binaries/data/mods/public/simulation/components/Attack.js
| 590| »   »   cmpTimer.SetTimeout(SYSTEM_ENTITY,·IID_Damage,·"MissileHit",·timeToTarget·*·1000·+·+this.template.Ranged.Delay,·data);
|    | [NORMAL] JSHintBear:
|    | Confusing plusses.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1072/display/redirect

Stan updated this revision to Diff 7508.Fri, Mar 1, 2:57 PM
  • Fix typo (multiplier was run twice)
  • Fix whitespace.
Vulcan added a comment.Fri, Mar 1, 2:58 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|  23|  23| 	let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
|  24|  24| 	let turnLength = cmpTimer.GetLatestTurnLength();
|  25|  25| 	return new Vector3D(
|  26|    |-			(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|    |  26|+		(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|  27|  27| 			0,
|  28|  28| 			(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|  29|  29| };
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|  24|  24| 	let turnLength = cmpTimer.GetLatestTurnLength();
|  25|  25| 	return new Vector3D(
|  26|  26| 			(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|  27|    |-			0,
|    |  27|+		0,
|  28|  28| 			(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|  29|  29| };
|  30|  30| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|  25|  25| 	return new Vector3D(
|  26|  26| 			(curPos.x * (turnLength - lateness) + prevPos.x * lateness) / turnLength,
|  27|  27| 			0,
|  28|    |-			(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|    |  28|+		(curPos.z * (turnLength - lateness) + prevPos.z * lateness) / turnLength);
|  29|  29| };
|  30|  30| 
|  31|  31| /**
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'if' condition.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
| 111| 111| 
| 112| 112| 	// Do this first in case the direct hit kills the target
| 113| 113| 	if (data.isSplash)
| 114|    |-	{
|    | 114|+	
| 115| 115| 		this.CauseSplashDamage({
| 116| 116| 			"attacker": data.attacker,
| 117| 117| 			"origin": Vector2D.from3D(data.position),
| 124| 124| 			"type": data.type,
| 125| 125| 			"attackerOwner": data.attackerOwner
| 126| 126| 		});
| 127|    |-	}
|    | 127|+	
| 128| 128| 
| 129| 129| 	let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager);
| 130| 130| 
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Damage.js
| 212| 212| 				damageMultiplier = 0;
| 213| 213| 		}
| 214| 214| 		else // In case someone calls this function with an invalid shape.
| 215|    |-		{
|    | 215|+		
| 216| 216| 			warn("The " + data.shape + " splash damage shape is not implemented!");
| 217|    |-		}
|    | 217|+		
| 218| 218| 
| 219| 219| 		if (data.splashBonus)
| 220| 220| 			damageMultiplier *= GetDamageBonus(ent, data.splashBonus, data.type, data.attacker);
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
| 495| 495| 
| 496| 496| 		let horizSpeed = +this.template[type].ProjectileSpeed;
| 497| 497| 		let gravity = +this.template[type].Gravity;
| 498|    |-		//horizSpeed /= 2; gravity /= 2; // slow it down for testing
|    | 498|+		// horizSpeed /= 2; gravity /= 2; // slow it down for testing
| 499| 499| 
| 500| 500| 		let cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
| 501| 501| 		if (!cmpPosition || !cmpPosition.IsInWorld())
|    | [NORMAL] ESLintBear (no-trailing-spaces):
|    | Trailing spaces not allowed.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
| 544| 544| 		let launchPoint = selfPosition.clone();
| 545| 545| 		// TODO: remove this when all the ranged unit templates are updated with Projectile/Launchpoint
| 546| 546| 		launchPoint.y += 3;
| 547|    |-		
|    | 547|+
| 548| 548| 		let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
| 549| 549| 		if (cmpVisual)
| 550| 550| 		{
|    | [NORMAL] ESLintBear (curly):
|    | Unnecessary { after 'else'.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Attack.js
| 615| 615| 			});
| 616| 616| 	}
| 617| 617| 	else
| 618|    |-	{
|    | 618|+	
| 619| 619| 		// Melee attack - hurt the target immediately
| 620| 620| 		cmpDamage.CauseDamage({
| 621| 621| 			"strengths": this.GetAttackStrengths(type),
| 625| 625| 			"type": type,
| 626| 626| 			"attackerOwner": attackerOwner
| 627| 627| 		});
| 628|    |-	}
|    | 628|+	
| 629| 629| };
| 630| 630| 
| 631| 631| /**

binaries/data/mods/public/simulation/components/Attack.js
| 485| ·»   let·cmpDamage·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_Damage);
|    | [NORMAL] ESLintBear (no-mixed-spaces-and-tabs):
|    | Mixed spaces and tabs.

binaries/data/mods/public/simulation/components/Attack.js
| 590| »   »   cmpTimer.SetTimeout(SYSTEM_ENTITY,·IID_Damage,·"MissileHit",·timeToTarget·*·1000·+·+this.template.Ranged.Delay,·data);
|    | [NORMAL] JSHintBear:
|    | Confusing plusses.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1073/display/redirect

Imarok added a subscriber: Imarok.Sun, Mar 3, 11:51 AM

Sorry to ask, but does this need petra support?

Stan added a comment.Sun, Mar 3, 12:41 PM

That's a good question. I guess it uses the same functions as everyone else but it deserve to be checked.