Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI for basic mobs, slightly harder mobs, random optimizations, partial action functionality, mobs deal with corpses #996

Open
wants to merge 48 commits into
base: main
Choose a base branch
from

Conversation

crix870
Copy link

@crix870 crix870 commented Dec 7, 2024

About The Pull Request

Ports basic mobs from Vanderlin as well as some AI components from TG/Monkeystation.

Vanderlin-Tales-Of-Wine/Vanderlin#48

The original intent behind porting this system was to help me familiarize myself with, learn and understand the intricacies of SS13’s code—and it has successfully served that purpose. I'll probably tinker around with it here and there for my own fun.

I encourage you if you have some time and motivation to play around with it, test, debug etc. I've done one or two runs of the wilds/orc dungeon and didn't have any major (non-skill) issues.

Why It's Good For The Game

Honestly I'm not sure if it is worth it. The current system in Azure Peak is functional with no major performance issues and it's unclear (to me) whether the potential performance improvements (?) justify the inevitable AI bugs that will arise. Still, it's here if anyone's interested.

Key problems at the moment:
- Mobs when running away won't attack back. Compared to the original AI, mobs at some point will turn around and attack you. But in this version, they will keep running until the end of the map, a barrier or if they fall a Z-level.

---- NEW

Complete list of changes.

  • New AI system for basic/simple mobs - the infrastructure is what's important.
  • Hostile mobs (not farm animals) are ported over to this new system.
  • Action system partially re-implemented for 2 mobs. It needs to be heavily fleshed out but is in working state for AI
  • Dragons have additional or changed functionality. (dragonbreath, dragon leap)
  • Additional turf helpers (get_ranged_target_turf_direct and slightly faster than the original mob checks for traversability/pathfinding (turf.can_traverse).
  • Slightly optimized can_see function, will check distance first, saved a single byte (maybe?) on the loop.
  • click function now allows for non-carbons to have weapon reach (this is stored in the intents).
  • Some mobs will now eat (butcher) corpses. (wolves, trolls, rats, spiders, dragons, minotaurs, moles)
  • Some additional mobs will now eat food. (rats, wolves, trolls)
    Currently this does nothing for the mob except sate their hunger which is also currently used for nothing (as they're non-farm animals). Could probably work in spawning more or healing the mob later on.
  • Added functionality to some mobs to sit and heal themselves when they have no target. (staunch bleeding, heal self). Current amounts are 0.01% for bleed, 0.1% for brute. Note, this does not refill blood.
  • Added a little bit of functionality to reduce flammability of non-flammable simple mobs (dragon).
  • Cleaned up a little of the retaliate mob code.
  • There was an old minotaur code file, don't know it's purpose but it's commented out for now. (code/modules/mob/living/simple_animal/rogue/creacher/minotaur.dm)
  • Reduced the chances of mobs idle sound playing slightly
  • Altered the damage balance of the penultimate mobs slightly (minotaur, dragon) - this may need to be tweaked up further. Increased the reach of their weapons from 1 to 2
  • Troll punches increased slightly.
  • Trialling improved AI marauder (spearmen) orcs. I think this code is somewhat taxing.
  • Dragon firebreath shifted over to spell but is unused at the moment. (chose action system as spells seemed to be a little bit of a mess. Can easily change over in the future if resolved)
  • Some runtime errors fixed with carbon mobs
  • Fixed some typos, magic numbers in code where I encountered them

Known Issues

  • If you pause the game while debugging it, it may spew out a multitude of null errors from the AI system - a timer or something. I'm unsure as of yet what causes it as the message is not helpful.
  • Shooting a mob from very far away, 1+ screens will generally not 'aggro' or activate it.
  • I don't know best practices for BYOND code so some may code not be as efficient where it can be.
  • Multiplayer performance: unknown, single player: within acceptable limits

Several issues remaining, namely AI freezing/not doing anything after a point.
Eat corpses may not be appropraite for Azure Peaks - may need to add a check if it is a player body.
…ble eat_corpses

trolls, moles, volfs, (azure peak's) minotaur, orcs, rous converted.

ai_controller now checks for both ghost and player on zlevel. Unsure as to performance hit - useful for my debugging, turf - check if there is an obstacle, to be used with environment_smash. tentative reverted an accidental find and replace behavior->behaviour in old txt file commented out animals eating, they'll just congregate around corpses for now (this may lead to mobs constantly fighting) add learn_ai.md from monkeystation

trolls, moles, volfs, (azure peak's) minotaur, orcs, rous converted.
@bearrrrrrrr
Copy link

HYPE

…ghtly, using actions rather than proj alt attacks for mob specials, some func improvements, added details to mobs

original plan was to use spells for mobs but the spell code appears to be in urgent need of refactoring,

still much to do for farm animals but other things appear to be in working condition,

will probably at some point go back to spells for targeted abilities,

improving, adding or incorporating (thank you tg) functions as I see them

added some commented notes for myself
@crix870 crix870 force-pushed the hopefully-smarter-mobs branch from d7cbe61 to 3d1bb11 Compare December 9, 2024 14:58
@dwasint
Copy link

dwasint commented Dec 10, 2024

their is an easy fix for them running away, and thats just adding a new var to the flee element that makes them stop fleeing after a certain point

@dwasint
Copy link

dwasint commented Dec 10, 2024

but the real reason to port this is it allows better control over what mobs do as you can give them more indepth plans that aren't a pain to read

@crix870
Copy link
Author

crix870 commented Dec 10, 2024

but the real reason to port this is it allows better control over what mobs do as you can give them more indepth plans that aren't a pain to read

Yup, I've realised this over the past few days -- especially with small tweaks for differing mob subtypes when needed. And it cuts down significantly on repetitive code.

Thanks for your work/inspo!

@dwasint
Copy link

dwasint commented Dec 10, 2024

but the real reason to port this is it allows better control over what mobs do as you can give them more indepth plans that aren't a pain to read

Yup, I've realised this over the past few days -- especially with small tweaks for differing mob subtypes when needed. And it cuts down significantly on repetitive code.

Thanks for your work/inspo!

if you get stuck I did make a pr on vanderlin a few hours ago redoing some of this code to help with the issue

updated ai turf pathfinding rather than going through a global list, it will instead check whether the pawn can traverse the turf safely
added a testing behaviour with elite orcs so they will try to (poorly) melee space against their targets when their swing is on cooldown.
Sounds good but doesn't work well (yet) in practice
That was the main reason for the reach change
mudcrabs don't attack and just move left/right
@crix870 crix870 force-pushed the hopefully-smarter-mobs branch from 97b99f4 to 7b3575d Compare December 10, 2024 17:44
Vanderlin-Tales-Of-Wine/Vanderlin#237
Fixed up a few type checks and returns just in the case the current_movement_target wasn't set by the plotter and a qdelete check on ai_flee_when_hurt

The mob self-healing during idle numbers should probably be tweaked but want to be mindful of too many expensive calcs on such a simple function.

missed a turf check in idle walk

placeholders for next actions
Built into the retaliate subtree itself, may need to be expanded in future.
Built into the retaliate subtree itself, may need to be expanded in future.

fix up melee_spacing, will now push if unit is hiding around a corner (dist vs reach)
only non-firebreathing dragons will use it
user error
commit 33de53ed0c5c2694ea2e8cd78abfbd7d91c672bd
Author: crix870 <[email protected]>
Date:   Fri Dec 13 23:15:30 2024 +1100

    add mossback, dragon actions, cleanup dragon abills

commit 824ae5ad4db1b963324e158619d7b375c1130322
Author: crix870 <[email protected]>
Date:   Fri Dec 13 22:23:11 2024 +1100

    code cleanup
hopefully fixes 'sentientish' mobs being kited
some wildlife (scavengers - rats, wolves, trolls) will also eat hide, fur, bones in addition to foodstuffs.
@crix870 crix870 changed the title Basic simplemob AI port from Vanderlin AI for mobs, some mob changes, random optimizations, partial action functionality Dec 14, 2024
@crix870 crix870 changed the title AI for mobs, some mob changes, random optimizations, partial action functionality partial AI(tg, vanderlin, monkeystation) for basic mobs, slight mob changes, random optimizations, partial action functionality, Dec 14, 2024
@crix870 crix870 marked this pull request as ready for review December 14, 2024 14:24
@crix870 crix870 changed the title partial AI(tg, vanderlin, monkeystation) for basic mobs, slight mob changes, random optimizations, partial action functionality, AI for basic mobs, slightly harder mobs, random optimizations, partial action functionality, mobs deal with corpses Dec 14, 2024
@Lutowski
Copy link
Collaborator

Lutowski commented Jan 1, 2025

Mobs may need nerfs

specifically for attack speed yes, last I checked there's no way to alter that for mobs. only npcs seem to have atk speed variables to edit

@crix870
Copy link
Author

crix870 commented Jan 1, 2025

Mobs may need nerfs

specifically for attack speed yes, last I checked there's no way to alter that for mobs. only npcs seem to have atk speed variables to edit

You can give them custom intents and make them slower. I think all of the mobs (on live) are using 1s generic attacks

@crix870
Copy link
Author

crix870 commented Jan 3, 2025

I've centralized all the general mob data (health, attack speed and movement speed) into defines so future-people can balance it to their heart's content.

@crix870 crix870 force-pushed the hopefully-smarter-mobs branch from 47d8ba0 to 95762b4 Compare January 3, 2025 11:52
@crix870 crix870 force-pushed the hopefully-smarter-mobs branch from 95762b4 to e82f6bf Compare January 3, 2025 12:28
Copy link

Test Merge Deployed

Details
Server Instance

Azure Peak

Merged By

lutowsk

Revision

Origin: 9c7fab3
Pull Request: ebec7d6
Server: 390a503a43e790c010edc4b7bf85e5f72803e72a

Comment

@Lutowski
Copy link
Collaborator

Lutowski commented Jan 3, 2025

testmerging for a little bit, poor pr's waited long enough already

Copy link

Test Merge Updated

Details
Server Instance

Azure Peak

Merged By

lutowsk

Revision

Origin: f28f2b2
Pull Request: ebec7d6
Server: 1baf6c2a4d8bac4390cf1be14ea7f4bac090950a

Comment

Copy link

Test Merge Updated

Details
Server Instance

Azure Peak

Merged By

lutowsk

Revision

Origin: b7b7956
Pull Request: ebec7d6
Server: 30c535e8d9e0e1b709794a9e2fad0161cf112ec1

Comment

Copy link

Test Merge Updated

Details
Server Instance

Azure Peak

Merged By

lutowsk

Revision

Origin: ddff52f
Pull Request: d344b66
Server: 415bbad2cbac1fb4cc87ac72a29922f26c189893

Comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants