Monday, May 21, 2012

On the complexity of missile combat

This bog post is the kick off post for ADOM II 0.3.0 development. The past two days did not unearth any particularly disturbing bugs in ADOM II 0.2.7 (although a couple of very nice enhancement ideas and game balance improvements already have been suggested). According to my evaluation none of them are harmful to the enjoyment of the game so that I decided to move on and start the development of ADOM II 0.3.0. I already have updated DevState in order to inform you about the most pressing issues I want to tackle with ADOM II 0.3.0. Despite "release early, release often" 0.3.0 is going to take a while longer (it probably will get released around the end of June).

Now for the main topic of this blog post: missile combat.

Let's look at the past first. In ADOM Classic missile combat is rather simple:
  • The player declares his intention to shoot a missile or throw a weapon (by keyboard input).
  • ADOM checks all prerequisites and either aborts or shoots the missile.
  • The shot itself is instantaneous. The path is calculated, the flight of the missile is animated, a target is reached, hits or misses are resolved, etc.
  • The game continues.
I want this to be different (and internally a lot more complex) for ADOM II as I believe that the new enhanced implementation will add tons of interesting details.

The most basic and most important change will be that shots no longer are going to be instantaneous. While this might sound like a trivial change the implications are tremendous. Let me explain:
  • In ADOM II a basic unit of action (internally called a "tick") is made up from 1000 minuscule units of time. One base time unit (1000 ticks) basically is equivalent to 10 seconds.
  • As soon as a "shot" (my current abstraction name for a missile attack) takes place and no longer is instantaneous it becomes a thing in the game world - even if just for a brief while.
And that's already the exciting thing. If a shot (a flying arrow, a thrown dagger, maybe even a thrown opponent - think of monks) becomes an actual entity in the game world and moves at high speed from source to target there are possible interactions:
  • A monster or the PC might step into the flight path, actually begin accidentally hit by the missile.
  • The target might move out of the flight path if he or she gets very lucky (the target would have to be able to move in the split second between shooting and hitting).
  • Other environmental effects might influence the shot (e.g. high liquid levels might stop or destroy it, strong gusts of wind might change the course, an exploding fireball might catch up with it before the shot reaches the target thus destroying it, etc.).
Sadly the complexity of the implementation also rises:
  • A shot needs to be an abstraction for everything from a thrown being to an arrow launched from a bow.
  • A shot needs to be able to actively influence the environment (what happens if a troll thrown by a monk hits a door?).
  • A shot needs to be influenceable by the environment (fireballs, wind, liquids, etc.).
While the complexity is quite high (as all the things above need to take into account the material and speed of the shot, the makeup of the intercepting environmental factor, etc.) I think it's definitely worth the effort since both combat and the general environment become a lot more interesting.

Just imagine a trap at the end of a very long tunnel - it shoots highly poisonous arrows but the PC just needs to move around a short corner... magic that speeds up movement extremely suddenly might become very desirable... and so on.

