Skip to content

Commit

Permalink
#66 add an option to allow static encounters to overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
Aelto authored Apr 8, 2022
1 parent 61da60b commit 916a1b7
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/static_encounters/static_encounter.ws
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ class RER_StaticEncounter {
}

class RER_PlaceholderStaticEncounter extends RER_StaticEncounter {
/**
* Controls whether this static encounter can spawn its creatures even if
* there are other creatures in the area.
* true: can spawn
* false: cannot spawn
*/
private var can_overlap_with_others: bool;

public function init(can_overlap_with_others: bool): RER_PlaceholderStaticEncounter {
this.can_overlap_with_others = can_overlap_with_others;

return this;
}

/**
* override the function to return true whenever it finds a monster instead of
Expand All @@ -171,6 +184,10 @@ class RER_PlaceholderStaticEncounter extends RER_StaticEncounter {
var actor: CActor;
var i: int;

if (this.can_overlap_with_others) {
return false;
}

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

Expand Down Expand Up @@ -211,18 +228,11 @@ class RER_PlaceholderStaticEncounter extends RER_StaticEncounter {
);
}

// TODO: should give a filter based on the creature size
return master.bestiary.getRandomEntryFromBestiary(
master,
EncounterType_HUNTINGGROUND,
RER_flag(RER_BREF_IGNORE_SETTLEMENT, true),
(new RER_SpawnRollerFilter in this)
.init()
.setOffsets(
constants.large_creature_begin,
constants.large_creature_max,
0 // creature outside the offset have 0% chance to appear
)
filter
);
}
}

0 comments on commit 916a1b7

Please sign in to comment.