Skip to content

Commit 0e9788b

Browse files
committed
Merge branch 'release/0.8.0.933'
2 parents 088903a + 969c501 commit 0e9788b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1709
-1135
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
# Version 0.8.0.933 - 2017-04-02
2+
3+
## Additions
4+
- Added height mechanics for world objects and characters
5+
- World objects that are bigger than a character will block the LOS
6+
- Shooting over a world object is only possible if the target behind the object can be seen
7+
- Added texture pack support
8+
- Users can add their own texture packs in the mod/texturepacks folder located in their save directory
9+
- Texture packs support arbitrary tile sizes
10+
- Added support for loading multiple maps
11+
- Added a second map
12+
- Added "Show Help" button to ingame menu
13+
14+
## Removals
15+
- Removed hotkey for help screen (and the ingame overlay for it)
16+
- Removed "Close" button from ingame menu
17+
- It can be closed via the escape-key now
18+
19+
## Fixes
20+
- Fixed button receiving events without actually having focus
21+
- Fixed status effects being applied more than once
22+
23+
## Other Changes
24+
- Attack and interaction modes are now toggleable
25+
- Pressing their keys again will switch back to the movement mode
26+
27+
28+
29+
130
# Version 0.7.1.883 - 2017-03-20
231

332
## Fixes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# On The Roadside
22

