]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Lyberta/URS3' into Lyberta/RandomStartWeapons
authorLyberta <lyberta@lyberta.net>
Sun, 10 Sep 2017 23:38:38 +0000 (02:38 +0300)
committerLyberta <lyberta@lyberta.net>
Sun, 10 Sep 2017 23:38:38 +0000 (02:38 +0300)
1  2 
qcsrc/common/t_items.qc
qcsrc/server/miscfunctions.qc

diff --combined qcsrc/common/t_items.qc
index 92c80d7111ab6c0683ef9de37a7d8e56621fc534,3e9fb141211cd3904f2416ad727d8af84381ff03..11d0911ab8d9497e05e1d703d59f1f03b1f32176
@@@ -682,75 -682,6 +682,75 @@@ void Item_ScheduleInitialRespawn(entit
        Item_ScheduleRespawnIn(e, max(0, game_starttime - time) + ((e.respawntimestart) ? e.respawntimestart : ITEM_RESPAWNTIME_INITIAL(e)));
  }
  
 +void GiveRandomWeapons(entity receiver, 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 (!(receiver.weapons & it.m_wepset) && (it.netname == weapon))
 +                              {
 +                                      RandomSelection_AddEnt(it, 1, 1);
 +                                      break;
 +                              }
 +                      });
 +              }
 +              if (RandomSelection_chosen_ent == NULL)
 +              {
 +                      return;
 +              }
 +              receiver.weapons |= RandomSelection_chosen_ent.m_wepset;
 +              if (RandomSelection_chosen_ent.ammo_type == RESOURCE_NONE)
 +              {
 +                      continue;
 +              }
 +              if (GetResourceAmount(receiver,
 +                      RandomSelection_chosen_ent.ammo_type) != 0)
 +              {
 +                      continue;
 +              }
 +              switch (RandomSelection_chosen_ent.ammo_type)
 +              {
 +                      case (RESOURCE_SHELLS):
 +                      {
 +                              GiveResource(receiver, RESOURCE_SHELLS, shells);
 +                              break;
 +                      }
 +                      case (RESOURCE_BULLETS):
 +                      {
 +                              GiveResource(receiver, RESOURCE_BULLETS, bullets);
 +                              break;
 +                      }
 +                      case (RESOURCE_ROCKETS):
 +                      {
 +                              GiveResource(receiver, RESOURCE_ROCKETS, rockets);
 +                              break;
 +                      }
 +                      case (RESOURCE_CELLS):
 +                      {
 +                              GiveResource(receiver, RESOURCE_CELLS, cells);
 +                              break;
 +                      }
 +                      case (RESOURCE_PLASMA):
 +                      {
 +                              GiveResource(receiver, RESOURCE_PLASMA, plasma);
 +                              break;
 +                      }
 +              }
 +      }
 +}
 +
  float Item_GiveAmmoTo(entity item, entity player, int resource_type, float ammomax)
  {
        float amount = GetResourceAmount(item, resource_type);
@@@ -970,6 -901,7 +970,7 @@@ LABEL(pickup
                                if(it.itemdef) // is a registered item
                                {
                                        Item_Show(it, -1);
+                                       it.scheduledrespawntime = 0;
                                        RandomSelection_AddEnt(it, it.cnt, 0);
                                }
                        });
index 48689cf0a94b63a48eb665d193f9a9984f3572a1,479e608b73697b25845d9c522e1fa05e4948c7af..78652f6f0cc0e75438dc387eb34b169437f12d71
@@@ -643,12 -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");
 +              random_start_weapons_count = cvar("g_random_start_weapons_count");
 +              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)
        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);
@@@ -949,8 -938,8 +949,8 @@@ bool EliminatedPlayers_SendEntity(entit
        serialize(byte, out, sendflags);
        if (sendflags & 1) {
                for (int i = 1; i <= maxclients; i += 8) {
-                   int f = 0;
-             entity e = edict_num(i);
+                       int f = 0;
+                       entity e = edict_num(i);
                        for (int b = 0; b < 8; ++b, e = nextent(e)) {
                                if (eliminatedPlayers.isEliminated(e)) {
                                        f |= BIT(b);