iAdded new 'best' AI difficulty. ATM this is not locked yet, and
art work (icon) is still missing. Also we have to find what to call it (atm 'Iron Man'). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12637 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
58e06f6cd7
commit
9a9ff77812
BIN
data/gui/difficulty_best.png
Normal file
BIN
data/gui/difficulty_best.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
@ -25,6 +25,8 @@
|
||||
I18N="Difficulty" text="Intermediate"/>
|
||||
<icon-button id="expert" width="128" height="128" icon="gui/difficulty_hard.png"
|
||||
I18N="Difficulty" text="Expert"/>
|
||||
<icon-button id="best" width="128" height="128" icon="gui/difficulty_best.png"
|
||||
I18N="Difficulty" text="Iron man"/>
|
||||
</ribbon>
|
||||
|
||||
<spacer proportion="1" width="25"/>
|
||||
|
@ -347,6 +347,23 @@
|
||||
rb-skid-probability="-50:1.0 -20:0.7 20:0.2 50:0.0"
|
||||
skidding-threshold="2.0"
|
||||
/>
|
||||
<best time-full-steer="0.1"
|
||||
straight-length-for-zipper="35"
|
||||
use-slipstream="true"
|
||||
disable-slipstream-usage="false"
|
||||
false-start-probability="0.0"
|
||||
min-start-delay="0.15" max-start-delay="0.2"
|
||||
nitro-usage="all"
|
||||
non-random-item-usage="true"
|
||||
collect-avoid-items="true"
|
||||
handle-bomb="true"
|
||||
speed-cap="0:1.0"
|
||||
max-item-angle="0.7" max-item-angle-high-speed="0.3"
|
||||
bad-item-closeness="6"
|
||||
collect-item-probability="0:1.0"
|
||||
rb-skid-probability="0:1.0"
|
||||
skidding-threshold="2.0"
|
||||
/>
|
||||
</ai>
|
||||
<!-- Slipstream: length: How far behind a kart slipstream works
|
||||
width: how wide slipstream works furthest away from the kart.
|
||||
@ -402,7 +419,7 @@
|
||||
have 3 values, one for low, medium, and hard.
|
||||
brake-factor: Value used when braking. max-speed-reverse-ratio is
|
||||
the percentage of max speed for reverse gear. -->
|
||||
<engine power="450 475 500" max-speed="17 21 23" brake-factor="11.0"
|
||||
<engine power="450 475 500 510" max-speed="17 21 23 25" brake-factor="11.0"
|
||||
max-speed-reverse-ratio="0.3"/>
|
||||
|
||||
<!-- Simulated gears: switch-ratio defines at what ratio of the maximum
|
||||
@ -501,7 +518,7 @@
|
||||
in your face is removed. -->
|
||||
<plunger band-max-length="50" band-force="1500" band-duration="1"
|
||||
band-speed-increase="7" band-fade-out-time="3"
|
||||
in-face-time="3 4 4.5"/>
|
||||
in-face-time="3 4 4.5 4.5"/>
|
||||
|
||||
<!-- Kart-specific explosion parameters.
|
||||
Time: how long it takes before the kart can drive again (this
|
||||
|
@ -160,13 +160,14 @@ ChallengeData::ChallengeData(const std::string& filename)
|
||||
difficulties[1] = root->getNode("medium");
|
||||
difficulties[2] = root->getNode("hard");
|
||||
|
||||
// Note that the challenges can only be done in three difficulties
|
||||
if (difficulties[0] == NULL || difficulties[1] == NULL ||
|
||||
difficulties[2] == NULL)
|
||||
{
|
||||
error("<easy> or <medium> or <hard>");
|
||||
}
|
||||
|
||||
for (int d=0; d<RaceManager::DIFFICULTY_COUNT; d++)
|
||||
for (int d=0; d<=RaceManager::DIFFICULTY_HARD; d++)
|
||||
{
|
||||
const XMLNode* karts_node = difficulties[d]->getNode("karts");
|
||||
if (karts_node == NULL) error("<karts .../>");
|
||||
@ -220,15 +221,7 @@ ChallengeData::ChallengeData(const std::string& filename)
|
||||
if (requirements_node->get("energy", &energy)) m_energy[d] = energy;
|
||||
|
||||
}
|
||||
|
||||
// TODO: add gp support
|
||||
/*
|
||||
else // GP
|
||||
{
|
||||
if (!root->get("gp", &m_gp_id )) error("gp");
|
||||
if (grand_prix_manager->getGrandPrix(m_gp_id) == NULL) error("gp");
|
||||
}
|
||||
*/
|
||||
|
||||
std::vector<XMLNode*> unlocks;
|
||||
root->getNodes("unlock", unlocks);
|
||||
for(unsigned int i=0; i<unlocks.size(); i++)
|
||||
|
@ -130,8 +130,10 @@ void UnlockManager::readAllChallengesInDirs(const std::vector<std::string>* all_
|
||||
}
|
||||
catch (std::runtime_error& ex)
|
||||
{
|
||||
std::cerr << "\n/!\\ An error occurred while loading challenge file '" << filename << "' : "
|
||||
<< ex.what() << " : challenge will be ignored.\n\n";
|
||||
Log::warn("unlock_manager", "An error occurred while "
|
||||
"loading challenge file '%s' : %s.\n"
|
||||
"Challenge will be ignored.",
|
||||
filename.c_str(), ex.what());
|
||||
continue;
|
||||
}
|
||||
addOrFreeChallenge(new_challenge);
|
||||
@ -174,9 +176,10 @@ void UnlockManager::addChallenge(const std::string& filename)
|
||||
}
|
||||
catch (std::runtime_error& ex)
|
||||
{
|
||||
std::cerr << "\n/!\\ An error occurred while loading challenge file '" << filename << "' : "
|
||||
<< ex.what() << " : challenge will be ignored.\n\n";
|
||||
if (new_challenge != NULL) delete new_challenge;
|
||||
Log::warn("unlock_manager", "An error occurred while loading "
|
||||
"challenge file '%s' : %s challenge will be ignored.",
|
||||
filename.c_str(), ex.what());
|
||||
if (new_challenge) delete new_challenge;
|
||||
return;
|
||||
}
|
||||
addOrFreeChallenge(new_challenge);
|
||||
@ -204,9 +207,8 @@ void UnlockManager::load()
|
||||
XMLNode* root = file_manager->createXMLTree(filename);
|
||||
if(!root || root->getName() != "challenges")
|
||||
{
|
||||
std::cerr << "Challenge file '" << filename << "' will be created."
|
||||
<< std::endl;
|
||||
|
||||
Log::info("unlock_manager", "Challenge file '%s' will be created.",
|
||||
filename.c_str());
|
||||
createSlotsIfNeeded();
|
||||
save();
|
||||
|
||||
@ -221,7 +223,8 @@ void UnlockManager::load()
|
||||
std::string player_id;
|
||||
if (!xml_game_slots[n]->get("playerID", &player_id))
|
||||
{
|
||||
fprintf(stderr, "[UnlockManager] WARNING: Found game slot without a player ID attached. Discarding it\n");
|
||||
Log::warn("unlock_manager", "Found game slot without "
|
||||
"a player ID attached. Discarding it.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -265,7 +268,9 @@ void UnlockManager::save()
|
||||
|
||||
if (!challenge_file.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open " << filename << " for writing, challenges won't be saved\n";
|
||||
Log::warn("unlock_manager",
|
||||
"Failed to open '%s' for writing, challenges won't be saved\n",
|
||||
filename.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -417,7 +422,7 @@ void UnlockManager::updateActiveChallengeList()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void UnlockManager::findWhatWasUnlocked(int pointsBefore, int pointsNow,
|
||||
void UnlockManager::findWhatWasUnlocked(int points_before, int points_now,
|
||||
std::vector<std::string>& tracks,
|
||||
std::vector<std::string>& gps)
|
||||
{
|
||||
@ -425,7 +430,8 @@ void UnlockManager::findWhatWasUnlocked(int pointsBefore, int pointsNow,
|
||||
it != m_all_challenges.end(); it++)
|
||||
{
|
||||
ChallengeData* c = it->second;
|
||||
if (c->getNumTrophies() > pointsBefore && c->getNumTrophies() <= pointsNow)
|
||||
if (c->getNumTrophies() > points_before &&
|
||||
c->getNumTrophies() <= points_now )
|
||||
{
|
||||
if (c->getTrackId() != "")
|
||||
{
|
||||
|
@ -570,6 +570,7 @@ bool IrrDriver::moveWindow(const int x, const int y)
|
||||
const SExposedVideoData& videoData = m_video_driver->getExposedVideoData();
|
||||
using namespace X11;
|
||||
|
||||
const SExposedVideoData& videoData = m_video_driver->getExposedVideoData();
|
||||
// TODO: Actually handle possible failure
|
||||
XMoveWindow((Display*)videoData.OpenGLLinux.X11Display,
|
||||
videoData.OpenGLLinux.X11Window,
|
||||
|
@ -63,8 +63,7 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
|
||||
// Set all other values to undefined, so that it can later be tested
|
||||
// if everything is defined properly.
|
||||
m_mass = m_brake_factor = m_engine_power[0] = m_engine_power[1] =
|
||||
m_engine_power[2] = m_max_speed[0] = m_max_speed[1] = m_max_speed[2] =
|
||||
m_mass = m_brake_factor =
|
||||
m_time_reset_steer = m_nitro_consumption = m_nitro_engine_force =
|
||||
m_nitro_small_container = m_nitro_big_container = m_nitro_max =
|
||||
m_nitro_max_speed_increase = m_nitro_duration = m_nitro_fade_out_time =
|
||||
@ -72,16 +71,13 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_wheel_damping_compression = m_friction_slip = m_roll_influence =
|
||||
m_wheel_radius = m_chassis_linear_damping = m_max_suspension_force =
|
||||
m_chassis_angular_damping = m_suspension_rest =
|
||||
m_max_speed_reverse_ratio =
|
||||
m_rescue_vert_offset = m_upright_tolerance =
|
||||
m_collision_terrain_impulse = m_collision_impulse = m_restitution =
|
||||
m_collision_impulse_time =
|
||||
m_max_speed_reverse_ratio = m_rescue_vert_offset =
|
||||
m_upright_tolerance = m_collision_terrain_impulse =
|
||||
m_collision_impulse = m_restitution = m_collision_impulse_time =
|
||||
m_upright_max_force = m_suspension_travel_cm =
|
||||
m_track_connection_accel =
|
||||
m_rubber_band_max_length = m_rubber_band_force =
|
||||
m_rubber_band_duration = m_rubber_band_speed_increase =
|
||||
m_rubber_band_fade_out_time = m_plunger_in_face_duration[0] =
|
||||
m_plunger_in_face_duration[1] = m_plunger_in_face_duration[2] =
|
||||
m_track_connection_accel = m_rubber_band_max_length =
|
||||
m_rubber_band_force = m_rubber_band_duration =
|
||||
m_rubber_band_speed_increase = m_rubber_band_fade_out_time =
|
||||
m_zipper_time = m_zipper_force = m_zipper_speed_gain =
|
||||
m_zipper_max_speed_increase = m_zipper_fade_out_time =
|
||||
m_slipstream_length = m_slipstream_width = m_slipstream_collect_time =
|
||||
@ -95,6 +91,11 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_swatter_distance2 = m_swatter_duration = m_squash_slowdown =
|
||||
m_squash_duration = m_downward_impulse_factor = UNDEFINED;
|
||||
|
||||
m_engine_power.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED);
|
||||
m_max_speed.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED);
|
||||
m_plunger_in_face_duration.resize(RaceManager::DIFFICULTY_COUNT,
|
||||
UNDEFINED);
|
||||
|
||||
m_terrain_impulse_type = IMPULSE_NONE;
|
||||
m_gravity_center_shift = Vec3(UNDEFINED);
|
||||
m_bevel_factor = Vec3(UNDEFINED);
|
||||
@ -338,6 +339,8 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
m_ai_properties[RaceManager::DIFFICULTY_MEDIUM]->load(medium);
|
||||
const XMLNode *hard = ai_node->getNode("hard");
|
||||
m_ai_properties[RaceManager::DIFFICULTY_HARD]->load(hard);
|
||||
const XMLNode *best = ai_node->getNode("best");
|
||||
m_ai_properties[RaceManager::DIFFICULTY_BEST]->load(best);
|
||||
}
|
||||
|
||||
if(const XMLNode *slipstream_node = root->getNode("slipstream"))
|
||||
@ -367,34 +370,22 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
{
|
||||
engine_node->get("brake-factor", &m_brake_factor);
|
||||
engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio);
|
||||
std::vector<float> v;
|
||||
if( engine_node->get("power", &v))
|
||||
engine_node->get("power", &m_engine_power);
|
||||
if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
if(v.size()!=3)
|
||||
Log::warn("KartProperties",
|
||||
"Incorrect engine-power specifications for kart '%s'\n",
|
||||
getIdent().c_str());
|
||||
else
|
||||
{
|
||||
m_engine_power[0] = v[0];
|
||||
m_engine_power[1] = v[1];
|
||||
m_engine_power[2] = v[2];
|
||||
}
|
||||
} // if engine-power
|
||||
v.clear();
|
||||
if( engine_node->get("max-speed", &v))
|
||||
Log::fatal("KartProperties",
|
||||
"Incorrect engine-power specifications for kart '%s'\n",
|
||||
getIdent().c_str());
|
||||
exit(-1);
|
||||
}
|
||||
engine_node->get("max-speed", &m_max_speed);
|
||||
if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
if(v.size()!=3)
|
||||
Log::error("KartProperties",
|
||||
"Incorrect max-speed specifications for kart '%s'\n",
|
||||
getIdent().c_str());
|
||||
else
|
||||
{
|
||||
m_max_speed[0] = v[0];
|
||||
m_max_speed[1] = v[1];
|
||||
m_max_speed[2] = v[2];
|
||||
}
|
||||
} // if max-speed
|
||||
Log::fatal("KartProperties",
|
||||
"Incorrect max-speed specifications for kart '%s'\n",
|
||||
getIdent().c_str());
|
||||
exit(-1);
|
||||
}
|
||||
} // if getNode("engine")
|
||||
|
||||
if(const XMLNode *gear_node = root->getNode("gear"))
|
||||
@ -482,18 +473,12 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
plunger_node->get("band-duration", &m_rubber_band_duration );
|
||||
plunger_node->get("band-speed-increase",&m_rubber_band_speed_increase);
|
||||
plunger_node->get("band-fade-out-time", &m_rubber_band_fade_out_time );
|
||||
std::vector<float> v;
|
||||
plunger_node->get("in-face-time", &v);
|
||||
if(v.size()!=3)
|
||||
plunger_node->get("in-face-time", &m_plunger_in_face_duration);
|
||||
if(m_plunger_in_face_duration.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
Log::error("KartProperties",
|
||||
Log::fatal("KartProperties",
|
||||
"Invalid plunger in-face-time specification.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_plunger_in_face_duration[0] = v[0];
|
||||
m_plunger_in_face_duration[1] = v[1];
|
||||
m_plunger_in_face_duration[2] = v[2];
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -629,12 +614,6 @@ void KartProperties::checkAllSet(const std::string &filename)
|
||||
CHECK_NEG(m_chassis_angular_damping, "stability chassis-angular-damping");
|
||||
CHECK_NEG(m_downward_impulse_factor, "stability downward-impulse-factor");
|
||||
CHECK_NEG(m_track_connection_accel, "stability track-connection-accel" );
|
||||
CHECK_NEG(m_engine_power[0], "engine power[0]" );
|
||||
CHECK_NEG(m_engine_power[1], "engine power[1]" );
|
||||
CHECK_NEG(m_engine_power[2], "engine power[2]" );
|
||||
CHECK_NEG(m_max_speed[0], "engine maximum-speed[0]" );
|
||||
CHECK_NEG(m_max_speed[1], "engine maximum-speed[1]" );
|
||||
CHECK_NEG(m_max_speed[2], "engine maximum-speed[2]" );
|
||||
CHECK_NEG(m_max_speed_reverse_ratio, "engine max-speed-reverse-ratio");
|
||||
CHECK_NEG(m_brake_factor, "engine brake-factor" );
|
||||
CHECK_NEG(m_suspension_stiffness, "suspension stiffness" );
|
||||
@ -650,9 +629,6 @@ void KartProperties::checkAllSet(const std::string &filename)
|
||||
CHECK_NEG(m_bevel_factor.getZ(), "collision bevel-factor" );
|
||||
CHECK_NEG(m_upright_tolerance, "upright tolerance" );
|
||||
CHECK_NEG(m_upright_max_force, "upright max-force" );
|
||||
CHECK_NEG(m_plunger_in_face_duration[0],"plunger in-face-time[0]" );
|
||||
CHECK_NEG(m_plunger_in_face_duration[1],"plunger in-face-time[1]" );
|
||||
CHECK_NEG(m_plunger_in_face_duration[2],"plunger in-face-time[2]" );
|
||||
CHECK_NEG(m_rubber_band_max_length, "plunger band-max-length" );
|
||||
CHECK_NEG(m_rubber_band_force, "plunger band-force" );
|
||||
CHECK_NEG(m_rubber_band_duration, "plunger band-duration" );
|
||||
@ -697,6 +673,14 @@ void KartProperties::checkAllSet(const std::string &filename)
|
||||
"explosion invulnerability-time");
|
||||
CHECK_NEG(m_explosion_radius, "explosion radius" );
|
||||
|
||||
for(unsigned int i=RaceManager::DIFFICULTY_FIRST;
|
||||
i<=RaceManager::DIFFICULTY_LAST; i++)
|
||||
{
|
||||
CHECK_NEG(m_max_speed[i], "engine maximum-speed[0]");
|
||||
CHECK_NEG(m_engine_power[i], "engine power" );
|
||||
CHECK_NEG(m_plunger_in_face_duration[i],"plunger in-face-time");
|
||||
}
|
||||
|
||||
m_skidding_properties->checkAllSet(filename);
|
||||
for(unsigned int i=0; i<RaceManager::DIFFICULTY_COUNT; i++)
|
||||
m_ai_properties[i]->checkAllSet(filename);
|
||||
|
@ -125,7 +125,7 @@ private:
|
||||
float m_mass;
|
||||
|
||||
/** Maximum force from engine for eachdifficulty. */
|
||||
float m_engine_power[3];
|
||||
std::vector<float> m_engine_power;
|
||||
|
||||
/** Braking factor * engine_power braking force. */
|
||||
float m_brake_factor;
|
||||
@ -194,7 +194,7 @@ private:
|
||||
/** Fade out time when the rubber band is removed. */
|
||||
float m_rubber_band_fade_out_time;
|
||||
/**Duration of plunger in face depending on difficulty. */
|
||||
float m_plunger_in_face_duration[3];
|
||||
std::vector<float> m_plunger_in_face_duration;
|
||||
/** Wheel base of the kart. */
|
||||
float m_wheel_base;
|
||||
/** Nitro consumption. */
|
||||
@ -255,7 +255,9 @@ private:
|
||||
/** Angular damping to prevent it from turning too easily. */
|
||||
float m_chassis_angular_damping;
|
||||
|
||||
float m_max_speed[3];
|
||||
/** The maximum speed at each difficulty. */
|
||||
std::vector<float> m_max_speed;
|
||||
|
||||
float m_max_speed_reverse_ratio;
|
||||
|
||||
/** Shift of center of gravity. */
|
||||
|
18
src/main.cpp
18
src/main.cpp
@ -786,18 +786,12 @@ int handleCmdLine(int argc, char **argv)
|
||||
}
|
||||
else if( (!strcmp(argv[i], "--mode") && i+1<argc ))
|
||||
{
|
||||
switch (atoi(argv[i+1]))
|
||||
{
|
||||
case 1:
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
|
||||
break;
|
||||
case 2:
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_MEDIUM);
|
||||
break;
|
||||
case 3:
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
|
||||
break;
|
||||
}
|
||||
int n = atoi(argv[i+1]);
|
||||
if(n<0 || n>RaceManager::DIFFICULTY_LAST)
|
||||
Log::warn("main", "Invalid difficulty '%s' - ignored.\n",
|
||||
argv[i+1]);
|
||||
else
|
||||
race_manager->setDifficulty(RaceManager::Difficulty(n));
|
||||
i++;
|
||||
}
|
||||
else if( (!strcmp(argv[i], "--type") && i+1<argc ))
|
||||
|
@ -56,6 +56,8 @@ RaceManager* race_manager= NULL;
|
||||
*/
|
||||
RaceManager::RaceManager()
|
||||
{
|
||||
// Several code depends on this, e.g. kart_properties
|
||||
assert(DIFFICULTY_FIRST == 0);
|
||||
m_num_karts = UserConfigParams::m_num_karts;
|
||||
m_difficulty = DIFFICULTY_HARD;
|
||||
m_major_mode = MAJOR_MODE_SINGLE;
|
||||
|
@ -230,7 +230,8 @@ public:
|
||||
DIFFICULTY_FIRST = DIFFICULTY_EASY,
|
||||
DIFFICULTY_MEDIUM,
|
||||
DIFFICULTY_HARD,
|
||||
DIFFICULTY_LAST = DIFFICULTY_HARD,
|
||||
DIFFICULTY_BEST,
|
||||
DIFFICULTY_LAST = DIFFICULTY_BEST,
|
||||
DIFFICULTY_COUNT};
|
||||
|
||||
/** Different kart types: A local player, a player connected via network,
|
||||
@ -502,6 +503,7 @@ public:
|
||||
case RaceManager::DIFFICULTY_EASY: return "easy"; break;
|
||||
case RaceManager::DIFFICULTY_MEDIUM: return "medium"; break;
|
||||
case RaceManager::DIFFICULTY_HARD: return "hard"; break;
|
||||
case RaceManager::DIFFICULTY_BEST: return "best"; break;
|
||||
default: assert(false);
|
||||
}
|
||||
return "";
|
||||
|
@ -96,6 +96,11 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
|
||||
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_HARD;
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
|
||||
}
|
||||
else if (selection == "best")
|
||||
{
|
||||
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_BEST;
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_BEST);
|
||||
}
|
||||
}
|
||||
else if (name == "gamemode")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user