3-
[![Version](https://img.shields.io/badge/Version-0.7.1.883-blue.svg)](https://github.com/rm-code/on-the-roadside/releases/latest)
3+
[![Version](https://img.shields.io/badge/Version-0.8.0.933-blue.svg)](https://github.com/rm-code/on-the-roadside/releases/latest)
44
[![LOVE](https://img.shields.io/badge/L%C3%96VE-0.10.2-EA316E.svg)](http://love2d.org/)
55
[![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)
66

config.ld

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
project = 'On The Roadside'
2+
title = 'On The Roadside - API'
3+
description = [[
4+
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.
5+
]]
6+
file = {
7+
'src',
8+
exclude = {
9+
'lib',
10+
'res',
11+
'spc'
12+
}
13+
}
14+
dir = '../docs'
15+
all = true

lib/Bresenham.lua

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
--==================================================================================
2222

2323
local Bresenham = {
24-
_VERSION = "1.1.1",
24+
_VERSION = "2.1.0",
2525
_DESCRIPTION = "Bresenham's line algorithm written in Lua." ,
2626
_URL = 'https://github.com/rm-code/bresenham/',
2727
}
@@ -34,15 +34,26 @@ local Bresenham = {
3434
-- way from the origin to the target tile. The line algorithm can be stopped
3535
-- early by making the callback return false.
3636
--
37-
-- @ox (number) The x-coordinates of the origin.
38-
-- @oy (number) The y-coordinates of the origin.
39-
-- @ex (number) The x-coordinates of the target.
40-
-- @ey (number) The y-coordinates of the target.
41-
-- @callback (function) A callback function being called for every tile the line passes.
42-
-- @... (varargs) Additional parameters which will be forwarded to the callback.
43-
-- @return (boolean) True if the target was reached, otherwise false.
37+
-- The callback will receive parameters in the following order:
38+
-- callback( ox, oy, counter, ... )
4439
--
45-
function Bresenham.calculateLine( ox, oy, ex, ey, callback, ... )
40+
-- With ox and oy being the coordinates of the pixel the algorithm is currently
41+
-- passing through, counter being the amount of passed pixels and ...
42+
-- representing variable arguments passed through.
43+
--
44+
-- @tparam number ox The origin's x-coordinates.
45+
-- @tparam number oy The origin's y-coordinates.
46+
-- @tparam number ex The target's x-coordinates.
47+
-- @tparam number ey The target's y-coordinates.
48+
-- @tparam[opt] function callback
49+
-- A callback function being called for every tile the line passes.
50+
-- The line algorithm will stop if the callback returns false.
51+
-- @tparam[opt] vararg ...
52+
-- Additional parameters which will be forwarded to the callback.
53+
-- @treturn boolean True if the target was reached, otherwise false.
54+
-- @treturn number The counter variable containing the number of passed pixels.
55+
--
56+
function Bresenham.line( ox, oy, ex, ey, callback, ... )
4657
local dx = math.abs( ex - ox )
4758
local dy = math.abs( ey - oy ) * -1
4859

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

5364
local counter = 0
5465
while true do
55-
local continue = callback( ox, oy, counter, ... )
56-
if not continue then
57-
return false
66+
-- If a callback has been provided, it controls wether the line
67+
-- algorithm should proceed or not.
68+
if callback then
69+
local continue = callback( ox, oy, counter, ... )
70+
if not continue then
71+
return false, counter
72+
end
5873
end
5974

6075
counter = counter + 1
6176

6277
if ox == ex and oy == ey then
63-
return true
78+
return true, counter
6479
end
6580

6681
local tmpErr = 2 * err

res/data/creatures/dog.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ return {
33
bloodVolume = 3,
44
defaultCarryWeight = 20,
55
defaultCarryVolume = 5,
6+
size = {
7+
stand = 50,
8+
crouch = 30,
9+
prone = 20
10+
},
611
tags = {
712
whitelist = {
813
'creature'

res/data/creatures/human.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ return {
33
bloodVolume = 5,
44
defaultCarryWeight = 100,
55
defaultCarryVolume = 10,
6+
size = {
7+
stand = 80,
8+
crouch = 50,
9+
prone = 30
10+
},
611
tags = {
712
whitelist = {
813
'humanoid'
File renamed without changes.
File renamed without changes.
File renamed without changes.

res/data/maps/info.lua renamed to res/data/maps/1/info.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
return {
2+
name = 'test',
23
ground = {
34
{ r = 68, g = 137, b = 26, tile = 'tile_grass' },
45
{ r = 0, g = 87, b = 132, tile = 'tile_water' },

res/data/maps/2/Map_Ground.png

2.18 KB
Loading

res/data/maps/2/Map_Objects.png

1.32 KB
Loading

res/data/maps/2/Map_Spawns.png

230 Bytes
Loading

res/data/maps/2/info.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
return {
2+
name = 'test2',
3+
ground = {
4+
{ r = 75, g = 105, b = 47, tile = 'tile_grass' },
5+
{ r = 105, g = 106, b = 106, tile = 'tile_asphalt' },
6+
{ r = 89, g = 86, b = 82, tile = 'tile_gravel' },
7+
{ r = 102, g = 57, b = 49, tile = 'tile_soil' },
8+
{ r = 143, g = 86, b = 59, tile = 'tile_woodenfloor' }
9+
},
10+
objects = {
11+
{ r = 0, g = 0, b = 0, object = 'worldobject_wall' },
12+
{ r = 5, g = 47, b = 21, object = 'worldobject_tree' },
13+
{ r = 251, g = 242, b = 54, object = 'worldobject_door' },
14+
{ r = 99, g = 155, b = 255, object = 'worldobject_window' },
15+
{ r = 132, g = 126, b = 135, object = 'worldobject_lowwall' },
16+
{ r = 223, g = 113, b = 38, object = 'worldobject_crate' }
17+
},
18+
spawns = {
19+
{ r = 48, g = 96, b = 130, type = 'allied' },
20+
{ r = 172, g = 50, b = 50, type = 'enemy' }
21+
}
22+
}

res/data/worldobjects/Crate.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ return {
22
id = 'worldobject_crate',
33
sprite = 247,
44
color = { 143, 86, 59 },
5-
size = 70,
5+
size = 50,
66
hp = 110,
77
energyReduction = 50,
88
destructible = true,
9-
blocksVision = false,
9+
blocksVision = true,
1010
blocksPathfinding = true,
1111
container = true,
1212
drops = {

res/data/worldobjects/LowWall.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ return {
1010
},
1111
destructible = false,
1212
climbable = true,
13-
blocksVision = false,
13+
blocksVision = true,
1414
blocksPathfinding = false
1515
}

res/img/license.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

res/misc/logo.gif

-262 KB
Binary file not shown.

res/misc/screenshot.png

-31.1 KB
Binary file not shown.

res/text/de_DE/ui_text.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ locale.strings = {
2020
['ui_on'] = "<An>",
2121
['ui_off'] = "<Aus>",
2222

23+
-- Texture packs
24+
['ui_texturepack'] = "Texturenpaket:",
25+
2326
-- Language selector
2427
['ui_lang'] = "Sprache:",
2528
['ui_lang_eng'] = "<English>",
@@ -35,6 +38,8 @@ locale.strings = {
3538
-- Ingame menu
3639
['ui_ingame_paused'] = "Pausiert",
3740
['ui_ingame_save_game'] = "Speichern",
41+
['ui_ingame_open_help'] = "Hilfe",
42+
['ui_ingame_exit'] = "Hauptmenü",
3843
}
3944

4045
return locale;

res/text/en_EN/ui_text.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ locale.strings = {
2020
['ui_on'] = "<On>",
2121
['ui_off'] = "<Off>",
2222

23+
-- Texture packs
24+
['ui_texturepack'] = "Texture Pack:",
25+
2326
-- Language selector
2427
['ui_lang'] = "Language:",
2528
['ui_lang_eng'] = "<English>",
@@ -30,11 +33,12 @@ locale.strings = {
3033

3134
-- Navigation
3235
['ui_back'] = "Back",
33-
['ui_exit'] = "Exit",
3436

3537
-- Ingame menu
3638
['ui_ingame_paused'] = "Paused",
3739
['ui_ingame_save_game'] = "Save game",
40+
['ui_ingame_open_help'] = "Show help",
41+
['ui_ingame_exit'] = "Main menu",
3842
}
3943

4044
return locale;
File renamed without changes.

res/texturepacks/default/info.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
return {
2+
name = 'default',
3+
tileset = {
4+
-- Tiles by Rogue Yun released as CCO (http://www.bay12forums.com/smf/index.php?topic=144897.0)
5+
source = '16x16_sm.png',
6+
tiles = {
7+
width = 16,
8+
height = 16
9+
}
10+
},
11+
font = {
12+
source = 'imagefont8x16.png',
13+
glyphs = {
14+
source = ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÄÖÜäöü0123456789.,:;!?-+/()[]%&"\'*=_<>ß^©',
15+
width = 8,
16+
height = 16
17+
}
18+
}
19+
}

src/Game.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local Object = require( 'src.Object' );
2-
local Map = require( 'src.map.Map' );
2+
local MapLoader = require( 'src.map.MapLoader' )
33
local Factions = require( 'src.characters.Factions' );
44
local TurnManager = require( 'src.turnbased.TurnManager' );
55
local ProjectileManager = require( 'src.items.weapons.ProjectileManager' );
@@ -35,7 +35,7 @@ function Game.new()
3535
-- ------------------------------------------------
3636

3737
function self:init( savegame )
38-
map = Map.new();
38+
map = MapLoader.createRandom()
3939
map:init( savegame );
4040

4141
factions = Factions.new( map );

src/characters/Character.lua

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,63 @@ function Character.new( map, tile, faction )
5959
---
6060
-- Marks a tile as seen by this character if it fullfills the necessary
6161
-- requirements. Used as a callback for Bresenham's line algorithm.
62-
-- @param cx (number) The tiles coordinate along the x-axis.
63-
-- @param cy (number) The tiles coordinate along the y-axis.
64-
-- @return (boolean) False if the algorithm should be stopped.
62+
-- @tparam number cx The tile's coordinate along the x-axis.
63+
-- @tparam number cy The tile's coordinate along the y-axis.
64+
-- @tparam number counter The number of tiles touched by the ray so far.
65+
-- @tparam number falloff Determines how much height the ray loses each step.
66+
-- @treturn boolean Returns true if the tile can be seen by the character.
6567
--
66-
local function markSeenTiles( cx, cy )
68+
local function markSeenTiles( cx, cy, counter, falloff )
6769
local target = map:getTileAt( cx, cy );
6870
if not target then
6971
return false;
7072
end
7173

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

75-
-- Mark tile as explored for this character's faction.
76-
target:setExplored( faction:getType(), true );
83+
-- Mark tile as explored for this character's faction.
84+
target:setExplored( faction:getType(), true );
7785

78-
-- Mark tile for drawing update.
79-
target:setDirty( true );
86+
-- Mark tile for drawing update.
87+
target:setDirty( true );
88+
end
8089

81-
if target:hasWorldObject() and target:getWorldObject():blocksVision() then
90+
-- A world object blocks vision if it has the "blocksVision" flag set
91+
-- to true in its template file and if the ray is smaller than the world
92+
-- object's size. This prevents characters from looking over bigger world
93+
-- objects and allows smaller objects like low walls to cast a "shadow"
94+
-- in which smaller objects could be hidden.
95+
if target:hasWorldObject()
96+
and target:getWorldObject():blocksVision()
97+
and height <= target:getWorldObject():getHeight() then
8298
return false;
8399
end
100+
84101
return true;
85102
end
86103

104+
---
105+
-- Determine the height falloff for rays of the FOV calculation. This value
106+
-- will be deducted from the ray's height for each tile the ray traverses.
107+
-- @tparam Tile The target tile.
108+
-- @tparam number The distance to the target.
109+
-- @treturn number The calculated falloff value.
110+
--
111+
local function calculateFalloff( target, steps )
112+
local oheight = self:getHeight()
113+
local theight = target:getHeight()
114+
115+
local delta = oheight - theight;
116+
return delta / steps;
117+
end
118+
87119
-- ------------------------------------------------
88120
-- Public Methods
89121
-- ------------------------------------------------
@@ -176,7 +208,9 @@ function Character.new( map, tile, faction )
176208

177209
for _, ttile in ipairs( list ) do
178210
local tx, ty = ttile:getPosition();
179-
Bresenham.calculateLine( sx, sy, tx, ty, markSeenTiles );
211+
local _, counter = Bresenham.line( sx, sy, tx, ty );
212+
local falloff = calculateFalloff( ttile, counter );
213+
Bresenham.line( sx, sy, tx, ty, markSeenTiles, falloff );
180214
end
181215
end
182216

@@ -325,6 +359,14 @@ function Character.new( map, tile, faction )
325359
return fov;
326360
end
327361

362+
---
363+
-- Returns the character's size based on his stance.
364+
-- @return (number) The character's size.
365+
--
366+
function self:getHeight()
367+
return body:getHeight( stance )
368+
end
369+
328370
---
329371
-- Returns the character's current stance.
330372
-- @return (number) The character's stance.

src/characters/Factions.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ local Factions = {};
1616
-- ------------------------------------------------
1717

1818
local FACTIONS = require( 'src.constants.FACTIONS' );
19+
local STATUS_EFFECTS = require( 'src.constants.STATUS_EFFECTS' )
1920

2021
-- ------------------------------------------------
2122
-- Constructor
@@ -80,7 +81,7 @@ function Factions.new( map )
8081
for type, sfaction in pairs( savedFactions ) do
8182
local faction = self:findFaction( type );
8283
for _, savedCharacter in ipairs( sfaction ) do
83-
if not savedCharacter.body.statusEffects.death then
84+
if not savedCharacter.body.statusEffects[STATUS_EFFECTS.DEATH] then
8485
local tile = map:getTileAt( savedCharacter.x, savedCharacter.y );
8586
faction:addCharacter( CharacterFactory.loadCharacter( map, tile, faction, savedCharacter ));
8687
end

0 commit comments

Comments
 (0)