added Cockatrice unit

This commit is contained in:
Dave White 2004-03-23 22:01:23 +00:00
parent 133c457e70
commit 5fdda70d0a
12 changed files with 246 additions and 278 deletions

View file

@ -1,6 +1,5 @@
[multiplayer]
name=Random map
map_generation=default
turns=90
id=ranmap
@ -10,4 +9,175 @@
{DUSK}
{FIRST_WATCH}
{SECOND_WATCH}
map_generation=default
[generator]
name=default
map_width=60
map_height=60
iterations=1000
hill_size=10
max_lakes=40
villages=25
players=2
min_lake_height=500
lake_size=150
river_frequency=20
temperature_iterations=40
temperature_size=50
default_flatland=g
roads=3
road_windiness=3
#list of common terrain types which come in at
#different heights, from highest to lowest
[height]
height=700
terrain=m
[/height]
[height]
height=600
terrain=h
[/height]
[height]
height=40
terrain=g
[/height]
[height]
height=30
terrain=d
[/height]
[height]
height=5
terrain=c
[/height]
[height]
height=0
terrain=s
[/height]
#at low temperatures, and at reasonable height,
#snow appears
[flatland]
max_temperature=200
min_height=400
terrain=S
[/flatland]
#swamp appears on low land, at moderate temperatures
[flatland]
min_temperature=500
max_temperature=700
max_height=200
terrain=w
[/flatland]
#forest appears at moderate temperatures
[flatland]
min_temperature=300
max_temperature=600
terrain=f
[/flatland]
#desert appears at high temperatures
[flatland]
min_temperature=900
terrain=d
[/flatland]
#road costs
[road_cost]
terrain=g
cost=1
convert_to=r
[/road_cost]
[road_cost]
terrain=d
cost=2
convert_to=r
[/road_cost]
[road_cost]
terrain=f
cost=3
convert_to=r
[/road_cost]
[road_cost]
terrain=c
cost=5
convert_to_bridge=|,/,\
[/road_cost]
[road_cost]
terrain=h
cost=5
convert_to=r
[/road_cost]
[road_cost]
terrain=m
cost=10
convert_to=r
[/road_cost]
[road_cost]
terrain=r
cost=0
convert_to=r
[/road_cost]
#road going through snow is covered over by
#the snow (presumably the road was built when
#it wasn't snowing)
[road_cost]
terrain=S
cost=2
convert_to=S
[/road_cost]
[village]
terrain=g
convert_to=v
[/village]
[village]
terrain=d
convert_to=v
[/village]
#villages in forest are Elvish
[village]
terrain=f
convert_to=t
[/village]
[village]
terrain=h
convert_to=v
[/village]
[village]
terrain=m
convert_to=v
[/village]
#villages in snow
[village]
terrain=S
convert_to=V
[/village]
[village]
terrain=F
convert_to=V
[/village]
[castle]
valid_terrain=g,f,h
min_distance=24
[/castle]
[/generator]
[/multiplayer]

View file

@ -1,218 +0,0 @@
[map_generator]
name=cave
map_width=50
map_height=50
[chamber]
id=1
size=6
[items]
[side]
side=1
[/side]
[/items]
[/chamber]
[chamber]
id=2
size=20
jagged=70
[items]
[side]
side=2
[/side]
[/items]
[passage]
destination=1
width=3
jagged=50
windiness=20
[/passage]
[/chamber]
[chamber]
id=3
size=5
[passage]
destination=2
width=2
jagged=50
windiness=8
laziness=3
[/passage]
[passage]
destination=1
width=2
jagged=50
windiness=8
laziness=5
[/passage]
[/chamber]
[/map_generator]
[map_generator]
name=default
map_width=60
map_height=60
iterations=1000
hill_size=10
max_lakes=40
villages=25
players=2
min_lake_height=500
lake_size=150
river_frequency=20
temperature_iterations=40
temperature_size=50
default_flatland=g
roads=3
road_windiness=3
#list of common terrain types which come in at
#different heights, from highest to lowest
[height]
height=700
terrain=m
[/height]
[height]
height=600
terrain=h
[/height]
[height]
height=40
terrain=g
[/height]
[height]
height=30
terrain=d
[/height]
[height]
height=5
terrain=c
[/height]
[height]
height=0
terrain=s
[/height]
#at low temperatures, and at reasonable height,
#snow appears
[flatland]
max_temperature=200
min_height=400
terrain=S
[/flatland]
#swamp appears on low land, at moderate temperatures
[flatland]
min_temperature=500
max_temperature=700
max_height=200
terrain=w
[/flatland]
#forest appears at moderate temperatures
[flatland]
min_temperature=300
max_temperature=600
terrain=f
[/flatland]
#desert appears at high temperatures
[flatland]
min_temperature=900
terrain=d
[/flatland]
#road costs
[road_cost]
terrain=g
cost=1
convert_to=r
[/road_cost]
[road_cost]
terrain=d
cost=2
convert_to=r
[/road_cost]
[road_cost]
terrain=f
cost=3
convert_to=r
[/road_cost]
[road_cost]
terrain=c
cost=5
convert_to_bridge=|,/,\
[/road_cost]
[road_cost]
terrain=h
cost=5
convert_to=r
[/road_cost]
[road_cost]
terrain=m
cost=10
convert_to=r
[/road_cost]
[road_cost]
terrain=r
cost=0
convert_to=r
[/road_cost]
#road going through snow is covered over by
#the snow (presumably the road was built when
#it wasn't snowing)
[road_cost]
terrain=S
cost=2
convert_to=S
[/road_cost]
[village]
terrain=g
convert_to=v
[/village]
[village]
terrain=d
convert_to=v
[/village]
#villages in forest are Elvish
[village]
terrain=f
convert_to=t
[/village]
[village]
terrain=h
convert_to=v
[/village]
[village]
terrain=m
convert_to=v
[/village]
#villages in snow
[village]
terrain=S
convert_to=V
[/village]
[village]
terrain=F
convert_to=V
[/village]
[castle]
valid_terrain=g,f,h
min_distance=24
[/castle]
[/map_generator]

