// Dungeon Tactics
// Copyright 2012 lukas w. irwin [ lukas.w.irwin@gmail.com ]
// This program is free software under the terms of the GNU General Public License version 3 or later.


//
// abstract
//




In the 1351st year of the Pan-Gaian Empire, the high wizard Mirak, Supreme Magister of the school of Mages, removed from it's resting place in the Imperial palace The Phylactery of Axiam. With this artifact, said to posses power over death, he kidnapped Lady Aethyta, Princess of royal house and heir to the eastern Kingdom, and fled the city. In his path he ravaged the land, leaving a trail of corpses in his wake. Eventually the Wizard came to the city of Kzad-namloch, and there beneath the ruins he took to lair; a place that quickly became known throughout the land as the 'Dungeon of Death'.

Now, by order of the Immortal Dragon Emperor himself, a group of newly trained adventurers, unknown in name and title, have been heralded together as instruments with which to combat this threat.



You are an Imperial Dragon Knight, leader of a mighty band of adventurers. It is your task to protect the realm fierce monsters, ancient evil artifacts, and insane wizards that threaten it's existance. Before you stands the greatest challenge you have ever faced; behind you stand your allies; the fearless warriors and mighty wizards you have brought together and trained to aid you in your purpose.

"Dungeon Tactics" is a skirmish role playing game featuring retro graphics and unique gameplay mechanics. It is free and open source, download it, play it, mod it, share it with your friends!





//


"Dungeon Tactics" is a skirmish role playing game featuring retro graphics and unique gameplay mechanics. It was created for the Liberated Pixel Cup; a free software game development competition. In the LPC, teams have one month to build a game using art submitted to the contest.

One month is not a lot of time to build a game. I decided early on that my aim would be to focus on a single core gameplay mechanic and ensure that mechanic was the most fun and most polished it could possibly be. At the same time I decided on using a distinct hybrid 3d environment in order to visually differentiate my project from other lpc entries.

My secondary goal was to create a simplistic re-useable engine that could easily be refactored to support any genre or art assets. It was designed to be easily modifiable, not just for programmers but for anyone in the community. All game logic is scripted in well commented plain text files, and all game data can be easily edited using built in GUI editing tools.

In my opinion the goal of the LPC was not necessarily to build a game, but rather to build resources that can be used by lots of people to build lots of games, to be freely shared and enjoyed by people all over the world for ages to come.

I can only hope my contribution will provide such to the Free Software community.

~xhrit


//
// Tips
//

Click on the start zone to deploy a unit.
Clear a map by defeating all enemy mobs, or by sending a friendly mob into the exit zone.
Pick up as much loot as you can, and upgrade your mob's gear often.
Special abilities require SP to activate.
SP does not regenerate until the end of a match so use it wiseley.

Lead off a match by deploying a tough mob such as a fighter to absorb early hits.
Do not overextend your mobs. If they are too far away they will not be able to support each other in an emergancy.
Action beats reaction. Focus attacks against mobs that have not activated to force opponents to lose activations.
Successful placement strategies maximize frontage while protecting vulnerable mobs from attack.
Timing is everything. A well placed attack can change the tide of a match.

//
// Rules
//












A match is divided into turns.

During a single turn all units will activate once.

Each turn is divided into phases.

Each phase is divided into rounds which alternate between players.

During a player's phase they can activate a set number of units.

Units may activate in any order.

Each player gets the same number of phases each turn, but the number of activations per phase may differ depending on the number of units each player has.

The number of each phase activations is adjusted each turn to keep the number of rounds equal.

If player A has 10 units and player B has 5 then there will be 5 phases, during which player A will activate 2 units, while player B will activate 1.


The "phased activation sequence" is quite complex, but is entirely unique, and circumvents the main issues that pleuge other turn based systems. In IGOUGO systems the victor is often decided on the first dice roll, as the side that wins the inititative roll can effectivly attack the opponent force unhindered, often reducing it to below effective combat status before the opposing player has a chance to make a single move. In stat based inititave systems high stat value units are favored to the exclusion of all else, as the importance of moving and attacking first in considerable. In random inititave roll systems, a series of bad rolls can doom a player to the same fate as loosing an inititave roll in IGOUGO systems.