Additionally I'm currently pondering to allow more targets for missile attacks:
  • Monsters are the trivial targets.
  • Items might be interesting targets (think about a quest of the type "prevent the evil lich Marcarak from gaining the vial of might - and when you finally reach the vial of might Marcarak also already is there and moving towards it to get it - it might be nice to decide whether to try destroying the vial before Marcarak gets to it or take some other gamble).
  • The environment itself might be interesting (maybe smashing doors by repeatedly shooting at them with special ammunition).
  • It might be interesting to add traits in the form of "can stop missiles" to other things in the game (walls are a natural candidate) in order to be able to build interesting spells in the 0.4.x development line (e.g. "area of protection from missiles").
It also would be a great ability for tinkers to be able to craft special ammunition. And high-level archers also might get some skill in that - or be tempted to travel to large cities to buy such stuff in Tinker Bazaars.

And finally it could be very interesting for combat to have varying missile speeds... e.g. thrown daggers being slower that arrows, which in turn might be slower that crossbow quarrels. So there are ample ideas I'm gambling with right now and I expect missile combat to be a lot more interesting and exciting in ADOM II :-)

Further ideas and discussion naturally is extremely welcome! 


  1. an idea, if a character has an extremely high speed and/or perception level he should be able to notice that someone is aiming at him a while before the shot is taken (depending on the speed of the shooter and the weapon being used). At the very least this could translate to enough time to brace for impact or put up a shield. If i had a great perception speed and dodge i should be able to dodge and or block most arrows, especially those coming from unskilled opponents.

    also, picking up and throwing dwarf children is a must

  2. and make boomerangs and scurgari more accesible please. I was always lucky to find 1 or 2 good boomerangs, if that, in an ADOM I game

  3. Environmental/physics-oriented stuff would certainly be good---things analogous to the forces of Magnetism, stuff along the lines of Telekinesis, cutting ropes and chains to varying effects ala chandeliers, lodging a weapon in a magic circle to disrupt it, potential for grappling hooks/spiked chains on the level of merriment and awe that the Roguelike Incursion had possible even in its Alpha state, etc.

  4. Does your design account for situations in which (due to unfortunate timing of turns/ticks) someone shoots at the PC, and PC's next turn to move comes mid-flight, and the player sees an arrow frozen in mid-air before him?

    It does not look 'right' from the gameplay standpoint (you don't have to be Neo for this to happen!), and it seems to me it could happen pretty often if the PC is e.g. hit by a barrage of arrows from an orcish army.

    1. I don't see a problem with this situation at all!

      First, you've got a whole Orc army firing arrows at you - hundreds of them. You expect to win this fight, so you are pretty much Neo.

      Second, even if you were going to die, if the entire force at Agincourt fired a volley of arrows at you, any time you looked up you'd see [b]lots[/b] of them in flight and hell, you'd be able to dodge several of them if you cared. Arrows move (~300 fps) a lot more slowly than bullets (~3,000 fps). To put that in perspective, an arrow only moves about three times faster than a major league fastball; especially if someone is far away, it is entirely possible (not the same as easy) to dodge an arrow in flight by jumping out of the way.

    2. I don't know, the situation seems irrelevant of distance and shots fired, it just happens more frequently that way. Maybe it's OK balance-wise, but it doesn't feel realistic...

    3. I'm fine with it working like this! Keep in mind that a PC with an AVERAGE speed is pretty much never going to see this. It's only when you get your speed up to superhuman levels that you're actually going to be able to react before the missile hits you - in which case "Neo" missile dodging makes a lot of sense. (I'm assuming that high-level archers will be able to shoot faster too, to make up for this?)

      You did raise a good point in that there needs to be a way to distinguish between "missiles in flight" and "missiles lying on the ground"... so that I don't walk onto a space trying to pick up an arrow and end up getting shot in the eye...

    4. i agree with humpolec. It's kinda weird to see an arrow frozen.

    5. I too dislike the idea of frozen arrows. While the game is turn based, I like some illusion that time is flowing. Overall I like the idea as long as it's implemented right. I'm okay with dodging a thrown troll, but an arrow ...

  5. i think this idea is great!

    hope the development goes well ^^

  6. One possible problem: Let's say there are several projectiles hanging in the air and it's your move; how will you visualize the projectiles' trajectories?

    In a complex battle situation it might be tough to know where each projectile is headed... Just something to think about.

  7. All of these situations you described sound fantastic, and I can't wait to see all of this ingame.


    One thing I want us to keep in mind is that all of the situations you've mentioned (hitting the wrong target because they move in the way, monsters walking out of the way of missiles, and the environment affecting missiles) will actually make missiles overall weaker and less effective than they were in ADOM. The only new 'advantage' that archers get so far is that they can now target objects and items (which seems highly situational, and not likely to come up in an average dungeon-crawl).

    Please don't get me wrong - I WANT all of the changes that you are planning on making to missile combat - but I just wanted to mention this!

  8. Imagine you are in a long single tile corridor and the target is an agile goblin. So you take off the bow and cast an arrow. Where? To the head, torso, legs, arms, groin ;)? So I aim to the head (+more damage;+ a lot better chance for a death blow; -chance to hit). The arrow flies, but the goblin, being an agile(alert,perceptive) m ... goblin, just tilts his head at the last moment. Next shot - to the torso. Hit. the goblin has lowered hitpoints and slightly lowered fighting capabilities(since the arrow in the stomach). Second arrow in the chest - pierced lung, and so on.

  9. Some ideas:

    Bars and grated doors should be must now -- passable for small projectiles (but not for, say, thrown trolls).

    The anti-missile protection spells should also probably distinguish between these cases. Perhaps there would be a limit for the weight of missile that can be stopped? And it would increase with level/rank of the spell? Above that level, the spells could be concepted as cutoff (won't work at all), lessening (decreases the damage until the weight of projectile reaches, say, double of maximum, then stops working) or probabilistic (too heavy projectile will be either stopped or it will pass through unimpeded).

    This would also allow for "anti-magic" prefix for missiles that would make them pass through missile-blocking spells.

    As for inhuman reflexes when you see arrow in mid-flight -- one way would be that even if you move away from the flight path, the action of actually dodging shouldn't be instantaeous either -- it will take a few ticks for you to physically move, and if the arrow hits you before the action is complete, then too bad for you. If not even the missiles are not instantaneous, then should anything actually be?

    What about magic shots like firebolts and magic missiles? Their speed might suddenly play a part as well. For example, if I understand you correctly, then a tick is 0.01 s and there is an additional unit (militick?) that is 0.00001 s when necessary. So, lightning bolts should be still instantaneous (since lightning moves more or less at the speed of light and that's still 3 km per militick), but firebolts would be slower. Bouncing from walls could be now explained by the speed of the projectile -- lightning and magic missiles are fast enough to bounce rather than being stopped dead, while fiery, icey or acidic shots are not.
    On the other hand, I imagine improved fireball to be a rather slow projectile, slow enough that you could dodge it if you notice it, but not that slow so you could completely escape the blast zone.

    As for seeing trajectories of missiles seen in-flight, I suggest that a when 'L'ooked at, they would show last two squares the missile was on and two panels where it should be next (in different color, so you would know what's past and what's future). That should be enough information for PC to determine where the missile is flying.

    Other missile ideas:
    Phasing missiles -- become immaterial along the way, only materializing when striking the target. Could shoot through friendly creatures, and even through walls (which wouldn't be too useful unless you have some way to ascertain what's on the other side).
    Multishot weapons -- like a crossbow that could load three quarrels at once and shoot them in three adjacent directions. Low accuracy, but potential to hurt multiple targets. Crowd control weapons.
    Missiles "of knockback" that would push target away in addition to damage. Would be pretty useful for interaction with level elements (imagine knocking back a locked door).

  10. Maybe something like quicklings that can avoid archer's missiles due to extremely high speed.

    Another idea is potion of quickling rage, that can speed up pc's speed for a moment, so it looks like time is freezing, that grant ability to dodge or escape incoming missiles.

  11. A few ideas:

    a) Artifact gloves that can grab arrows out of the air - requires you to leave a free hand - arrows / projectiles drop on the floor at your feet, so you can pick them up.

    b) Missile repulsion field - similar to the "area of protection from missiles" but bounces missiles back in the direction they came from, with equal force. Requires more energy to cast.

    c) If a target is moving fast, in a specific direction it would be possible to shoot the arrow ahead of the target in the direction it is going. (10 seconds is a long time to someone running at full speed, so if you are shooting say to protect a child from a hungry wolf, you will need to lead the target by a short distance if you are a long way away).

  12. Another idea, related to the missile dodging -- like you can set your tactics, which is basically a trade-off between attack and defense, you should be able to set a trade-off between the speed of movement and awareness of your surroundings. At high speed settings, you'd get penalties to Perception and might not even notice an enemy until you run into him -- on high awareness settings you would have much better chance to accidentally find secret door or traps or to dodge an unexpected attack, melee or missile.

  13. Just wanted to point out, TOME has a similar system where missiles are not instant and depending on the speed of the missile and your character you will sometimes get an opportunity to move out of the way of an incoming missile. Anyone wanting to see how it plays could give that a try. (It's a good roguelike and worth playing anyway.)

  14. I second the idea of Marek14, also it will be good to be able to switch to stealth mode - slow crawling forward, to ambush from behind an enemy. What about a special crossbow for the trolls, aka the portable ballista from Strong in the Arm(R). Used for opening trapped doors and pinning foes to the wall, perhaps second or third if they are not very solid.

  15. It would be nice if you could kick or push an enemy in the path of a projectile.

  16. Arrows that pass through fire should become fire arrows and such..

    1. The thing is... why exactly? First of all, a normal arrowhead is made of metal, possible stone, bone etc. -- all decidedly nonflammable materials. If the shaft or the feathers start to burn... it won't help it do much damage.

      If you'd want an arrow to burn, you'd wrap some cloth around the arrowhead, soak it in a flammable liquid, and if you're going to do all this work, why shooting through fire? Why not just light the thing before shooting?

      The second problem is that things generally have to spend some time in fire before they start to burn. Every flammable material has an ignition temperature and you have to warm it up to this temperature before it burns. A fast-moving arrow would probably not even get warm if you shoot it through a curtain of flames or something like that.

    2. Because it is fun? You think too much lol.

  17. Missiles should have also aim-time, during this aimtime aware targets have opportunity to try to evade fire somehow (lift shield, dodge-manouver, cast a spell etc). Thrown weapons have smaller aimtime than bows/crossbows.

    And now when we are in this... also directed spells should have that, not just cast-time.

    With good perception one should spot aiming/preparing monster/pc earlier than someone not so aware, thus he can start readying his counter earlier than other characters would. This would make perception/awareness much more usable skill in game in terms of survival.

    So it would be like this:
    Orc starts aiming at PC with bow.
    PC succeeds awareness check, he has shield at hand and throwing daggers with high skill.
    PC opts to counterattack thinking he might be fast enough to throw his dagger before orc shoots due faster aimtime.
    PC succeeds, but because dagger has slower flightspeed also orc manages to shoot...

    1. I like the idea of being able to interrupt spells/shots. I've always felt funny firing a bow at a monster adjacent to me but the game mechanics normally make this a better option then changing to a melee weapon with an archer.

  18. Visualize this:

    Arrows of Healing
    Controlled Teleport
    High dodge value

  19. Now that you talk about teleport, it would also be very very cool if teleport traps could teleport arrows and other missiles.

  20. Feels like a feature creep that will lead to physics-based inconsistencies. Field manipulation (throwing/knocking around enemies) is interesting, but incorporating missile timing into necessarily reductionistic combat rules gets stupid. Turn-based games and simulation is pointless.

    Stepping out of the missile trajectory effectively nullifies the point of having skills associated with missile avoidance (in a possible case). A character with ridiculous speed and absolutely zero dodge could actively avoid an unreasonable amount of attacks (and spells). If hi-speed translates to a greater number moves in a given period of ticks, then we have the potential for characters to suddenly change direction at the negligence of momentum. Mixing abstractions and simulation is an unnecessary complication. If a hi-speed entity is charging at an archer, the dodge should be handled by combat mechanics, not the board state.

    Similarly, the skill of an archer is the determining factor as to whether or not they effectively read the wind. A sudden gust of wind throwing the arrow off course should be a skill failure in a windy environment. Emulating gusts of wind and other stuff is a sheer waste of development time.

    If a PC can move very quickly, that doesn't translate to magically dodging arrows like a SHMUP. A very skilled archer leads a fast target appropriately-- Will ranged attacks now target "squares" instead of objects? Do we have to lead our shots against the rate of movement of enemies and vice versa? This is ridiculous and defeats the point of having mechanics. The very point of having combat rules is to eliminate the need to simulate!

    Make better rules that allow for emerging factors, don't try and simulate physics.

    Roguelikes are interesting because the map is like a board- we reliably understand how moves take place and can assess the gamble of any given decision. The addition of simulated time and physics only adds unnecessary calculations on top of what could be handled with just the RNG. It also can lead to odd situations where events take place without the player possibly knowing they are taking place. The only way to communicate information reasonably and fairly is with clear and concise graphics in real-time.

    The only exception in which this sort of thing might be appropriate is with a completely deterministic combat system.