Page MenuHomeWildfire Games

Allow to play different sounds based on what attacked you
ClosedPublic

Authored by Stan on Jul 3 2020, 1:59 PM.

Details

Reviewers
bb
Freagarach
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP23989: Allow to play different sounds based on what attacked you
Summary

Currently whether it's gaia, or a vain attempt to capture your building you can't tell the difference.

TODO: Maybe a bit better sound for gaia, and a new one for capture.

Test Plan

Make sure that when gaia attacks you, you get a different sound

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Stan created this revision.Jul 3 2020, 1:59 PM
Vulcan added a comment.Jul 3 2020, 2:04 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|  39|  39| 	this.ActivateTimer();
|  40|  40| };
|  41|  41| 
|  42|    |-//// Message handlers ////
|    |  42|+// // Message handlers ////
|  43|  43| 
|  44|  44| AttackDetection.prototype.OnGlobalAttacked = function(msg)
|  45|  45| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|  53|  53| 	this.AttackAlert(msg.target, msg.attacker, msg.type, msg.attackerOwner);
|  54|  54| };
|  55|  55| 
|  56|    |-//// External interface ////
|    |  56|+// // External interface ////
|  57|  57| 
|  58|  58| AttackDetection.prototype.AttackAlert = function(target, attacker, type, attackerOwner)
|  59|  59| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '||' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
| 103| 103| 		isPriorityIncreased = element.targetIsDomesticAnimal && !targetIsDomesticAnimal;
| 104| 104| 		var isPriorityDescreased = !element.targetIsDomesticAnimal && targetIsDomesticAnimal;
| 105| 105| 
| 106|    |-		if (isPriorityIncreased
| 107|    |-		    || (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))
|    | 106|+		if (isPriorityIncreased ||
|    | 107|+		    (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))
| 108| 108| 			this.UpdateSuppressionEvent(i, event);
| 109| 109| 
| 110| 110| 		// If priority has increased, exit the loop to send the upgraded notification below

binaries/data/mods/public/simulation/components/AttackDetection.js
| 107| »   »   ····||·(!isPriorityDescreased·&&·dist·<·this.suppressionTransferRangeSquared))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2576/display/redirect

Freagarach added inline comments.Jul 6 2020, 12:32 PM
binaries/data/mods/public/simulation/components/AttackDetection.js
133–134 ↗(On Diff #12536)

I don't like the hardcoding of capture here.
Perhaps have a list of implemented types, convert the type to _lowercase and default to attacked?

let soundGroup = "attacked";
if (type in AttackDetection.prototype.SupportedTypes)
  soundGroup += "_" + type.toLowerCase();
wraitii added inline comments.
binaries/data/mods/public/simulation/components/AttackDetection.js
133–134 ↗(On Diff #12536)

You could define the sound in the attack_effects global script.

Stan updated this revision to Diff 12677.Jul 14 2020, 5:16 PM
Stan marked 2 inline comments as done.

Hardcode global instead

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/globalscripts/AttackEffects.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/globalscripts/AttackEffects.js
|  18|  18| 	"Capture": {
|  19|  19| 		"sound": "attacked_capture"
|  20|  20| 	}
|  21|    |-}
|    |  21|+};

binaries/data/mods/public/globalscripts/AttackEffects.js
|  21| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|  39|  39| 	this.ActivateTimer();
|  40|  40| };
|  41|  41| 
|  42|    |-//// Message handlers ////
|    |  42|+// // Message handlers ////
|  43|  43| 
|  44|  44| AttackDetection.prototype.OnGlobalAttacked = function(msg)
|  45|  45| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|  53|  53| 	this.AttackAlert(msg.target, msg.attacker, msg.type, msg.attackerOwner);
|  54|  54| };
|  55|  55| 
|  56|    |-//// External interface ////
|    |  56|+// // External interface ////
|  57|  57| 
|  58|  58| AttackDetection.prototype.AttackAlert = function(target, attacker, type, attackerOwner)
|  59|  59| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '||' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
| 103| 103| 		isPriorityIncreased = element.targetIsDomesticAnimal && !targetIsDomesticAnimal;
| 104| 104| 		var isPriorityDescreased = !element.targetIsDomesticAnimal && targetIsDomesticAnimal;
| 105| 105| 
| 106|    |-		if (isPriorityIncreased
| 107|    |-		    || (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))
|    | 106|+		if (isPriorityIncreased ||
|    | 107|+		    (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))
| 108| 108| 			this.UpdateSuppressionEvent(i, event);
| 109| 109| 
| 110| 110| 		// If priority has increased, exit the loop to send the upgraded notification below