36
data/units/Cockatrice.cfg Normal file
View file

@ -0,0 +1,36 @@
[unit]
name=Cockatrice
race=monster
image=cockatrice.png
hitpoints=42
movement_type=smallfoot
movement=5
experience=500
level=2
alignment=chaotic
advanceto=null
cost=25
usage=fighter
unit_description="These mystical snake-like creatures appear weak, but they are very powerful: by gazing at their enemies, they can turn them into stone!"
get_hit_sound=groan.wav
[attack]
name=gaze
type=cold
range=long
damage=2
number=2
special=stone
[frame]
begin=-300
end=-100
image=cockatrice-attack1.png
[/frame]
[frame]
begin=-100
end=100
image=cockatrice-attack2.png
[/frame]
[/attack]
[/unit]

View file

@ -2,11 +2,9 @@
#include "pathfind.hpp"
#include "util.hpp"
cave_map_generator::cave_map_generator(const config& cfg) : wall_('W'), clear_('u'), village_('D'), castle_('C'),
cfg_(NULL), width_(50), height_(50)
cave_map_generator::cave_map_generator(const config* cfg) : wall_('W'), clear_('u'), village_('D'), castle_('C'),
cfg_(cfg), width_(50), height_(50)
{
cfg_ = cfg.find_child("map_generator","name",name());
if(cfg_ == NULL) {
static const config default_cfg;
cfg_ = &default_cfg;
@ -178,6 +176,7 @@ void cave_map_generator::place_items(const chamber& c, config::all_children_iter
while(i1 != i2) {
const std::string& key = *(*i1).first;
config cfg = *(*i1).second;
config* const filter = cfg.child("filter");
if(cfg["same_location_as_previous"] != "yes") {
index = rand()%c.locs.size();
}
@ -188,9 +187,15 @@ void cave_map_generator::place_items(const chamber& c, config::all_children_iter
char buf[50];
sprintf(buf,"%d",loc->x+1);
cfg.values["x"] = buf;
if(filter != NULL) {
(*filter)["x"] = buf;
}
sprintf(buf,"%d",loc->y+1);
cfg.values["y"] = buf;
if(filter != NULL) {
(*filter)["y"] = buf;
}
//if this is a side, place a castle for the side
if(key == "side" && cfg["no_castle"] != "yes") {

View file

@ -6,7 +6,7 @@
class cave_map_generator : public map_generator
{
public:
cave_map_generator(const config& game_config);
cave_map_generator(const config* game_config);
bool allow_user_config() const;
void user_config(display& disp);

View file

@ -266,8 +266,6 @@ int play_game(int argc, char** argv)
game_config::load_config(game_config.child("game_config"));
const map_generator::manager map_generation_manager(game_config);
const config::child_list& units = game_config.get_children("units");
if(units.empty()) {
std::cerr << "ERROR: Could not find game configuration files\n";

View file

@ -13,31 +13,32 @@
#include "mapgen.hpp"
#include "mapgen_dialog.hpp"
#include "pathfind.hpp"
#include "scoped_resource.hpp"
#include "util.hpp"
//function to generate a random map, from a string which describes
//the generator to use and its arguments
std::string random_generate_map(const std::string& parms)
std::string random_generate_map(const std::string& parms, const config* cfg)
{
//the first token is the name of the generator, tokens after
//that are arguments to the generator
std::vector<std::string> parameters = config::split(parms,' ');
map_generator* const generator = get_map_generator(parameters.front());
util::scoped_ptr<map_generator> generator(create_map_generator(parameters.front(),cfg));
if(generator == NULL) {
std::cerr << "could not find map generator '" << parameters.front() << "'\n";
return "";
}
parameters.erase(parameters.begin());
return generator->create_map(parameters);
return generator.get()->create_map(parameters);
}
config random_generate_scenario(const std::string& parms)
config random_generate_scenario(const std::string& parms, const config* cfg)
{
//the first token is the name of the generator, tokens after
//that are arguments to the generator
std::vector<std::string> parameters = config::split(parms,' ');
map_generator* const generator = get_map_generator(parameters.front());
util::scoped_ptr<map_generator> generator(create_map_generator(parameters.front(),cfg));
if(generator == NULL) {
std::cerr << "could not find map generator '" << parameters.front() << "'\n";
return config();
@ -802,32 +803,15 @@ generator_map generators;
}
map_generator::manager::manager(const config& game_config)
map_generator* create_map_generator(const std::string& name, const config* cfg)
{
map_generator* gen = new default_map_generator(game_config);
assert(generators.count(gen->name()) == 0);
generators[gen->name()] = gen;
gen = new cave_map_generator(game_config);
generators[gen->name()] = gen;
}
map_generator::manager::~manager()
{
for(generator_map::iterator i = generators.begin(); i != generators.end(); ++i) {
delete i->second;
}
generators.clear();
}
map_generator* get_map_generator(const std::string& name)
{
const generator_map::iterator i = generators.find(name);
if(i != generators.end())
return i->second;
else
if(name == "default" || name == "") {
return new default_map_generator(cfg);
} else if(name == "cave") {
return new cave_map_generator(cfg);
} else {
return NULL;
}
}
#ifdef TEST_MAPGEN

View file

@ -6,8 +6,8 @@
#include <string>
std::string random_generate_map(const std::string& parms);
config random_generate_scenario(const std::string& parms);
std::string random_generate_map(const std::string& parms, const config* cfg);
config random_generate_scenario(const std::string& parms, const config* cfg);
class map_generator
{
@ -31,15 +31,9 @@ public:
virtual std::string create_map(const std::vector<std::string>& args) = 0;
virtual config create_scenario(const std::vector<std::string>& args);
struct manager
{
manager(const config& game_config);
~manager();
};
};
map_generator* get_map_generator(const std::string& name);
map_generator* create_map_generator(const std::string& name, const config* cfg);
std::string default_generate_map(size_t width, size_t height,
size_t iterations, size_t hill_size,

View file

@ -10,13 +10,11 @@
#include "widgets/button.hpp"
#include "widgets/slider.hpp"
default_map_generator::default_map_generator(const config& game_config)
default_map_generator::default_map_generator(const config* cfg)
: width_(40), height_(40), iterations_(1000), hill_size_(10), max_lakes_(20),
nvillages_(25), nplayers_(2), cfg_(NULL)
nvillages_(25), nplayers_(2), cfg_(cfg)
{
const config* const cfg = game_config.find_child("map_generator","name",name());
if(cfg != NULL) {
cfg_ = cfg;
if(cfg_ != NULL) {
const int width = ::atoi((*cfg)["map_width"].c_str());
if(width > 0)

View file

@ -6,7 +6,7 @@
class default_map_generator : public map_generator
{
public:
default_map_generator(const config& game_config);
default_map_generator(const config* game_config);
bool allow_user_config() const;
void user_config(display& disp);

View file

@ -11,6 +11,7 @@
See the COPYING file for more details.
*/
#include "scoped_resource.hpp"
#include "events.hpp"
#include "font.hpp"
#include "language.hpp"
@ -184,7 +185,7 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
update_whole_screen();
//the current map generator
map_generator* generator = NULL;
util::scoped_ptr<map_generator> generator(NULL);
CKey key;
config* level_ptr = NULL;
@ -272,7 +273,7 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
if(maps_menu.selection() != cur_selection) {
map_changed = true;
generator = NULL;
generator.assign(NULL);
cur_selection = maps_menu.selection();
if(size_t(maps_menu.selection()) != options.size()-1) {
@ -285,7 +286,7 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
//if the map should be randomly generated
if((*level_ptr)["map_generation"] != "") {
generator = get_map_generator((*level_ptr)["map_generation"]);
generator.assign(create_map_generator((*level_ptr)["map_generation"],level_ptr->child("generator")));
}
}else{
const scoped_sdl_surface disk(image::get_image("misc/disk.png",image::UNSCALED));
@ -310,14 +311,14 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
}
}
if(generator != NULL && generator->allow_user_config() && generator_settings.process(mousex,mousey,left_button)) {
generator->user_config(disp);
if(generator != NULL && generator.get()->allow_user_config() && generator_settings.process(mousex,mousey,left_button)) {
generator.get()->user_config(disp);
map_changed = true;
}
if(generator != NULL && (map_changed || regenerate_map.process(mousex,mousey,left_button))) {
if(generator.get() != NULL && (map_changed || regenerate_map.process(mousex,mousey,left_button))) {
//generate the random map
(*level_ptr)["map_data"] = generator->create_map(std::vector<std::string>());
(*level_ptr)["map_data"] = generator.get()->create_map(std::vector<std::string>());
map_changed = true;
//set the scenario to have placing of sides based on the terrain they prefer

View file

@ -111,7 +111,7 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& game_config,
//if the map should be randomly generated
if(map_data == "" && (*level)["map_generation"] != "") {
map_data = random_generate_map((*level)["map_generation"]);
map_data = random_generate_map((*level)["map_generation"],level->child("generator"));
}
gamemap map(game_config,map_data);