Skip to content

Commit

Permalink
A few more bug fixes and the annihilate command
Browse files Browse the repository at this point in the history
  • Loading branch information
jt-traub committed Aug 18, 2024
1 parent 2bce36c commit 30f970f
Show file tree
Hide file tree
Showing 17 changed files with 362 additions and 65 deletions.
12 changes: 6 additions & 6 deletions aregion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void ARegion::RunDecayEvent(Object *o, ARegionList *pRegs)
forlist (pFactions) {
Faction *f = ((FactionPtr *) elem)->ptr;
string tmp = string(GetDecayFlavor().const_str()) + " " + ObjectDefs[o->type].name +
" in " + ShortPrint(pRegs).const_str() + ".";
" in " + ShortPrint().const_str() + ".";
f->event(tmp, "decay");
}
}
Expand Down Expand Up @@ -739,13 +739,13 @@ int ARegion::GetRealDirComp(int realDirection)
return complementDirection;
}

AString ARegion::ShortPrint(ARegionList *pRegs)
AString ARegion::ShortPrint()
{
AString temp = TerrainDefs[type].name;

temp += AString(" (") + xloc + "," + yloc;

ARegionArray *pArr = pRegs->pRegionArrays[zloc];
ARegionArray *pArr = this->level;
if (pArr->strName) {
temp += ",";
if (Globals->EASIER_UNDERWORLD &&
Expand Down Expand Up @@ -779,9 +779,9 @@ AString ARegion::ShortPrint(ARegionList *pRegs)
return temp;
}

AString ARegion::Print(ARegionList *pRegs)
AString ARegion::Print()
{
AString temp = ShortPrint(pRegs);
AString temp = ShortPrint();
if (town) {
temp += AString(", contains ") + *(town->name) + " [" +
TownString(town->TownType()) + "]";
Expand Down Expand Up @@ -1677,7 +1677,7 @@ int ARegion::NotifySpell(Unit *caster, char const *spell, ARegionList *pRegs)
forlist_reuse (&flist) {
FactionPtr *fp = (FactionPtr *) elem;
string tmp = string(caster->name->const_str()) + " uses " + SkillStrs(sp).const_str() +
" in " + Print(pRegs).const_str() + ".";
" in " + Print().const_str() + ".";
fp->ptr->event(tmp, "cast");
}
return 1;
Expand Down
4 changes: 2 additions & 2 deletions aregion.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ class ARegion : public AListElem
json basic_region_data();
void build_json_report(json& j, Faction *fac, int month, ARegionList *pRegions);

AString ShortPrint(ARegionList *pRegs);
AString Print(ARegionList *pRegs);
AString ShortPrint();
AString Print();

void Kill(Unit *);
void ClearHell();
Expand Down
6 changes: 3 additions & 3 deletions battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ int Battle::Run(Events* events,
assassination = ASS_SUCC;
asstext = armies[1]->leader->name->const_str();
asstext += " is assassinated in ";
asstext += region->ShortPrint(pRegs).const_str();
asstext += region->ShortPrint().const_str();
asstext += "!";
}
if (armies[1]->NumAlive()) {
Expand Down Expand Up @@ -695,10 +695,10 @@ void Battle::WriteSides(ARegion * r,
{
if (ass) {
AddLine(*att->name + " attempts to assassinate " + *tar->name
+ " in " + r->ShortPrint( pRegs ) + "!");
+ " in " + r->ShortPrint() + "!");
} else {
AddLine(*att->name + " attacks " + *tar->name + " in " +
r->ShortPrint( pRegs ) + "!");
r->ShortPrint() + "!");
}
AddLine("");

Expand Down
10 changes: 5 additions & 5 deletions edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void Game::EditGameRegion(ARegion *pReg)
{
do {
Awrite( AString("Region ") + pReg->num + ": " +
pReg->Print( &regions ) );
pReg->Print() );
Awrite( " 1) Edit objects..." );
Awrite( " 2) Edit terrain..." );
Awrite( " q) Return to previous menu." );
Expand Down Expand Up @@ -157,7 +157,7 @@ void Game::EditGameRegionObjects( ARegion *pReg )
//template copied from AtlantisDev 030730 post. Modified option a, added option h, m.
{
do {
Awrite( AString( "Region: " ) + pReg->ShortPrint( &regions ) );
Awrite( AString( "Region: " ) + pReg->ShortPrint() );
Awrite( "" );
int i = 0;
AString temp = AString("");
Expand Down Expand Up @@ -439,7 +439,7 @@ void Game::EditGameRegionTerrain( ARegion *pReg )
{
do {
Awrite("");
Awrite( AString( "Region: " ) + pReg->Print( &regions ) );
Awrite( AString( "Region: " ) + pReg->Print() );
Awrite( "" );
// write pop stuff
Awrite( AString("") + pReg->population + " " + ItemDefs[pReg->race].names + " basepop");
Expand Down Expand Up @@ -737,7 +737,7 @@ void Game::EditGameRegionMarkets( ARegion *pReg )
/* This only gets called if pReg->town exists! */
do {
Awrite("");
Awrite( AString( "Region: " ) + pReg->Print( &regions ) );
Awrite( AString( "Region: " ) + pReg->Print() );
Awrite( "" );
// write pop stuff
Awrite( AString("") + pReg->town->pop + " " + ItemDefs[pReg->race].names + " townpop");
Expand Down Expand Up @@ -1047,7 +1047,7 @@ void Game::EditGameUnit(Unit *pUnit)
Awrite(AString("Unit: ") + *(pUnit->name));
Awrite(AString("Faction: ") + pUnit->faction->num);
Awrite(AString(" in ") +
pUnit->object->region->ShortPrint(&regions));
pUnit->object->region->ShortPrint());
Awrite(" 1) Edit items...");
Awrite(" 2) Edit skills...");
Awrite(" 3) Move unit...");
Expand Down
37 changes: 37 additions & 0 deletions events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,40 @@ std::string Events::Write(std::string worldName, std::string month, int year) {

return text;
}

AnnihilationFact::AnnihilationFact() {
this->message = "";
}

AnnihilationFact::~AnnihilationFact() {
}

void AnnihilationFact::GetEvents(std::list<Event> &events) {
events.push_back({
.category = EventCategory::EVENT_ANNIHILATION,
.score = 1000,
.text = this->message
});
}

AnomalyFact::AnomalyFact() {
this->location = nullptr;
}

AnomalyFact::~AnomalyFact() {
}

void AnomalyFact::GetEvents(std::list<Event> &events) {
std::ostringstream buffer;

buffer
<< "A strange anomaly was detected in regions "
<< location->Print()
<< ".";

events.push_back({
.category = EventCategory::EVENT_ANOMALY,
.score = 100,
.text = buffer.str()
});
}
22 changes: 22 additions & 0 deletions events.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ enum EventCategory {
EVENT_MONSTER_HUNT,
EVENT_MONSTER_AGGRESSION,
EVENT_ASSASSINATION,
EVENT_ANNIHILATION,
EVENT_ANOMALY,
};

struct Event {
Expand Down Expand Up @@ -174,4 +176,24 @@ class AssassinationFact : public FactBase {
int outcome; // BATTLE_LOST, BATTLE_WON, BATTLE_DRAW
};

class AnnihilationFact : public FactBase {
public:
AnnihilationFact();
~AnnihilationFact();

void GetEvents(std::list<Event> &events);

string message;
};

class AnomalyFact : public FactBase {
public:
AnomalyFact();
~AnomalyFact();

void GetEvents(std::list<Event> &events);

ARegion *location;
};

#endif
6 changes: 3 additions & 3 deletions gamedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3650,7 +3650,7 @@ static ObjectType ot[] =
// defencearray (ATTACK_COMBAT, ATTACK_ENERGY, ATTACK_SPIRIT, ATTACK_WEATHER, ATTACK_RIDING and ATTACK_RANGED)
//
{"None",
ObjectType::NEVERDECAY,
ObjectType::NEVERDECAY | ObjectType::NOANNIHILATE,
0,0,0,0,
-1,0,NULL,0,
-1, -1, 0, -1, 0,
Expand Down Expand Up @@ -4968,7 +4968,7 @@ static TerrainType td[] = {
1,I_PIRATES,-1,-1,
5,{O_ISLE,-1,O_OCAVE,-1,-1,-1}},

// Terrain for NO7 (barren)
// Terrain for NO7 (barren)
{"barren", "barrens", "barren", '*', R_BARREN,
TerrainType::BARREN | TerrainType::RIDINGMOUNTS | TerrainType::FLYINGMOUNTS | TerrainType::ANNIHILATED,
0,0,0,1,
Expand Down Expand Up @@ -5391,7 +5391,7 @@ EffectType *EffectDefs = efd;
int NUMEFFECTS = sizeof(efd) / sizeof(efd[0]);

// Range definitions
// flags, rangeclass, rangemult, crosslevelpenalty
// key, flags, rangeclass, rangemult, crosslevelpenalty
static RangeType rtd[] = {
{"rng_teleport", 0, RangeType::RNG_LEVEL2, 2, 4},
{"rng_portal", 0, RangeType::RNG_LEVEL2, 2, 4},
Expand Down
2 changes: 1 addition & 1 deletion havilah/extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ Faction *Game::CheckVictory()
if (r->Population() > 0 && !r->visited) {
if (!count--) {
message = "The people of the ";
message += r->ShortPrint(&regions);
message += r->ShortPrint();
switch (getrandom(4)) {
case 0:
message += " have not been visited by exiles.";
Expand Down
34 changes: 17 additions & 17 deletions monthorders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Location *Game::Do1SailOrder(ARegion *reg, Object *fleet, Unit *cap)
stop = 1;
} else if (fleet->SailThroughCheck(x->dir) < 1) {
cap->error("SAIL: Could not sail " + DirectionStrs[x->dir] + " from " +
reg->ShortPrint(&regions).const_str() + ". Cannot sail through land.");
reg->ShortPrint().const_str() + ". Cannot sail through land.");
stop = 1;
}

Expand All @@ -319,7 +319,7 @@ Location *Game::Do1SailOrder(ARegion *reg, Object *fleet, Unit *cap)
}
if (!has_key) {
cap->error("SAIL: Can't sail " + DirectionStrs[x->dir] + " from " +
reg->ShortPrint(&regions).const_str() + " due to mystical barrier.");
reg->ShortPrint().const_str() + " due to mystical barrier.");
stop = 1;
}
}
Expand Down Expand Up @@ -357,9 +357,9 @@ Location *Game::Do1SailOrder(ARegion *reg, Object *fleet, Unit *cap)
Faction * f = ((FactionPtr *) elem)->ptr;
string temp = fleet->name->const_str();
temp += (x->dir == MOVE_PAUSE ? " performs maneuvers in " : " sails from ") +
string(reg->ShortPrint(&regions).const_str());
string(reg->ShortPrint().const_str());
if(x->dir != MOVE_PAUSE) {
temp += " to " + string(newreg->ShortPrint(&regions).const_str());
temp += " to " + string(newreg->ShortPrint().const_str());
}
f->event(temp, "sail");
}
Expand Down Expand Up @@ -391,7 +391,7 @@ Location *Game::Do1SailOrder(ARegion *reg, Object *fleet, Unit *cap)
reg = newreg;
if (newreg->ForbiddenShip(fleet)) {
string temp = string(fleet->name->const_str()) + " is stopped by guards in " +
newreg->ShortPrint(&regions).const_str() + ".";
newreg->ShortPrint().const_str() + ".";
cap->faction->event(temp, "sail");
stop = 1;
}
Expand Down Expand Up @@ -720,12 +720,12 @@ void Game::RunBuildShipOrder(ARegion * r,Object * obj,Unit * u)

if (unfinished == 0) {
u->event("Finishes building a " + ItemDefs[ship].name + " in " +
r->ShortPrint(&regions).const_str() + ".", "build");
r->ShortPrint().const_str() + ".", "build");
CreateShip(r, u, ship);
} else {
percent = 100 * output / ItemDefs[ship].pMonths;
u->event("Performs construction work on a " + ItemDefs[ship].name + " (" + to_string(percent) +
"%) in " + r->ShortPrint(&regions).const_str() + ".", "build", r);
"%) in " + r->ShortPrint().const_str() + ".", "build", r);
}

delete u->monthorders;
Expand Down Expand Up @@ -869,7 +869,7 @@ void Game::RunBuildHelpers(ARegion *r)
int percent = 100 * output / ItemDefs[ship].pMonths;
u->event("Helps " + string(target->name->const_str()) + " with construction of a " +
ItemDefs[ship].name + " (" + to_string(percent) + "%) in " +
r->ShortPrint(&regions).const_str() + ".", "build", r);
r->ShortPrint().const_str() + ".", "build", r);
}
// no need to move unit if item-type ships
// are being built. (leave this commented out)
Expand Down Expand Up @@ -1193,7 +1193,7 @@ void Game::RunUnitProduce(ARegion *r, Unit *u)
}

u->items.SetNum(o->item,u->items.GetNum(o->item) + output);
u->event("Produces " + ItemString(o->item,output) + " in " + r->ShortPrint(&regions).const_str() + ".",
u->event("Produces " + ItemString(o->item,output) + " in " + r->ShortPrint().const_str() + ".",
"produce", r);
u->Practice(o->skill);
o->target -= output;
Expand Down Expand Up @@ -1360,13 +1360,13 @@ void Game::RunAProduction(ARegion * r, Production * p)
//
if (po->skill == -1) {
u->event("Earns " + to_string(ubucks) + " silver working in " +
r->ShortPrint(&regions).const_str() + ".", "work", r);
r->ShortPrint().const_str() + ".", "work", r);
} else {
//
// ENTERTAIN
//
u->event("Earns " + to_string(ubucks) + " silver entertaining in " +
r->ShortPrint(&regions).const_str() + ".", "entertain", r);
r->ShortPrint().const_str() + ".", "entertain", r);
// If they don't have PHEN, then this will fail safely
u->Practice(S_PHANTASMAL_ENTERTAINMENT);
u->Practice(S_ENTERTAINMENT);
Expand All @@ -1376,7 +1376,7 @@ void Game::RunAProduction(ARegion * r, Production * p)
{
/* Everything else */
u->event("Produces " + ItemString(po->item,ubucks) + " in " +
r->ShortPrint(&regions).const_str() + ".", "produce", r);
r->ShortPrint().const_str() + ".", "produce", r);
u->Practice(po->skill);
}
delete u->monthorders;
Expand Down Expand Up @@ -1863,7 +1863,7 @@ Location *Game::DoAMoveOrder(Unit *unit, ARegion *region, Object *obj)
return 0;

if (x->dir == MOVE_PAUSE) {
unit->event("Pauses to admire the scenery in " + string(region->ShortPrint(&regions).const_str()) +
unit->event("Pauses to admire the scenery in " + string(region->ShortPrint().const_str()) +
".", "movement");
unit->movepoints -= cost * Globals->MAX_SPEED;
unit->moved += cost;
Expand All @@ -1875,7 +1875,7 @@ Location *Game::DoAMoveOrder(Unit *unit, ARegion *region, Object *obj)
if ((TerrainDefs[newreg->type].similar_type == R_OCEAN) &&
(!unit->CanSwim() ||
unit->GetFlag(FLAG_NOCROSS_WATER))) {
unit->event("Discovers that " + string(newreg->ShortPrint(&regions).const_str()) + " is " +
unit->event("Discovers that " + string(newreg->ShortPrint().const_str()) + " is " +
TerrainDefs[newreg->type].name + ".", "movement");
goto done_moving;
}
Expand All @@ -1899,7 +1899,7 @@ Location *Game::DoAMoveOrder(Unit *unit, ARegion *region, Object *obj)
forbid = newreg->Forbidden(unit);
if (forbid && !startmove && unit->guard != GUARD_ADVANCE) {
int obs = unit->GetAttribute("observation");
unit->event("Is forbidden entry to " + string(newreg->ShortPrint(&regions).const_str()) + " by " +
unit->event("Is forbidden entry to " + string(newreg->ShortPrint().const_str()) + " by " +
forbid->GetName(obs).const_str() + ".", "movement");
obs = forbid->GetAttribute("observation");
forbid->event("Forbids entry to " + string(unit->GetName(obs).const_str()) + ".", "guarding");
Expand Down Expand Up @@ -1937,8 +1937,8 @@ Location *Game::DoAMoveOrder(Unit *unit, ARegion *region, Object *obj)
temp = "Swims ";
break;
}
unit->event(temp + "from " + string(region->ShortPrint(&regions).const_str()) + " to " +
newreg->ShortPrint(&regions).const_str() + ".", "movement");
unit->event(temp + "from " + string(region->ShortPrint().const_str()) + " to " +
newreg->ShortPrint().const_str() + ".", "movement");

if (forbid) {
unit->advancefrom = region;
Expand Down
2 changes: 1 addition & 1 deletion neworigins/extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ Faction *Game::CheckVictory()
if (r->Population() > 0 && !r->visited) {
if (!count--) {
message = "The people of the ";
message += r->ShortPrint(&regions);
message += r->ShortPrint();
switch (getrandom(4)) {
case 0:
message += " have not been visited by exiles.";
Expand Down
2 changes: 2 additions & 0 deletions neworigins/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2882,6 +2882,8 @@ void ARegionList::FinalSetup(ARegionArray *pArr)
ocean_name += " Ocean";
reg->SetName(ocean_name.Str());
}
} else if (TerrainDefs[reg->type].similar_type == R_BARREN) {
reg->SetName("The Barrens");
} else {
if (reg->wages == -1)
reg->SetName("The Void");
Expand Down
Loading

0 comments on commit 30f970f

Please sign in to comment.