binaries/data/mods/public/simulation/components/AttackDetection.js
| 107| »   »   ····||·(!isPriorityDescreased·&&·dist·<·this.suppressionTransferRangeSquared))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2644/display/redirect

Freagarach added inline comments.Jul 15 2020, 6:14 PM
binaries/data/mods/public/globalscripts/AttackEffects.js
19 ↗(On Diff #12677)

Can this be in g_EffectsReceiver?

Stan updated this revision to Diff 12920.Jul 25 2020, 2:53 PM

Address inline, fix bug.

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|  39|  39| 	this.ActivateTimer();
|  40|  40| };
|  41|  41| 
|  42|    |-//// Message handlers ////
|    |  42|+// // Message handlers ////
|  43|  43| 
|  44|  44| AttackDetection.prototype.OnGlobalAttacked = function(msg)
|  45|  45| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|  53|  53| 	this.AttackAlert(msg.target, msg.attacker, msg.type, msg.attackerOwner);
|  54|  54| };
|  55|  55| 
|  56|    |-//// External interface ////
|    |  56|+// // External interface ////
|  57|  57| 
|  58|  58| AttackDetection.prototype.AttackAlert = function(target, attacker, type, attackerOwner)
|  59|  59| {
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '||' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
| 103| 103| 		isPriorityIncreased = element.targetIsDomesticAnimal && !targetIsDomesticAnimal;
| 104| 104| 		var isPriorityDescreased = !element.targetIsDomesticAnimal && targetIsDomesticAnimal;
| 105| 105| 
| 106|    |-		if (isPriorityIncreased
| 107|    |-		    || (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))
|    | 106|+		if (isPriorityIncreased ||
|    | 107|+		    (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))
| 108| 108| 			this.UpdateSuppressionEvent(i, event);
| 109| 109| 
| 110| 110| 		// If priority has increased, exit the loop to send the upgraded notification below

binaries/data/mods/public/simulation/components/AttackDetection.js
| 107| »   »   ····||·(!isPriorityDescreased·&&·dist·<·this.suppressionTransferRangeSquared))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2781/display/redirect

Freagarach accepted this revision.Aug 4 2020, 5:46 PM
  • Works as intended.
  • Code looks clean.

Do you plan to update the sounds in this diff as well?

binaries/data/mods/public/simulation/components/AttackDetection.js
132 ↗(On Diff #12920)

Any reason why type in instead of g_EffectReceiver[type] &&?

binaries/data/mods/public/simulation/templates/template_structure.xml
138 ↗(On Diff #12920)

I'm not sure whether it should be attacked_capture_gaia or attacked_gaia_capture, but I guess it doesn't matter much ^^

This revision is now accepted and ready to land.Aug 4 2020, 5:46 PM
Stan updated this revision to Diff 13108.Aug 6 2020, 3:48 PM
Stan marked 3 inline comments as done.

Style changes

binaries/data/mods/public/simulation/templates/template_structure.xml
138 ↗(On Diff #12920)

I'm not sure one is better than the other, so I'll leave as is ^^

Vulcan added a comment.Aug 6 2020, 3:54 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
**** ESLintBear (spaced-comment) [Section <empty> | Severity NORMAL] ****
!    ! Expected space or tab after '//' in comment.
[----] /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
[++++] /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
[  42] //// Message handlers ////
[  42] // // Message handlers ////
**** ESLintBear (spaced-comment) [Section <empty> | Severity NORMAL] ****
!    ! Expected space or tab after '//' in comment.
[----] /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
[++++] /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
[  56] //// External interface ////
[  56] // // External interface ////
**** ESLintBear (operator-linebreak) [Section <empty> | Severity NORMAL] ****
!    ! '||' should be placed at the end of the line.
[----] /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
[++++] /zpool0/trunk/binaries/data/mods/public/simulation/components/AttackDetection.js
[ 106] 		if (isPriorityIncreased
[ 107] 		    || (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))
[ 106] 		if (isPriorityIncreased ||
[ 107] 		    (!isPriorityDescreased && dist < this.suppressionTransferRangeSquared))

binaries/data/mods/public/simulation/components/AttackDetection.js
[ 107] »   »   ····||·(!isPriorityDescreased·&&·dist·<·this.suppressionTransferRangeSquared))
**** JSHintBear [Section: JS | Severity: NORMAL] ****
!    ! Misleading line break before '||'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2920/display/redirect

This revision was automatically updated to reflect the committed changes.
Owners added subscribers: Restricted Owners Package, Restricted Owners Package.Aug 21 2020, 12:45 PM