added basic random map for Scepter of Fire

This commit is contained in:
Dave White 2004-04-01 19:19:09 +00:00
parent 37004bf0dc
commit 0744913000
7 changed files with 433 additions and 297 deletions

View file

@ -1,26 +0,0 @@
ggggggfffffffffffffggggtgggcs
fffffhfffggfftgggrrrffffggggc
ffffffggghggghgrrgfgrrfffgggf
ffthgggffggggmrgggfftgrrrggff
fffgggfgfggghCrghhgggffgfrggf
fffgggffggtCC1rggggffffggrggf
fffffgggggggCCCggfffffffggrgg
ccccftffffgghhgffffftffcccrgt
ccc//cggffffggghggggfcccccrrg
csssccgcfffggggfhfgcccsssscrg
ssssccptgfffggggggccssgtssccr
sssccgggffffffgggggcsssgssccr
sssschgggffhhmffggccssshssscr
cccccchhhtfmfhhhfgcccsstssscr
c/gcgthmmmhhhmmfffccssssssccr
tcggggghmmmtmmmhhggcccccsscpg
ccsggggfffhhhmmmthgggcgcsccrt
gggtggfffhhmmmmhhfffggccccrhh
gggggfffhmmmhmmmmmfffgtcc//gf
chhgggfffmhhhhmmhffffrc//cgtf
sccfgfffhhhmmmhhhhffgr/cccgff
ccgggggffggfhhfffffrrggccgggf
tggggfffgCgfghgrtrrggtgcggfff
gggffhhfCC2rhhrfrgggggcctggfh
ggtggftfhgCCrrrhhffccccsscghm
ggggffhhggggggggmmcccssssschm

View file

@ -1,43 +0,0 @@
gggggggggggggggggSgggggggrggggrrrgggggggggggggg
ggggggvggSmVmmSmmVgmggggggrrgggrggggggggggggggg
ggggggggggmSSCRCSmSgggggggtrggrvggggggggggggggg
ccgcgcggggmShC2CmSggggggggggrrrgggggggggggggggg
ccccccccggggmhCShhgggggggggrrgggggggggggggggggg
vpsscscsccggVhmhSSgggggggggrggggggggggggggggggg
tccssssssscgSVhShmggggggggvrggggggggggggvgggggg
ccsscpcccpcgggggggggggggggrrggggggggggggggggggg
ggcccgg\cgtggggggggggggggggrggggggggggggggggggg
ggggggcggggggfgggggggggvggggrgggggggggggggggggd
gggggggggfgggvfgggggggggggggrggggggggggggggggdd
ggffggfgggggggggggggggggggggrrgggtgggggggggggcc
ggggfgggggggggfggggggggggggggrggggggggggggggccc
gggfggggfgggggggggggggggggggggrggggggggggggccdd
ggggggggfgggfggvffffggggggggggrggggggggggccdccd
gtgfgggggggggggffggggggggggggrrtgggggggggcdgdcc
fffggfgfgggggfggggggfggggggggrrgggggtgggdcdgddc
ffffgfffffgggggggfgggvgggggrrggggggggggddcgggdc
ffffffftfffggggggggggggggggrtggggggdgccccgggggd
gffffffffffggggfgggfgggggggrrcddgddccgggggggggg
gffftgtffgffgggfggggggggggr\|dcddddcggggggggggg
fffffffffffggggggggfgggggcctrgccccdcggggggggggg
fffffffffffffggggggggggccccrrgggggccggggggggggg
fffffffffffgggtggggggccccggrgggggggcggggggggggg
ffffffffffffgggggfvgdcdggggrggggggggccggggggggg
ffffffggtgffgggggggdcggggggrggggggggggccggggggg
ffffgggggggfggfggcdccgggggtrggggggggggggccggggg
fffgfffgggggggggccccgggggggrggggggggggggccgmggg
fggCggfffgfgfggfcdcdgggggggrgggggggggggggmcDmgg
ffCCCgffgfggfggfccdgggggggggrrgggggggggggmchmgg
gC3ffffgggffggffccdgggggggggtrgggggrgtggggmmmmg
ggfffffggfffggggfgcggggggggrrgrrrrrgrrgggggmmgg
gfffffffffgfgggfgccggggtrrrggggggggggrggggggggg
fffffffffggggggfcdggggrrrgggggggggggrrrgggggggg
fgfffffgfggffgggcdgggggrggggggggggggr1Cgggggggg
fgfffffgffgggffdcdgggggrrgggggggggggCCCgggggghg
gfffgfgfgffgffdccgggggggrtggggggggggggggggghgmh
gffgfggffffggccccgggggggrgggggggggggggggghhmhhm
gfgdgggffggfcddggggggggrrggggggggggggguummmmmmh
ccccccgdgddccdgggggggrrRrgggggggggggghhDmmhumuV
ccddccccdccdcdgggggggrtggggggggggggggmmhmhmmmmu
cddddddccdccdggggggggrgggggggggggggggumumhmmmuu
dddddccccdcccggggggggrggggggggggggggDhhhDhmmhhD

