From d733199088e67ed0e0c7544d346810446fb969c2 Mon Sep 17 00:00:00 2001 From: stupidnewbie <55667763+stupidnewbie@users.noreply.github.com> Date: Wed, 4 May 2022 19:18:42 -0400 Subject: [PATCH 1/7] add ambush functions to ship --- src/lib/Default/AbstractSmrShip.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib/Default/AbstractSmrShip.php b/src/lib/Default/AbstractSmrShip.php index bedbb8ffa..24be9604c 100644 --- a/src/lib/Default/AbstractSmrShip.php +++ b/src/lib/Default/AbstractSmrShip.php @@ -34,6 +34,7 @@ class AbstractSmrShip { protected array $hardware = []; protected bool $isCloaked = false; protected array|false $illusionShip = false; + protected bool $ambush = false; protected bool $hasChangedWeapons = false; protected bool $hasChangedCargo = false; @@ -367,6 +368,27 @@ public function getIllusionAttack(): int { public function getIllusionDefense(): int { return $this->getIllusionShip()['Defense']; } + + /** + * returns whether or not an ambush bonus is active + */ + public function getAmbush() : bool { + return $ambush; + } + + /** + * sets ambush bonus firing out of cloak + */ + public function setAmbush() : void { + $ambush = true; + } + + /** + * clears ambush bonus after shot out of cloak + */ + public function clearAmbush() : void { + $ambush = false; + } public function getPlayer(): AbstractSmrPlayer { return $this->player; From 8093850e57954f6c17feee3750611e6b0e7f90c4 Mon Sep 17 00:00:00 2001 From: stupidnewbie <55667763+stupidnewbie@users.noreply.github.com> Date: Wed, 4 May 2022 19:21:18 -0400 Subject: [PATCH 2/7] flag ambush on decloak shot, remove flag at end of shot --- src/engine/Default/trader_attack_processing.php | 5 ++++- src/lib/Default/AbstractSmrShip.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/Default/trader_attack_processing.php b/src/engine/Default/trader_attack_processing.php index a97a92e3a..dc76f491d 100644 --- a/src/engine/Default/trader_attack_processing.php +++ b/src/engine/Default/trader_attack_processing.php @@ -47,7 +47,10 @@ //decloak all fighters foreach ($fightingPlayers as $teamPlayers) { foreach ($teamPlayers as $teamPlayer) { - $teamPlayer->getShip()->decloak(); + if ($teamPlayer->getShip()->isCloaked()) { + $teamPlayer->getShip()->setAmbush(); + $teamPlayer->getShip()->decloak(); + } } } diff --git a/src/lib/Default/AbstractSmrShip.php b/src/lib/Default/AbstractSmrShip.php index 24be9604c..3b5cfef16 100644 --- a/src/lib/Default/AbstractSmrShip.php +++ b/src/lib/Default/AbstractSmrShip.php @@ -783,6 +783,7 @@ public function shootPlayers(array $targetPlayers): array { $results['Drones'] = $thisCDs->shootPlayer($thisPlayer, array_rand_value($targetPlayers)); $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; } + $thisPlayer->getShip()->clearAmbush; $thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLAYER)); $thisPlayer->increaseHOF($results['TotalDamage'], ['Combat', 'Player', 'Damage Done'], HOF_PUBLIC); $thisPlayer->increaseHOF(1, ['Combat', 'Player', 'Shots'], HOF_PUBLIC); From e6b42d2d2523d46873af12e032555c1028f59165 Mon Sep 17 00:00:00 2001 From: stupidnewbie <55667763+stupidnewbie@users.noreply.github.com> Date: Wed, 4 May 2022 19:22:24 -0400 Subject: [PATCH 3/7] boost damage on ambush shot --- src/lib/Default/AbstractSmrCombatWeapon.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/Default/AbstractSmrCombatWeapon.php b/src/lib/Default/AbstractSmrCombatWeapon.php index b44334ee6..437a9da44 100644 --- a/src/lib/Default/AbstractSmrCombatWeapon.php +++ b/src/lib/Default/AbstractSmrCombatWeapon.php @@ -64,6 +64,9 @@ protected function doPlayerDamageToForce(array $return, AbstractSmrPlayer $weapo protected function doPlayerDamageToPlayer(array $return, AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer): array { $return['WeaponDamage'] = $this->getModifiedDamageAgainstPlayer($weaponPlayer, $targetPlayer); + if ($weaponPlayer->getShip()->getAmbush()) { + $return ['WeaponDamage'] *= 1.1; + } $return['ActualDamage'] = $targetPlayer->getShip()->takeDamage($return['WeaponDamage']); if ($return['ActualDamage']['KillingShot']) { From 9108ec1dae3ad51460f6c5f7cd566cca226031d5 Mon Sep 17 00:00:00 2001 From: stupidnewbie <55667763+stupidnewbie@users.noreply.github.com> Date: Wed, 4 May 2022 19:52:44 -0400 Subject: [PATCH 4/7] Update AbstractSmrShip.php fixed typo --- src/lib/Default/AbstractSmrShip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Default/AbstractSmrShip.php b/src/lib/Default/AbstractSmrShip.php index 3b5cfef16..9f281c3a9 100644 --- a/src/lib/Default/AbstractSmrShip.php +++ b/src/lib/Default/AbstractSmrShip.php @@ -783,7 +783,7 @@ public function shootPlayers(array $targetPlayers): array { $results['Drones'] = $thisCDs->shootPlayer($thisPlayer, array_rand_value($targetPlayers)); $results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage']; } - $thisPlayer->getShip()->clearAmbush; + $thisPlayer->getShip()->clearAmbush(); $thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLAYER)); $thisPlayer->increaseHOF($results['TotalDamage'], ['Combat', 'Player', 'Damage Done'], HOF_PUBLIC); $thisPlayer->increaseHOF(1, ['Combat', 'Player', 'Shots'], HOF_PUBLIC); From 77795412c2b625e2fbf53ad42000380ff6f06dd3 Mon Sep 17 00:00:00 2001 From: stupidnewbie <55667763+stupidnewbie@users.noreply.github.com> Date: Wed, 4 May 2022 21:46:18 -0400 Subject: [PATCH 5/7] fix missing reference --- src/lib/Default/AbstractSmrShip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Default/AbstractSmrShip.php b/src/lib/Default/AbstractSmrShip.php index 9f281c3a9..42786c7fb 100644 --- a/src/lib/Default/AbstractSmrShip.php +++ b/src/lib/Default/AbstractSmrShip.php @@ -373,7 +373,7 @@ public function getIllusionDefense(): int { * returns whether or not an ambush bonus is active */ public function getAmbush() : bool { - return $ambush; + return $this->$ambush; } /** From bc8172daa0661fd9bf69688af47a4da78d27be6c Mon Sep 17 00:00:00 2001 From: stupidnewbie <55667763+stupidnewbie@users.noreply.github.com> Date: Wed, 4 May 2022 21:57:58 -0400 Subject: [PATCH 6/7] and fix another typo --- src/lib/Default/AbstractSmrShip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Default/AbstractSmrShip.php b/src/lib/Default/AbstractSmrShip.php index 42786c7fb..4c640057e 100644 --- a/src/lib/Default/AbstractSmrShip.php +++ b/src/lib/Default/AbstractSmrShip.php @@ -373,7 +373,7 @@ public function getIllusionDefense(): int { * returns whether or not an ambush bonus is active */ public function getAmbush() : bool { - return $this->$ambush; + return $this->ambush; } /** From 1ceeed6371e4307b87365f942cde3f8572e8eee4 Mon Sep 17 00:00:00 2001 From: stupidnewbie <55667763+stupidnewbie@users.noreply.github.com> Date: Wed, 4 May 2022 22:04:21 -0400 Subject: [PATCH 7/7] fix more variable reference errors --- src/lib/Default/AbstractSmrShip.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Default/AbstractSmrShip.php b/src/lib/Default/AbstractSmrShip.php index 4c640057e..48fa4c8e9 100644 --- a/src/lib/Default/AbstractSmrShip.php +++ b/src/lib/Default/AbstractSmrShip.php @@ -380,14 +380,14 @@ public function getAmbush() : bool { * sets ambush bonus firing out of cloak */ public function setAmbush() : void { - $ambush = true; + $this->ambush = true; } /** * clears ambush bonus after shot out of cloak */ public function clearAmbush() : void { - $ambush = false; + $this->ambush = false; } public function getPlayer(): AbstractSmrPlayer {