Hi folks,
I'm working on a prototype of a top-down RPG set in medieval North Asia, with focus on tactical problem-solving (varied combat options vs AI manipulation - avatar will be able to play a tune that changes the NPC behaviour patterns - cautious vs reckless, peaceful vs aggressive). Currently finishing the core of combat AI. The artwork is currently placeholder opensource tileset, and the level just a testing ground for the mechanics
While putting together Main AI Switch (the "updating" event, which manages NPC behavior), I ran into a problem.
Expected behavior: When the player attacks the NPC outside the NPC’s detection range, the NPC should stop its current “Wander” behavior, switch to “PullToAvatar” (move in a straight line towards the avatar), then if the NPC collides head-on with a Tile, switch to “PathfindingToAvatar” (simple movement on a tile-based path created with the AI Tools extension). Once “PathfindingToAvatar” is initiated, it should switch the “path_initiated” boolean attribute ON, and there is a special block in the “Main AI Switch” event (see the first “Otherwise if” block that initiates the “PathfindingToAvatar” event) that ensures that while “path_initiated” = TRUE or “path_to_avatar” list contains any items, the NPC executes the “PathfindingToAvatar” event until reaching the end of the path or until getting within the weapon range of the player.
Current state: either the NPC doesn't move on the path at all OR the NPC executes pathfinding once but for new instances of pathfinding it just stands facing a tile. Please also note that in the “Pull path” video the number of remaining "steps" to travel is changing as the avatar moves on the scene, which is incorrect behaviour. It means that the pathfinding movement cycle is not properly initiated. Please also note that the pathfinding algorithm itself used to work perfectly in my previous (less complex) versions of NPC AI. I suspect there is a fault in my Boolean switches and their resets (or in how the engine handles the triggered events, maybe it doesn’t get enough time to turn the “path_initiated” switch ON and executes the “Main AI Switch” event again?
Please see an export of the game, a few screenshots and two videos here:
https://www.dropbox.com/sh/dxn9cbjddmnzg87/AAAmbxwa3dEHkA6iVMW9mLtRa?dl=0If you import the game, please note that controls are currently keyboard only: arrows or WASD for movement, space bar for attacking (single press for normal attack, very long press for aimed attack), tab and arrows for changing weapon (press tab again to close the weapon selection menu).
I’ll appreciate any leads, this bug has been really frustrating over the last 2-3 days...
Thank you!