Added a 'powerup collect' mode setting to stk config. This controls

what happens if a kart already has a powerup when it hits a bous box:
you can get one more item of the same kind, one new item, or only one
more item if a random item is the same one as the one you currently have
(the latter being the old STK mode). stk_config.xml now sets 'new'
(always get a new randomly chosen item) as mode.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6072 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-09-20 01:15:16 +00:00
parent db012e081f
commit 3db98d8ba7
4 changed files with 70 additions and 12 deletions

View File

@ -26,8 +26,11 @@
</grand-prix>
<!-- Time in follow-the-leader after which karts are removed.
The last values applies for all remaining karts. -->
<follow-the-leader intervals="30 20 10"/>
The last values applies for all remaining karts.
time-per-kart Additional time added to the interval
for each kart in the race. -->
<follow-the-leader intervals="30 20 10"
time-per-kart="1.5" />
<!-- Startup information.
Penalty: Penalty time if a kart accelerates before GO. -->
@ -74,6 +77,13 @@
speed on the terrain. -->
<zipper time="3.5" force="250.0" speed-gain="4.5" max-speed-fraction="2.0"/>
<!-- Powerup collect-mode decides what is collected if a kart has already an
powerup: same: get one more item of the same type.
new: always get a new item.
only-if-same: if the random item is the same one as the
one currently owned, increase the number, otherwise
no more/new item s are given to the kart. -->
<powerup collect-mode="new"/>
<!-- time: How long a switch is being effective.
items for each item list the index of the item it is switched with.
Order: item, banana, big-nitro, small-nitro, bubble-bum -->
@ -128,8 +138,10 @@
<!-- Nitro: power-boost: increase in engine power, i.e. 1=plus 100%
consumption: nitro consumption - heavier characters can be set
to need more nitro than lighter character. -->
<nitro power-boost="3" consumption="1"/>
to need more nitro than lighter character.
small-container: how much energy a small container gives.
big-container: how much energy a big container gives. -->
<nitro power-boost="3" consumption="1" small-container="1" big-container="3"/>
<!-- Skidding: increase: multiplicative increase of skidding factor in each frame.
decrease: multiplicative decrease of skidding factor in each frame.

View File

@ -117,6 +117,7 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_near_ground, "near-ground" );
CHECK_NEG(m_delay_finish_time, "delay-finish-time" );
CHECK_NEG(m_music_credit_time, "music-credit-time" );
CHECK_NEG(m_leader_time_per_kart, "leader time-per-kart" );
CHECK_NEG(m_penalty_time, "penalty-time" );
m_kart_properties.checkAllSet(filename);
@ -140,7 +141,7 @@ void STKConfig::init_defaults()
m_explosion_impulse = m_explosion_impulse_objects =
m_delay_finish_time = m_skid_fadeout_time =
m_near_ground = m_item_switch_time =
m_penalty_time = UNDEFINED;
m_penalty_time = UNDEFINED;
m_bubble_gum_counter = -100;
m_max_karts = -100;
m_gp_order = -100;
@ -152,6 +153,7 @@ void STKConfig::init_defaults()
m_max_track_version = -100;
m_title_music = NULL;
m_enable_networking = true;
m_same_powerup_mode = POWERUP_MODE_ONLY_IF_SAME;
m_score_increase.clear();
m_leader_intervals.clear();
m_switch_items.clear();
@ -210,7 +212,10 @@ void STKConfig::getAllData(const XMLNode * root)
}
if(const XMLNode *leader_node= root->getNode("follow-the-leader"))
leader_node->get("intervals", &m_leader_intervals);
{
leader_node->get("intervals", &m_leader_intervals );
leader_node->get("time-per-kart", &m_leader_time_per_kart);
}
if(const XMLNode *startup_node= root->getNode("startup"))
{
@ -273,6 +278,23 @@ void STKConfig::getAllData(const XMLNode * root)
zipper_node->get("max-speed-fraction", &m_zipper_max_speed_fraction);
}
if(const XMLNode *powerup_node= root->getNode("powerup"))
{
std::string s;
powerup_node->get("collect-mode", &s);
if(s=="same")
m_same_powerup_mode = POWERUP_MODE_SAME;
else if(s=="new")
m_same_powerup_mode = POWERUP_MODE_NEW;
else if(s=="only-if-same")
m_same_powerup_mode = POWERUP_MODE_ONLY_IF_SAME;
else
{
printf("Invalid item mode '%s' - ignored.\n",
s.c_str());
}
}
if(const XMLNode *switch_node= root->getNode("switch"))
{
switch_node->get("items", &m_switch_items );

View File

@ -42,6 +42,16 @@ class STKConfig : public NoCopy
protected:
KartProperties m_kart_properties; /**< Default kart properties. */
public:
/** What to do if a kart already has a powerup when it hits a bonus box:
* - NEW: give it a random new bonx box.
* - SAME: give it one more item of the type it currently has.
* - ONLY_IF_SAME: only give it one more item if the randomly chosen item
* has the same type as the currently held item. */
enum {POWERUP_MODE_NEW,
POWERUP_MODE_SAME,
POWERUP_MODE_ONLY_IF_SAME}
m_same_powerup_mode;
static float UNDEFINED;
float m_anvil_weight; /**<Additional kart weight if anvil is
attached. */
@ -94,6 +104,8 @@ public:
std::vector<float>
m_leader_intervals; /**<Interval in follow the leader till
last kart is reomved. */
float m_leader_time_per_kart; /**< Additional time to each leader
interval for each additional kart. */
std::vector<int> m_switch_items; /**< How to switch items. */
/** The number of points a kart on position X has more than the
* next kart. From this the actual number of points for each

View File

@ -348,15 +348,27 @@ void Powerup::hitBonusBox(int n, const Item &item, int add_info)
PowerupManager::PowerupType new_powerup =
powerup_manager->getRandomPowerup(position);
if(m_type==PowerupManager::POWERUP_NOTHING)
// Always add a new powerup in ITEM_MODE_NEW (or if the kart
// doesn't have a powerup atm).
if(m_type == PowerupManager::POWERUP_NOTHING ||
stk_config->m_same_powerup_mode == STKConfig::POWERUP_MODE_NEW )
{
set( new_powerup, n );
}
else if(new_powerup==m_type)
else
{
m_number+=n;
if(m_number > MAX_POWERUPS)
m_number = MAX_POWERUPS;
// If powerup mode is 'SAME', or it's ONLY_IF_SAME and it is the
// same powerup, increase the number of items.
if(stk_config->m_same_powerup_mode == STKConfig::POWERUP_MODE_SAME ||
new_powerup==m_type)
{
m_number+=n;
if(m_number > MAX_POWERUPS)
m_number = MAX_POWERUPS;
}
}
// Ignore new powerup if it is different from the current one
// Ignore new powerup if it is different from the current one and not
// POWERUP_MODE_SAME
} // hitBonusBox