Skip to content

Experimental Saycode Optimization

Rob Nelson requested to merge pull/5342/FUCKYOUSAYLAGGYSAYCODE into Bleeding-Edge

Created by: clusterfack

Every hearer in the game is now attached what I call a virtualhearer. These are mobs that are set at the hearers location. The virtualhearers have max invisibility, alpha at 0, name = "", so by all rights they are full undetectable to a normal player. They have an attached var to the hearer they represent, and when that normal hearer is destroyed it will find its attached hearer and pluck it back into pooling.

These virtualhearers will all update their location when either hearers_in_view, (regular say), or get_mobs_in_radio_ranges, (radio code) is called. Updating each loc has a relatively small cost, on my slower private server about 6e-6 each for ~200-300 of them. They will update only every .5s at most to prevent spam calls.

The advantage to these virtualhearers is that get_hear is no longer a requirement. Get_hear itself costs 1e-4, which itself still gathers every object you must then recursively loop through. Updating all virtualhearers costs 2-3e-4, but only must be called once if a mob speaks through a radio. Instead of using get_hear we can uses either viewers() or hearers() on every location we want to check and get the results much more quickly.

Compare get_mobs_in_radio_ranges Before After

Merge request reports