click on the start zone to deploy a unit
click to select a unit
click buttons on action menu to give commands

turn ends when all mobs have been activated
each player may activate a set number of mobs per phase.
a phase ends after a player has activated all avaliable units. Then the next players phase begins, wherin they may activate mobs of their own.

activations in round = allied mobs / enemy mobs
rounds in turn = allied mobs / allied activations
	
During a characters turn they may move, attack, special, or use item. Choosing move shows areas avaliable to move. Attack shows targetable enemies. special shows list of special attacks by level. and item shows list of players's shared inventory.

Map is made up of grids, black or white. black unpassable, white are .
Map is randomly generated, and 2 stairs are placed; one down and one up. Players mobs enter via stairs up.

A match is cleared when all npc mobs are destroyed or all player's mobs are destroyed / or have descended into the stairs down.
Game ends when specified depth is cleared ( last floor gets super chest, that needs to be looted? )

Each turn is made up of a variable number of rounds and rach round is made up of phases.

Game ends when user has cleared a set number of floors.

//
// Stats
// 

d6 style system. all stat values are based off of a d6 roll.

Attack / Defense
HP     / Damage 
SP     / Res (Drain)
Move   / Range

to hit = attack * d6 v.s. defense * d6
damage = damage *d6 - res

Special attacks do not need to roll to hit.

//
// Items
//

// Heavy Weapons
Axe            - +5 Damage, +1 Attack
Long Sword     - +2 Damage, +2 Attack, +2 Defense
Spear          - +2 Damage, +2 Attack, +1 Defense, +1 Range
Long Bow       - +2 Damage, +4 Range
Heavy Crossbow - +3 Damage, +3 Range

// Light Weapons
Short Bow      - +2 Attack, +3 range, +1 Damage
Light Crossbow - +2 Attack, +2 range, +2 damage
Dagger         - +6 Attack
Short Sword    - +5 Attack, +1 damage

// Hafted Weapons
Hammer
Mace
Rod
Cane
Staff

// Soft Weapons
Whipchain
Iron Fan

// Soft Armor
Cloth Armor    - +1 Defense, +5 SP
Paper Armor    - +2 Defense, +2 HP, +2 SP

// Light Armor
Leather Armor  - +3 defense, +2 HP, +1 Attack
hide Armor

// Medium Armor
Chain Mail     - +4 defense, +2 HP


// Heavy Armor
Half Plate     - +5 defense, +2 HP, -1 move
Full Plate     - +6 defense, +2 HP, -2 move

// Accessories
Shield                 - +1 Def
Gauntlets of Strength  - +1 Damage
Running Shoes          - +1 Move
Crystal Ball           - -1 Drain

// Consumables
Healing Potion       - recovers hp
Recovery Potion      - recovers sp
Cure Potion          - removes status effects
Skeleton Key         - opens doors and chests 

//
// Classes
//

Basic Class -> Advanced Classes -> Heroic Classes -> Ultimate Class

Classes are not neccessaralary more powerful then each other, but rather more specialized or more versitile.

// Class Tree

     1           T1
    / \
   2   3         T2
  / \ / \
 4  5 6  7       T3
 |  | |  |
 ---------
	 |
     8           T4

A mob must reach level cap (10) to unlock the next class tier.  A user must level all T3 herioc classes to 10 to unlock the Tier 4 class.

// Class         ( role )                     - Desc

Fighter          ( tank / aoe )               - AOE tank 
 Knight          ( tank )
  Lord           ( tank / buffs )
  Palidin        ( tank / heals )
 Gladiator       ( aoe )
  Pit Fighter?   ( aoe / cc )
  Dualist        ( aoe / melee )
   Weapon Master ( tank / aoe / cc )

Mage             ( debuffs / cc )              - debuffs and cc
 Warlock         ( debuffs )
  Necromancer    ( debuffs / summons )
  Sorcerer       ( debuffs / aoe )
 Wizard          ( cc )
  Elementalist   ( cc / ranged )
  Summoner       ( cc / summons )  
   Arch Mage     ( cc / debuffs / summons )

