I can't understand the pattern yet, but the enemy sometimes stands in a distance (about 2-3 cells) and doesn't attack.
Seems like this CTD has something to do with it:
Traceback (most recent call last):
File "/home/eugene/rogueboxadventures/main.py", line 14244, in <module>
File "/home/eugene/rogueboxadventures/main.py", line 14228, in main
test = player.user_input()
File "/home/eugene/rogueboxadventures/main.py", line 10362, in user_input
File "/home/eugene/rogueboxadventures/main.py", line 13909, in tick
File "/home/eugene/rogueboxadventures/main.py", line 4356, in AI_move
if self.npcs[y][x].lp < self.npcs[y][x].basic_attribute.max_lp/2 and player.lp > player.attribute.max_lp/2 and distance < 3 and self.npcs[y][x].num_special > 0 :#this is a defensive situation for the monster
NameError: global name 'distance' is not defined
The CTD should be fixed now. (Was just a typo)
The other things you reported could be a bug but I need a bit more info.
I added function that checks if monsters can see the player when I implemented invisibility. Maybe the monsters line of sight is blocked if it won't attack?
Nope. The enemy can see the player directly, but just stands in one place a few cells away and doesn't move (however, if has a ranged attack - uses it as usually).
I'll try to put those together...
This pretty affects over 50% of enemies. The ones highlighted with red circle just stand there and don't move. Yet, they throw daggers, shot, as expected. They start acting a bit more actively, if player closes in to melee range, however they stop again if player disengages. Seldomly they do move when the player character changes position, seems like random - I couldn't find any pattern. Sometimes an enemy may "just stand" and after some time player moves around, the enemy starts attacking normally.
Looks like debuging this will become a pain.
Update: I tried to make the 'line of sight' of monsters visible. I think the problem is obvious. Now I need to find a way to fix this.
I made a little change. Now it seems to work better. But I've no time for extensive testing, so I leave this issue open for now.
Much, much better. Still enemies sometimes don't move as I'd expect them (when they are too many), but eventually they don't just stand in one place. By far (about 10 minutes) I've got only one enemy "permanently stuck" in position, if player doesn't move (e.g. trying to walk into walls or wait) - see screenshot.
Upd - got one more with a Nymph.
Another example: vase monsters would stay in their places for about 3-4 turns, and after that 1 or 2 of those move. However, eventually all of them do close in to the player (but very-very slowly, skipping a few turns before moving).
Maybe we could fix this with an idyl counter for monsters. After 3 turns of idyl the monsters could do a random move if possible. This would change their perspective.
Monsters move now randomly (like npcs with green dots) when they can't see the player. I hope this will help a bit. They maybe not allways do a logical move but at least they should not stuck.
Had you any more problems since my last change?
Nope, I didn't have a chance to play this week. Maybe somewhere closer to weekends.
Yes, it feels a bit better, but still:
Enemies move extremely slowly (up to 5 times slower than expected) by skipping turns.
If the player gets out of visual range enemies soon loose track of character and start walking around randomly (while being directly seen by the player).
Some (?) spawners also dropped spawning frequency? I'm talking about daemonic chest first of all. Seems like the spawners don't spawn minions when they "don't see" the player character.
It seems the old 'stupid' AI worked better for RBA. Maybe I should remove the LoS check. Here is an idea for a simplified system:
Monsters should have a view range. By default this range should be as big as players maximum view range. If the distance between player and monster is bigger then the monsters view range los_check() returns False. Same happens if the monster is blinded or the player char is invisible (Memo to myself: Need to an item like 'Potion of invisibility' to allow players to obtain this buff without cheats). In all other situations los_check() will return True. This way monsters should act ike before in the most situations.
As a little bonus the variable view range will allow features like monsters that only act hostile if you come to close.
Another variant, monsters become active once the player sees them (a but might be if player is blinded and can't see them) and never check LOS again unless blinded or player turns invisible.
I've changed the system one more time. Now monsters have an inner_view_range and an outer_view_range variable. If the distance between player and monster is smaller then inner_view_range the monster turns active. If player is outside outer_view_range the mob turns inactive again. Inactive means the monster just randomly moves around. Active monsters will try to attack the player.
Let's see how this system will work.
Tested it today. It's much better, seems equal to what has been before.