Skip to content

Commit

Permalink
Add freezing effect stage 1 in NOv6 (#158)
Browse files Browse the repository at this point in the history
* Add freezing effect in NOv6
  • Loading branch information
artyomtrityak authored Nov 28, 2023
1 parent 957b3f4 commit 3375fef
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
14 changes: 12 additions & 2 deletions aregion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,12 @@ void ARegion::write_text_report(ostream &f, Faction *fac, int month, ARegionList
f << temp.const_str() << "\n";
}

// Freezing effect
if (weather == W_BLIZZARD && !clearskies) {
temp = "There was an unnatural freezing last month.";
f << temp.const_str() << "\n";
}

#if 0
f << "\nElevation is " << elevation << ".\n";
f << "Humidity is " << humidity << ".\n";
Expand Down Expand Up @@ -1954,8 +1960,12 @@ int ARegion::MoveCost(int movetype, ARegion *fromRegion, int dir, AString *road)
int cost = 1;
if (Globals->WEATHER_EXISTS) {
cost = 2;
if (weather == W_BLIZZARD) return 10;
if (weather == W_NORMAL || clearskies) cost = 1;
if (weather == W_NORMAL || clearskies) {
cost = 1;
}
}
if (weather == W_BLIZZARD && !clearskies) {
return 4;
}
if (movetype == M_SWIM) {
cost = (TerrainDefs[type].movepoints * cost);
Expand Down
2 changes: 0 additions & 2 deletions genrules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2726,10 +2726,8 @@ int Game::GenRules(const AString &rules, const AString &css, const AString &intr
<< "structure which allows transportation of items. The structures which allow this are: ";
last = -1;
comma = 0;
int j = 0;
for (int i = 0; i < NOBJECTS; i++) {
if (!(ObjectDefs[i].flags & ObjectType::TRANSPORT)) continue;
j++;
if (last == -1) {
last = i;
continue;
Expand Down
6 changes: 6 additions & 0 deletions monthorders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ Location *Game::Do1SailOrder(ARegion *reg, Object *fleet, Unit *cap)
newreg = reg->neighbors[x->dir];
}
cost = 1;

// Blizzard effect
if (newreg && newreg->weather == W_BLIZZARD && !newreg->clearskies) {
cost = 4;
}

if (Globals->WEATHER_EXISTS) {
if (newreg && newreg->weather != W_NORMAL &&
!newreg->clearskies)
Expand Down
23 changes: 23 additions & 0 deletions neworigins/extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,29 @@ Faction *Game::CheckVictory()
}
}

if (TurnNumber() >= 29) { // 29 is just a number to avoid breaking snapshots
// Freezing effect
forlist_reuse(&regions) {
ARegion *r = (ARegion *) elem;

// No effect for regions with clear skies
if (r->clearskies) {
continue;
}

// Check if regions in freezing zome in surface
if (r->zloc == ARegionArray::LEVEL_SURFACE && (r->yloc <= 0 || r->yloc >= 71)) {
r->Pillage();
r->SetWeather(W_BLIZZARD);
printf("Freeze (%d,%d) region in %s of %s\n",
r->xloc, r->yloc, r->name->Str(), TerrainDefs[TerrainDefs[r->type].similar_type].name
);
}

// TODO: Check if regions in freezing zome in UW
}
}

return NULL;
}

Expand Down

0 comments on commit 3375fef

Please sign in to comment.