User Tools

Site Tools


Draw distance and its effects in-game

By: Chthon Original post:

(The rest of) this post is dedicated to explaining what goes into doing draw distance correctly. This is useful for (1) people making their own draw distance mod, (2) people merging draw distance with other mods, and (3) people who want to know what to look for by way of potential errors to report.

I. Camera Distance

Camera distance is how far the camera is zoomed out from the ground. It's not “draw distance,” but it's often part of the draw distance mods. Originally I had not intended on messing with camera distance, but balance issues with aggro forced me to. Camera distance is set per map, and controlled by the CAMERAMULT value in the .TEMPLATE files found in MEDIA\LAYOUTS\. The default for most outdoor levels is 1.2. The default for most indoor levels is 1.0. Increasing indoor levels higher than 1.1 causes 2 problems: (1) sometimes the ceiling gets between the camera and the battlefield, and (2) sometimes you encounter “end of the word” bugs where you can see the boundary between the map and the undefined space beyond. These happen noticeably, but rarely, at 1.2, and more frequently as you increase camera distance.

For this mod, camera distance for indoor levels has been increased to 1.1.

II. Draw Distance

A. Introduction

Draw distance is the distance away from the player at which monsters are rendered to the scene. Many people dislike the default draw distance because the monsters fade in too close for comfort, often in places that you thought were safe territory until the monster appeared.

Draw distance is controlled by some values in GLOBALS.DAT.

  • UNIT_NEAR_RANGE is the distance at which the game instantiates monsters as you move towards them. If you move away from an existing monster, at this distance it will instantly disappear into suspended state until you get near it again.
  • TRIGGER_NEAR_RANGE performs the same function as UNIT_NEAR_RANGE for the stash, shared stash, practice dummy, and landmarks.
  • OUTDOOR_UNIT_ACTIVE_RANGE is the distance at which a monster in an overworld map starts to fade in or out, and starts to do things like idle and wander.
  • INDOOR_UNIT_ACTIVE_RANGE is the same thing for dungeon maps.

Obviously, you want UNIT_NEAR_RANGE at least slightly bigger than both OUTDOOR_UNIT_ACTIVE_RANGE and INDOOR_UNIT_ACTIVE_RANGE.

B. Values

Now, what are sane values for OUTDOOR_UNIT_ACTIVE_RANGE and INDOOR_UNIT_ACTIVE_RANGE? I did some testing using a modified elemental attunement and the damage shapes console command. Here are the results:

For a 1.2 camera zoom (i.e. most outdoors stuff):

12 - brushes bottom of the screen
18 - almost reaches bottom corners
20 - default
32 - all but a really, really tiny bit in the top corners
33 - full coverage

For a 1.0 camera zoom (i.e. most indoors stuff):

10 - brushes bottom of the screen
15 - almost reaches bottom corners
16 - default
26 - all but a tiny bit in top corners
27 - full coverage

For this mod, I set OUTDOOR_UNIT_ACTIVE_RANGE to 32 and INDOOR_UNIT_ACTIVE_RANGE to 29 (29 gets all but a tiny bit in the top corners at 1.1 zoom), and UNIT_NEAR_RANGE to 34.

C. Side Efects

Now, adjusting the draw distance has two major side effects:

  1. Making the game keep track of and draw these extra monsters makes the program more resource-intensive, and less powerful computers can't handle it and will lag. This is an unavoidable cost of draw distance mods.
  2. It causes all sorts of problems with the AI aggro model. In a minute, we're going to come back to this and look at what it takes to get the aggro working right.

III. The Render Always Flag

NOTE: As noted later in the thread linked above, DO NOT use this flag globally. It messes up a number of particle effects. -Chthon

When monsters come out from behind an obstruction, such as a UI menu, they fade in. This causes the same sort of “oh surprise, there's a monster there!” problem as a short draw distance. The solution is to set the RENDERALWAYS:true in the base monster so that all the monsters inherit it.

Unfortunately, this has a side effect. Some monsters don't display properly with RENDERALWAYS:true, so you need to go back through and set RENDERALWAYS:false for some units. This seems to happen mostly with breakables and other units that switch between two visible states. I think I've found them all, but maybe missed some. Please keep an eye out for these while testing.

Here's the list of units I changed back to RENDERALWAYS:false:
nether_flytrap_lootable_01.dat (ichor pod)
vaultturretmobilespawnertop.dat (mobile spawner top)
eggs flyer_egg_01.dat through 04 + trillbot_egg.dat (skara eggs)
Gargoyal_Lava ??? (think this one was just my imagination…)

