]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added random start weapons.
authorLyberta <lyberta@lyberta.net>
Wed, 16 Aug 2017 01:12:53 +0000 (04:12 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 16 Aug 2017 01:12:53 +0000 (04:12 +0300)
12 files changed:
balance-mario.cfg
balance-nexuiz25.cfg
balance-overkill.cfg
balance-samual.cfg
balance-xdf.cfg
balance-xonotic.cfg
balance-xpm.cfg
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
qcsrc/server/client.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh

index 42cf31196553096d8e7a3e6df76db560f99cdc29..eabbff57773e40081b8130a5cad68e14e03588bc 100644 (file)
@@ -9,6 +9,13 @@ set g_start_ammo_rockets 0
 set g_start_ammo_cells 0
 set g_start_ammo_plasma 0
 set g_start_ammo_fuel 0
+set g_num_random_start_weapons 0
+set g_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator"
+set g_random_start_shells 15
+set g_random_start_bullets 80
+set g_random_start_rockets 40
+set g_random_start_cells 30
+set g_random_start_plasma 30
 set g_warmup_start_health 100 "starting values when being in warmup-stage"
 set g_warmup_start_armor 100 "starting values when being in warmup-stage"
 set g_warmup_start_ammo_shells 30 "starting values when being in warmup-stage"
index 4967fa7e47936208ca64c9e719e5e41fa373b968..b31df84a6a3bd54d3aa7e717f1252025dac5e5f3 100644 (file)
@@ -9,6 +9,13 @@ set g_start_ammo_rockets 0
 set g_start_ammo_cells 0
 set g_start_ammo_plasma 0
 set g_start_ammo_fuel 0
+set g_num_random_start_weapons 0
+set g_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator"
+set g_random_start_shells 15
+set g_random_start_bullets 80
+set g_random_start_rockets 15
+set g_random_start_cells 25
+set g_random_start_plasma 25
 set g_warmup_start_health 250 "starting values when being in warmup-stage"
 set g_warmup_start_armor 100 "starting values when being in warmup-stage"
 set g_warmup_start_ammo_shells 50 "starting values when being in warmup-stage"
index fc99616f94eaff821e575442fcdfca74d0de6052..eb9fe4fd43a4f6678481889af262ba84a4dcaca2 100644 (file)
@@ -9,6 +9,13 @@ set g_start_ammo_rockets 0
 set g_start_ammo_cells 0
 set g_start_ammo_plasma 0
 set g_start_ammo_fuel 0
+set g_num_random_start_weapons 0
+set g_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator"
+set g_random_start_shells 15
+set g_random_start_bullets 80
+set g_random_start_rockets 40
+set g_random_start_cells 30
+set g_random_start_plasma 30
 set g_warmup_start_health 100 "starting values when being in warmup-stage"
 set g_warmup_start_armor 100 "starting values when being in warmup-stage"
 set g_warmup_start_ammo_shells 30 "starting values when being in warmup-stage"
index 4357eff7646aad75e967bfbd9de0f32b697b104b..f1d81cab1d06d42ec31bae9e7dfbe97b229ff029 100644 (file)
@@ -9,6 +9,13 @@ set g_start_ammo_rockets 0
 set g_start_ammo_cells 0
 set g_start_ammo_plasma 0
 set g_start_ammo_fuel 0
+set g_num_random_start_weapons 0
+set g_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator"
+set g_random_start_shells 15
+set g_random_start_bullets 80
+set g_random_start_rockets 40
+set g_random_start_cells 30
+set g_random_start_plasma 30
 set g_warmup_start_health 100 "starting values when being in warmup-stage"
 set g_warmup_start_armor 100 "starting values when being in warmup-stage"
 set g_warmup_start_ammo_shells 30 "starting values when being in warmup-stage"
index a7d6b43740de047372c391bb438c70919ffd87b4..87643b8b2e08e08d3d86d97349b99d9c14e04bae 100644 (file)
@@ -9,6 +9,13 @@ set g_start_ammo_rockets 0
 set g_start_ammo_cells 0
 set g_start_ammo_plasma 0
 set g_start_ammo_fuel 0
+set g_num_random_start_weapons 0
+set g_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator"
+set g_random_start_shells 15
+set g_random_start_bullets 80
+set g_random_start_rockets 40
+set g_random_start_cells 30
+set g_random_start_plasma 30
 set g_warmup_start_health 100 "starting values when being in warmup-stage"
 set g_warmup_start_armor 100 "starting values when being in warmup-stage"
 set g_warmup_start_ammo_shells 30 "starting values when being in warmup-stage"
index 5bd1536feab823df7b40dbd50df1133d194222ef..02b928c90b661494f3481f644d76a712046bb1bc 100644 (file)
@@ -9,6 +9,13 @@ set g_start_ammo_rockets 0
 set g_start_ammo_cells 0
 set g_start_ammo_plasma 0
 set g_start_ammo_fuel 0
+set g_num_random_start_weapons 0
+set g_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator"
+set g_random_start_shells 15
+set g_random_start_bullets 80
+set g_random_start_rockets 40
+set g_random_start_cells 30
+set g_random_start_plasma 30
 set g_warmup_start_health 100 "starting values when being in warmup-stage"
 set g_warmup_start_armor 100 "starting values when being in warmup-stage"
 set g_warmup_start_ammo_shells 30 "starting values when being in warmup-stage"
index 5c14aa36206256e19c240ecf105815a8c7fc8e41..9731f7ee0a6058596d960b63f43ce356fe581484 100644 (file)
@@ -9,6 +9,13 @@ set g_start_ammo_rockets 0
 set g_start_ammo_cells 0
 set g_start_ammo_plasma 0
 set g_start_ammo_fuel 0
+set g_num_random_start_weapons 0
+set g_random_start_weapons "machinegun mortar electro crylink vortex hagar devastator"
+set g_random_start_shells 15
+set g_random_start_bullets 80
+set g_random_start_rockets 40
+set g_random_start_cells 30
+set g_random_start_plasma 30
 set g_warmup_start_health 100 "starting values when being in warmup-stage"
 set g_warmup_start_armor 100 "starting values when being in warmup-stage"
 set g_warmup_start_ammo_shells 30 "starting values when being in warmup-stage"
index 61bc7dc5785a945f1729e63d1bff192ff3e38eab..4c0125afb687c923ac92e1fcd068232e03e19482 100644 (file)
@@ -711,6 +711,87 @@ void GivePlayerAmmo(entity player, .float ammotype, float amount)
        player.(ammotype) = min(player.(ammotype) + amount, maxvalue);
 }
 
