diff --git a/lib/Lacuna/Constants.pm b/lib/Lacuna/Constants.pm index 669fca12..5694a988 100644 --- a/lib/Lacuna/Constants.pm +++ b/lib/Lacuna/Constants.pm @@ -114,7 +114,7 @@ use constant SHIP_TYPES => (qw( probe short_range_colony_ship colony_ship spy_po supply_pod supply_pod2 supply_pod3 supply_pod4 drone fighter spy_shuttle observatory_seeker security_ministry_seeker spaceport_seeker excavator detonator scanner barge hulk hulk_fast hulk_huge galleon stake - placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper + placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper fissure_healer )); use constant SHIP_TRADE_TYPES => (qw( cargo_ship smuggler_ship freighter dory barge galleon hulk hulk_huge hulk_fast diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index 3256d596..be46f7a1 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -67,6 +67,7 @@ use constant MEDALS => { spy_shuttle => 'Built Spy Shuttle', observatory_seeker => 'Built Observatory Seeker', security_ministry_seeker => 'Built Security Ministry Seeker', + fissure_healer => 'Built Fissure Healer', spaceport_seeker => 'Built SpacePort Seeker', excavator => 'Built Excavator', detonator => 'Built Detonator', diff --git a/lib/Lacuna/DB/Result/Ships.pm b/lib/Lacuna/DB/Result/Ships.pm index 1c4653f8..6e2445f4 100644 --- a/lib/Lacuna/DB/Result/Ships.pm +++ b/lib/Lacuna/DB/Result/Ships.pm @@ -89,6 +89,7 @@ __PACKAGE__->typecast_map(type => { 'observatory_seeker' => 'Lacuna::DB::Result::Ships::ObservatorySeeker', 'spaceport_seeker' => 'Lacuna::DB::Result::Ships::SpacePortSeeker', 'security_ministry_seeker' => 'Lacuna::DB::Result::Ships::SecurityMinistrySeeker', + 'fissure_healer' => 'Lacuna::DB::Result::Ships::FissureHealer', }); with 'Lacuna::Role::Container'; diff --git a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm new file mode 100644 index 00000000..216c6e9f --- /dev/null +++ b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm @@ -0,0 +1,28 @@ +package Lacuna::DB::Result::Ships::ColonyShip; + +use Moose; +use utf8; +no warnings qw(uninitialized); +extends 'Lacuna::DB::Result::Ships'; + +use constant prereq => [ { class=> 'Lacuna::DB::Result::Building::Observatory', level => 15 } ]; +use constant base_food_cost => 15_000; +use constant base_water_cost => 30_000; +use constant base_energy_cost => 90_000; +use constant base_ore_cost => 500_000; +use constant base_time_cost => 60 * 60 * 24 * 2; +use constant base_waste_cost => 50_000; +use constant base_combat => 0; +use constant base_speed => 250; +use constant base_stealth => 0; +use constant base_hold_size => 0; +use constant pilotable => 0; +use constant build_tags => ['Exploration']; + +with "Lacuna::Role::Ship::Send::Planet"; +with "Lacuna::Role::Ship::Send::Uninhabited"; +with "Lacuna::Role::Ship::Send::IsHostile"; +with "Lacuna::Role::Ship::Arrive::SealFissure"; + +no Moose; +__PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm new file mode 100644 index 00000000..e6a1b90a --- /dev/null +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -0,0 +1,55 @@ +package Lacuna::Role::Ship::Arrive::DamageBuilding; + +use strict; +use Moose::Role; +use Lacuna::Util qw(randint); +use DateTime; + +after handle_arrival_procedures => sub { + my ($self) = @_; + + # we're coming home + return if ($self->direction eq 'in'); + + # Turn around if occupied + return if ($self->foreign_body->empire_id); + + # determine target building + my $building; + my $body_hit = $self->foreign_body; + my ($fissure) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::Fissure'} @{$body_hit->building_cache}; + return if not defined $fissure; + + $body_hit->add_news(70, sprintf('An attempt to fix the fissure on %s happened today.', $body_hit->name)); + + # handle fissure + if (defined $fissure) { + my $curr_eff = $fissure->efficiency + randint(1,7); + $curr_eff = 100 if $curr_eff > 100; + $curr_lev = $fissure->level; + + if ( int(5.5 + $curr_eff/10) > randint(0,99) ) { + $curr_lev--; + } + if ($curr_lev < 1) { + $fissure->delete; + } + else { + $fissure->level($curr_lev); + $fissure->efficiency($curr_eff); + $fissure->update; + } + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'our_ship_hit_fissure.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name, $curr_lev, $curr_eff ], + ); + $self->delete; + $body_hit->needs_surface_refresh(1); + $body_hit->update; + } + + confess [-1]; +}; + +1; diff --git a/var/messages/our_ship_hit_fissure.txt b/var/messages/our_ship_hit_fissure.txt new file mode 100644 index 00000000..8e9a6a6e --- /dev/null +++ b/var/messages/our_ship_hit_fissure.txt @@ -0,0 +1,7 @@ +Fissure Hit +~~~ +Our %s reached {Starmap %s %s %s} and left the fissure at level %s and %s%% efficiency. + +Regards, + +Your Humble Assistant diff --git a/var/www/public/resources.json b/var/www/public/resources.json index 54761f2e..05c1d6a5 100644 --- a/var/www/public/resources.json +++ b/var/www/public/resources.json @@ -192,6 +192,7 @@ "hulk" : { "description" : "Extra large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_fast" : { "description" : "Extra large transport ship slightly bigger and much faster than a Hulk. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_huge" : { "description" : "Incredibly large and very slow transport ship, useful for supply chains. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, + "fissure_healer" : { "description" : "Large slow ship, used to attempt sealing fissures on uninhabited planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/fissure-healer" }, "freighter" : { "description" : "Large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/freighter" }, "snark" : { "description" : "Robotic bombardment weapon, that can be used to destroy buildings on remote planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, "snark2" : { "description" : "An improved version of the Snark, which has a splash damage radius of 1.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, -- 2.51.2 From f9832cb2700fc82d01c2f64ab8f763f46e4f578d Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 17:29:10 -0700 Subject: [PATCH 02/11] Couple needed fixes. --- lib/Lacuna/DB/Result/Ships/Fissurehealer.pm | 2 +- lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm index 216c6e9f..b1a755ab 100644 --- a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm +++ b/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm @@ -1,4 +1,4 @@ -package Lacuna::DB::Result::Ships::ColonyShip; +package Lacuna::DB::Result::Ships::FissureHealer; use Moose; use utf8; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index e6a1b90a..40598b41 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -1,4 +1,4 @@ -package Lacuna::Role::Ship::Arrive::DamageBuilding; +package Lacuna::Role::Ship::Arrive::SealFissure; use strict; use Moose::Role; -- 2.51.2 From 109d95cd6fe8dff85a09bfc8f39636a789f6d068 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 18:06:01 -0700 Subject: [PATCH 03/11] fix fix fix --- .../DB/Result/Ships/{Fissurehealer.pm => FissureHealer.pm} | 0 lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/Lacuna/DB/Result/Ships/{Fissurehealer.pm => FissureHealer.pm} (100%) diff --git a/lib/Lacuna/DB/Result/Ships/Fissurehealer.pm b/lib/Lacuna/DB/Result/Ships/FissureHealer.pm similarity index 100% rename from lib/Lacuna/DB/Result/Ships/Fissurehealer.pm rename to lib/Lacuna/DB/Result/Ships/FissureHealer.pm diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 40598b41..847cb7fd 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -26,7 +26,7 @@ after handle_arrival_procedures => sub { if (defined $fissure) { my $curr_eff = $fissure->efficiency + randint(1,7); $curr_eff = 100 if $curr_eff > 100; - $curr_lev = $fissure->level; + my $curr_lev = $fissure->level; if ( int(5.5 + $curr_eff/10) > randint(0,99) ) { $curr_lev--; -- 2.51.2 From 59676b64546904932a9a913b84daab1d6c9badb3 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 20:17:39 -0700 Subject: [PATCH 04/11] Refinements. --- lib/Lacuna/DB/Result/Ships/FissureHealer.pm | 1 - lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 22 ++++++++++++++------- var/messages/we_destroyed_a_fissure.txt | 7 +++++++ var/www/public/changes.txt | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 var/messages/we_destroyed_a_fissure.txt diff --git a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm b/lib/Lacuna/DB/Result/Ships/FissureHealer.pm index b1a755ab..f380e2de 100644 --- a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm +++ b/lib/Lacuna/DB/Result/Ships/FissureHealer.pm @@ -21,7 +21,6 @@ use constant build_tags => ['Exploration']; with "Lacuna::Role::Ship::Send::Planet"; with "Lacuna::Role::Ship::Send::Uninhabited"; -with "Lacuna::Role::Ship::Send::IsHostile"; with "Lacuna::Role::Ship::Arrive::SealFissure"; no Moose; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 847cb7fd..7e81dd39 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -24,26 +24,34 @@ after handle_arrival_procedures => sub { # handle fissure if (defined $fissure) { - my $curr_eff = $fissure->efficiency + randint(1,7); + my $curr_eff = $fissure->efficiency + randint(1,5); $curr_eff = 100 if $curr_eff > 100; my $curr_lev = $fissure->level; - if ( int(5.5 + $curr_eff/10) > randint(0,99) ) { + my $down_chance = $curr_eff; + $down_chance = 5 if ($down_chance < 5); + $down_chance = 95 if ($down_chance > 95); + + if ( $down_chance > randint(0,99) ) { $curr_lev--; } if ($curr_lev < 1) { $fissure->delete; + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'we_destroyed_a_fissure.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name ], } else { $fissure->level($curr_lev); $fissure->efficiency($curr_eff); $fissure->update; + $self->body->empire->send_predefined_message( + tags => ['Alert'], + filename => 'our_ship_hit_fissure.txt', + params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name, $curr_lev, $curr_eff ], + ); } - $self->body->empire->send_predefined_message( - tags => ['Alert'], - filename => 'our_ship_hit_fissure.txt', - params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name, $curr_lev, $curr_eff ], - ); $self->delete; $body_hit->needs_surface_refresh(1); $body_hit->update; diff --git a/var/messages/we_destroyed_a_fissure.txt b/var/messages/we_destroyed_a_fissure.txt new file mode 100644 index 00000000..7af588b5 --- /dev/null +++ b/var/messages/we_destroyed_a_fissure.txt @@ -0,0 +1,7 @@ +Fissure Destroyed +~~~ +Our %s reached {Starmap %s %s %s} and destroyed a fissure. + +Regards, + +Your Humble Assistant diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 0825a970..ae06d609 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0874: - Mod: Fissures have an interesting effect on gas giants. + - Add: Fissure Healer Ship added. 3.0873: - Mod: Observatory can only abandon a probe it controls. -- 2.51.2 From 163f86546ae26646b3a0dbb0c4152b45c8b35707 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 22:48:00 -0700 Subject: [PATCH 05/11] Using ore amount for sealing. --- lib/Lacuna/Constants.pm | 2 +- lib/Lacuna/DB/Result/Medals.pm | 2 +- lib/Lacuna/DB/Result/Ships.pm | 2 +- .../{FissureHealer.pm => FissureSealer.pm} | 4 +- lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 41 ++++++++++++++++++- var/www/public/resources.json | 2 +- 6 files changed, 46 insertions(+), 7 deletions(-) rename lib/Lacuna/DB/Result/Ships/{FissureHealer.pm => FissureSealer.pm} (90%) diff --git a/lib/Lacuna/Constants.pm b/lib/Lacuna/Constants.pm index 5694a988..e7749f4f 100644 --- a/lib/Lacuna/Constants.pm +++ b/lib/Lacuna/Constants.pm @@ -114,7 +114,7 @@ use constant SHIP_TYPES => (qw( probe short_range_colony_ship colony_ship spy_po supply_pod supply_pod2 supply_pod3 supply_pod4 drone fighter spy_shuttle observatory_seeker security_ministry_seeker spaceport_seeker excavator detonator scanner barge hulk hulk_fast hulk_huge galleon stake - placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper fissure_healer + placebo placebo2 placebo3 placebo4 placebo5 placebo6 bleeder sweeper fissure_sealer )); use constant SHIP_TRADE_TYPES => (qw( cargo_ship smuggler_ship freighter dory barge galleon hulk hulk_huge hulk_fast diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index be46f7a1..5c079228 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -67,7 +67,7 @@ use constant MEDALS => { spy_shuttle => 'Built Spy Shuttle', observatory_seeker => 'Built Observatory Seeker', security_ministry_seeker => 'Built Security Ministry Seeker', - fissure_healer => 'Built Fissure Healer', + fissure_sealer => 'Built Fissure Sealer', spaceport_seeker => 'Built SpacePort Seeker', excavator => 'Built Excavator', detonator => 'Built Detonator', diff --git a/lib/Lacuna/DB/Result/Ships.pm b/lib/Lacuna/DB/Result/Ships.pm index 6e2445f4..ec985c55 100644 --- a/lib/Lacuna/DB/Result/Ships.pm +++ b/lib/Lacuna/DB/Result/Ships.pm @@ -89,7 +89,7 @@ __PACKAGE__->typecast_map(type => { 'observatory_seeker' => 'Lacuna::DB::Result::Ships::ObservatorySeeker', 'spaceport_seeker' => 'Lacuna::DB::Result::Ships::SpacePortSeeker', 'security_ministry_seeker' => 'Lacuna::DB::Result::Ships::SecurityMinistrySeeker', - 'fissure_healer' => 'Lacuna::DB::Result::Ships::FissureHealer', + 'fissure_sealer' => 'Lacuna::DB::Result::Ships::FissureSealer', }); with 'Lacuna::Role::Container'; diff --git a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm similarity index 90% rename from lib/Lacuna/DB/Result/Ships/FissureHealer.pm rename to lib/Lacuna/DB/Result/Ships/FissureSealer.pm index f380e2de..cb8f1f08 100644 --- a/lib/Lacuna/DB/Result/Ships/FissureHealer.pm +++ b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm @@ -9,13 +9,13 @@ use constant prereq => [ { class=> 'Lacuna::DB::Result::Building use constant base_food_cost => 15_000; use constant base_water_cost => 30_000; use constant base_energy_cost => 90_000; -use constant base_ore_cost => 500_000; +use constant base_ore_cost => 100_000; use constant base_time_cost => 60 * 60 * 24 * 2; use constant base_waste_cost => 50_000; use constant base_combat => 0; use constant base_speed => 250; use constant base_stealth => 0; -use constant base_hold_size => 0; +use constant base_hold_size => 50_000; use constant pilotable => 0; use constant build_tags => ['Exploration']; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 7e81dd39..d780ca0b 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -4,6 +4,7 @@ use strict; use Moose::Role; use Lacuna::Util qw(randint); use DateTime; +use Lacuna::Constants qw(FOOD_TYPES ORE_TYPES); after handle_arrival_procedures => sub { my ($self) = @_; @@ -14,6 +15,13 @@ after handle_arrival_procedures => sub { # Turn around if occupied return if ($self->foreign_body->empire_id); + my $amount = 0; + my $payload = $self->payload; + foreach my $type (ORE_TYPES) { + if (defined($payload->{resources}{$type})) { + $amount += $payload->{resources}{$type}; + } + } # determine target building my $building; my $body_hit = $self->foreign_body; @@ -24,7 +32,7 @@ after handle_arrival_procedures => sub { # handle fissure if (defined $fissure) { - my $curr_eff = $fissure->efficiency + randint(1,5); + my $curr_eff = $fissure->efficiency + randint(1,5) + int($amount/1_000_000); $curr_eff = 100 if $curr_eff > 100; my $curr_lev = $fissure->level; @@ -34,6 +42,7 @@ after handle_arrival_procedures => sub { if ( $down_chance > randint(0,99) ) { $curr_lev--; + $curr_eff = 10; } if ($curr_lev < 1) { $fissure->delete; @@ -41,6 +50,7 @@ after handle_arrival_procedures => sub { tags => ['Alert'], filename => 'we_destroyed_a_fissure.txt', params => [$self->type_formatted, $body_hit->x, $body_hit->y, $body_hit->name ], + ); } else { $fissure->level($curr_lev); @@ -60,4 +70,33 @@ after handle_arrival_procedures => sub { confess [-1]; }; +after send => sub { + my $self = shift; + my $part = $self->hold_size; + my $ore = $part; + my $body = $self->body; + my $payload; + my $ore_stored = 0; + my $ore_type_count = 0; + for my $type (ORE_TYPES) { + my $stored = $body->type_stored($type); + $ore_stored += $stored; + $ore_type_count++ if ($stored); + } + $ore = $ore_stored if ($ore > $ore_stored); + foreach my $type (ORE_TYPES) { + my $stored = $body->type_stored($type); + if ($stored) { + my $amt = int(($ore * $stored)/$ore_stored) - 100; + if ( $amt > 0 ) { + $body->spend_type($type, $amt); + $payload->{resources}{$type} = $amt; + } + } + } + $self->payload($payload); + $self->update; + $body->update; +}; + 1; diff --git a/var/www/public/resources.json b/var/www/public/resources.json index 05c1d6a5..60b9491f 100644 --- a/var/www/public/resources.json +++ b/var/www/public/resources.json @@ -192,7 +192,7 @@ "hulk" : { "description" : "Extra large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_fast" : { "description" : "Extra large transport ship slightly bigger and much faster than a Hulk. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, "hulk_huge" : { "description" : "Incredibly large and very slow transport ship, useful for supply chains. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/hulk" }, - "fissure_healer" : { "description" : "Large slow ship, used to attempt sealing fissures on uninhabited planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/fissure-healer" }, + "fissure_sealer" : { "description" : "Large slow ship, used to attempt sealing fissures on uninhabited planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/fissure-sealer" }, "freighter" : { "description" : "Large transport ship. Can be used to push resources between your colonies, trade with other empires, or gather ore from mining platforms.", "wiki" : "http://community.lacunaexpanse.com/wiki/freighter" }, "snark" : { "description" : "Robotic bombardment weapon, that can be used to destroy buildings on remote planets.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, "snark2" : { "description" : "An improved version of the Snark, which has a splash damage radius of 1.", "wiki" : "http://community.lacunaexpanse.com/wiki/snark" }, -- 2.51.2 From a809b3a7bc53482e7d3c4ec0a15e9a26cae81841 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 29 Nov 2012 23:21:25 -0700 Subject: [PATCH 06/11] Fix and seal. --- lib/Lacuna/DB/Result/Ships/FissureSealer.pm | 4 ++-- lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Lacuna/DB/Result/Ships/FissureSealer.pm b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm index cb8f1f08..28abe2d8 100644 --- a/lib/Lacuna/DB/Result/Ships/FissureSealer.pm +++ b/lib/Lacuna/DB/Result/Ships/FissureSealer.pm @@ -1,4 +1,4 @@ -package Lacuna::DB::Result::Ships::FissureHealer; +package Lacuna::DB::Result::Ships::FissureSealer; use Moose; use utf8; @@ -15,7 +15,7 @@ use constant base_waste_cost => 50_000; use constant base_combat => 0; use constant base_speed => 250; use constant base_stealth => 0; -use constant base_hold_size => 50_000; +use constant base_hold_size => 100_000; use constant pilotable => 0; use constant build_tags => ['Exploration']; diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index d780ca0b..7a8f8ffb 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -32,7 +32,7 @@ after handle_arrival_procedures => sub { # handle fissure if (defined $fissure) { - my $curr_eff = $fissure->efficiency + randint(1,5) + int($amount/1_000_000); + my $curr_eff = $fissure->efficiency + int($amount/1_000_000) + 1; $curr_eff = 100 if $curr_eff > 100; my $curr_lev = $fissure->level; -- 2.51.2 From a0a3a90de2613164940f78d53517e8266dd29647 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Fri, 30 Nov 2012 13:12:46 -0700 Subject: [PATCH 07/11] Message to send added. --- bin/util/fissure_sealer_message.pl | 76 ++++++++++++++++++++++ lib/Lacuna/Role/Ship/Arrive/SealFissure.pm | 4 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 bin/util/fissure_sealer_message.pl diff --git a/bin/util/fissure_sealer_message.pl b/bin/util/fissure_sealer_message.pl new file mode 100644 index 00000000..ccb0c634 --- /dev/null +++ b/bin/util/fissure_sealer_message.pl @@ -0,0 +1,76 @@ +use 5.010; +use strict; +use lib '/data/Lacuna-Server/lib'; +use Lacuna::DB; +use Lacuna; +use Lacuna::Util qw(randint format_date); +use Getopt::Long; +$|=1; +our $quiet; +our $all; +GetOptions( + 'quiet' => \$quiet, + 'all' => \$all, +); + + +out('Started'); +my $start = time; + +out('Loading DB'); +our $db = Lacuna->db; +my $empires = $db->resultset('Lacuna::DB::Result::Empire'); + +my $lec = $empires->find(1); + +if (not $all) { + $empires = $empires->search({ is_admin => 1 }); +} + +$empires = $empires->search({ id => {'>' => 1}}); + +my $message = q{Despite our warnings about using Black Hole Generators and how they can cause unstable conditions on planets, your scientists have found more uses for them. Our instruments have noticed more fissures forming recently on unoccupied worlds. + +Since we can't seem to get most of you to stop using the Black Hole Generators, our scientists have come up with a way to seal these fissures though it only works on uninhabited planets. + +These Fissure Sealers do need to be sent with a quantity of ore, but still have a chance to help seal a fissure even if empty. In most cases, it will take multiple applications to fully seal a fissure. + +We have noticed that some of your scientists have come up with a method to neutralize Black Hole Generators by putting out a field from your Space Stations. We are glad that some of you have listened to us. + +Your Trading Partner, + +Tou Re Ell + +Lacuna Expanse Corp}; + +out('Sending Messages'); +while (my $empire = $empires->next) { + my $home = $empire->home_planet; + next unless defined $home; + out('Sending message to '.$empire->name); + $empire->send_message( + tag => 'Correspondence', + subject => 'A new device', + from => $lec, + body => $message, + ); + +} + +my $finish = time; +out('Finished'); +out((($finish - $start)/60)." minutes have elapsed"); + + +############### +## SUBROUTINES +############### + +sub out { + my $message = shift; + unless ($quiet) { + say format_date(DateTime->now), " ", $message; + } +} + + diff --git a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm index 7a8f8ffb..e5eeaaa0 100644 --- a/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm +++ b/lib/Lacuna/Role/Ship/Arrive/SealFissure.pm @@ -10,7 +10,9 @@ after handle_arrival_procedures => sub { my ($self) = @_; # we're coming home - return if ($self->direction eq 'in'); + if ($self->direction eq 'in') { + $self->unload($self->body); + } # Turn around if occupied return if ($self->foreign_body->empire_id); -- 2.51.2 From 21e339fe0f10c9c7162e031ef05c3a577bb52808 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Fri, 30 Nov 2012 15:42:11 -0700 Subject: [PATCH 08/11] n19 and asteroid mining medal fix. --- lib/Lacuna/DB/Result/Building/Network19.pm | 5 +++++ lib/Lacuna/DB/Result/Medals.pm | 4 ++++ var/www/public/changes.txt | 2 ++ 3 files changed, 11 insertions(+) diff --git a/lib/Lacuna/DB/Result/Building/Network19.pm b/lib/Lacuna/DB/Result/Building/Network19.pm index 5fcfbb61..f14accef 100644 --- a/lib/Lacuna/DB/Result/Building/Network19.pm +++ b/lib/Lacuna/DB/Result/Building/Network19.pm @@ -49,5 +49,10 @@ sub happiness_consumption { return ($self->body->restrict_coverage) ? 30 : 0; } +before delete => sub { + my ($self) = @_; + $self->body->restrict_coverage(0); +}; + no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index 5c079228..84c3c055 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -180,6 +180,10 @@ use constant MEDALS => { A19 => 'Mined A19 Type Asteroid', A20 => 'Mined A20 Type Asteroid', A21 => 'Mined Debris Field', + A22 => 'Mined A22 Type Asteroid', + A23 => 'Mined A23 Type Asteroid', + A24 => 'Mined A24 Type Asteroid', + A25 => 'Mined A25 Type Asteroid', building1 => 'Built Level 1 Building', building2 => 'Built Level 2 Building', building3 => 'Built Level 3 Building', diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index ae06d609..27252e31 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,6 +1,8 @@ 3.0874: - Mod: Fissures have an interesting effect on gas giants. - Add: Fissure Healer Ship added. + - Fix: N19 coverage restriction turned off if N19 demolished on body. + - Fix: Corrected emails for deploying mining platforms A22-A25. 3.0873: - Mod: Observatory can only abandon a probe it controls. -- 2.51.2 From bbe1c1a5e6f4573537689843597bf2d380fc690c Mon Sep 17 00:00:00 2001 From: ysth Date: Sun, 2 Dec 2012 11:20:46 -0800 Subject: [PATCH 09/11] Partial repair cost fix --- lib/Lacuna/DB/Result/Building.pm | 47 +++++++++++++++----------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building.pm b/lib/Lacuna/DB/Result/Building.pm index f5d19cf8..9bb3e79e 100755 --- a/lib/Lacuna/DB/Result/Building.pm +++ b/lib/Lacuna/DB/Result/Building.pm @@ -916,24 +916,25 @@ sub can_repair { my ($self, $costs) = @_; $costs ||= $self->get_repair_costs; my $body = $self->body; - my $fix = 100; + my $damage = 100 - $self->efficiency; + my $fix = $damage; if ($body->food_stored < $costs->{food} and $costs->{food} > 0) { - my $teff = int(($body->food_stored-50)*100/$costs->{food}); + my $teff = int($body->food_stored * $damage / $costs->{food}); $fix = $teff if ($teff < $fix); } if ($body->water_stored < $costs->{water} and $costs->{water} > 0) { - my $teff = int($body->water_stored*100/$costs->{water}); + my $teff = int($body->water_stored * $damage / $costs->{water}); $fix = $teff if ($teff < $fix); } if ($body->ore_stored < $costs->{ore} and $costs->{ore} > 0) { - my $teff = int(($body->ore_stored-50)*100/$costs->{ore}); + my $teff = int($body->ore_stored * $damage / $costs->{ore}); $fix = $teff if ($teff < $fix); } if ($body->energy_stored < $costs->{energy} and $costs->{energy} > 0) { - my $teff = int($body->energy_stored*100/$costs->{energy}); + my $teff = int($body->energy_stored * $damage / $costs->{energy}); $fix = $teff if ($teff < $fix); } - if ($fix <= 0) { + if ($damage && $fix <= 0) { confess [1011, 'Not enough resources to do a partial repair.']; } return 1; @@ -943,39 +944,35 @@ sub repair { my ($self, $costs) = @_; $costs ||= $self->get_repair_costs; my $body = $self->body; - my $fix = 100; - my $c_eff = $self->efficiency; + my $damage = 100 - $self->efficiency; + if ($damage <= 0) { + return 0; + } + my $fix = $damage; if ($body->food_stored < $costs->{food} and $costs->{food} > 0) { - my $teff = int(($body->food_stored-50)*100/$costs->{food}); + my $teff = int($body->food_stored * $damage / $costs->{food}); $fix = $teff if ($teff < $fix); } if ($body->water_stored < $costs->{water} and $costs->{water} > 0) { - my $teff = int($body->water_stored*100/$costs->{water}); + my $teff = int($body->water_stored * $damage / $costs->{water}); $fix = $teff if ($teff < $fix); } if ($body->ore_stored < $costs->{ore} and $costs->{ore} > 0) { - my $teff = int(($body->ore_stored-50)*100/$costs->{ore}); + my $teff = int($body->ore_stored * $damage / $costs->{ore}); $fix = $teff if ($teff < $fix); } if ($body->energy_stored < $costs->{energy} and $costs->{energy} > 0) { - my $teff = int($body->energy_stored*100/$costs->{energy}); + my $teff = int($body->energy_stored * $damage / $costs->{energy}); $fix = $teff if ($teff < $fix); } if ($fix <= 0) { -# confess [1011, 'Not enough resources to do a partial repair.']; - return 0; - } - $costs->{food} = int($fix*$costs->{food}/100); - $costs->{water} = int($fix*$costs->{water}/100); - $costs->{ore} = int($fix*$costs->{ore}/100); - $costs->{energy} = int($fix*$costs->{energy}/100); - my $n_eff = 100; - if ($fix < 100) { - my $p_add = int( (100 - $c_eff) * $fix/100 + 0.5); - $p_add = 1 if $p_add < 1; - $n_eff = $c_eff + $p_add; - $n_eff = 100 if ($n_eff > 100); + return 0; } + $costs->{food} = int($fix*$costs->{food}/$damage); + $costs->{water} = int($fix*$costs->{water}/$damage); + $costs->{ore} = int($fix*$costs->{ore}/$damage); + $costs->{energy} = int($fix*$costs->{energy}/$damage); + my $n_eff = $self->efficiency + $fix; $self->efficiency($n_eff); $self->update; $body->spend_food($costs->{food}, 0); -- 2.51.2 From 843890ff64dd0aa479a66a820e42ac4845d61b63 Mon Sep 17 00:00:00 2001 From: ysth Date: Sun, 2 Dec 2012 14:53:01 -0800 Subject: [PATCH 10/11] waste chain capacity: truncate, don't round, so .5% doesn't round up to 1% (essentially doubling capacity) --- lib/Lacuna/DB/Result/Building/Trade.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/DB/Result/Building/Trade.pm b/lib/Lacuna/DB/Result/Building/Trade.pm index 9df24aeb..cbf440c9 100644 --- a/lib/Lacuna/DB/Result/Building/Trade.pm +++ b/lib/Lacuna/DB/Result/Building/Trade.pm @@ -264,7 +264,7 @@ sub recalc_waste_production { while (my $waste_chain = $waste_chains->next) { $chain_wphpd += $body->calculate_distance_to_target($waste_chain->star) * 2 * $waste_chain->waste_hour; } - my $shipping_capacity = $chain_wphpd ? sprintf('%.0f',($ship_wphpd / $chain_wphpd) * 100) : 0; + my $shipping_capacity = $chain_wphpd ? int(100 * $ship_wphpd / $chain_wphpd) : 0; $waste_chains->reset; while (my $waste_chain = $waste_chains->next) { -- 2.51.2 From 5c8e963e093709cc4c19d44a6dd1d2081777466d Mon Sep 17 00:00:00 2001 From: ysth Date: Sun, 2 Dec 2012 15:11:47 -0800 Subject: [PATCH 11/11] repair: don't run food and ore down to 0 --- lib/Lacuna/DB/Result/Building.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building.pm b/lib/Lacuna/DB/Result/Building.pm index 9bb3e79e..2da8d2d5 100755 --- a/lib/Lacuna/DB/Result/Building.pm +++ b/lib/Lacuna/DB/Result/Building.pm @@ -918,16 +918,16 @@ sub can_repair { my $body = $self->body; my $damage = 100 - $self->efficiency; my $fix = $damage; - if ($body->food_stored < $costs->{food} and $costs->{food} > 0) { - my $teff = int($body->food_stored * $damage / $costs->{food}); + if ($body->food_stored-50 < $costs->{food} and $costs->{food} > 0) { + my $teff = int(($body->food_stored-50) * $damage / $costs->{food}); $fix = $teff if ($teff < $fix); } if ($body->water_stored < $costs->{water} and $costs->{water} > 0) { my $teff = int($body->water_stored * $damage / $costs->{water}); $fix = $teff if ($teff < $fix); } - if ($body->ore_stored < $costs->{ore} and $costs->{ore} > 0) { - my $teff = int($body->ore_stored * $damage / $costs->{ore}); + if ($body->ore_stored-50 < $costs->{ore} and $costs->{ore} > 0) { + my $teff = int(($body->ore_stored-50) * $damage / $costs->{ore}); $fix = $teff if ($teff < $fix); } if ($body->energy_stored < $costs->{energy} and $costs->{energy} > 0) { @@ -949,16 +949,16 @@ sub repair { return 0; } my $fix = $damage; - if ($body->food_stored < $costs->{food} and $costs->{food} > 0) { - my $teff = int($body->food_stored * $damage / $costs->{food}); + if ($body->food_stored-50 < $costs->{food} and $costs->{food} > 0) { + my $teff = int(($body->food_stored-50) * $damage / $costs->{food}); $fix = $teff if ($teff < $fix); } if ($body->water_stored < $costs->{water} and $costs->{water} > 0) { my $teff = int($body->water_stored * $damage / $costs->{water}); $fix = $teff if ($teff < $fix); } - if ($body->ore_stored < $costs->{ore} and $costs->{ore} > 0) { - my $teff = int($body->ore_stored * $damage / $costs->{ore}); + if ($body->ore_stored-50 < $costs->{ore} and $costs->{ore} > 0) { + my $teff = int(($body->ore_stored-50) * $damage / $costs->{ore}); $fix = $teff if ($teff < $fix); } if ($body->energy_stored < $costs->{energy} and $costs->{energy} > 0) {