Rogue            ( ranged / melee )           - single target DPS
 Ranger          ( ranged )
  Beast Tamer    ( ranged / buffs )
  Druid          ( ranged / summons )
 Assassin        ( melee )
  SpellSword?    ( melee / cc )
  Ninja          ( melee / debuffs )
   Master Thief? ( ranged / melee / debuffs )

Cleric           ( heals / buffs )             - heals and buffs
 Priest          ( heals )
  Inquisitor     ( heals / ranged )
  Templar        ( heals / melee )
 Monk            ( buffs )
  Samuri         ( buffs / melee )
  Sage           ( buffs / debuffs )
   High Cleric?  ( heals / buffs / melee )

// roles
tank
ranged dps
melee dps
heals
cc
debuffs
buffs
summons


//
// Monsters
//

Monsters tend to specialize in one specific attack or theme. Monsters can join a party temporarily by way of summon spells. In addition, beasts and magical creatures can tamed with monster bait. Tame monsters will join a party permanently.  


Undead
 Skeleton
 Zombie
 Ghost
 Wraith
 Vampire
 Goul
 Wright
 Banshee

Beasts
 Bat
 Cat
 Rat
 Dog
 Spider
 Snake
 Wolf
 Weasel

Humanoids
 Elf 
 Dwarf
 Ork
 Gobblin
 Pixie
 Sylph
 Nayad
 Dryad

Magical Creatures
 Wyvern
 Dragon
 Phoenix
 Watcher
 Slime
 Hydra
 Griffen
 Chimera


//
// Specials
//

All characters automaticly gain access to all class specials for their level. Using a special attack requires a number of special points.

Cleric
 Heal            - ranged single target heal
 Cure            - removes status effects
 Bless           - ranged single target buff
 Smite           - ranged single target attack
 Mass            - ranged aoe heal
 Revive          - returns brings dead party members to life.
 ??
 ??
 ??
 ??

Mage
 Ice Arrow       - ranged single target attack
 Earth Binding   - ranged cc 
 Fire Ball       - ranged radius aoe attack
 Lightning Bolt  - ranged line aoe attack
 Enfeeblement    - attack debuff
 Weakness        - def debuff
 Slow            - mov debuff
 Drain Soul      - SP damage
 Shocking Touch  - melee cc
 ??
 
Rogue
 Sneak Attack    - melee single target attack
 Pick Lock       - remove door
 Disarm Trap     - remove trap
 Pick Pocket     - steal item
 ??
 ??
 ??
 ??
 ??
 ??

Fighter
 Bash         - melee power attack
 Takedown     - melee cc
 Sweep        - melee aoe
 Rush         - melee line aoe attack
 Guard        - defense stance
 Rage         - attack stance

Necromancer
 Summon Undead I - summons a skeleton
 Summon Undead II - summons a zombie
 Summon Undead III - summons a ghost
 Summon Undead IV - summons a vampire
 Summon Undead V - summons a banshee
 Pestilance   - Weak DOT
 Enfeeblement - attack debuff
 Weakness     - def debuff
 Slow         - mov debuff
 Drain Soul   - SP damage
 
Knight
 Dragon's Favored - (passive) all temple services are reduced in price to 1 gold.
 Takedown         - melee cc
 Rightous Blow    - single target attack
 Full Guard       - defense stance
 Protection       - absorb adjacent allies damage

Ranger
Monk

Gladiator
 Rage         - attack stance
 Counter      -
 ??
 ??

Witch
Priest
Assassin

// stats    Attack    Defense   Move   Range    HP    SP
Fighter       4         5        4      1        5     1   = 20
Sage          2         3        3      3		 3	   6   = 20
Thief         4         3        5      1        4     3   = 20
Cleric        3         4        3      1        4     4   = 20

Animations ( walk, attack, special, die ) - 6/9 frames each

//
// EXP
//

Lv		1   2    3    4     5     6      8     9     10
Per		   10   20   40    80    160   320   640   1280
Total	   10   30   70    150   310   630  1270   2550+

//
// Nodes
//

