}
}
+// GunGame
+
+/// \brief Duration of transition between the weapons pictures.
+const float gg_weapon_transition_duration = 0.5;
+
+int gg_current_weapon; ///< Current weapon.
+string gg_current_weapon_picture; ///< Current weapon picture.
+int gg_previous_weapon; ///< Previous weapon.
+string gg_previous_weapon_picture; ///< Previous weapon picture.
+float gg_weapon_change_time; ///< Time when the weapon changed.
+
+string GG_GetWeaponPicture(int weapon)
+{
+ FOREACH(Weapons, it != WEP_Null,
+ {
+ if (it.m_id == weapon)
+ {
+ return it.model2;
+ }
+ });
+ return "";
+}
+
void HUD_Mod_GG(vector pos, vector mySize)
{
- mod_active = 1; // required in each mod function that always shows something
+ // Required in each mod function that always shows something.
+ mod_active = 1;
int stat_weapon = STAT(GUNGAME_LEADING_WEAPON);
+ if (stat_weapon != gg_current_weapon)
+ {
+ // New leading weapon.
+ gg_previous_weapon = gg_current_weapon;
+ gg_previous_weapon_picture = gg_current_weapon_picture;
+ gg_current_weapon = stat_weapon;
+ gg_current_weapon_picture = GG_GetWeaponPicture(gg_current_weapon);
+ gg_weapon_change_time = time;
+ }
vector pic_pos, pic_size;
if (mySize.x > mySize.y)
{
pic_pos = pos + eY * 0.25 * mySize.y;
pic_size = vec2(mySize.x, 0.5 * mySize.y);
}
- string weapon_pic = string_null;
- FOREACH(Weapons, it != WEP_Null,
+ float weapon_change_elapsed_time = time - gg_weapon_change_time;
+ // Weapon transition phase. 0 at the start of transition. 1 at the end.
+ float phase = bound(0, weapon_change_elapsed_time /
+ gg_weapon_transition_duration, 1);
+
+ // Draw current weapon picture. Fading in if phase is less than 1.
+ if (gg_current_weapon_picture)
{
- if (it.m_id == stat_weapon)
- {
- weapon_pic = it.model2;
- break;
- }
- });
- if (!weapon_pic)
+ drawpic_aspect_skin(pic_pos, gg_current_weapon_picture, pic_size,
+ '1 1 1', phase, DRAWFLAG_NORMAL);
+ }
+ // Draw previous weapon picture on top of current one so it gives a nice
+ // fade out effect.
+ if ((phase < 1) && gg_previous_weapon_picture)
{
- return;
+ drawpic_aspect_skin_expanding(pic_pos, gg_previous_weapon_picture,
+ pic_size, '1 1 1', 1 - phase, DRAWFLAG_NORMAL, phase);
}
- drawpic_aspect_skin(pic_pos, weapon_pic, pic_size, '1 1 1', 1,
- DRAWFLAG_NORMAL);
}
void HUD_ModIcons_SetFunc()
//============================ Constants ======================================
-const string GUNGAME_WEAPONS = "g_gg_weapons";
+const string GUNGAME_WEAPONS_CVAR = "g_gg_weapons";
//======================= Global variables ====================================
//====================== Forward declarations =================================
/// \brief Resets the state to initial one.
-/// \return No return.
void GunGame_Reset();
/// \brief Returns the weapon that corresponds to the given level.
entity GunGame_GetWeapon(int level);
/// \brief Updates stats of all players.
-/// \return No return.
void GunGame_UpdateStats();
//========================= Free functions ====================================
void GunGame_Reset()
{
- if (gungame_weapons)
- {
- strunzone(gungame_weapons);
- }
- gungame_weapons = strzone(cvar_string(GUNGAME_WEAPONS));
+ strcpy(gungame_weapons, cvar_string(GUNGAME_WEAPONS_CVAR));
gungame_max_level = tokenize_console(gungame_weapons) *
autocvar_g_gg_kills_per_weapon;
if (gungame_max_level == 0)
{
- error("GunGame: Invalid weapon configuration.");
+ LOG_FATAL("GunGame: Invalid weapon configuration.");
}
GameRules_limit_score(gungame_max_level);
gungame_leading_player = NULL;
return it;
}
});
- error("GunGame_GetWeapon: Invalid level or weapon name");
+ LOG_FATAL("GunGame_GetWeapon: Invalid level or weapon name");
return NULL;
}
}
/// \brief Updates the information about the leading player.
-/// \return No return.
void GunGame_UpdateLeadingPlayer()
{
entity previous_leader = gungame_leading_player;
/// \brief Gives the player a weapon that corresponds to their level.
/// \param[in,out] player Player to give weapon to.
-/// \return No return.
void GunGame_GivePlayerWeapon(entity player)
{
int level = GunGame_GetPlayerLevel(player);
}
/// \brief Hook that is called when an item is about to spawn.
-MUTATOR_HOOKFUNCTION(gg, FilterItem)
+MUTATOR_HOOKFUNCTION(gg, FilterItemDefinition)
{
- //PrintToChatAll("FilterItem");
+ //PrintToChatAll("FilterItemDefinition");
entity item = M_ARGV(0, entity);
- if (item.itemdef.instanceOfWeaponPickup)
+ if (item.instanceOfAmmo)
+ {
+ // Block ammo from spawning.
+ return true;
+ }
+ if (item.instanceOfWeaponPickup)
{
// Block weapons from spawning.
return true;
--- /dev/null
+// Random items mutator config for GunGame gamemode
+
+// Map items
+
+set g_random_items_health_probability 10 "Probability of random health items spawning in the map."
+set g_random_items_armor_probability 10 "Probability of random armor items spawning in the map."
+set g_random_items_resource_probability 0 "Probability of random resource items spawning in the map."
+set g_random_items_weapon_probability 0 "Probability of random weapons spawning in the map."
+set g_random_items_powerup_probability 1 "Probability of random powerups spawning in the map."
+set g_random_items_item_health_small_probability 10 "Probability of random small health spawning in the map."
+set g_random_items_item_health_medium_probability 4 "Probability of random medium health spawning in the map."
+set g_random_items_item_health_big_probability 2 "Probability of random big health spawning in the map."
+set g_random_items_item_health_mega_probability 1 "Probability of random mega health spawning in the map."
+set g_random_items_item_armor_small_probability 10 "Probability of random small armor spawning in the map."
+set g_random_items_item_armor_medium_probability 4 "Probability of random medium armor spawning in the map."
+set g_random_items_item_armor_big_probability 2 "Probability of random big armor spawning in the map."
+set g_random_items_item_armor_mega_probability 1 "Probability of random mega armor spawning in the map."
+set g_random_items_item_strength_probability 1 "Probability of random strength spawning in the map."
+set g_random_items_item_shield_probability 1 "Probability of random shield spawning in the map."
+set g_random_items_item_fuel_regen_probability 0 "Probability of random fuel regeneration spawning in the map."
+set g_random_items_item_jetpack_probability 0 "Probability of random jetpack spawning in the map."
+
+// Loot
+
+set g_random_loot_min 0 "Minimum amount of loot items."
+set g_random_loot_max 4 "Maximum amount of loot items."
+set g_random_loot_time 10 "Amount of time the loot will stay in seconds."
+set g_random_loot_spread 200 "How far can loot be thrown."
+set g_random_loot_health_probability 8 "Probability of random health items spawning as loot."
+set g_random_loot_armor_probability 8 "Probability of random armor items spawning as loot."
+set g_random_loot_resource_probability 0 "Probability of random ammo items spawning as loot."
+set g_random_loot_weapon_probability 0 "Probability of random weapons spawning as loot."
+set g_random_loot_powerup_probability 1 "Probability of random powerups spawning as loot."
+set g_random_loot_item_health_small_probability 4 "Probability of random small health spawning as loot."
+set g_random_loot_item_health_medium_probability 3 "Probability of random medium health spawning as loot."
+set g_random_loot_item_health_big_probability 2 "Probability of random big health spawning as loot."
+set g_random_loot_item_health_mega_probability 1 "Probability of random mega health spawning as loot."
+set g_random_loot_item_armor_small_probability 4 "Probability of random small armor spawning as loot."
+set g_random_loot_item_armor_medium_probability 3 "Probability of random medium armor spawning as loot."
+set g_random_loot_item_armor_big_probability 2 "Probability of random big armor spawning as loot."
+set g_random_loot_item_armor_mega_probability 1 "Probability of random mega armor spawning as loot."
+set g_random_loot_item_strength_probability 1 "Probability of random strength spawning as loot."
+set g_random_loot_item_shield_probability 1 "Probability of random shield spawning as loot."
+set g_random_loot_item_fuel_regen_probability 0 "Probability of random fuel regeneration spawning as loot."
+set g_random_loot_item_jetpack_probability 0 "Probability of random jetpack spawning as loot."