View file

@ -193,7 +193,7 @@ Defeat:
[event]
name=time out
name=time over
[message]
id=undeadmages_11
description=Quirind

View file

@ -1,16 +1,25 @@
[scenario]
name=The Sceptre of Fire
id=Sceptre
map=sceptre
turns=60
name=The Sceptre of Fire
id=Sceptre
scenario_generation=cave
{UNDERGROUND}
[generator]
next_scenario=A_Choice_Must_Be_Made
music="wesnoth-3.ogg"
[settings]
name=The Sceptre of Fire
id=Sceptre
map=sceptre
turns=60
explicit_endlevel=yes
objectives="
{UNDERGROUND}
next_scenario=A_Choice_Must_Be_Made
music="wesnoth-3.ogg"
objectives="
Victory:
@Capture the Sceptre of Fire with Konrad or Li'sar
Defeat:
@ -19,241 +28,379 @@ Defeat:
#Death of Kalenz
#Death of Li'sar"
[bigmap]
image=misc/map.png
[dot]
type=cross
x=127
y=226
[/dot]
[/bigmap]
[bigmap]
image=misc/map.png
[dot]
type=cross
x=127
y=226
[/dot]
[/bigmap]
[side]
type=Commander
description=Konrad
side=1
canrecruit=1
controller=human
shroud=yes
[/side]
[side]
type=Orcish Warlord
facing=reverse
side=2
canrecruit=1
controller=ai
leader_value=10
recruit=Goblin Knight,Wolf Rider,Troll,Orcish Warrior,Orcish Crossbow
team_name=orcs
[event]
name=start
[recall]
description=Delfador
[/recall]
[recall]
description=Kalenz
[/recall]
[recall]
description=Li'sar
[/recall]
[message]
description=Konrad
id=scep1
message="The Sceptre must be getting close now! Where shall we go?"
[/message]
[message]
description=Delfador
id=scep2
message="Yes, I feel it is near here! We must search for it carefully."
[/message]
[/event]
{GOLD 100 200 300}
{INCOME 5 10 20}
[/side]
[side]
type=Troll Warrior
side=3
canrecruit=1
controller=ai
leader_value=10
recruitment_pattern=fighter
{deaths.cfg}
[/settings]
map_width=50
map_height=70
flipx_chance=50
village_density=20
#the chamber with the player. Somewhere in the far south
[chamber]
id=player
x=10-40
y=68
size=8
jagged=50
[items]
[side]
type=Commander
description=Konrad
side=1
canrecruit=1
controller=human
shroud=yes
[/side]
[/items]
[/chamber]
#the chamber with the first orc. Somewhere in the mid-east
[chamber]
id=orc1
x=30-50
y=35-50
size=6
[passage]
destination=player
width=2
jagged=5
windiness=10
[/passage]
[items]
[side]
type=Orcish Warlord
facing=reverse
side=2
canrecruit=1
controller=ai
leader_value=10
recruit=Goblin Knight,Wolf Rider,Troll,Orcish Warrior,Orcish Crossbow
team_name=orcs
{GOLD 80 150 200}
{INCOME 5 10 20}
[/side]
[/items]
[/chamber]
#the chamber with the troll. Somewhere in the mid-west.
[chamber]
id=troll
x=2-15
y=35-50
size=10
jagged=50
#there is a 50% chance of a narrow passage direct to the troll
[passage]
chance=50
width=1
windiness=20
destination=player
[/passage]
[items]
[side]
type=Troll Warrior
side=3
canrecruit=1
controller=ai
leader_value=10
recruitment_pattern=fighter
#ifdef EASY
recruit=Troll,Troll Whelp,Ogre
recruit=Troll,Troll Whelp,Ogre
#else
recruit=Troll,Troll Warrior,Ogre
recruit=Troll,Troll Warrior,Ogre
#endif
team_name=orcs
{GOLD 100 200 300}
{INCOME 5 10 20}
[/side]
team_name=orcs
{GOLD 80 150 200}
{INCOME 5 10 20}
[/side]
[/items]
[/chamber]
[side]
type=Orcish Warlord
side=4
canrecruit=1
controller=ai
leader_value=10
recruitment_pattern=fighter,fighter,scout
#intermediate chamber between the troll and the player
[chamber]
id=troll_player
x=10-20
y=50-60
size=4
#passages to both the troll's chamber and the player's chamber
[passage]
destination=player
width=3
windiness=10
jagged=5
[/passage]
[passage]
destination=troll
width=2
windiness=10
jagged=5
[/passage]
[/chamber]
#chamber with the second orc. Somewhere in the north.
[chamber]
id=orc2
x=2-40
y=2-10
size=12
[items]
[side]
type=Orcish Warlord
side=4
canrecruit=1
controller=ai
leader_value=10
recruitment_pattern=fighter,fighter,scout
#ifdef EASY
recruit=Troll,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
recruit=Troll,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
#else
recruit=Troll,Troll Warrior,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
recruit=Troll,Troll Warrior,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
#endif
team_name=orcs
team_name=orcs
{GOLD 150 230 350}
{INCOME 5 10 20}
[/side]
{GOLD 80 150 200}
{INCOME 5 10 20}
[/side]
[/items]
[/chamber]
[side]
type=Orcish Warlord
side=5
canrecruit=1
controller=ai
leader_value=10
recruitment_pattern=fighter,fighter,scout
#chamber with the third orc. Somewhere in the north-east
[chamber]
id=orc3
x=40-48
y=10-20
size=10
[items]
[side]
type=Orcish Warlord
side=5
canrecruit=1
controller=ai
leader_value=10
recruitment_pattern=fighter,fighter,scout
#ifdef EASY
recruit=Troll,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
recruit=Troll,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
#else
recruit=Troll,Troll Warrior,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
recruit=Troll,Troll Warrior,Ogre,Goblin Knight,Wolf Rider,Troll Whelp
#endif
team_name=orcs
{GOLD 120 230 350}
{INCOME 5 10 20}
[/side]
team_name=orcs
{GOLD 80 150 200}
{INCOME 5 10 20}
[/side]
[/items]
#dummy enemy that forces finding the Sceptre
[side]
type=Orcish Warlord
side=6
canrecruit=1
controller=ai
recruit=Troll
team_name=orcs
gold=0
[/side]
#has a passage to the first orc
[passage]
destination=orc1
width=3
windiness=5
[/passage]
[event]
name=start
[recall]
description=Delfador
[/recall]
[recall]
description=Kalenz
[/recall]
[recall]
description=Li'sar
[/recall]
[message]
description=Konrad
id=scep1
message="The Sceptre must be getting close now! Where shall we go?"
[/message]
[message]
description=Delfador
id=scep2
message="Yes, I feel it is near here! We must search for it carefully."
[/message]
[/event]
#has a passage to the second orc 50% of the time
[passage]
chance=50
destination=orc2
width=2
jagged=3
windiness=5
[/passage]
[item]
x=22
y=32
image=misc/item-sceptreoffire.png
[/item]
#has a passage to the scepter 50% of the time
[passage]
chance=50
destination=scepter
width=1
jagged=5
windiness=5
[/passage]
[/chamber]
[event]
name=moveto
first_time_only=no
[filter]
side=1
x=22
y=32
[/filter]
[object]
id=object_sceptre
name=Sceptre of Fire
image=misc/item-sceptreoffire.png
duration=forever
description="This ancient Sceptre was forged by the Dwarves. A symbol of the kingship of Wesnoth, the Sceptre has the power to shoot fireballs at enemies of the bearer!"
cannot_use_message="This is the Sceptre of Fire. Only a true successor to the throne can possibly dare to take this!"
[filter]
type=Princess,Commander,Lord
[/filter]
[effect]
apply_to=new_attack
name=sceptre of fire
type=fire
range=long
special=magical
damage=16
number=4
[sound]
time=-200
sound=fire.wav
[/sound]
[missile_frame]
begin=-100
end=0
image=fireball.png
image_diagonal=fireball.png
[/missile_frame]
[/effect]
[/object]
[/event]
#chamber with the Scepter in it. Somewhere around the center
[chamber]
id=scepter
x=20-40
y=20-40
size=15
jagged=50
[items]
[item]
image=misc/item-sceptreoffire.png
[/item]
[event]
same_location_as_previous=yes
name=moveto
first_time_only=no
[filter]
side=1
x=22
y=32
[/filter]
[object]
id=object_sceptre
name=Sceptre of Fire
image=misc/item-sceptreoffire.png
duration=forever
description="This ancient Sceptre was forged by the Dwarves. A symbol of the kingship of Wesnoth, the Sceptre has the power to shoot fireballs at enemies of the bearer!"
cannot_use_message="This is the Sceptre of Fire. Only a true successor to the throne can possibly dare to take this!"
[filter]
type=Princess,Commander,Lord
[/filter]
[effect]
apply_to=new_attack
name=sceptre of fire
type=fire
range=long
special=magical
damage=16
number=4
[sound]
time=-200
sound=fire.wav
[/sound]
[missile_frame]
begin=-100
end=0
image=fireball.png
image_diagonal=fireball.png
[/missile_frame]
[/effect]
[/object]
[/event]
[event]
name=moveto
[filter]
description=Konrad
x=22
y=32
[/filter]
[set_variable]
name=sceptre
value="Konrad"
[/set_variable]
[message]
description=Konrad
id=sceptre3
message="Here it is at last, I have the Sceptre!"
[/message]
[message]
description=Kalenz
message="So it is in our hands! Now let us leave this stinking pit."
id=sceptre4
[/message]
[message]
description=Li'sar
message="I think that if we travel just a little north, we might be able to get out."
id=sceptre5
[/message]
[event]
same_location_as_previous=yes
name=moveto
[filter]
description=Konrad
[/filter]
[set_variable]
name=sceptre
value="Konrad"
[/set_variable]
[message]
description=Konrad
id=sceptre3
message="Here it is at last, I have the Sceptre!"
[/message]
[message]
description=Kalenz
message="So it is in our hands! Now let us leave this stinking pit."
id=sceptre4
[/message]
[message]
description=Li'sar
message="I think that if we travel just a little north, we might be able to get out."
id=sceptre5
[/message]
[endlevel]
result=victory
[/endlevel]
[/event]
[endlevel]
result=victory
[/endlevel]
[/event]
[event]
name=moveto
[filter]
description=Li'sar
x=22
y=32
[/filter]
[set_variable]
name=sceptre
value="Li'sar"
[/set_variable]
[message]
description=Li'sar
id=sceptre6
message="At last! I have the Sceptre!"
[/message]
[message]
description=Konrad
id=sceptre7
message="Indeed. You managed to reach it Li'sar. I hope you shall use it wisely."
[/message]
[message]
description=Li'sar
id=sceptre8
message="Well my first use for it is going to be to help us get out of this hole! I hope you consider that wise."
[/message]
[message]
description=Delfador
id=sceptre9
message="The Sceptre makes its wielder powerful, but hardly immortal, child. Use it prudently. Now come, I believe there is an exit to the north!"
[/message]
[message]
description=Li'sar
id=sceptre10
message="I think I know what I'm doing. Come, let us go!"
[/message]
[event]
same_location_as_previous=yes
name=moveto
[filter]
description=Li'sar
[/filter]
[set_variable]
name=sceptre
value="Li'sar"
[/set_variable]
[message]
description=Li'sar
id=sceptre6
message="At last! I have the Sceptre!"
[/message]
[message]
description=Konrad
id=sceptre7
message="Indeed. You managed to reach it Li'sar. I hope you shall use it wisely."
[/message]
[message]
description=Li'sar
id=sceptre8
message="Well my first use for it is going to be to help us get out of this hole! I hope you consider that wise."
[/message]
[message]
description=Delfador
id=sceptre9
message="The Sceptre makes its wielder powerful, but hardly immortal, child. Use it prudently. Now come, I believe there is an exit to the north!"
[/message]
[message]
description=Li'sar
id=sceptre10
message="I think I know what I'm doing. Come, let us go!"
[/message]
[endlevel]
result=victory
[/endlevel]
[/event]
[endlevel]
result=victory
[/endlevel]
[/event]
[/items]
[/chamber]
{deaths.cfg}
#chamber that is between the troll, the second orc, and the scepter
[chamber]
x=1-10
y=20-30
size=5
[passage]
destination=scepter
windiness=10
width=2
jagged=2
[/passage]
[passage]
destination=orc2
windiness=10
width=3
jagged=5
[/passage]
[passage]
destination=troll
windiness=5
width=3
jagged=5
[/passage]
[/chamber]
[/generator]
[/scenario]