sack    ( basic loot node. can be picked up. )
door    ( 0 move monsters, spawn in doorways. can be picked, bashed or opened with a key  )
switch  ( special nodes that remove the closest door when triggered )
trap    ( tiles that deal damage when moved over.  can be disarmed by Rogues )
key     ( consumable item that removes adjacent doors ) 
barrel  ( 0 move monsters, spawn at edge of rooms, have low chance to drop loot )
chest   ( use key or smash for random loot )

//
// Stances
//

target : strongest / closest / weakest              ( most dam, closest range, least hp )
role   : aggressive / defensive / passive			( charge, stay back/ranged, run away/buff )
flee   : reckless / normal / cautious               ( to the death, 33%, 66% )

//
// Design
//

You can stop reading now. The rest of this document has move past brain-dump and into pure tech.

//
// Interface Layout
//

Menu
 Continue
 New game
 Scores
 Options
 Edit
 Quit

New game

deletes all mobs and reser user score.
if has no mobs - > create mob
if user level = 0 then ask for tutorial
at end of tutorial advance level to 1

use highscore list to track user unlocks?
we are already keep a record of the levels a user clears after all.

Create Character
 Class Icon
 Next class button
 Back class button
 Character name textfield
 Class description text
 Done button
 Cancel button

Quest hub
 Quest List    ( Start Quest )
 Merchant      ( Buy / Sell items )
 Guild Hall
  Party Roster Table ( Name, Class, Level )
  Create button - > character creator
  Rename button
   name field
  Remove buttons
  
 Warehouse     ( Desposit and Withdraw items )
 Temple        ( Heal party / Raise dead )
 Arena         ( ! )

Game
 Actions
  Attack 
  Move 
  Special 
  Use Item 
  View 
  Wait 

 Base
  Unit List 

 Inventory
  Item List

 Special Abilities
  Special list

//
// tables
//

// game data

_stats
stat_id
stat_attack
stat_defense
stat_speed
stat_range
stat_damage
stat_drain
stat_sp
stat_hp

_classes
class_id
class_campaign_id
class_name
class_wpn
class_arm
class_stat
class_graphic
class_level
class_type

_items
item_id
item_campaign_id
item_name
item_type      -- weapon, armor, accessory
item_class     -- 0 can be used by any class (acc)
item_effect
item_stat      -- statline bonus
item_level

_specials
special_name
special_level
special_class
special_effect -- allied, enemy
special_radius
special_stats

_scores
_name
_level
_depth
_score

_groups
group_id
group_name
group_level_min
group_level_max

_encounters
encounter_id
encounter_group_id
encounter_mob_id
encounter_mobs_min
encounter_mobs_max
encounter_chance
encounter_type     -- 1 = exclusive, 0 = cumalitave

_users
user_id
user_name
user_level -- for area unlocks?
user_gold

_inventory
inventory_id
inventory_user_id
inventory_item_id
inventory_stored

_characters
character_name
character_owner_id
character_class
character_level
character_exp
character_hp
character_sp
character_status
character_wpn
character_arm
character_itm
character_state

_tiles
tile_id
tile_name
tile_type
tile_set
tile_model
tile_texture
tile_scale
tile_base

_stages
stage_id
stage_name
stage_desc
stage_type
stage_depth
stage_size
stage_level_min
stage_level_max
stage_image
stage_sequence

_dialog
dialog_id
dialog_stage        -- what stage this dialog plays at
dialog_depth        -- what substage
dialog_target       -- next order index in the chain
dialog_type         -- dialog chain / dialog link / dialog option
dialog_text         -- the dialog text
dialog_image        -- background image for conversation
dialog_char         -- optional, what user mob says this line (marching order)
dialog_name         -- optional, what NPC says this line.
dialog_icon         -- optional, icon for NPC dialog line
dialog_sound        -- optional, for voiceover
dialog_order        -- sort order.

//
// Todo
//

// 1.0
X) Map
X) Mobs
X) Deployment
X) Movement
X) Combat
X) Special abilities
X) Line of sight
X) Consumables
X) Character progression
X) AOE effects
X) Anisotropic filtering
X) UI revamp
X) Special attack graphics

// 1.1
X) Increased signage
X) Added camera options
X) Minor bugfixes

