Shopkeeper now has bodyguards next time you meet after kiling him

Fixed cl warnings in cmake and added some more walldecorations as well.
Wall decorations needs better logic so we get the right decoration on
the right tile.
This commit is contained in:
Linus Probert 2019-03-08 14:39:23 +01:00
parent af0c61684d
commit 8c9622d6bd
8 changed files with 102 additions and 35 deletions

View File

@ -68,15 +68,17 @@ endif()
IF ( MSVC )
MESSAGE ( STATUS "Setting MSVC MT switches")
SET (
CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} /MTd"
CACHE STRING "MSVC MT flags " FORCE
string (REPLACE
"/MDd"
"/MTd"
CMAKE_C_FLAGS_DEBUG
${CMAKE_C_FLAGS_DEBUG}
)
SET (
CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} /MT"
CACHE STRING "MSVC MT flags " FORCE
string (REPLACE
"/MDd"
"/MTd"
CMAKE_C_FLAGS_RELEASE
${CMAKE_C_FLAGS_RELEASE}
)
ELSEIF ( WIN32 )
SET (
@ -320,16 +322,12 @@ if (NOT DEBUG_BUILD)
"monstergen.lua"
"trapgen.lua"
"chestgen.lua"
"layoutparser.lua"
"pitlayouts.dat"
"walllayouts.dat"
"shoplayouts.dat"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data
)
if (WIN32 AND NOT MSVC)
add_definitions(-mwindows)
endif()
else()
if (WIN32)
add_definitions(-mconsole)
endif()
endif ()
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT "Release")

View File