+void GivePlayerRandomWeapons(entity player, int num_weapons,
+       string weapon_names, float shells, float bullets, float rockets,
+       float cells, float plasma)
+{
+       if (num_weapons == 0)
+       {
+               return;
+       }
+       int num_potential_weapons = tokenize_console(weapon_names);
+       for (int i = 0; i < num_weapons; ++i)
+       {
+               RandomSelection_Init();
+               for (int j = 0; j < num_potential_weapons; ++j)
+               {
+                       string weapon = argv(j);
+                       FOREACH(Weapons, it != WEP_Null,
+                       {
+                               // Finding a weapon which player doesn't have.
+                               if (!(player.weapons & it.m_wepset) && (it.netname == weapon))
+                               {
+                                       RandomSelection_AddEnt(it, 1, 1);
+                                       break;
+                               }
+                       });
+               }
+               if (RandomSelection_chosen_ent == NULL)
+               {
+                       return;
+               }
+               player.weapons |= RandomSelection_chosen_ent.m_wepset;
+               switch (RandomSelection_chosen_ent.ammo_field)
+               {
+                       case (ammo_shells):
+                       {
+                               if (player.ammo_shells != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_shells, shells);
+                               break;
+                       }
+                       case (ammo_nails):
+                       {
+                               if (player.ammo_nails != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_nails, bullets);
+                               break;
+                       }
+                       case (ammo_rockets):
+                       {
+                               if (player.ammo_rockets != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_rockets, rockets);
+                               break;
+                       }
+                       case (ammo_cells):
+                       {
+                               if (player.ammo_cells != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_cells, cells);
+                               break;
+                       }
+                       case (ammo_plasma):
+                       {
+                               if (player.ammo_plasma != 0)
+                               {
+                                       break;
+                               }
+                               GivePlayerAmmo(player, ammo_plasma, plasma);
+                               break;
+                       }
+               }
+       }
+}
+
 float Item_GiveAmmoTo(entity item, entity player, .float ammotype, float ammomax, float mode)
 {
        if (!item.(ammotype))
index 331d3ac8c3edf342571aae9204e14cc7b5ed932c..1fc84a0320d258481b350c3829908ee681183f3a 100644 (file)
@@ -105,6 +105,19 @@ void GivePlayerArmor(entity player, float amount);
 /// \return No return.
 void GivePlayerAmmo(entity player, .float ammotype, float amount);
 
+/// \brief Give several random weapons and ammo to the player.
+/// \param[in,out] player Player to give weapons to.
+/// \param[in] num_weapons Number of weapons to give.
+/// \param[in] weapon_names Names of weapons to give separated by spaces.
+/// \param[in] shells Amount of shells to give with shell-based weapon.
+/// \param[in] bullets Amount of bullets to give with bullet-based weapon.
+/// \param[in] rockets Amount of rockets to give with rocket-based weapon.
+/// \param[in] cells Amount of cells to give with cell-based weapon.
+/// \param[in] cells Amount of plasma to give with plasma-based weapon.
+void GivePlayerRandomWeapons(entity player, int num_weapons,
+       string weapon_names, float shells, float bullets, float rockets,
+       float cells, float plasma);
+
 float ITEM_MODE_NONE = 0;
 float ITEM_MODE_HEALTH = 1;
 float ITEM_MODE_ARMOR = 2;
index b0eb75ae41bd1c1954a3bdad671924a5133b947c..43fd0be913da0d1a49efec3a54ece028ca430fdf 100644 (file)
@@ -546,6 +546,10 @@ void PutPlayerInServer(entity this)
                this.health = start_health;
                this.armorvalue = start_armorvalue;
                this.weapons = start_weapons;
+               GivePlayerRandomWeapons(this, num_random_start_weapons,
+                       cvar_string("g_random_start_weapons"), random_start_shells,
+                       random_start_bullets, random_start_rockets, random_start_cells,
+                       random_start_plasma);
        }
        SetSpectatee_status(this, 0);
 