[edit: This breaks some particle effects, so it has to go. :(]

IV. The Horrible Mess That Is Aggro

A. Aggro Generally

This section is basic information about how aggro works in TL2. There are three ways that a monster can notice you.

  • First, it can notice you if you are within its Sight Radius in a direction that falls within its View Angle (i.e., it notices you by looking at you).
  • Second, it can notice you if you are within its Motion Radius, regardless of the direction (i.e., it notices you because it hears you/smells you/sees you from the corner of its eye).
  • Third, it can notice you if you do damage to any monster that is within its DMG React Radius. (That includes the monster itself, except that critical hits reset the monster's “mind” so it won't react to them.)

After the monster has noticed you, it decides whether or not to chase you based on its Follow Radius.

B. Aggro Problems

Problem #1: No Reaction to Long Range Pot Shots

The first major side effect of upping the draw distance is that it creates a situation in which you can hit monsters near the edge of the screen with long-range skills, but they won't react. So you can just sit back and take pot shots until they die. This makes the game braindead easy, and that's not good.

The solution is to increase the monsters' Follow Radii. But how much?

To sort this one out, I wrote a small program that surveys the dat files to make a report of the existing Follow Radii, and then changes them according to a mapping between old and new values that I provide. This enabled me to keep the new Follow Radii in roughly the same proportion to OUTDOOR_UNIT_ACTIVE_RANGE and INDOOR_UNIT_ACTIVE_RANGE as they were before. This means that there are still some monsters that you can take out with cheesy pot shots – but they are the same monsters that you can do that to in vanilla TL2. Everything else will give chase when you attack it (or its buddies).

If you want to play with it, the program is here:

(I'm not offering support for this, since it was primarily intended for my own use.)

For (my draw distance) mod, I used the following mapping:

10→16; 14→22; 16→26;
17→27; 18→29; 19→30;
20→32; 22→33; 24→34;
25→34; 26→34; 27→35;
28→35; 30→36; 35→36;
36→36; 40→40.

Problem #2: Pot Shots Part Duex

In addition to increasing follow distance across the board, some monsters needed additional special tweaks to their aggro-related stats to make them adequately aggressive. Most of these were bosses, who would lose sight of the player and thus stop chasing until the player damaged them. While not as bad as monsters that won't chase at all, bosses that stop chasing and give you free hits are also too easy.

Here's the list of monsters that needed tweaks to increase their aggro-related stats:

C_STURM_MELEE_GUNNBREN_CHAMP.DAT (increase sight to 20 & follow to 32)
C_STURM_MELEE_STENNBRUM_CHAMP.DAT (increase sight to 20 & follow to 32)
C_STURM_MELEECHAMPELEC.DAT (increase sight to 20 & follow to 32)
C_STURM_MELEECHAMPFIRE.DAT (increase sight to 20 & follow to 32)
bandit_ranged (increase sight to 12)
bandit_ranged_tower (increase sight to 12)
boss_goblin_mine (increase sight to 30)
boss_map_troll (increase sight to 30)
boss_faceless_king (increase sight to 30)
boos_bloatfang (increase sight to 32)
boss_fungus (increase sight to 30)
boss_map_ancient_guardian (increase sight to 30)
boss_map_sturm (increase sight to 30)
boss_map_tutara (increase sight to 30)
boss_map_werewolf (increase sight to 30)
boss_map_wraith (increase sight to 30)
boss_netherim_shadow (increase sight to 30)
boss_pider_cave (increase sight to 30)
boss_werewwolf (increase sight to 30)
boss_wraith (increase sight to 30)
boss_yakutaur (increase sight to 30, motion to 25)

Also, some scripted events with bosses got broken, so I have to edit the map layouts for these two events:

  • increase sphere trigger range around winter widow to 29 (without this it's possible to hit the boss without ever triggering her active state)
  • increase bandit kings box trigger width from 6 to 12 (without this you won't get close enough to trigger the boss banner and music before aggroing the bosses)

Please keep an eye out for insufficiently aggressive monsters (especially bosses) when testing this mod out. I think I got them all, but I may have missed some.

Problem #3: Off-Screen Aggro

The second major side effect of increasing draw distance is that you get a lot of aggro coming from off-screen. The heart of this problem is the isometric view angle.

Getting the draw distance circle (really an oval form the player's point of view) big enough to cover the top corners of the screen requires extending the circle way, way, way past the bottom of the screen. (Remember that the bottom of the screen is 12 units away at 1.2 zoom, but it takes a 32 unit circle to (almost) reach the top corners.) So there are quite a few monsters with sufficient sight and follow distances that they will aggro from pretty far beyond the bottom of the screen (and the sides to a lesser degree). (Especially since we just increased follow distances across the board…)

Why doesn't this happen in vanilla TL2? Because the monsters don't exist yet when you enter the range at which they'd see and attack you. The low draw distance in vanilla TL2 is effectively clamping monster aggro range, and the draw distance increase removes that limit. (By the way, this is the problem that forced me to up the camera distance for indoors areas.)

I tweaked my little program to generate a report of monsters that end up with unusually large increases in the size of the area from which they'd aggro from off-screen. The math is as follows:

Distance_at_which_monster_will_attack = D = Min{sight_radius, draw_distance};
Size_of_area_from_which_monster_will_aggro_from_off-screen = S = Max{0, (D - distance_to_bottom_of_screen)};
so, S = Max{0, Min{sight_radius, draw_distance} - distance_to_bottom_of_screen};
DeltaS = New_S - Old_S;

If DeltaS is unusually big, then the monster may be a problem. (Ideally, DeltaS would have a baseline of zero, but that's not possible. I think I ended up with a baseline around 2-3.)

Using the auto-generated list of potential troublemakers, combined with some playtesting, I came up with the following list of monsters that needed some tweaks to their aggro-related stats:

FUNGUS_SPORE.DAT (set fdist back to 18)
FUNGUS_SPORE_PET.DAT (set fdist back to 18)
skill_skeletonwarrior_Agressive (versions 1-6) (set fdist back to 18)
skill_bloodskeleton (set fdist back to 18)
TROG_BRUTE.DAT (sight -2)
WEREWOLF.DAT (sight -3)
WEREWOLF2.DAT (sight -3)
WEREWOLF3.DAT (sight -3)
ZOMBIE_ANCIENT_CHAMP.DAT (sight, motion, & damage react -5)
ZOMBIE_SWAMP_WITCH.DAT (sight, motion, & damage react -5)

Also, it turns out that monsters using teleport+attack skills from off-screen is just no fair, so these two skills got their ranges cut down:

Gargoyal_Jump skill (range -5 (down to 15))
NetherimTeleportToPlayer skill (range -14 (down to 16))

Once again, I think I caught everything that needed fixing, but I may have missed some. So, please test the mod out, and post what you find.

Please note that some amount of increased off-screen aggro is unavoidable. So don't expect to see it reduced back down to the levels in vanilla TL2 – because it's not possible. Also, it wouldn't be fair. Increased draw distance gives the player a pretty big advantage in terms of hitting first and having a lot of time to keep on hitting while the monster closes the gap, so I don't feel too bad about letting the monsters sometimes get the drop on the player.

Problem #4: Friendly Minions... Oh F*ck!

So…. it turns out that friendly summonable minions get a hidden bonus to some of their aggro-related stats. And this makes a complete and utter mess of their aggro behavior with increased draw distance. Surprise!

I'm not sure which stats get the hidden bonus, and I'm not sure how to design an experiment to isolate them properly. I suspect that Sight Radius, Motion Radius, and Follow Radius all get the bonus. Probably DMG React Radius, too.

I'm also not 100% sure how big the bonus is. I suspect that it's equal to OUTDOOR_UNIT_ACTIVE_RANGE or INDOOR_UNIT_ACTIVE_RANGE depending on the current map.

The one thing I am proud of figuring out is how to counteract the damned bonus to make minions sane again – apply a passive sight bonus with a negative value. After messing around, I settled on a value of -23.5 for all friendly minions, plus special tweaks to individual minions:

spider-mine (negative sight bonus + revert follow back to 18)
hammerbot (no special tweaks, just the negative sight bonus)
machine_gun_bot (negative sight bonus + revert follow back to 18)
eng_copterbot (no special tweaks, just the negative sight bonus)
embermageavatar (no special tweaks, just the negative sight bonus)
wolfshade (negative sight bonus + adjust follow radius down to 10)
shadowling brute (no special tweaks, just the negative sight bonus)
shadowlingbat (negative sight bonus + adjust sight and motion down from 20 to 8, react up from 10 to 20)
zombiedustfiend (negative sight bonus + adjust sight and motion down from 20 to 8, react up from 10 to 20)
zombie pet (negative sight bonus + revert follow back to 18)
zombie item summon (negative sight bonus + revert follow back to 18)
zombie pet blood (negative sight bonus + revert follow back to 18)
skeleton warrior skill (negative sight bonus + follow from 18 down to 13, react 2 up to 7)
skeleton blood skill (negative sight bonus + follow from 18 down to 13, react 2 up to 7)
nether imp summon (negative sight bonus + follow from 18 down to 13, react 2 up to 7) (also fixed abnormally high follow on rank 1)

(Non-moving minions don't need adjustments)
(Did not adjust flaming sword since the spell isn't in vanilla TL2, and the skill is a complete mess that needs work in order to be usable.)
(Did not adjust aloe gel since the unit itself doesn't exist in vanilla TL2.)

This is something that could use a lot of play testing. It was quite difficult to get the minions to (mostly) stay on the screen without making them too unaggressive.

There's also an unfixable problem with minions “island hopping” off the screen by taking out a nearby monster, then a second monster near the first monster and closer to the edge of the screen, then a third monster near the second monster and even closer to the edge of the screen, etc., until the damned minion's gone and run off the damned screen. (Wolf Shade is particularly bad about this because he's so darned fast.)

In any event, I think the balance with the minions is definitely 1000x better than with a naive draw distance mod, even if it isn't perfect.

edit: hey, I totally forgot to make notes for one more set of changes – OOPS!


The SPAWN_INVISIBLE flag causes monsters to not get rendered for their very first frame. This prevents monsters that are supposed to “pop up” from somewhere from flickering for a moment before popping up. (This problem is most notable with the Varkolyn in the dragon-theme dungeons.) To give credit where credit is due, I totally borrowed this list of monsters that need SPAWN_INVISIBLE set to true from Deezire's Unearthed Arcana mod:

draw_distance_and_its_effects_in-game.txt · Last modified: 2015/06/30 21:05 by chthon