Internal development notes, very slightly cleaned up and commented a week later.
TL;DR: more development for combat AI and various fixes.
The past two weeks with the holidays in the middle have been low intensity for development, but work advances steadily.
- generic sdl backend handle non-vsync main loop custom cursors window close confirmation - migrate windows to generic sdl for display/events
After a few more reports of occasional fullscreen problems in Windows, plus existing problems with some keyboard layouts, I’ve decided to dump the custom direct Win32 windowing code and use SDL2. The advantage of SDL2 is the years of fixes and thousands of shipped games. Being a proven library will make it less likely for problems to surface in platform-depending areas of the code.
- auto discovery of sound fx with scheme-compatible discovery proc still indexed by file name remove the "sound/" of the current paths
Sound effects are now autodiscovered on load, and folders for them can be provided my mod scripts.
- add fauna camps to planet gen
Another V2 parity feature: random fauna camps have been added on planets.
- add last-attacker-component on attack - last-attacker decay system - last-attacker system: attacked entities can put the last-attacker component on same-civ entities around them - use last-attacker-component as preferred target in aggressor SM and make it override any friend/hostile rep evaluation
Another component for the combat AI. The
last-attacker-component is added by aggressors to entities being attacked. Those entities in turn can make use of the component to trigger a series of behaviors. One of them is a system that looks up friendly entities and sets them with a new
last-attacker-component referencing the original attacker. This “empathy” behavior then makes those friendly entities either flee along with the original entity or start attacking the aggressor, depending on their component configuration.
- more attack model attack-model-component, decoupled from aggressor-component proc is now a symbol ref - attack: melee - fix: range check related problems with melee ecs-walk-to-entity uses ecs-preferred-center, which is meant for interactive objects, so it keeps a margin this walking for melee range fails, the target pos is sometimes out of range but behavior is still useful, to attack impassables for example just increase melee range - fix: useless walk to original sight point in aggressor, when target moved check when target moves too much and reset aggressor state
Some cleanups to the aggressor AI as the code moves from a testing prototype to more robust behavior.
- diff neutral vs hostile stance
A true neutral combat stance is now supported, with neutral entities ignoring each other unless provoked.
- true line of sight use coarse Bresenham to check tiles for walkable - use LoS in vulnerable sm sightings too
Line of sight testing has now been implemented and attacks can make use of it as required. The default aggressor state machine now requires LoS for initiating an attack (including checking while the aggressor aproaches the target, so for example it is able to walk down a corridor and them stop in the entrance to a room when the target is in sight). The vulnerable state machine (later renamed to the flee state machine) also requires LoS for triggering a fear-motivated walk.
- turrets need aggressor on building-like component, but cannot move also aggressor sm uses pathing test for vuln finding, which is always #f with fixed, impassable objects first tile of path is blocked - support vulnerable component on fixed impassable objects vuln sm requires PhysicsC so it's not enabled on fixed objects - OK bug: walkable aggressor tries to find path to F+I but doesnt find it, so it doesnt attack (using ecs-pos-center) bug: walkable aggressor tries to find path to F+I last attacker but doesnt find it for some pathological cases (cornered impassable objects) this actually generates error (#f in preferred-center) fix both errors by making sure center-or-4side is used, and allow it in some places to be #f
More V2 parity, this time enabling turrets. This posed a challenge since turrets are based on an impassable tile, and some of the combat code uses walkability testing. This has now been fixed by using a “center or nearby walkable tile” position test.
- add model accesors to proxy hp changes - vulnerable: death proc proto for now add to existing comps, a symbol proc to call on hp = 0 in hp-delta - vulnerable: formalize current mess of components vulnerable-component: tracks hp, hp max, and procs for various hp changes, including fatal hits. replaces hitpoints-component flee-compoment/SM/system: rename of old vulnerable-component, concerns exclusively with flee behavior separate make-flee/make-vulnerable - default fatal proc: helper to spawn death posed placeholder copy components from original entity with specialized helpers
The vulnerable component, system and state machine was mixing concepts and was in general in a bad shape, being barely prototype code. It has now been fixed to be more generic and extensible. The flee behavior has been moved to its own system and is now opt-in. And entities are now finally able to die. A proc system has been introduced for this, based on a centralized handling of all hit points changes combined with a flexible proc configuration. Entities can then completely customize death and damage reciving behavior. A default behavior has been provided for death that clones the dead pose from the just killed entity and creates a temporary corpse entity.