index 78d290c81131bce368b9aa3711f32b9fc54b9516..1abcf850c46e44219a90e223394e023adbf0c583 100644 (file)
@@ -643,6 +643,12 @@ void readplayerstartcvars()
                start_ammo_cells = cvar("g_start_ammo_cells");
                start_ammo_plasma = cvar("g_start_ammo_plasma");
                start_ammo_fuel = cvar("g_start_ammo_fuel");
+               num_random_start_weapons = cvar("g_num_random_start_weapons");
+               random_start_shells = cvar("g_random_start_shells");
+               random_start_bullets = cvar("g_random_start_bullets");
+               random_start_rockets = cvar("g_random_start_rockets");
+               random_start_cells = cvar("g_random_start_cells");
+               random_start_plasma = cvar("g_random_start_plasma");
        }
 
        if (warmup_stage)
@@ -711,6 +717,11 @@ void readplayerstartcvars()
        start_ammo_cells = max(0, start_ammo_cells);
        start_ammo_plasma = max(0, start_ammo_plasma);
        start_ammo_fuel = max(0, start_ammo_fuel);
+       random_start_shells = max(0, random_start_shells);
+       random_start_bullets = max(0, random_start_bullets);
+       random_start_rockets = max(0, random_start_rockets);
+       random_start_cells = max(0, random_start_cells);
+       random_start_plasma = max(0, random_start_plasma);
 
        warmup_start_ammo_shells = max(0, warmup_start_ammo_shells);
        warmup_start_ammo_nails = max(0, warmup_start_ammo_nails);
index 1c01a573797713c4fe39345da3f895e60717aad9..23a5778e0c2ef2a65b427f0d72413bb725a5568f 100644 (file)
@@ -188,6 +188,12 @@ float start_ammo_rockets;
 float start_ammo_cells;
 float start_ammo_plasma;
 float start_ammo_fuel;
+int num_random_start_weapons;
+float random_start_shells;
+float random_start_bullets;
+float random_start_rockets;
+float random_start_cells;
+float random_start_plasma;
 float start_health;
 float start_armorvalue;
 WepSet warmup_start_weapons;