ban cores by GameType?

Defender

Member
I have a bunch of cores in my OP mod, I want to ban if not current game ctf game type..
In tribes2, this would work, but not here.. So I need an easy way to do this, any ideas Devs?



Code:
%type = fileBase(%file); // get the name of the script
  if(%type !$= CtfGame){ // ZOD: Add this if statement
      bottomPrintClient(%player.client, "Your Core is only enabled for CTF game types.", 3000);
      return;
  }
 

RockeyRex

Legions Developer
Uhh... Game type based banning. Yes. How would you like to do it? From gametype or from the core?


First off change loadouts.cs from line 100 forward to this

Code:
function serverCmdSetupLoadout( %client, %armor, %weapons, %nade, %core )
{  
   %armorObj = %armor;
   if (isObject(%armorObj) && !itemBanCheck(%armorObj))
   {
     %maxWeaponInventory = %armorObj.maxWeaponInventory;
   }
   else
   {
     messageClient(%client, 'InvHudListInvalid', "InvHudListArmor", %armorObj);
     return;
   }
  
   %weaponcount = 0;
   for (%i = 0; %i < %maxWeaponInventory; %i++)
   {
     %wep = getField(%weapons, %i);
     if (%armorObj.maxInventory[%wep] && !itemBanCheck(%wep))
     {
       %weapon[%weaponcount] = %wep;
       %weaponcount++;
     }
     else
       messageClient(%client, 'InvHudListInvalid', "InvHudListWeapon", %i);
   }
  
   if (%weapon[0] $= "")
     return;
  
   %loadoutname = "CustomLoadout" @ %client;
   if (!isObject(%loadoutname))
   {  
     new ScriptObject(%loadoutname)
     {
       class = CustomLoadout;
       name = "CustomLoadout";
     };
   }
  
   %loadoutname.dataBlock = %armorObj;
   %loadoutname.weapon[0] = %weapon[0];
   %loadoutname.weapon[1] = %weapon[1];
   %loadoutname.weapon[2] = %weapon[2];
   %loadoutname.weaponCount = %weaponcount;

   if ((%nade.class !$= "Grenade") || %armorObj.maxInventory[%nade] == 0 || itemBanCheck(%nade))
   {
     messageClient(%client, 'InvHudListInvalid', "InvHudListOffhand", %nade);
     %nade = "";
   }
   %loadoutname.grenade = %nade;

   if ((%core.class !$= "PlayerCore") || %armorObj.maxInventory[%core] == 0 || itemBanCheck(%core))
   {
     messageClient(%client, 'InvHudListInvalid', "InvHudListCore", %core);
     %core = "";
   }
   %loadoutname.core = %core;

   %client.selectedLoadout = %loadoutname;
}

function itemBanCheck(%item)
{
  if (MissionItemBans.ban[%item] || Game.itemBan[%item] || %item.gametypeBan[Game.shortname])
  return true;
}


Now you can do things either way.

Gametype:
%this.itemBan[datablock] = 1; to setup function of the gametype (ex. live/server/game/gameTypes/ctf.cs:CtfGame::setup( %this ))

OR

Straight from ANY item datablock. Example for overdrive core:
live/server/game/dataBlocks/cores/cores.cs.
Add
gametypeBan["CTF"] = 1;
under datablock ItemData(OverdriveCore)


I'll try to sneak that loadouts.cs code change to an update at some point. It's a good enough feature to have I suppose.
 

Defender

Member
This helps a lot,
Thanks!!

Since we are adding some good ban stuff here...
I would love to add some armor ban options, for gametypes,
like for death-match, have a light only armors option in the server admin menu...
 
Last edited:

Fixious

Test Lead
This could be used to create a 'Classic' Legions mode. Overdrive only, no nades, etc. Unfortunately it isn't working for me. I changed loadouts.cs like you said, and tried banning from both locations (ctf.cs and cores.cs). I was still able to select the cores. Even modifying the mission file doesn't work, though Engineer can still be banned.
 
Last edited:

The_Horny_Rat

New Member
In my server admin mod, I added admin option that let the admin change the server to a classic mod type.. You could just add the $Host::ClassicMod =1; to the top of each map, and have it set back to $Host::ClassicMod =0; on mission change.. then if the new map has it set to 1, it will work again...

this goes in each cores item datablock...

Code:
datablock ItemData(WarpCore)
{
   class = PlayerCore;
   longName = "Warp";
   shortName = "Warp";
   engineId = 2;
   image = WarpCoreImage;
   cooldown = 6600; // Cooldown duration.
   warpDamage = 15; // How much damage to apply for warp core use
   warpHistoryTime = 3500; // How far back in time we should go
   IODDisableTime = 3500;
   scarTime = 4000; // How long the warp scar stays open
   scarInheritVelocity = true; // If player should inherit original warping player's velocity
   timeoutFromFlagThrow = 4000; // If player just threw flag, how long before they can warp again
   Description = "Warp back 3 seconds in time to whatever your position/velocity was at that moment. Creates a scar that can be followed through for 4 seconds";

// Only ban these if classic mod, enabled.
gametypeBan["CTF"] = 1;
gametypeBan["Rabbit"] = 1;
gametypeBan["TDM"] = 1;
gametypeBan["TeamRabbit"] = 1;
gametypeBan["Hunters"] = 1;
gametypeBan["Challenge"] = 1;
};








This part in the loadouts.cs

Code:
//-----------------------------------------------------------------------------------------------------------
// Updated with gametype ban for itens, cores..
// code changes by RockeyRex, Legions Developer!
//-----------------------------------------------------------------------------------------------------------
function serverCmdSetupLoadout( %client, %armor, %weapons, %nade, %core )
{
   %armorObj = %armor;
   if (isObject(%armorObj) && !itemBanCheck(%armorObj)) // new Update, by RockeyRex, Legions Developer
   //if (isObject(%armorObj) && !MissionItemBans.ban[%armorObj])
   {
     %maxWeaponInventory = %armorObj.maxWeaponInventory;
   }
   else
   {
     messageClient(%client, 'InvHudListInvalid', "InvHudListArmor", %armorObj);
     return;
   }

   %weaponcount = 0;
   for (%i = 0; %i < %maxWeaponInventory; %i++)
   {
     %wep = getField(%weapons, %i);
     if (%armorObj.maxInventory[%wep] && !itemBanCheck(%wep)) // new Update, by RockeyRex, Legions Developer
     //if (%armorObj.maxInventory[%wep] && !MissionItemBans.ban[%wep])
     {
       %weapon[%weaponcount] = %wep;
       %weaponcount++;
     }
     else
       messageClient(%client, 'InvHudListInvalid', "InvHudListWeapon", %i);
   }

   if (%weapon[0] $= "")
     return;

   %loadoutname = "CustomLoadout" @ %client;
   if (!isObject(%loadoutname))
   {
     new ScriptObject(%loadoutname)
     {
       class = CustomLoadout;
       name = "CustomLoadout";
     };
   }

   %loadoutname.dataBlock = %armorObj;
   %loadoutname.weapon[0] = %weapon[0];
   %loadoutname.weapon[1] = %weapon[1];
   %loadoutname.weapon[2] = %weapon[2];
   %loadoutname.weaponCount = %weaponcount;

   if ((%nade.class !$= "Grenade") || %armorObj.maxInventory[%nade] == 0 || itemBanCheck(%nade)) // new Update, by RockeyRex, Legions Developer
   //if ((%nade.class !$= "Grenade") || (%armorObj.maxInventory[%nade] == 0) || MissionItemBans.ban[%nade])
   {
     messageClient(%client, 'InvHudListInvalid', "InvHudListOffhand", %nade);
     %nade = "";
   }
   %loadoutname.grenade = %nade;

   if ((%core.class !$= "PlayerCore") || %armorObj.maxInventory[%core] == 0 || itemBanCheck(%core)) // new Update, by RockeyRex, Legions Developer
   //if ((%core.class !$= "PlayerCore") || (%armorObj.maxInventory[%core] == 0) || MissionItemBans.ban[%core])
   {
     messageClient(%client, 'InvHudListInvalid', "InvHudListCore", %core);
     %core = "";
   }
   %loadoutname.core = %core;

   %client.selectedLoadout = %loadoutname;
}

//$Host::ClassicMod =0;
//------------------------------------------------------------------------------------------------
//by RockeyRex, Legions Developer
//------------------------------------------------------------------------------------------------
function itemBanCheck(%item) // new ban function, new Update
{
if($Host::ClassicMod)
itemBan2(%item);
else
itemBan1(%item);
}

function itemBan1(%item) // new ban function, new Update
{
  if (MissionItemBans.ban[%item] || Game.itemBan[%item])
  return true;
}

function itemBan2(%item) // new ban function, new Update
{
if (MissionItemBans.ban[%item] || Game.itemBan[%item] || %item.gametypeBan[Game.shortname])
  return true;
}
 

Fixious

Test Lead
This could be used to create a 'Classic' Legions mode. Overdrive only, no nades, etc. Unfortunately it isn't working for me. I changed loadouts.cs like you said, and tried banning from both locations (ctf.cs and cores.cs). I was still able to select the cores. Even modifying the mission file doesn't work, though Engineer can still be banned.

A far easier method is to simply modify the banlistdata.cs file. That way it affects all missions instead of needing to modify each and every mission file. This was likely done due to enabling Engineer on certain maps, but now that Engy is dead I don't really see why we can't use the banlistdata.cs file so it affects ALL maps. I just tested it out and it seems to work fine. Creating a 'classic' server is extremely easy now.

Code:
   new SimGroup(MissionItemBans) {
      canSaveDynamicFields = "1";
      Enabled = "1";
         banEngineerCore = "1";
         banWarpCore = "1";
         banDodgeCore = "1";
         banShieldCore = "1";
         banBoostCore = "1";
         banRegenerationCore = "1";
         banBlaster = "1";
         banPlasma = "1";
         banSkyboltLauncher = "1";
         banBoostGrenade = "1";
         banEmpGrenade = "1";
         banFragGrenade = "1";
   };

The only thing that needs to be done is removing the existing MissionItemBans code from every mission file, which is currently only there to disable Engineer. The banlist file also should be set to read-only, as it get erased every time you close Legions.
 
Top