Fixes: #30
- Also fixes a bug with artifact generation - Extends menu room with new features - Adds more descriptive text to container openings - Fixes bug with container loot generation
This commit is contained in:
parent
62d1bbd49d
commit
4ba301769a
|
@ -1,5 +1,7 @@
|
||||||
local room_builder = require "maproombuilder"
|
local room_builder = require "maproombuilder"
|
||||||
local monster_gen = require "monstergen"
|
local monster_gen = require "monstergen"
|
||||||
|
local trap_gen = require "trapgen"
|
||||||
|
local chest_gen = require "chestgen"
|
||||||
|
|
||||||
map = create_map(CURRENT_LEVEL) -- 'map' needs to be global
|
map = create_map(CURRENT_LEVEL) -- 'map' needs to be global
|
||||||
|
|
||||||
|
@ -10,5 +12,9 @@ local room = room_builder.create_empty_room()
|
||||||
room_builder.build_room(room)
|
room_builder.build_room(room)
|
||||||
room_builder.add_full_lighting(room)
|
room_builder.add_full_lighting(room)
|
||||||
monster_gen.add_monsters_to_room(room, 0, 0)
|
monster_gen.add_monsters_to_room(room, 0, 0)
|
||||||
|
trap_gen.add_traps_to_room(room, 0, 0)
|
||||||
|
chest_gen.add_chests_to_room(room, 0, 0)
|
||||||
room_builder.load_room(map, room)
|
room_builder.load_room(map, room)
|
||||||
monster_gen.load_monsters(map, room.monsters)
|
monster_gen.load_monsters(map, room.monsters)
|
||||||
|
trap_gen.load_traps(map, room.traps)
|
||||||
|
chest_gen.load_chests(map, room.chests)
|
||||||
|
|
|
@ -95,20 +95,13 @@ Artifact *
|
||||||
artifact_create_random(Player *p, Uint8 level)
|
artifact_create_random(Player *p, Uint8 level)
|
||||||
{
|
{
|
||||||
int option = -1;
|
int option = -1;
|
||||||
switch (p->stats.lvl) {
|
if (p->stats.lvl >= 4)
|
||||||
case 4:
|
option = get_random(LAST_ARTIFACT_EFFECT);
|
||||||
option = get_random(CHARGE_THROUGH);
|
else if (p->stats.lvl >= 3)
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
option = get_random(INCREASED_STUN);
|
option = get_random(INCREASED_STUN);
|
||||||
break;
|
else
|
||||||
case 1:
|
|
||||||
option = get_random(FEAR_INDUCING);
|
option = get_random(FEAR_INDUCING);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
option = get_random(LAST_ARTIFACT_EFFECT) - 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Artifact *a = artifact_create(option);
|
Artifact *a = artifact_create(option);
|
||||||
a->level = level;
|
a->level = level;
|
||||||
return a;
|
return a;
|
||||||
|
|
22
src/item.c
22
src/item.c
|
@ -20,6 +20,7 @@
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
Item *
|
Item *
|
||||||
item_create(void)
|
item_create(void)
|
||||||
|
@ -48,21 +49,22 @@ item_collected(Item *item, Player *player)
|
||||||
if (item->collected || item->opened)
|
if (item->collected || item->opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (item->items) {
|
if (!item->openable) {
|
||||||
Item *subitem = linkedlist_pop(&item->items);
|
item->collected = true;
|
||||||
item_collected(subitem, player);
|
} else {
|
||||||
item_destroy(subitem);
|
mixer_play_effect(CHEST_OPEN);
|
||||||
|
gui_log("You open a container");
|
||||||
|
item->opened = true;
|
||||||
|
item->sprite->texture_index = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->effect != NULL)
|
if (item->effect != NULL)
|
||||||
item->effect(item, player);
|
item->effect(item, player);
|
||||||
|
|
||||||
if (!item->openable) {
|
while (item->items) {
|
||||||
item->collected = true;
|
Item *subitem = linkedlist_pop(&item->items);
|
||||||
} else {
|
item_collected(subitem, player);
|
||||||
mixer_play_effect(CHEST_OPEN);
|
item_destroy(subitem);
|
||||||
item->opened = true;
|
|
||||||
item->sprite->texture_index = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ create_treasure(int current_level)
|
||||||
unsigned int highest_treasure;
|
unsigned int highest_treasure;
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
|
|
||||||
amt = (unsigned int) get_random(5*current_level) % 40;
|
amt = (unsigned int) 1 + get_random(5*current_level) % 40;
|
||||||
|
|
||||||
if (current_level > 9) {
|
if (current_level > 9) {
|
||||||
highest_treasure = TREASURE_COUNT;
|
highest_treasure = TREASURE_COUNT;
|
||||||
|
@ -125,7 +125,7 @@ create_treasure(int current_level)
|
||||||
highest_treasure = GOLD;
|
highest_treasure = GOLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = get_random(highest_treasure) - 1;
|
value = get_random(highest_treasure);
|
||||||
|
|
||||||
SDL_Rect clip = CLIP16(0, 0);
|
SDL_Rect clip = CLIP16(0, 0);
|
||||||
switch (value) {
|
switch (value) {
|
||||||
|
|
|
@ -333,11 +333,11 @@ l_add_chest(lua_State *L)
|
||||||
lua_pop(L, 4);
|
lua_pop(L, 4);
|
||||||
|
|
||||||
if (get_random(1) == 0)
|
if (get_random(1) == 0)
|
||||||
linkedlist_append(&chest->items, item_builder_build_item(level, TREASURE));
|
linkedlist_append(&chest->items, item_builder_build_item(TREASURE, level));
|
||||||
if (get_random(4) == 0)
|
if (get_random(4) == 0)
|
||||||
linkedlist_append(&chest->items, item_builder_build_item(level, HEALTH));
|
linkedlist_append(&chest->items, item_builder_build_item(HEALTH, level));
|
||||||
if (get_random(4) == 0)
|
if (get_random(4) == 0)
|
||||||
linkedlist_append(&chest->items, item_builder_build_item(level, DAGGER));
|
linkedlist_append(&chest->items, item_builder_build_item(DAGGER, level));
|
||||||
|
|
||||||
linkedlist_append(&map->items, chest);
|
linkedlist_append(&map->items, chest);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue