Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloak ambush bonus #1322

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/engine/Default/trader_attack_processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib/Default/AbstractSmrCombatWeapon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
23 changes: 23 additions & 0 deletions src/lib/Default/AbstractSmrShip.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 $this->ambush;
}

/**
* sets ambush bonus firing out of cloak
*/
public function setAmbush() : void {
$this->ambush = true;
}

/**
* clears ambush bonus after shot out of cloak
*/
public function clearAmbush() : void {
$this->ambush = false;
}

public function getPlayer(): AbstractSmrPlayer {
return $this->player;
Expand Down Expand Up @@ -761,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);
Expand Down