// 1.2 changes
X) Added attack bonus against outnumbered mobs.
X) Sound effects ( attack, cast, hurt?, win, fail )
X) Support menu 
X) Unit List Menu
X) New logo for main menu
X) Main menu theme music
X) Volume control options
X) Minor bugfixes

// 1.4
X) In-game currency. Loot drops now have a chance to contain gold coins in addition to items.
X) Quest Hub. (towns) Right now towns are purely menu driven, but maybe sometime in the future we will be able to walk around and talk to npcs.
X) Save and Load features. When you exit your mobs are now saved, but maps are not. When you load you will be in town with all the mobs you had when you quit.
X) Death. Now when mobs are defeated they are not automaticly revived at the start of the next match. Instead they are dead, and stay dead.
X) Mobs can be healed or revived at a quest hub in exchange for gold coins.
X) A match will end if a player ends their turn with no mobs on the field. The player and all mobs will return to the quest hub.
X) If a player quits the game during a match then all mobs flee without exp or loot, and the player will return to the quest hub on game load.
X) Added support for variable height tiles
X) Raised maximum party members from 4 to 6
X) Lowered starting party members from 4 to 1
X) Quest Selector ( Quest List. Select quests, view high scores? )
X) Party Manager  ( Hire, Retire, and Rename mobs )
X) Vendor   ( Buy / Sell items )
X) Temple   ( Heal party / Raise dead )
X) Forest map
X) Tutorial
X) Story / Plotline
X) Dialog Menu
X) Quest rewards. Gold bonus as well as exp.
X) adjusted score and endgame score screen.
X) adjusted class balance
X) fixed bug where weapons would sometimes no longer equip correctly
X) fixed bug where units were sometimes allowed to deploy when not supposed to

1.6
// Feautures
X) Action system revamp; units now have more options what they can do during their activations; they can now move and attack, attack and move, attack twice, or move twice.
X) Adjusted character graphics - character sprites are now 20% bigger
X) Added a heal all button in temple.
X) Added keyboard shortcuts ( M for move, A to attack, W to wait, E to end turn, S for special, H for home base, space for rotate camera )
X) Added detailed class descriptions in character creation. (could be better, w/ list of skills... but I want to make sure that skills work correctly first.)
X) Info box now displays stats for mobs you hover over
X) Changed unit list so that just clicking on a reserve unit will deploy it
X) Action state icons; [R]eady, [A]ctive, [D]one. could be better but it works for now.
X) NPC mobs can now use special abilities on both allies and enemies.
X) Ability enhancements ( Added status effects; CC, Stuns, Dots, Buffs, Debuffs )
X) New Skills ( Bless, Sleep, Haste, Slow, Cure, etc, etc! )
X) New Monsters!

// 
// Status Effects
//

// status effect types

EFFECT_TYPE_CLEAR       - removes status effects
EFFECT_TYPE_NO_ACT      - prevents all actions
EFFECT_TYPE_NO_MOVE     - prevents move actions
EFFECT_TYPE_NO_SPECIAL  - prevents special actions
EFFECT_TYPE_NO_ATTACK   - prevents attack actions
EFFECT_TYPE_DAMAGE      - inflicts damage over time
EFFECT_TYPE_BUFF        - alters a stat value
EFFECT_TYPE_DEBUFF      - alters a stat value
EFFECT_TYPE_SUMMON      - spawns a controlable minion.
EFFECT_TYPE_TRAP        - spawns a trap
EFFECT_TYPE_STEAL       - steals an item

// data structure
table_effects
effect_id
effect_name           - 
effect_type           - STATUS_EFFECT_TYPE
effect_duration       - how many turns this status effect lasts; -1 for unlimited duration.
effect_magnitude      - how strong this effect is
effect_break          - does this effect break on damage? 0 = no break; 1 = breaks on damage
effect_stack          - can this effect stack with other effects of the same type?
effect_icon           - the interface icon overlay this effect uses
effect_animation      - what animation/fx this effect adds to afflicted mob (Zz.., poision bubbles, flames, icecube, etc... )
effect_stats          - this effect's statline

