Skip to content

Commit

Permalink
Merge branch 'release/0.8.0.933'
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-code committed Apr 1, 2017
2 parents 088903a + 969c501 commit 0e9788b
Show file tree
Hide file tree
Showing 82 changed files with 1,709 additions and 1,135 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# Version 0.8.0.933 - 2017-04-02

## Additions
- Added height mechanics for world objects and characters
- World objects that are bigger than a character will block the LOS
- Shooting over a world object is only possible if the target behind the object can be seen
- Added texture pack support
- Users can add their own texture packs in the mod/texturepacks folder located in their save directory
- Texture packs support arbitrary tile sizes
- Added support for loading multiple maps
- Added a second map
- Added "Show Help" button to ingame menu

## Removals
- Removed hotkey for help screen (and the ingame overlay for it)
- Removed "Close" button from ingame menu
- It can be closed via the escape-key now

## Fixes
- Fixed button receiving events without actually having focus
- Fixed status effects being applied more than once

## Other Changes
- Attack and interaction modes are now toggleable
- Pressing their keys again will switch back to the movement mode




# Version 0.7.1.883 - 2017-03-20

## Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# On The Roadside

[![Version](https://img.shields.io/badge/Version-0.7.1.883-blue.svg)](https://github.com/rm-code/on-the-roadside/releases/latest)
[![Version](https://img.shields.io/badge/Version-0.8.0.933-blue.svg)](https://github.com/rm-code/on-the-roadside/releases/latest)
[![LOVE](https://img.shields.io/badge/L%C3%96VE-0.10.2-EA316E.svg)](http://love2d.org/)
[![Build Status](https://travis-ci.com/rm-code/On-The-Roadside.svg?token=q3rLXeyGTBN9VB2zsWMr&branch=develop)](https://travis-ci.com/rm-code/On-The-Roadside)

Expand Down
15 changes: 15 additions & 0 deletions config.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project = 'On The Roadside'
title = 'On The Roadside - API'
description = [[
On the Roadside is a turn-based strategy game in which you take control of a squad of mercenaries fighting for survival in a world shaped by unknown forces.
]]
file = {
'src',
exclude = {
'lib',
'res',
'spc'
}
}
dir = '../docs'
all = true
41 changes: 28 additions & 13 deletions lib/Bresenham.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
--==================================================================================

local Bresenham = {
_VERSION = "1.1.1",
_VERSION = "2.1.0",
_DESCRIPTION = "Bresenham's line algorithm written in Lua." ,
_URL = 'https://github.com/rm-code/bresenham/',
}
Expand All @@ -34,15 +34,26 @@ local Bresenham = {
-- way from the origin to the target tile. The line algorithm can be stopped
-- early by making the callback return false.
--
-- @ox (number) The x-coordinates of the origin.
-- @oy (number) The y-coordinates of the origin.
-- @ex (number) The x-coordinates of the target.
-- @ey (number) The y-coordinates of the target.
-- @callback (function) A callback function being called for every tile the line passes.
-- @... (varargs) Additional parameters which will be forwarded to the callback.
-- @return (boolean) True if the target was reached, otherwise false.
-- The callback will receive parameters in the following order:
-- callback( ox, oy, counter, ... )
--
function Bresenham.calculateLine( ox, oy, ex, ey, callback, ... )
-- With ox and oy being the coordinates of the pixel the algorithm is currently
-- passing through, counter being the amount of passed pixels and ...
-- representing variable arguments passed through.
--
-- @tparam number ox The origin's x-coordinates.
-- @tparam number oy The origin's y-coordinates.
-- @tparam number ex The target's x-coordinates.
-- @tparam number ey The target's y-coordinates.
-- @tparam[opt] function callback
-- A callback function being called for every tile the line passes.
-- The line algorithm will stop if the callback returns false.
-- @tparam[opt] vararg ...
-- Additional parameters which will be forwarded to the callback.
-- @treturn boolean True if the target was reached, otherwise false.
-- @treturn number The counter variable containing the number of passed pixels.
--
function Bresenham.line( ox, oy, ex, ey, callback, ... )
local dx = math.abs( ex - ox )
local dy = math.abs( ey - oy ) * -1

Expand All @@ -52,15 +63,19 @@ function Bresenham.calculateLine( ox, oy, ex, ey, callback, ... )

local counter = 0
while true do
local continue = callback( ox, oy, counter, ... )
if not continue then
return false
-- If a callback has been provided, it controls wether the line
-- algorithm should proceed or not.
if callback then
local continue = callback( ox, oy, counter, ... )
if not continue then
return false, counter
end
end

counter = counter + 1

if ox == ex and oy == ey then
return true
return true, counter
end

local tmpErr = 2 * err
Expand Down
5 changes: 5 additions & 0 deletions res/data/creatures/dog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ return {
bloodVolume = 3,
defaultCarryWeight = 20,
defaultCarryVolume = 5,
size = {
stand = 50,
crouch = 30,
prone = 20
},
tags = {
whitelist = {
'creature'
Expand Down
5 changes: 5 additions & 0 deletions res/data/creatures/human.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ return {
bloodVolume = 5,
defaultCarryWeight = 100,
defaultCarryVolume = 10,
size = {
stand = 80,
crouch = 50,
prone = 30
},
tags = {
whitelist = {
'humanoid'
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions res/data/maps/info.lua → res/data/maps/1/info.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
return {
name = 'test',
ground = {
{ r = 68, g = 137, b = 26, tile = 'tile_grass' },
{ r = 0, g = 87, b = 132, tile = 'tile_water' },
Expand Down
Binary file added res/data/maps/2/Map_Ground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/data/maps/2/Map_Objects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/data/maps/2/Map_Spawns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions res/data/maps/2/info.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
return {
name = 'test2',
ground = {
{ r = 75, g = 105, b = 47, tile = 'tile_grass' },
{ r = 105, g = 106, b = 106, tile = 'tile_asphalt' },
{ r = 89, g = 86, b = 82, tile = 'tile_gravel' },
{ r = 102, g = 57, b = 49, tile = 'tile_soil' },
{ r = 143, g = 86, b = 59, tile = 'tile_woodenfloor' }
},
objects = {
{ r = 0, g = 0, b = 0, object = 'worldobject_wall' },
{ r = 5, g = 47, b = 21, object = 'worldobject_tree' },
{ r = 251, g = 242, b = 54, object = 'worldobject_door' },
{ r = 99, g = 155, b = 255, object = 'worldobject_window' },
{ r = 132, g = 126, b = 135, object = 'worldobject_lowwall' },
{ r = 223, g = 113, b = 38, object = 'worldobject_crate' }
},
spawns = {
{ r = 48, g = 96, b = 130, type = 'allied' },
{ r = 172, g = 50, b = 50, type = 'enemy' }
}
}
4 changes: 2 additions & 2 deletions res/data/worldobjects/Crate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ return {
id = 'worldobject_crate',
sprite = 247,
color = { 143, 86, 59 },
size = 70,
size = 50,
hp = 110,
energyReduction = 50,
destructible = true,
blocksVision = false,
blocksVision = true,
blocksPathfinding = true,
container = true,
drops = {
Expand Down
2 changes: 1 addition & 1 deletion res/data/worldobjects/LowWall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ return {
},
destructible = false,
climbable = true,
blocksVision = false,
blocksVision = true,
blocksPathfinding = false
}
1 change: 0 additions & 1 deletion res/img/license.txt

This file was deleted.

Binary file removed res/misc/logo.gif
Binary file not shown.
Binary file removed res/misc/screenshot.png
Binary file not shown.
5 changes: 5 additions & 0 deletions res/text/de_DE/ui_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ locale.strings = {
['ui_on'] = "<An>",
['ui_off'] = "<Aus>",

-- Texture packs
['ui_texturepack'] = "Texturenpaket:",

-- Language selector
['ui_lang'] = "Sprache:",
['ui_lang_eng'] = "<English>",
Expand All @@ -35,6 +38,8 @@ locale.strings = {
-- Ingame menu
['ui_ingame_paused'] = "Pausiert",
['ui_ingame_save_game'] = "Speichern",
['ui_ingame_open_help'] = "Hilfe",
['ui_ingame_exit'] = "Hauptmenü",
}

return locale;
6 changes: 5 additions & 1 deletion res/text/en_EN/ui_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ locale.strings = {
['ui_on'] = "<On>",
['ui_off'] = "<Off>",

-- Texture packs
['ui_texturepack'] = "Texture Pack:",

-- Language selector
['ui_lang'] = "Language:",
['ui_lang_eng'] = "<English>",
Expand All @@ -30,11 +33,12 @@ locale.strings = {

-- Navigation
['ui_back'] = "Back",
['ui_exit'] = "Exit",

-- Ingame menu
['ui_ingame_paused'] = "Paused",
['ui_ingame_save_game'] = "Save game",
['ui_ingame_open_help'] = "Show help",
['ui_ingame_exit'] = "Main menu",
}

return locale;
File renamed without changes
File renamed without changes
19 changes: 19 additions & 0 deletions res/texturepacks/default/info.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
return {
name = 'default',
tileset = {
-- Tiles by Rogue Yun released as CCO (http://www.bay12forums.com/smf/index.php?topic=144897.0)
source = '16x16_sm.png',
tiles = {
width = 16,
height = 16
}
},
font = {
source = 'imagefont8x16.png',
glyphs = {
source = ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÄÖÜäöü0123456789.,:;!?-+/()[]%&"\'*=_<>ß^©',
width = 8,
height = 16
}
}
}
4 changes: 2 additions & 2 deletions src/Game.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local Object = require( 'src.Object' );
local Map = require( 'src.map.Map' );
local MapLoader = require( 'src.map.MapLoader' )
local Factions = require( 'src.characters.Factions' );
local TurnManager = require( 'src.turnbased.TurnManager' );
local ProjectileManager = require( 'src.items.weapons.ProjectileManager' );
Expand Down Expand Up @@ -35,7 +35,7 @@ function Game.new()
-- ------------------------------------------------

function self:init( savegame )
map = Map.new();
map = MapLoader.createRandom()
map:init( savegame );

factions = Factions.new( map );
Expand Down
66 changes: 54 additions & 12 deletions src/characters/Character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,63 @@ function Character.new( map, tile, faction )
---
-- Marks a tile as seen by this character if it fullfills the necessary
-- requirements. Used as a callback for Bresenham's line algorithm.
-- @param cx (number) The tiles coordinate along the x-axis.
-- @param cy (number) The tiles coordinate along the y-axis.
-- @return (boolean) False if the algorithm should be stopped.
-- @tparam number cx The tile's coordinate along the x-axis.
-- @tparam number cy The tile's coordinate along the y-axis.
-- @tparam number counter The number of tiles touched by the ray so far.
-- @tparam number falloff Determines how much height the ray loses each step.
-- @treturn boolean Returns true if the tile can be seen by the character.
--
local function markSeenTiles( cx, cy )
local function markSeenTiles( cx, cy, counter, falloff )
local target = map:getTileAt( cx, cy );
if not target then
return false;
end

-- Add tile to this character's FOV.
self:addSeenTile( cx, cy, target );
-- Calculate the height of the ray on the current tile. If the height
-- is smaller than the tile's height it is marked as visible. This
-- simulates how small objects can be hidden behind bigger objects, but
-- not the other way around.
local height = self:getHeight() - (counter+1) * falloff
if height <= target:getHeight() then
-- Add tile to this character's FOV.
self:addSeenTile( cx, cy, target );

-- Mark tile as explored for this character's faction.
target:setExplored( faction:getType(), true );
-- Mark tile as explored for this character's faction.
target:setExplored( faction:getType(), true );

-- Mark tile for drawing update.
target:setDirty( true );
-- Mark tile for drawing update.
target:setDirty( true );
end

if target:hasWorldObject() and target:getWorldObject():blocksVision() then
-- A world object blocks vision if it has the "blocksVision" flag set
-- to true in its template file and if the ray is smaller than the world
-- object's size. This prevents characters from looking over bigger world
-- objects and allows smaller objects like low walls to cast a "shadow"
-- in which smaller objects could be hidden.
if target:hasWorldObject()
and target:getWorldObject():blocksVision()
and height <= target:getWorldObject():getHeight() then
return false;
end

return true;
end

---
-- Determine the height falloff for rays of the FOV calculation. This value
-- will be deducted from the ray's height for each tile the ray traverses.
-- @tparam Tile The target tile.
-- @tparam number The distance to the target.
-- @treturn number The calculated falloff value.
--
local function calculateFalloff( target, steps )
local oheight = self:getHeight()
local theight = target:getHeight()

local delta = oheight - theight;
return delta / steps;
end

-- ------------------------------------------------
-- Public Methods
-- ------------------------------------------------
Expand Down Expand Up @@ -176,7 +208,9 @@ function Character.new( map, tile, faction )

for _, ttile in ipairs( list ) do
local tx, ty = ttile:getPosition();
Bresenham.calculateLine( sx, sy, tx, ty, markSeenTiles );
local _, counter = Bresenham.line( sx, sy, tx, ty );
local falloff = calculateFalloff( ttile, counter );
Bresenham.line( sx, sy, tx, ty, markSeenTiles, falloff );
end
end

Expand Down Expand Up @@ -325,6 +359,14 @@ function Character.new( map, tile, faction )
return fov;
end

---
-- Returns the character's size based on his stance.
-- @return (number) The character's size.
--
function self:getHeight()
return body:getHeight( stance )
end

---
-- Returns the character's current stance.
-- @return (number) The character's stance.
Expand Down
3 changes: 2 additions & 1 deletion src/characters/Factions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local Factions = {};
-- ------------------------------------------------

local FACTIONS = require( 'src.constants.FACTIONS' );
local STATUS_EFFECTS = require( 'src.constants.STATUS_EFFECTS' )

-- ------------------------------------------------
-- Constructor
Expand Down Expand Up @@ -80,7 +81,7 @@ function Factions.new( map )
for type, sfaction in pairs( savedFactions ) do
local faction = self:findFaction( type );
for _, savedCharacter in ipairs( sfaction ) do
if not savedCharacter.body.statusEffects.death then
if not savedCharacter.body.statusEffects[STATUS_EFFECTS.DEATH] then
local tile = map:getTileAt( savedCharacter.x, savedCharacter.y );
faction:addCharacter( CharacterFactory.loadCharacter( map, tile, faction, savedCharacter ));
end
Expand Down
Loading

0 comments on commit 0e9788b

Please sign in to comment.