View file

@ -3,7 +3,8 @@
#include "util.hpp"
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), width_(50), height_(50), village_density_(0),
flipx_(false), flipy_(false)
{
if(cfg_ == NULL) {
static const config default_cfg;
@ -12,6 +13,35 @@ cave_map_generator::cave_map_generator(const config* cfg) : wall_('W'), clear_('
width_ = atoi((*cfg_)["map_width"].c_str());
height_ = atoi((*cfg_)["map_height"].c_str());
village_density_ = atoi((*cfg_)["village_density"].c_str());
const int r = rand()%100;
const int chance = atoi((*cfg_)["flipx_chance"].c_str());
flipx_ = r < chance;
std::cerr << "flipx: " << r << " < " << chance << " = " << (flipx_ ? "true" : "false") << "\n";
flipy_ = (rand()%100) < atoi((*cfg_)["flipy_chance"].c_str());
}
size_t cave_map_generator::translate_x(size_t x) const
{
if(flipx_) {
x = width_ - x - 1;
}
return x;
}
size_t cave_map_generator::translate_y(size_t y) const
{
if(flipy_) {
y = height_ - y - 1;
}
return y;
}
bool cave_map_generator::allow_user_config() const { return true; }
@ -31,7 +61,12 @@ config cave_map_generator::create_scenario(const std::vector<std::string>& args)
map_ = std::vector<std::vector<gamemap::TERRAIN> >(width_,std::vector<gamemap::TERRAIN>(height_,wall_));
chambers_.clear();
passages_.clear();
res_.clear();
const config* const settings = cfg_->child("settings");
if(settings != NULL) {
res_ = *settings;
}
std::cerr << "creating scenario....\n";
generate_chambers();
@ -111,8 +146,8 @@ void cave_map_generator::generate_chambers()
}
}
const size_t x = min_xpos + (rand()%(max_xpos-min_xpos));
const size_t y = min_ypos + (rand()%(max_ypos-min_ypos));
const size_t x = translate_x(min_xpos + (rand()%(max_xpos-min_xpos)));
const size_t y = translate_y(min_ypos + (rand()%(max_ypos-min_ypos)));
const std::string& size = (**i)["size"];
size_t chamber_size = 3;
@ -275,8 +310,12 @@ bool cave_map_generator::on_board(const gamemap::location& loc) const
void cave_map_generator::set_terrain(gamemap::location loc, gamemap::TERRAIN t)
{
if(on_board(loc)) {
if(t == clear_ && (rand()%1000) < village_density_) {
t = village_;
}
gamemap::TERRAIN& c = map_[loc.x][loc.y];
if(c == clear_ || c == wall_) {
if(c == clear_ || c == wall_ || c == village_) {
c = t;
}
}

View file

@ -53,7 +53,14 @@ private:
config res_;
const config* cfg_;
size_t width_, height_;
size_t width_, height_, village_density_;
//the scenario may have a chance to flip all x values or y values
//to make the scenario appear all random. This is kept track of here.
bool flipx_, flipy_;
size_t translate_x(size_t x) const;
size_t translate_y(size_t y) const;
};
#endif

View file

@ -100,6 +100,18 @@ LEVEL_RESULT play_level(game_data& gameinfo, const config& game_config,
game_state& state_of_game,
const std::vector<config*>& story)
{
//if the entire scenario should be randomly generated
if((*level)["scenario_generation"] != "") {
std::cerr << "randomly generating scenario...\n";
const cursor::setter cursor_setter(cursor::WAIT);
static config scenario;
scenario = random_generate_scenario((*level)["scenario_generation"],level->child("generator"));
level = &scenario;
state_of_game.starting_pos = scenario;
}
std::string map_data = (*level)["map_data"];
if(map_data == "" && (*level)["map"] != "") {
map_data = read_file("data/maps/" + (*level)["map"]);