mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-10 00:08:19 +00:00
## About The Pull Request The way we add multiple actions has been very unstandardized, with several implementations of this code doing certain things wrongly (i.e. not nullchecking `ai_controller`), so let's do something in the vein of #74037 and just make one nice big ol' proc that catches a lot of these cases. There are still a few things that simply can't be done here, but this gets the most generic "give my mob some actions and also maybe tell the AI about it" stuff done. This is only useful in cases where we don't ever need to reference the ability ever again when it's added. In an ideal world we would never need to reference the ability again and it would all be self-contained, but this is not an ideal world. However, a lot of the latticework has been built around certain implementations of this behavior making refactoring it just a bit easier. I also did a lot of auditing on `Destroy()` stuff, because `/datum/action`s listen to signals when their parent is `qdel`ing, so we don't need to neither hold nor clear references on our mob's `Destroy()`. This was all cleaned up now because even if we couldn't use `grant_multiple_actions()` (the new proc I add in this PR), it's just not useful at all and will further hinder efforts to implement this new proc. Also also, I noticed in some places (such as megafauna) that we were initializing a lot of datum actions _in nullspace_. We didn't pass the `src` argument to `New()`. I quickly fixed that, as well as got rid of the useless types we had going on. Also also also, I added a define macro to handle some of the cases that melbert was speaking about in his review down below. All you need to do is invoke the define on the typepath, and you should be good to go from there. There's probably a better way to do it, lmk though. we do the whole `do while` thing in order to prevent code leakages. ## Why It's Good For The Game * Very easy to change the implementation. In case we need to do something different in how we add actions or anything like that, we can simply just edit instances where this proc is located. * Standardizes addition behavior. There's a lot of cases like the aforementioned not-null-checking `ai_controller` that we really need to look out for, so having it all in one accessible proc ensures standard behavior. * Reduces copy-pasta. A lot of mobs had their own individual implementation of this, so let's just clean up all those lines of code. ## Changelog 🆑 refactor: The way mobs get specialized actions (like revenants shocking lights or regal rats summoning rats to their side when you slap them) have been modified, please report any bugs. /🆑 This doesn't touch the following case FTR: * Instances where we need to do work on the `/datum/action` after we `Grant()` it, like if we were to edit some variable on the action or if we need to call procs on said action. I don't like how the current code is so reliant on storing a variable to it, but that's a windmill to attack another time.