Deployables List Author: Drone1k Deploybles Menu List Tutorial: This Tutorial will guide you through adding code so you can have a Deployables Menu list. This is very helpful since Sierra decided to make the hud list with very limited space to grow. If you haven't seen it in action then check out the Anarchy mod. The work will be done in two files, InventoryHud.cs and Hud.cs. We will be begin with Inventoryhud.cs. Step #1 Open Inventoryhud.cs look for, $InvPack[0] = "Energy Pack";, this will be our starting point. //****************************************************************************************************************** //This is the first of six sections that you need to add to create the Deployables List //This is the section that lets you see what you can select from in the Inventory list when you //pull up the inventory hud. //Copy From Here---Begin Add by Drone1k $InvPack[0] = "Energy Pack"; $InvPack[1] = "Repair Pack"; $InvPack[2] = "Shield Pack"; $InvPack[3] = "Cloak Pack"; $InvPack[4] = "Sensor Jammer Pack"; $InvPack[5] = "Ammunition Pack"; $InvPack[6] = "Satchel Charge"; $InvPack[7] = "ELF Turret Barrel"; $InvPack[8] = "Mortar Turret Barrel"; $InvPack[9] = "Plasma Turret Barrel"; $InvPack[10] = "AA Turret Barrel"; $InvPack[11] = "Missile Turret Barrel"; // non-team mission pack choices (DM, Hunters, Rabbit) $NTInvPack[0] = "Energy Pack"; $NTInvPack[1] = "Repair Pack"; $NTInvPack[2] = "Shield Pack"; $NTInvPack[3] = "Cloak Pack"; $NTInvPack[4] = "Sensor Jammer Pack"; $NTInvPack[5] = "Ammunition Pack"; $NTInvPack[6] = "Satchel Charge"; $NameToInv["Energy Pack"] = "EnergyPack"; $NameToInv["Repair Pack"] = "RepairPack"; $NameToInv["Shield Pack"] = "ShieldPack"; $NameToInv["Cloak Pack"] = "CloakingPack"; $NameToInv["Sensor Jammer Pack"] = "SensorJammerPack"; $NameToInv["Ammunition Pack"] = "AmmoPack"; $NameToInv["Satchel Charge"] = "SatchelCharge"; $NameToInv["ELF Turret Barrel"] = "ELFBarrelPack"; $NameToInv["Mortar Turret Barrel"] = "MortarBarrelPack"; $NameToInv["Plasma Turret Barrel"] = "PlasmaBarrelPack"; $NameToInv["AA Turret Barrel"] = "AABarrelPack"; $NameToInv["Missile Turret Barrel"] = "MissileBarrelPack"; //To Here--- //Now paste what you copied From Here --- //Now what you do here is simple you remove the lines that you don't want to appear, Since this is a deployables //Menu item leave only the true Deployable items in this list and leave the True packs in the org list above. //Also change $InvPack to $InvDepl. This will be used when you create the second section. Without it your //list will not generate correctly when the hud is pulled up. //As an example you will see that all the deployable sensors and turrets are in this list amd removed from the org list //You will need to alter the numbers in between the [] so they are sequential, if you don't the Inventory list drop down //stops at the last sequential number. //This is an important part so pay attention when moving things around or you will loose your items. $InvDepl[1] = "Motion Sensor Pack"; $InvDepl[2] = "Pulse Sensor Pack"; $InvDepl[3] = "Inventory Station"; $InvDepl[4] = "Landspike Turret"; $InvDepl[5] = "Spider Clamp Turret"; // non-team mission deployable choices (DM, Hunters, Rabbit) $NTInvDepl[1] = "Motion Sensor Pack"; $NTInvDepl[2] = "Pulse Sensor Pack"; $NTInvDepl[3] = "Inventory Station"; $NameToInv["Motion Sensor Pack"] = "MotionSensorDeployable"; $NameToInv["Pulse Sensor Pack"] = "PulseSensorDeployable"; $NameToInv["Inventory Station"] = "InventoryDeployable"; $NameToInv["Landspike Turret"] = "TurretOutdoorDeployable"; $NameToInv["Spider Clamp Turret"] = "TurretIndoorDeployable"; //To Here---End Add by Drone1k //****************************************************************************************************************** Step #2 Look for, Create - PACK - List //****************************************************************************************************************** //Create - PACK - List //This is the second of section that you need to add to create the Deployables List //Copy From Here---Begin Add by Drone1k if ( %noSniperRifle ) { if ( getFieldCount( %client.packIndex ) ) %packList = %client.favorites[getField( %client.packIndex, 0 )]; else { %packList = "EMPTY"; %client.numFavs++; } for ( %y = 0; $InvPack[%y] !$= ""; %y++ ) { %PInv = $NameToInv[$InvPack[%y]]; if ( ( $InvPack[%y] !$= %client.favorites[getField( %client.packIndex, 0 )]) && %armor.max[%PInv] && !($InvBanList[%cmt, %PInv])) %packList = %packList TAB $Invpack[%y]; } } //To Here--- //Create - DEPLOYABLES - List Added by Drone1k //Now paste what you copied From Here --- //Now change %client.packIndex to %client.deplIndex, %packlist to %depllist, %PInv to %DpInv and $Invpack to $InvDepl. This is //very important so don't miss it. You will maintain the same format throughout the rest of the file. if ( %noSniperRifle ) { if ( getFieldCount( %client.deplIndex ) ) %deplList = %client.favorites[getField( %client.deplIndex, 0 )]; else { %deplList = "EMPTY"; %client.numFavs++; } for ( %y = 0; $InvDepl[%y] !$= ""; %y++ ) { %DpInv = $NameToInv[$InvDepl[%y]]; if ( ( $InvDepl[%y] !$= %client.favorites[getField( %client.deplIndex, 0 )]) && %armor.max[%DpInv] && !($InvBanList[%cmt, %DpInv])) %deplList = %deplList TAB $InvDepl[%y]; } } //To Here---END Add by Drone1k //****************************************************************************************************************** Step #3 Now look for, if ( getField( %packList, 0 ) !$= empty && %noSniperRifle ) //****************************************************************************************************************** //This is the third place that you will make a change. This is the section that places the Hud Items in Order. //What I did was place my Deployables section before the Packs. //Copy From Here---Begin Add by Drone1k %client.numFavsCount++; if ( getField( %packList, 0 ) !$= empty && %noSniperRifle ) %packList = %packList TAB "EMPTY"; %packText = %packList; %packOverFlow = ""; if ( strlen( %packList ) > 255 ) { %packText = getSubStr( %packList, 0, 255 ); %packOverFlow = getSubStr( %packList, 255, 512 ); } messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Pack:", %packText, pack, %client.numFavsCount, %packOverFlow ); %lineCount++; //To Here--- //Now paste what you copied From Here --- //Now change .packIndex to .deplIndex, %packlist to %depllist, %packText to %deplText, %packOverflow to %deplOverflow //and finally change "Pack:" to "Deployables:" and pack to deployables. This will be used in the Hud.cs file Later. %client.numFavsCount++; if ( getField( %deplList, 0 ) !$= empty && %noSniperRifle ) %deplList = %deplList TAB "EMPTY"; %deplText = %deplList; %deplOverFlow = ""; if ( strlen( %deplList ) > 255 ) { %deplText = getSubStr( %deplList, 0, 255 ); %deplOverFlow = getSubStr( %deplList, 255, 512 ); } messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Deployables:", %deplText, deployables, %client.numFavsCount, %deplOverFlow ); %lineCount++; //To Here---End Add by Drone1k //****************************************************************************************************************** Step # 4 Now Look for, %pCh = $NameToInv[%client.favorites[%client.packIndex]]; //****************************************************************************************************************** //This is the fourth section that will need to be added //Copy From Here---Begin Add by Drone1k // pack %pCh = $NameToInv[%client.favorites[%client.packIndex]]; if ( %pCh $= "" ) %client.clearBackpackIcon(); else %client.player.setInventory( %pCh, 1 ); // if this pack is a deployable that has a team limit, warn the purchaser // if it's a deployable turret, the limit depends on the number of players (deployables.cs) if(%pCh $= "TurretIndoorDeployable" || %pCh $= "TurretOutdoorDeployable") %maxDep = countTurretsAllowed(%pCh); else %maxDep = $TeamDeployableMax[%pCh]; if(%maxDep !$= "") { %depSoFar = $TeamDeployedCount[%client.player.team, %pCh]; %packName = %client.favorites[%client.packIndex]; if(Game.numTeams > 1) %msTxt = "Your team has "@%depSoFar@" of "@%maxDep SPC %packName@"s deployed."; else %msTxt = "You have deployed "@%depSoFar@" of "@%maxDep SPC %packName@"s."; messageClient(%client, 'MsgTeamDepObjCount', %msTxt); } //To Here--- //Now paste what you copied From Here --- //Now change .packIndex to .deplIndex, %packlist to %depllist, %pCH to %dpCH and %packName to %deplName //This is used to tell let you know what you have purchased so far from the Base Inventory Station. //There will be a replicate for the Deployable Inventory next. // deployable %dpCh = $NameToInv[%client.favorites[%client.deplIndex]]; if ( %dpCh $= "" ) %client.clearBackpackIcon(); else %client.player.setInventory( %dpCh, 1 ); // if this pack is a deployable that has a team limit, warn the purchaser // if it's a deployable turret, the limit depends on the number of players (deployables.cs) if(%dpCh $= "TurretIndoorDeployable" || %dpCh $= "TurretOutdoorDeployable") %maxDep = countTurretsAllowed(%dpCh); else %maxDep = $TeamDeployableMax[%dpCh]; if(%maxDep !$= "") { %depSoFar = $TeamDeployedCount[%client.player.team, %dpCh]; %deplName = %client.favorites[%client.deplIndex]; if(Game.numTeams > 1) %msTxt = "Your team has "@%depSoFar@" of "@%maxDep SPC %deplName@"s deployed."; else %msTxt = "You have deployed "@%depSoFar@" of "@%maxDep SPC %deplName@"s."; messageClient(%client, 'MsgTeamDepObjCount', %msTxt); } //To Here---End Add by Drone1k //****************************************************************************************************************** Step # 5 Now Look for, %packChoice = $NameToInv[%client.favorites[%client.packIndex]]; //****************************************************************************************************************** //This is the fifth section that will need to be added. This is a very big section so be careful and make sure you pay //Close attention to the Curly Brackets {} and keep everything in line or you will have problems. If you follow the format // of the %packChoice you want have problems. //Copy From Here---Begin Add by Drone1k %packChoice = $NameToInv[%client.favorites[%client.packIndex]]; if ( !($InvBanList[DeployInv, %packChoice]) ) %player.setInventory( %packChoice, 1 ); // if this pack is a deployable that has a team limit, warn the purchaser // if it's a deployable turret, the limit depends on the number of players (deployables.cs) if(%packChoice $= "TurretIndoorDeployable" || %packChoice $= "TurretOutdoorDeployable") %maxDep = countTurretsAllowed(%packChoice); else %maxDep = $TeamDeployableMax[%packChoice]; if((%maxDep !$= "") && (%packChoice !$= "InventoryDeployable")) { %depSoFar = $TeamDeployedCount[%client.player.team, %packChoice]; %packName = %client.favorites[%client.packIndex]; if(Game.numTeams > 1) %msTxt = "Your team has "@%depSoFar@" of "@%maxDep SPC %packName@"s deployed."; else %msTxt = "You have deployed "@%depSoFar@" of "@%maxDep SPC %packName@"s."; messageClient(%client, 'MsgTeamDepObjCount', %msTxt); } if(%prevPack > 0) { // if player had a "forbidden" pack (such as a deployable inventory station) // BEFORE visiting a deployed inventory station AND still has that pack chosen // as a favorite, give it back if((%packChoice $= %prevPack.item) && ($InvBanList[DeployInv, %packChoice])) %player.setInventory( %prevPack.item, 1 ); } //To Here--- //Now paste what you copied From Here --- //Now change .packIndex to .deplIndex, %packChoice to %deplChoice, and %packName to %deplName //This is for the Deployable Inventory Station //DON'T CHANGE THE %PREVPACK, IF YOU DO THINGS WILL WIG OUT LATER!!!!!!! %deplChoice = $NameToInv[%client.favorites[%client.deplIndex]]; if ( !($InvBanList[DeployInv, %deplChoice]) ) %player.setInventory( %deplChoice, 1 ); // if this pack is a deployable that has a team limit, warn the purchaser // if it's a deployable turret, the limit depends on the number of players (deployables.cs) if(%deplChoice $= "TurretIndoorDeployable" || %deplChoice $= "TurretOutdoorDeployable") %maxDep = countTurretsAllowed(%deplChoice); else %maxDep = $TeamDeployableMax[%deplChoice]; if((%maxDep !$= "") && (%deplChoice !$= "InventoryDeployable")) { %depSoFar = $TeamDeployedCount[%client.player.team, %deplChoice]; %deplName = %client.favorites[%client.deplIndex]; if(Game.numTeams > 1) %msTxt = "Your team has "@%depSoFar@" of "@%maxDep SPC %deplName@"s deployed."; else %msTxt = "You have deployed "@%depSoFar@" of "@%maxDep SPC %deplName@"s."; messageClient(%client, 'MsgTeamDepObjCount', %msTxt); } if(%prevPack > 0) { // if player had a "forbidden" pack (such as a deployable inventory station) // BEFORE visiting a deployed inventory station AND still has that pack chosen // as a favorite, give it back if((%deplChoice $= %prevPack.item) && ($InvBanList[DeployInv, %deplChoice])) %player.setInventory( %prevPack.item, 1 ); } //To Here---End Add by Drone1k //****************************************************************************************************************** Step # 6 Now Look for, for(%i = 0; $InvPack[%i] !$= ""; %i++) //****************************************************************************************************************** //Copy From Here---Begin Add by Drone1k //This is the sixth and final section. This can be used to add deployable Items to the Banlist for the //Deployable Inventory Station. From here we move to the Hud.cs file. for(%i = 0; $InvPack[%i] !$= ""; %i++) if($InvBanList[$CurrentMissionType, $NameToInv[$InvPack[%i]]]) $BanCount["Pack"]++; $InvTotalCount["Pack"] = %i; //To Here--- //Now paste what you copied From Here --- for(%i = 0; $InvDepl[%i] !$= ""; %i++) if($InvBanList[$CurrentMissionType, $NameToInv[$InvDepl[%i]]]) $BanCount["Deployables"]++; $InvTotalCount["Deployables"] = %i; //To Here---End Add by Drone1k //****************************************************************************************************************** Finally we have finished with the InventoryHud.cs file!!!! Now go and open the Hud.cs file this is going to be a long bit of coding, but in the end it is worth it. When all is said and done it is really simple, but can rack the brain sometimes trying to figure it out. Step # 1 Look for, serverCmdSetClientFav //****************************************************************************************************************** //Our Coding Begins Here---Begin Add by Drone1k function serverCmdSetClientFav(%client, %text) { if ( getWord( getField( %text, 0 ), 0 ) $= armor ) { %client.curFavList = %text; %validList = checkInventory( %client, %text ); %client.favorites[0] = getField( %text, 1 ); %armor = getArmorDatablock( %client, $NameToInv[getField( %validList,1 )] ); %weaponCount = 0; %packCount = 0; %grenadeCount = 0; %mineCount = 0; %count = 1; %client.weaponIndex = ""; %client.packIndex = ""; %client.grenadeIndex = ""; %client.mineIndex = ""; //First we add these three lines below. The %client.deplIndex is what you the player selects when you have the //Inventory Hud pulled up. The %hasdeploy and %haspack are new values we are setting here to control the menu list //after you have made your selection. %client.deplIndex = ""; %hasdeploy = ""; %haspack = ""; //Now we create a new "for loop" that will set one of the new values above, either %hasdeploy or %haspack. for(%i = 3; %i < getFieldCount(%validList); %i = %i + 2) { switch$ (getField(%validList,%i-1)) { case deployables: if(getField(%validList,%i) !$= "EMPTY" && getField(%validList,%i) !$= "INVALID") { %hasdeploy = true; } case pack: if(getField(%validList,%i) !$= "EMPTY" && getField(%validList,%i) !$= "INVALID") { %haspack = true; } } } //Now that we have a value set from above we test it to see what the player actually picked. //That is what the below tests are doing. Depending upon what is selected above it will set //a new value that we can now control on the server and no longer need the client. //We used a value called %client.lastused, in reality it can be called anything, but we are going to //use it in a little bit in the next "for loop" if(%haspack == true && %hasdeploy == true) { if(%client.lastused $= "PACK") { %haspack = false; %client.lastused = "DEPLOY"; } else { %hasdeploy = false; %client.lastused = "PACK"; } } else { if(%haspack == true) { %client.lastused = "PACK"; } else { %client.lastused = "DEPLOY"; } } //This is the end of our new "for loop" //One more thing to add below and we are done for(%i = 3; %i < getFieldCount(%validList); %i = %i + 2) { %setItem = false; switch$ (getField(%validList,%i-1)) { case weapon: if(%weaponCount < %armor.maxWeapons) { if(!%weaponCount) %client.weaponIndex = %count; else %client.weaponIndex = %client.weaponIndex TAB %count; %weaponCount++; %setItem = true; } //Now to explain what happens here. We get the results of our test above and test them before letting the //player have what they selected. If they selected a deployable then the %hasdeploy will test true and //%haspack will be set to false and vice versa. //When the what the player picks tests true the opposite menu list is them set to a "false" state and that is //what causes it to flip to Empty depending upon which menu item you choose. //The reason that this works like this is that each time you select an Item no matter what it is from the Inventory Hud //The entire list recreates itself with your new selection, but it does it so fast you don't notice it. //To see the end results start up your game and try out your new list. To see how it works currently Jump onto //one of the Anarchy Server. case deployables: //org lines if(%deplCount < 1 ) //org lines if(%hasdeploy == true ) { %client.deplIndex = %count; //org lines %deplCount++; //org lines %setItem = true; //org lines } //org lines else { %setItem = false; } case pack: //org lines if(%packCount < 1 ) //org lines if(%haspack == true ) { //org lines %client.packIndex = %count; //org lines %packCount++; //org lines %setItem = true; //org lines } //org lines else { %setItem = false; } //End of new Coding Section---End Add by Drone1k //****************************************************************************************************************** case grenade: if(%grenadeCount < %armor.maxGrenades) { if(!%grenadeCount) %client.grenadeIndex = %count; else %client.grenadeIndex = %client.grenadeIndex TAB %count; %grenadeCount++; %setItem = true; } case mine: if(%mineCount < %armor.maxMines) { if(!%mineCount) %client.mineIndex = %count; else %client.mineIndex = %client.mineIndex TAB %count; %mineCount++; %setItem = true; } } if(%setItem) { %client.favorites[%count] = getField(%validList, %i); %count++; } } %client.numFavs = %count; %client.numFavsCount = 0; inventoryScreen::updateHud(1, %client, 'inventoryScreen'); } }