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

[MIRROR] Basic mobs now use z-level turnoff instead of simple #2771

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

Steals-The-PRs
Copy link
Collaborator

Mirrored on Nova: NovaSector/NovaSector#1837
Original PR: tgstation/tgstation#82469

About The Pull Request

On one compile of MetaStation, I saw that there's 45 basic mobs on the station, 256 on lavaland (the number growing from tendrils), and 59 in all other z levels combined.

While we do expect Lavaland to be visited every round, at least it won't be running during the times when no one is there, but even more importantly, space exploration is something not done every round, so we don't have any reason to waste our resources on AIs that will never be interacted with.

Simple animals had an easy solution to this:
If no one is on the Z level, their AI turns off
If someone is on the Z level, they are idle unless needed.

The last simple animals that exists right now are bots, megafauna, geese, gondolas, and some minor ones like mimic, zombie, dark wizard, soulscythe, etc.
Point is, we're very much nearly done going through all simple animals, so this code is being wasted just to ensure things like cleanbots won't work if no one is on the z level, something I doubt happens often, so I took their code and made it work for basic mobs instead. I could've done both but I thought it would look very bad, and maybe this is a good incentivize to get more basic mob conversions.

There's one major change here and it's that we're missing the "Idle" mode, some basic mobs like the Lavaland village seems to be made with intent that they'll be running even if players aren't around, so this sets up a future PR that makes idle AI easier to add, and I want to make sure those cases are taken into account.

Why It's Good For The Game

We don't need to always be processing these basic mobs, and sets us in the future to hopefully also implement idle AIs.

Changelog

🆑 JohnFulpWillard
balance: Basic mob AIs with no mobs on the Z level now stop.
/:cl:

* Basic mobs now use z-level turnoff instead of simple (#82469)

## About The Pull Request

On one compile of MetaStation, I saw that there's 45 basic mobs on the
station, 256 on lavaland (the number growing from tendrils), and 59 in
all other z levels combined.

While we do expect Lavaland to be visited every round, at least it won't
be running during the times when no one is there, but even more
importantly, space exploration is something not done every round, so we
don't have any reason to waste our resources on AIs that will never be
interacted with.

Simple animals had an easy solution to this:
If no one is on the Z level, their AI turns off
If someone is on the Z level, they are idle unless needed.

The last simple animals that exists right now are bots, megafauna,
geese, gondolas, and some minor ones like mimic, zombie, dark wizard,
soulscythe, etc.
Point is, we're very much nearly done going through all simple animals,
so this code is being wasted just to ensure things like cleanbots won't
work if no one is on the z level, something I doubt happens often, so I
took their code and made it work for basic mobs instead. I could've done
both but I thought it would look very bad, and maybe this is a good
incentivize to get more basic mob conversions.

There's one major change here and it's that we're missing the "Idle"
mode, some basic mobs like the Lavaland village seems to be made with
intent that they'll be running even if players aren't around, so this
sets up a future PR that makes idle AI easier to add, and I want to make
sure those cases are taken into account.

## Why It's Good For The Game

We don't need to always be processing these basic mobs, and sets us in
the future to hopefully also implement idle AIs.

## Changelog

:cl:
balance: Basic mob AIs with no mobs on the Z level now stop.
/:cl:

---------

Co-authored-by: san7890 <[email protected]>

* Basic mobs now use z-level turnoff instead of simple

---------

Co-authored-by: John Willard <[email protected]>
Co-authored-by: san7890 <[email protected]>
@mogeoko mogeoko merged commit 4f48580 into master Apr 7, 2024
27 checks passed
@mogeoko mogeoko deleted the upstream-mirror-1837 branch April 7, 2024 08:10
AnywayFarus added a commit that referenced this pull request Apr 7, 2024
Iajret pushed a commit that referenced this pull request Jun 1, 2024
…ging light replacers 200000 times a charge tick (#2771)

* Stops janiborgs from killing the machinery subsystem by charging light replacers 200000 times a charge tick (#83624)

## About The Pull Request

So, with the somewhat-recent power changes, cells now have a shitton of
charge compared to the old one.

Now, recently, the `model.respawn_consumable` call in
`/mob/living/silicon/robot/proc/charge` was changed to use this
variable, so every time you had a borg inside a charger, it would
constantly drain 0.5% of its cell charge, and use it for the light
replacer charge calculation.

### The light replacer

So, we now have about 200000 as the charge coefficient on bluespace
cells. On code that was made back for 1000 charge in like 2012 according
to the gitblame. Slight issue: **There's a fucking for loop looping
200000 times every time we charge**, calling
`/obj/item/lightreplacer/proc/Charge` every time it loops. It has no
break condition, so it does this every machinery tick. This, with a
single janiborg with a blue cell kills the machinery subsystem and
causes a hell of a lot of overtime, and a hilarious profiler log:

![image](https://github.com/tgstation/tgstation/assets/49160555/92726216-3bc3-4504-ab69-a2f2adf954f8)

### The fix

Simply not make the light replacer calculation loop like this and just
use division and a modulo, like a normal sensible coder, plus adjust it
to the new cell values.

See the profiler log now:

![image](https://github.com/tgstation/tgstation/assets/49160555/d909de18-f0a2-4172-ae8d-98f2641bcc89)

## Why It's Good For The Game

It fixes a potentially game killing bug. A FUCK moment to be sure

## Warning for upstreams

_Looks at Nova and Skyrat_ check your Charge() proc usages, I know you
have at least one extra hit for it.

## Changelog

:cl:
fix: Fixes janitor borgs killing the machinery subsystem by charging
light replacers 200k times a tick.
/:cl:

* Stops janiborgs from killing the machinery subsystem by charging light replacers 200000 times a charge tick

* Fixes our override as well

---------

Co-authored-by: Waterpig <[email protected]>
Co-authored-by: NovaBot13 <[email protected]>
Co-authored-by: Mal <[email protected]>
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.

3 participants