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

View File

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

View File

@ -3,6 +3,7 @@ local pits = {}
local walls = {} local walls = {}
local fences = {} local fences = {}
local lights = {} local lights = {}
local decor = {}
local function readLayoutFile(file) local function readLayoutFile(file)
local layoutfile = read_file(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 }, candle1 = { t_decor0, t_decor1, 1 * 16, 8 * 16, true, true },
candle2 = { t_decor0, t_decor1, 5 * 16, 8 * 16, true, false }, 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 end
function createJumbleLayout(matrix) function createJumbleLayout(matrix)
@ -226,6 +244,9 @@ function draw_layout_to_room(room, matrix, roomx, roomy)
setPitTile(room, matrix, i, j); setPitTile(room, matrix, i, j);
elseif matrix[i][j] == "#" then elseif matrix[i][j] == "#" then
setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/"}, false) 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 elseif matrix[i][j] == "\"" then
setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/"}, false) setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/"}, false)
room.decor[i][j] = lights.candle1 room.decor[i][j] = lights.candle1

View File

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

View File

@ -54,11 +54,11 @@ local function load_decor_textures()
table.insert(floorDecor, { td0, td1, 48, 13 * 16, false, false }) table.insert(floorDecor, { td0, td1, 48, 13 * 16, false, false })
-- Webs -- Webs
table.insert(floorDecor, { td0, td1, 0 * 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, 1 * 16, 19 * 16, false })
table.insert(floorDecor, { td0, td1, 2 * 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, 3 * 16, 19 * 16, false })
table.insert(floorDecor, { td0, td1, 4 * 16, 19 * 16, false }) --table.insert(floorDecor, { td0, td1, 4 * 16, 19 * 16, false })
-- Urns -- Urns
table.insert(floorDecor, { td0, td1, 6 * 16, 48, false, false }) 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]) eastereggs[i] = concat({ texturePaths.player0, texturePaths.player1 }, eastereggs[i])
end end
local shopkeeperBehaviour = behaviour.passive
if PlayerData.shopOwnerKiller then
shopkeeperBehaviour = behaviour.hostile
end
local shopkeeper = { local shopkeeper = {
texturePaths.humanoid0, texturePaths.humanoid0,
texturePaths.humanoid1, texturePaths.humanoid1,
@ -285,7 +290,17 @@ local shopkeeper = {
16, 16,
12*16, 12*16,
"The Trader", "The Trader",
behaviour.passive shopkeeperBehaviour
}
local bodyguard = {
texturePaths.humanoid0,
texturePaths.humanoid1,
stats.orc,
32,
12*16,
"A Bodyguard",
behaviour.hostile
} }
-- Add Platino -- Add Platino
@ -420,6 +435,24 @@ function module.add_shopkeeper_to_room(room, roomx, roomy)
end end
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) function module.load_monsters(map, monsters)
for i=0,15 do for i=0,15 do
for j=0,11 do for j=0,11 do

View File

@ -375,7 +375,6 @@ l_add_chest(lua_State *L)
static int static int
l_add_monster(lua_State *L) l_add_monster(lua_State *L)
{ {
Player *player = luaL_checkplayer(L);
Monster *monster; Monster *monster;
Map *map; Map *map;
int x, y, clip_x, clip_y, behaviour; int x, y, clip_x, clip_y, behaviour;
@ -419,10 +418,6 @@ l_add_monster(lua_State *L)
lua_pop(L, 8); lua_pop(L, 8);
// Make sure traders stay hostile if you've killed one // 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 = monster_create();
monster->sprite->clip = (SDL_Rect) { clip_x, clip_y, 16, 16 }; monster->sprite->clip = (SDL_Rect) { clip_x, clip_y, 16, 16 };
monster_update_pos(monster, (Position) { x, y }); monster_update_pos(monster, (Position) { x, y });
@ -532,6 +527,17 @@ l_create_shop_artifact(lua_State *L)
return 0; 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* static Map*
generate_map(unsigned int level, const char *file, GameMode gameMode, Player *player, SDL_Renderer *renderer) 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 // Present stuff to lua
build_player_state_table(L, player);
lua_pushlightuserdata(L, renderer); lua_pushlightuserdata(L, renderer);
lua_setglobal(L, "_sdl_renderer"); lua_setglobal(L, "_sdl_renderer");

View File

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