// Example special abilities with status effects
sleep       ( can not act, long duration, breaks on damage, no stack )
stun        ( can not act, short duration, no break, no stack )
immobilize  ( can not move )
bind        ( can not attack )
mute        ( can not use specials )
slow        ( -1 speed debuff )
haste       ( +1 speed buff )
burn        ( fire; strong dot, short duration, can not stack )
freeze      ( water; no actions, short duration, can stack, breaks on damage )
shock       ( wind; no actions, long duration, no stack, no break )
poison      ( earth; weak dot, long duration, can stack )
cure        ( clears negitive status effetcts and debuffs from allies )
dispell     ( strips buffs from enemies )

// Summons
summond mobs are brought into play at a target adjacent square.
summoned mobs need to kee ptrack of their owner so they can despawn if owner is killed.
summoned mobs despawn at end of match
if summons are kept a status effect on a mob, then can they be stripped? i'd say no? but maybe.
so... summon skills need to have target mob summon name/id, as well as duration?
so duration ends, status is removed and mob unsummons.

1.8
-) Summon skills
-) Arena style multiplayer pvp matches
-) Monster bait. use it to tame monsters.
-) Inventory enhancements ( item limit, deposit and withdraw items, equip and remove items in town)
-) party manager improvements ( retire instead of delete, ability to rename mobs )
-) Allow friendly units to move through each other?
-) Give characters full hp/mp on levelup
-) target indicator for AOE/line effects
-) Improved character development ( passive skills, stat growth )
-) auto-loot any sacks left on the map when it ends via stage clear.
-) HP/SP bars.
-) event triggers?
-) Auto-move/ attack option?
-) Adjust menu size / positions
-) better dialog screen - change the more button on lower dialog box? i dono... 
-) Books. contain lore.
-) hotkey dialogue box asking if I'm sure I want to wait, hit W again to confirm. etc
-) first strike / charge bonus?
-) rear strike / backstab bonus?
-) Undo button for movement?
-) hotkey to toggle action/ status icons on and off (they are useful but i hate screen clutter.)
-) More enemy enhancements ( multi-type ai, random movement when blocked, reinforcements )

2.0
-) overworld map

// Content
-) More items ( weapons, armor, acc, consumables )
-) More node types (doors, traps, switches, levers )
-) More tiles ( rough terrain, water, lava, low obstacles, height tiles )
-) More class abilities ( summons, buffs, debuffs, dots )
-) More classes ( ranger, monk, witch, gladiator, priest, assassin )
-) More monsters ( zombies, orks, gobblins, elves )
-) More maps ( mountain, cave, themed map areas )
-) Better graphics ( shadows on mobs, bump maps on walls, character portraits )
-) Better sounds ( voiceovers, music, die, level up and equip item. also special ability specific sounds?)
-) Enchanted items. each +1 will add a flat +1 bonus to attack and damage, or defense and damage reduction (not +1d6 but just +1)
-) Item decay / critical failure / weapon breaks
-) Background art.

// Known Issues
-) Match does not auto-end when no more hostile mobs are left in play, if any hostiles go into reserve. If this happens, you must reload the level.
-) Slider widgets have invisible handles. They still work, however.
-) Audio bugs?

// Administration
X) website redesign ( black / single page style )
-) switch from sourceforge to github / bitbucket
-) curl


Dungeon Tactics 1.6 - combat action overhaul, status effects, new skills, new monsters, and a lot more!


Dungeon Tactics version 1.6 now avaliable!

This release refines and enhances the core SRPG combat mechanics at the heart of Dungeon Tactics. The main feature in this new patch is a major overhaul of the action system. Units now have more options what they can do during their activations; they can now move and attack, attack and move, attack twice, or move twice. Now matches literally happen twice as fast; units enter battle twice as fast and once the battle has been joined, the combat itself is over twice as fast. This change alone dramatically streamlines gameplay, but combined with the other enhancements included in version 1.6, like status effects, dozens of new skills and abilities, state information icons, hotkeys, new monsters, monster special attacks and more... it really takes Dungeon Tactics to an exciting new level.

Don't take my word for it though, when you can play it for free right now and see for yourself!