@ -13,15 +13,17 @@ add_library(bh_random STATIC
IF ( MSVC )
MESSAGE ( STATUS "Setting MSVC MT switches")
SET (
CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} /MTd"
CACHE STRING "MSVC MT flags " FORCE
string (REPLACE
"/MDd"
"/MTd"
CMAKE_C_FLAGS_DEBUG
${CMAKE_C_FLAGS_DEBUG}
)
SET (
CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} /MT"
CACHE STRING "MSVC MT flags " FORCE
string (REPLACE
"/MDd"
"/MTd"
CMAKE_C_FLAGS_RELEASE
${CMAKE_C_FLAGS_RELEASE}
)
endif ()

View File

@ -3,6 +3,7 @@ local pits = {}
local walls = {}
local fences = {}
local lights = {}
local decor = {}
local function readLayoutFile(file)
local layoutfile = read_file(file)
@ -187,6 +188,23 @@ function module.load_textures(map, wall_xoffset, wall_yoffset)
candle1 = { t_decor0, t_decor1, 1 * 16, 8 * 16, true, true },
candle2 = { t_decor0, t_decor1, 5 * 16, 8 * 16, true, false },
}
decor = {
-- Webs
{ t_decor0, nil, 0 * 16, 19 * 16, false },
{ t_decor0, nil, 1 * 16, 19 * 16, false },
{ t_decor0, nil, 2 * 16, 19 * 16, false },
{ t_decor0, nil, 3 * 16, 19 * 16, false },
{ t_decor0, nil, 4 * 16, 19 * 16, false },
-- Cracks
{ t_decor0, nil, 0 * 16, 2 * 16, false },
{ t_decor0, nil, 1 * 16, 2 * 16, false },
-- Vines
{ t_decor0, nil, 4 * 16, 2 * 16, false },
{ t_decor0, nil, 5 * 16, 2 * 16, false },
}
end
function createJumbleLayout(matrix)
@ -226,6 +244,9 @@ function draw_layout_to_room(room, matrix, roomx, roomy)
setPitTile(room, matrix, i, j);
elseif matrix[i][j] == "#" then
setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/"}, false)
if (random(4) == 1) then
room.decor[i][j] = decor[random(#decor)]
end
elseif matrix[i][j] == "\"" then
setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/"}, false)
room.decor[i][j] = lights.candle1

View File

@ -128,7 +128,7 @@ local function generate_path ()
for j=1,10 do
room = map_matrix[i][j]
if room then
if roomCount > 5 and shopLevel and not shopAdded then
if roomCount > 4 and shopLevel and not shopAdded then
room.type = "shop"
shopAdded = true
end
@ -140,6 +140,10 @@ local function generate_path ()
chest_gen.add_chests_to_room(room, i-1, j-1)
else
monster_gen.add_shopkeeper_to_room(room, i-1, j-1)
if PlayerData.shopOwnerKiller then
monster_gen.add_bodyguard_to_room(room, i-1, j-1)
monster_gen.add_bodyguard_to_room(room, i-1, j-1)
end
end
if roomCount > 3 and bossLevel and not bossAdded then
bossAdded = true

View File

@ -54,11 +54,11 @@ local function load_decor_textures()
table.insert(floorDecor, { td0, td1, 48, 13 * 16, false, false })
-- Webs
table.insert(floorDecor, { td0, td1, 0 * 16, 19 * 16, false })
table.insert(floorDecor, { td0, td1, 1 * 16, 19 * 16, false })
table.insert(floorDecor, { td0, td1, 2 * 16, 19 * 16, false })
table.insert(floorDecor, { td0, td1, 3 * 16, 19 * 16, false })
table.insert(floorDecor, { td0, td1, 4 * 16, 19 * 16, false })
--table.insert(floorDecor, { td0, td1, 0 * 16, 19 * 16, false })
--table.insert(floorDecor, { td0, td1, 1 * 16, 19 * 16, false })
--table.insert(floorDecor, { td0, td1, 2 * 16, 19 * 16, false })
--table.insert(floorDecor, { td0, td1, 3 * 16, 19 * 16, false })
--table.insert(floorDecor, { td0, td1, 4 * 16, 19 * 16, false })
-- Urns
table.insert(floorDecor, { td0, td1, 6 * 16, 48, false, false })

View File

@ -278,6 +278,11 @@ for i=1,#eastereggs do
eastereggs[i] = concat({ texturePaths.player0, texturePaths.player1 }, eastereggs[i])
end
local shopkeeperBehaviour = behaviour.passive
if PlayerData.shopOwnerKiller then
shopkeeperBehaviour = behaviour.hostile
end
local shopkeeper = {
texturePaths.humanoid0,
texturePaths.humanoid1,
@ -285,7 +290,17 @@ local shopkeeper = {
16,
12*16,
"The Trader",
behaviour.passive
shopkeeperBehaviour
}
local bodyguard = {
texturePaths.humanoid0,
texturePaths.humanoid1,
stats.orc,
32,
12*16,
"A Bodyguard",
behaviour.hostile
}
-- Add Platino
@ -420,6 +435,24 @@ function module.add_shopkeeper_to_room(room, roomx, roomy)
end
end
function module.add_bodyguard_to_room(room, roomx, roomy)
local success = false
while not success do
local rx = random(13) + 1
local ry = random(9) + 1
if room_builder.is_tile_avilable(room, rx, ry) then
local x = (roomx * 512) + rx * 32
local y = (roomy * 384) + ry * 32
room.monsters[rx][ry] = {
x,
y,
bodyguard
}
success = true
end
end
end
function module.load_monsters(map, monsters)
for i=0,15 do
for j=0,11 do

View File

@ -375,7 +375,6 @@ l_add_chest(lua_State *L)
static int
l_add_monster(lua_State *L)
{
Player *player = luaL_checkplayer(L);
Monster *monster;
Map *map;
int x, y, clip_x, clip_y, behaviour;
@ -419,10 +418,6 @@ l_add_monster(lua_State *L)
lua_pop(L, 8);
// Make sure traders stay hostile if you've killed one
if (strcmp(label, "The Trader") == 0 && player->stateData.shopOwnerKiller) {
behaviour = HOSTILE;
}
monster = monster_create();
monster->sprite->clip = (SDL_Rect) { clip_x, clip_y, 16, 16 };
monster_update_pos(monster, (Position) { x, y });
@ -532,6 +527,17 @@ l_create_shop_artifact(lua_State *L)
return 0;
}
static void
build_player_state_table(lua_State *L, Player *player)
{
lua_createtable(L, 0, 1);
lua_pushboolean(L, player ? player->stateData.shopOwnerKiller : false);
lua_setfield(L, -2, "shopOwnerKiller");
lua_pushnumber(L, player ? player->stats.lvl : 1);
lua_setfield(L, -2, "level");
lua_setglobal(L, "PlayerData");
}
static Map*
generate_map(unsigned int level, const char *file, GameMode gameMode, Player *player, SDL_Renderer *renderer)
{
@ -552,6 +558,8 @@ generate_map(unsigned int level, const char *file, GameMode gameMode, Player *pl
}
// Present stuff to lua
build_player_state_table(L, player);
lua_pushlightuserdata(L, renderer);
lua_setglobal(L, "_sdl_renderer");

View File

@ -18,6 +18,7 @@
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "monster.h"
#include "util.h"