fixed seg fault
This commit is contained in:
parent
70db49cc75
commit
dbdc8ab04a
6 changed files with 113 additions and 74 deletions
|
@ -63,7 +63,7 @@ Defeat:
|
|||
canrecruit=1
|
||||
recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Troll Whelp
|
||||
recruitment_pattern=scout,scout,fighter,fighter,archer
|
||||
{GOLD 80 120 240}
|
||||
{GOLD 60 120 240}
|
||||
enemy=1
|
||||
[/side]
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
@6. Defeat bandit leader.
|
||||
Defeat:
|
||||
#Death of Konrad
|
||||
#Death of Deflador
|
||||
#Death of Delfador
|
||||
#Death of any of the elvish leaders
|
||||
#Turns run out"
|
||||
|
||||
|
@ -48,7 +48,7 @@ Defeat:
|
|||
[/side]
|
||||
|
||||
[side]
|
||||
type=Elvish Fighter
|
||||
type=Elvish Captain
|
||||
description=Galdrad
|
||||
side=2
|
||||
canrecruit=0
|
||||
|
@ -124,12 +124,12 @@ Defeat:
|
|||
[story]
|
||||
[part]
|
||||
id=tutorial_1
|
||||
story="After they found refuge in the elvish lands, the elder mage Delfador tried to teach the young Konrad all the skills and knowledge needed to be a leader among peers."
|
||||
story="After they found refuge in the Elvish lands, the elder mage Delfador tried to teach the young Konrad all the skills and knowledge needed to be a leader among his peers."
|
||||
image="misc/story0a.png"
|
||||
[/part]
|
||||
[part]
|
||||
id=tutorial_2
|
||||
story="Meanwhile in the woods border a group of dark preachers made an unholy pact with some desperate bandits."
|
||||
story="Meanwhile in the nearby woods, a group of dark preachers made an unholy pact with some desperate bandits."
|
||||
image="misc/story0b.png"
|
||||
[/part]
|
||||
[/story]
|
||||
|
@ -176,20 +176,22 @@ Defeat:
|
|||
[message]
|
||||
id=tut1
|
||||
description=Delfador
|
||||
message="It's been a great time here, Konrad. With our friends, the Elves, we enjoyed many years in peace. You are no longer child, Konrad. Every lord is skilled to be the first in battle, to lead his army against enemy of any race and abilities. Soon, the will be time to replace training sword with steal and return to your homeland -- Wesnoth. But there are things learn before that."
|
||||
message="It has been a great time here, Konrad. With our friends, the Elves, we have enjoyed many years in peace.
|
||||
|
||||
But you are no longer child, Konrad. Every lord must learn the ways of battle, to have the ability to lead his army against enemies of any race. Soon will be time to replace your training sword with an iron one, and claim your inheritance. But there are things that we must learn before that."
|
||||
[/message]
|
||||
|
||||
[message]
|
||||
id=tut2
|
||||
description=Konrad
|
||||
message="What is that, Delfador?"
|
||||
message="What must I learn, Delfador?"
|
||||
[/message]
|
||||
|
||||
[message]
|
||||
id=tut3
|
||||
description=Delfador
|
||||
message="Before entering any battle, you need to hire soldiers. Gold is necessary for that. There are villages through the land. Those which you gain control (marked with a red flag), will give you a extra gold coin every turn and pay the cost of one of your units. To conquer a village, move any of your units there.
|
||||
@EXCERCISE
|
||||
@EXERCISE
|
||||
Go to the nearest villages, so with the earned gold we can continue our lesson."
|
||||
[/message]
|
||||
[message]
|
||||
|
@ -203,7 +205,7 @@ Go to the nearest villages, so with the earned gold we can continue our lesson."
|
|||
speaker=narrator
|
||||
image="misc/tutorial2.png"
|
||||
message=".. then select his destination.
|
||||
If the destination is far away a unit could need more than one turn to reach it, the number shows how much turns it will take him."
|
||||
If the destination is far away a unit could need more than one turn to reach it, the number shows how many turns it will take him."
|
||||
[/message]
|
||||
[message]
|
||||
id=tut3c
|
||||
|
@ -223,7 +225,7 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
[message]
|
||||
id=tut15
|
||||
description=Delfador
|
||||
message="It was only practice, Konrad, but remember that in real, this would be end of yours."
|
||||
message="This has only been a practice, Konrad, but remember that if it were a real battle, you would now be dead."
|
||||
[/message]
|
||||
[/event]
|
||||
|
||||
|
@ -235,7 +237,7 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
[message]
|
||||
id=tut16
|
||||
description=Delfador
|
||||
message="Aii... Excuse me Konrad. I did my best to stop them, but you were obligued to protect me as well. End of training for today."
|
||||
message="Konrad, I did my best to stop them, but you were obligued to protect me as well. That is the end of training for today."
|
||||
[/message]
|
||||
[endlevel]
|
||||
result=defeat
|
||||
|
@ -314,7 +316,7 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
[then]
|
||||
[message]
|
||||
description=Delfador
|
||||
message="You did all the excercises, but four days was not enough for you to defeat bandits. I'm afraid you won't have so much time in real battle."
|
||||
message="You did all the exercies, but four days was not enough for you to defeat bandits. I'm afraid you won't have so much time in real battle."
|
||||
[/message]
|
||||
[message]
|
||||
description=Galdrad
|
||||
|
@ -324,19 +326,12 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
[else]
|
||||
[message]
|
||||
description=Delfador
|
||||
message="You look miserable, Konrad. Four days have passed and you haven't done even simple excercises. I'm giving up."
|
||||
message="You look miserable, Konrad. Four days have passed and you haven't completed the exercises. In a real battle you must act quickly, before your enemies summon reinforcements. We will have to try again another time."
|
||||
[/message]
|
||||
[/else]
|
||||
[/if]
|
||||
[/event]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
########
|
||||
# Item #
|
||||
########
|
||||
|
@ -402,25 +397,18 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
[message]
|
||||
id=tut_staff
|
||||
description=Delfador
|
||||
message="This is my old staff. Although not very useful in close range, its magic proves to be deadly to your enemies. It's powers are wanning so it will not last long. Don't be afraid to use this weapon now - I will make sure you won't hurt yourself."
|
||||
message="This is my old staff. Although not very useful in close range, its magic proves to be deadly to your enemies. Its powers are waning so it will not last long. Don't be afraid to use this weapon now - I will make sure you won't hurt yourself."
|
||||
[/message]
|
||||
[message]
|
||||
id=tut_staff2
|
||||
speaker=narrator
|
||||
image="misc/tutorial3b.png"
|
||||
message="Magic items couls help you in your quest, but you should be aware that some items can only be picked by some units."
|
||||
message="Magic items could help you in your quest, but you should be aware that some items can only be picked up by certain units."
|
||||
[/message]
|
||||
[/event]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##########
|
||||
# TASK 1 #
|
||||
##########
|
||||
|
@ -436,12 +424,30 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
name=task
|
||||
value=1
|
||||
[/set_variable]
|
||||
|
||||
#define POACHER_WEAKENER
|
||||
[modifications]
|
||||
[trait]
|
||||
[effect]
|
||||
apply_to=hitpoints
|
||||
increase_total=-15
|
||||
heal_full=yes
|
||||
[/effect]
|
||||
[effect]
|
||||
apply_to=attack
|
||||
range=long
|
||||
increase_damage=-1
|
||||
[/effect]
|
||||
[/trait]
|
||||
[/modifications]
|
||||
#enddef
|
||||
[unit]
|
||||
type=Poacher
|
||||
description=Rapprah
|
||||
x=26
|
||||
y=21
|
||||
side=3
|
||||
{POACHER_WEAKENER}
|
||||
[/unit]
|
||||
[unit]
|
||||
type=Poacher
|
||||
|
@ -449,11 +455,12 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
x=24
|
||||
y=20
|
||||
side=3
|
||||
{POACHER_WEAKENER}
|
||||
[/unit]
|
||||
[message]
|
||||
id=amb1
|
||||
description=Rapprah
|
||||
message="Aaaaaa!"
|
||||
message="Surprise! You have walked into our trap, foolish boy!"
|
||||
[/message]
|
||||
[message]
|
||||
id=amb2
|
||||
|
@ -473,8 +480,9 @@ If the destination is far away a unit could need more than one turn to reach it,
|
|||
[message]
|
||||
id=amb5
|
||||
description=Delfador
|
||||
message="Fight is the best way to improve your skills. When you get enough experience (XP) you advance to become better soldier.
|
||||
When you choose to attack enemy unit, you may choose which weapon you want to fight with. For every weapon, there are three important numbers shown: damage it causes, number of attacks you have and probability of hitting the enemy. Also the opponent's values are displayed."
|
||||
message="Fighting is the best way to improve your skills. When you get enough experience (XP) you advance to become a better fighter.
|
||||
|
||||
When you choose to attack an enemy unit, you may choose which weapon you want to fight with. For every weapon, there are three important numbers shown: the damage it causes, the number of attacks you have and the probability of hitting the enemy. Also the opponent's values are displayed."
|
||||
[/message]
|
||||
[message]
|
||||
id=tut4a
|
||||
|
@ -487,7 +495,7 @@ When you choose to attack enemy unit, you may choose which weapon you want to fi
|
|||
speaker=narrator
|
||||
image="misc/tutorial5.png"
|
||||
message="...then click to select a target.
|
||||
Once you do this you have to chose the weapon."
|
||||
Once you do this you have to choose the weapon."
|
||||
[/message]
|
||||
[/event]
|
||||
|
||||
|
@ -546,7 +554,7 @@ Once you do this you have to chose the weapon."
|
|||
[message]
|
||||
id=kill4
|
||||
description=Delfador
|
||||
message="If you are finished with the villages, go back to the castle, to recruit your soldiers."
|
||||
message="If you are finished with the villages, go back to the castle, to recruit your soldiers. Remember that in a real battle, you will probably start with some money to recruit soldiers from the beginning."
|
||||
[/message]
|
||||
[message]
|
||||
id=tut3a
|
||||
|
@ -631,7 +639,7 @@ Once you do this you have to chose the weapon."
|
|||
[message]
|
||||
id=recr3
|
||||
description=Delfador
|
||||
message="You have to carefully review their skills. Early on, you want fast units to seize as many villages as possible. After that, fighters should probably make up the bulk of your army. Remember that all Elvish units fight very well in forest. Horsemen are excellent on open ground. Mages are good for support, and can be used much like archers. If you can get your mages more experienced, they can be especially powerful."
|
||||
message="You have to carefully review their skills. Early on, you want fast units to sieze as many villages as possible. After that, fighters should probably make up the bulk of your army. Remember that all Elvish units fight very well in forest. Horsemen are excellent on open ground. Mages are good for support, and can be used much like archers. If you can get your mages more experienced, they can be especially powerful."
|
||||
[/message]
|
||||
[gold]
|
||||
side=1
|
||||
|
@ -1008,8 +1016,8 @@ You are now allowed to recruit all units. Good luck!"
|
|||
[then]
|
||||
[message]
|
||||
description=Uli'ar
|
||||
message="You have recruited Scouts. Elvish Scouts aren't very well in combat although they can seize large territories in short time. They are excellent in capturing villages.
|
||||
@EXCERCISE
|
||||
message="You have recruited Scouts. Elvish Scouts aren't very well in combat although they can sieze large territories in short time. They are excellent in capturing villages.
|
||||
@EXERCISE
|
||||
Take over the western villages to get more gold."
|
||||
[/message]
|
||||
[set_variable]
|
||||
|
@ -1029,9 +1037,9 @@ Take over the western villages to get more gold."
|
|||
[then]
|
||||
[message]
|
||||
description=Alisar
|
||||
message="You have recruited Archers. Elvish archers are weak in arm to arm combats, but are excellent shooters. Send your archers against enemies who don't have long range weapons and avoid exiting forests and villages.
|
||||
message="You have recruited Archers. Elvish archers are weak in hand-to-hand combat, but are excellent shooters. Send your archers against enemies who don't have long range weapons and avoid exiting forests and villages.
|
||||
Archers advance to sharpshooters or avengers who are deadly with their long bows and swords.
|
||||
@EXCERCISE
|
||||
@EXERCISE
|
||||
We have prepared a practice target for you -- Gerlog, the thief, due south of your castle."
|
||||
[/message]
|
||||
[unit]
|
||||
|
@ -1060,7 +1068,7 @@ We have prepared a practice target for you -- Gerlog, the thief, due south of yo
|
|||
description=Enelar
|
||||
message="You have recruited Fighters. They are well prepared to combat in both close and long range. As all the Elves, they defend well in forests and villages.
|
||||
Fighter's career ends at marshal or champion, both well prepared to fight against all types of enemies. Marshals can also lead soldiers in battle.
|
||||
@EXCERCISE
|
||||
@EXERCISE
|
||||
To test fighters, send them against Kharhbrah, the Poacher on the brigde."
|
||||
[/message]
|
||||
[unit]
|
||||
|
@ -1105,7 +1113,7 @@ To test fighters, send them against Kharhbrah, the Poacher on the brigde."
|
|||
[message]
|
||||
description=Uli'ar
|
||||
message="Horsemen advance to paladins, great warriors who can also heal their companions in battle.
|
||||
@EXCERCISE
|
||||
@EXERCISE
|
||||
There is practice target on the clearing, south-east of your castle. Go there and wipe the area out of our enemies."
|
||||
[/message]
|
||||
[unit]
|
||||
|
@ -1160,7 +1168,7 @@ There is practice target on the clearing, south-east of your castle. Go there an
|
|||
description=Chantal
|
||||
message="Humans are famous of their deep knowlegde about the world. Mages are the elite of human researchers -- they are able to summon forces of nature and use them against any fool who would opose. Because of the magic, their fire missiles almost always hit the target.
|
||||
Mage is weak yet, but experienced, they specialize either in white magic as mages of light or other kinds of forces to become great mages.
|
||||
@EXCERCISE
|
||||
@EXERCISE
|
||||
On the other side of the road, undead have spread. Make sure, they don't move any step further!"
|
||||
[/message]
|
||||
[unit]
|
||||
|
@ -1187,22 +1195,36 @@ On the other side of the road, undead have spread. Make sure, they don't move an
|
|||
# Check if the player has completed task 2.
|
||||
#
|
||||
[if]
|
||||
[variable]
|
||||
name=exc_archer
|
||||
greater_than=1
|
||||
[/variable]
|
||||
[variable]
|
||||
name=exc_scout
|
||||
greater_than=4
|
||||
[/variable]
|
||||
[variable]
|
||||
name=exc_fighter
|
||||
greater_than=1
|
||||
[/variable]
|
||||
[variable]
|
||||
name=task
|
||||
equals=2
|
||||
[/variable]
|
||||
[or]
|
||||
[variable]
|
||||
name=exc_archer
|
||||
greater_than=1
|
||||
[/variable]
|
||||
[variable]
|
||||
name=task
|
||||
equals=2
|
||||
[/variable]
|
||||
[/or]
|
||||
[or]
|
||||
[variable]
|
||||
name=exc_scout
|
||||
greater_than=4
|
||||
[/variable]
|
||||
[variable]
|
||||
name=task
|
||||
equals=2
|
||||
[/variable]
|
||||
[/or]
|
||||
[or]
|
||||
[variable]
|
||||
name=exc_fighter
|
||||
greater_than=1
|
||||
[/variable]
|
||||
[variable]
|
||||
name=task
|
||||
equals=2
|
||||
[/variable]
|
||||
[/or]
|
||||
[then]
|
||||
[set_variable]
|
||||
name=exc_horse
|
||||
|
|
|
@ -429,7 +429,10 @@ void attack(display& gui, const gamemap& map,
|
|||
|
||||
gamemap::location loc = d->first;
|
||||
gamemap::location attacker_loc = a->first;
|
||||
const int defender_side = d->second.side();
|
||||
game_events::fire("die",loc,a->first);
|
||||
d = units.end();
|
||||
a = units.end();
|
||||
|
||||
//the handling of the event may have removed the object
|
||||
//so we have to find it again
|
||||
|
@ -440,12 +443,11 @@ void attack(display& gui, const gamemap& map,
|
|||
if(stats.attacker_plague && map.underlying_terrain(map[loc.x][loc.y]) != gamemap::TOWER) {
|
||||
a = units.find(attacker_loc);
|
||||
if(a != units.end()) {
|
||||
units.insert(std::pair<gamemap::location,unit>(
|
||||
loc,a->second));
|
||||
units.insert(std::pair<gamemap::location,unit>(loc,a->second));
|
||||
gui.draw_tile(loc.x,loc.y);
|
||||
}
|
||||
}
|
||||
recalculate_fog(map,state,info,units,teams,d->second.side()-1);
|
||||
recalculate_fog(map,state,info,units,teams,defender_side-1);
|
||||
gui.recalculate_minimap();
|
||||
gui.update_display();
|
||||
break;
|
||||
|
@ -552,7 +554,10 @@ void attack(display& gui, const gamemap& map,
|
|||
|
||||
gamemap::location loc = a->first;
|
||||
gamemap::location defender_loc = d->first;
|
||||
const int attacker_side = a->second.side();
|
||||
game_events::fire("die",loc,d->first);
|
||||
a = units.end();
|
||||
d = units.end();
|
||||
|
||||
//the handling of the event may have removed the object
|
||||
//so we have to find it again
|
||||
|
@ -570,7 +575,7 @@ void attack(display& gui, const gamemap& map,
|
|||
}
|
||||
gui.recalculate_minimap();
|
||||
gui.update_display();
|
||||
recalculate_fog(map,state,info,units,teams,a->second.side()-1);
|
||||
recalculate_fog(map,state,info,units,teams,attacker_side-1);
|
||||
break;
|
||||
} else if(hits) {
|
||||
if(stats.defend_special == poison_string &&
|
||||
|
|
|
@ -909,7 +909,6 @@ void display::draw_minimap(int x, int y, int w, int h)
|
|||
SDL_Rect rect = {x + (u->first.x*w)/map_.x(),
|
||||
y + (u->first.y*h)/map_.y(),
|
||||
w/map_.x(), h/map_.y() };
|
||||
std::cerr << "drawing unit " << rect.x << "," << rect.y << "," << rect.w << "," << rect.h << "\n";
|
||||
SDL_FillRect(video().getSurface(),&rect,mapped_col);
|
||||
}
|
||||
|
||||
|
@ -1075,8 +1074,7 @@ void display::draw_unit_on_tile(int x, int y, SDL_Surface* unit_image_override,
|
|||
return;
|
||||
}
|
||||
|
||||
unit_energy = double(it->second.hitpoints()) /
|
||||
double(it->second.max_hitpoints());
|
||||
unit_energy = minimum<double>(1.0,double(it->second.hitpoints()) / double(it->second.max_hitpoints()));
|
||||
|
||||
if(highlight_ratio == 1.0)
|
||||
highlight_ratio = it->second.alpha();
|
||||
|
|
|
@ -33,6 +33,16 @@ bool conditional_passed(game_state& state_of_game,
|
|||
const std::map<gamemap::location,unit>* units,
|
||||
const config& cond)
|
||||
{
|
||||
//an 'or' statement means that if the contained statements are true,
|
||||
//then it automatically passes
|
||||
const config::child_list& or_statements = cond.get_children("or");
|
||||
for(config::child_list::const_iterator or_it = or_statements.begin();
|
||||
or_it != or_statements.end(); ++or_it) {
|
||||
if(conditional_passed(state_of_game,units,**or_it)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//if the if statement requires we have a certain unit, then
|
||||
//check for that.
|
||||
const config::child_list& have_unit = cond.get_children("have_unit");
|
||||
|
@ -124,7 +134,7 @@ bool conditional_passed(game_state& state_of_game,
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return !have_unit.empty() || !variables.empty();
|
||||
}
|
||||
|
||||
} //end namespace game_events
|
||||
|
|
20
src/unit.cpp
20
src/unit.cpp
|
@ -500,12 +500,6 @@ void unit::read(game_data& data, const config& cfg)
|
|||
upkeep_ = UPKEEP_FREE;
|
||||
}
|
||||
|
||||
const config* const modifications = cfg.child("modifications");
|
||||
if(modifications != NULL) {
|
||||
modifications_ = *modifications;
|
||||
apply_modifications();
|
||||
}
|
||||
|
||||
const std::string& facing = cfg["facing"];
|
||||
if(facing == "reverse")
|
||||
facingLeft_ = false;
|
||||
|
@ -538,7 +532,7 @@ void unit::read(game_data& data, const config& cfg)
|
|||
|
||||
const std::string& hitpoints = cfg["hitpoints"];
|
||||
if(hitpoints.size() == 0)
|
||||
hitpoints_ = type().hitpoints();
|
||||
hitpoints_ = maxHitpoints_;
|
||||
else
|
||||
hitpoints_ = atoi(hitpoints.c_str());
|
||||
|
||||
|
@ -547,6 +541,12 @@ void unit::read(game_data& data, const config& cfg)
|
|||
experience_ = 0;
|
||||
else
|
||||
experience_ = atoi(experience.c_str());
|
||||
|
||||
const config* const modifications = cfg.child("modifications");
|
||||
if(modifications != NULL) {
|
||||
modifications_ = *modifications;
|
||||
apply_modifications();
|
||||
}
|
||||
}
|
||||
|
||||
void unit::write(config& cfg) const
|
||||
|
@ -762,6 +762,7 @@ void unit::add_modification(const std::string& type,
|
|||
a->apply_modification(**i.first);
|
||||
}
|
||||
} else if(apply_to == "hitpoints") {
|
||||
std::cerr << "applying hitpoint mod...." << hitpoints_ << "/" << maxHitpoints_ << "\n";
|
||||
const std::string& increase_hp = (**i.first)["increase"];
|
||||
const std::string& heal_full = (**i.first)["heal_full"];
|
||||
const std::string& increase_total = (**i.first)["increase_total"];
|
||||
|
@ -793,8 +794,11 @@ void unit::add_modification(const std::string& type,
|
|||
hitpoints_ += increase;
|
||||
}
|
||||
|
||||
if(hitpoints_ > maxHitpoints_ && violate_max.empty())
|
||||
std::cerr << "modded to " << hitpoints_ << "/" << maxHitpoints_ << "\n";
|
||||
if(hitpoints_ > maxHitpoints_ && violate_max.empty()) {
|
||||
std::cerr << "resetting hp to max\n";
|
||||
hitpoints_ = maxHitpoints_;
|
||||
}
|
||||
|
||||
if(hitpoints_ < 1)
|
||||
hitpoints_ = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue