Skip to content

Commit

Permalink
#66 wip: implement the placeholder static encounter class
Browse files Browse the repository at this point in the history
  • Loading branch information
Aelto committed Apr 4, 2022
1 parent b27490a commit 83ef064
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/static_encounters/states/spawning.ws
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ state Spawning in RER_StaticEncounterManager {
composition = new CreatureHuntingGroundComposition in master;

composition.init(master.settings);
composition.setBestiaryEntry(encounter.bestiary_entry)
composition.setBestiaryEntry(encounter.getBestiaryEntry(master))
.setSpawnPosition(encounter.getSpawningPosition())
.spawn(master);

Expand Down
42 changes: 42 additions & 0 deletions src/static_encounters/static_encounter.ws
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class RER_StaticEncounter {
var radius: float;
default radius = 0.01;

public latent function getBestiaryEntry(master: CRandomEncounters): RER_BestiaryEntry {
return this.bestiary_entry;
}

public function isInRegion(region: string): bool {
if (this.region_constraint == RER_RegionConstraint_NO_VELEN && (region == "no_mans_land" || region == "novigrad")
|| this.region_constraint == RER_RegionConstraint_NO_SKELLIGE && (region == "skellige" || region == "kaer_morhen")
Expand Down Expand Up @@ -155,3 +159,41 @@ class RER_StaticEncounter {
}

}

class RER_PlaceholderStaticEncounter extends RER_StaticEncounter {

/**
* override the function to return true whenever it finds a monster instead of
* a specific bestiary entry.
*/
private function areThereEntitiesWithSameTemplate(entities: array<CGameplayEntity>): bool {
var hashed_name: string;
var actor: CActor;
var i: int;

for (i = 0; i < entities.Size(); i += 1) {
actor = (CActor)entities[i];

if (actor) {
if (actor.IsMonster()) {
return true;
}
}
}

return false;
}

/**
* override the function to return a random entry based on the surrounding
* ecosystem.
*/
public latent function getBestiaryEntry(master: CRandomEncounters): RER_BestiaryEntry {
// TODO: should give a filter based on the creature size
return master.bestiary.getRandomEntryFromBestiary(
master,
EncounterType_HUNTINGGROUND,
RER_flag(RER_BREF_IGNORE_SETTLEMENT, true)
);
}
}

0 comments on commit 83ef064

Please sign in to comment.