class a_WeaponManager extends Actor config(HideMutWeapons); // when exit save weapon list as "CurrentWeaponList" var() KFPlayerController kfpc; var() HideMutInteraction interaction; var() config bool bUseVanillaManagement; var() config bool bFastWeaponChanging; var() array weaponGroup1; var() array weaponGroup2; var() array weaponGroup3; var() array weaponGroup4; var() array weaponGroup5; var() array weaponGroup6; var() array weaponGroup7; var() array weaponGroup8; var() array weaponGroup9; var() array allUsedWeapons; struct serverPreset { var string gameMode; var string weaponPreset; var string serverName; var bool bUseVanillaManagement; }; var() config array serverPresets; function postBeginPlay() { super.postBeginPlay(); // CrossbuzzsawBlade sound spam fix class'CrossbuzzsawBlade'.default.AmbientSoundRef = ""; class'FNFALFire'.default.AmbientFireVolume = 0; class'CashPickup'.default.TransientSoundVolume = 0.0; class'CashPickup'.default.AmbientGlow = 0; class'machete'.default.priority = 3; loadWeaponList("CurrentWeaponList"); if(serverPresets.length > 0) checkGameType(); forEach allObjects(class'HideMutInteraction', interaction) break; } simulated function checkGameType() { local GameReplicationInfo tempGri; local int i; local bool highestPriority; local bool newBUseVanillaManagement; local bool bFoundMatchingPreset; local string newPreset; foreach allActors(class'GameReplicationInfo', tempGri) { for(i = 0; i < serverPresets.length; i++) { if(tempGri.gameClass == serverPresets[i].gameMode) { // if server name is defined, this preset has higher priority (highestPriority = true) if(serverPresets[i].serverName != "") { if(inStr(caps(tempGri.serverName), caps(serverPresets[i].serverName)) != -1) { newBUseVanillaManagement = serverPresets[i].bUseVanillaManagement; if(serverPresets[i].weaponPreset != "") newPreset = serverPresets[i].weaponPreset; highestPriority = true; bFoundMatchingPreset = true; } } // if we found preset matching gameType and server name, we should skip presets without server name else if(!highestPriority) { newBUseVanillaManagement = serverPresets[i].bUseVanillaManagement; if(serverPresets[i].weaponPreset != "") newPreset = serverPresets[i].weaponPreset; bFoundMatchingPreset = true; } } } } if(bFoundMatchingPreset) { bUseVanillaManagement = newBUseVanillaManagement; if(newPreset != "") loadWeaponList(newPreset); } } simulated function saveWeaponList(string listName) { local WeaponManagerList newWeaponList; newWeaponList = new(none, listName) class'WeaponManagerList'; newWeaponList.clearConfig(); newWeaponList.weaponGroup1 = weaponGroup1; newWeaponList.weaponGroup2 = weaponGroup2; newWeaponList.weaponGroup3 = weaponGroup3; newWeaponList.weaponGroup4 = weaponGroup4; newWeaponList.weaponGroup5 = weaponGroup5; newWeaponList.weaponGroup6 = weaponGroup6; newWeaponList.weaponGroup7 = weaponGroup7; newWeaponList.weaponGroup8 = weaponGroup8; newWeaponList.saveConfig(); } simulated function loadWeaponList(string listName) { local WeaponManagerList newWeaponList; clearAllGroups(); newWeaponList = new(none, listName) class'WeaponManagerList'; weaponGroup1 = newWeaponList.weaponGroup1; weaponGroup2 = newWeaponList.weaponGroup2; weaponGroup3 = newWeaponList.weaponGroup3; weaponGroup4 = newWeaponList.weaponGroup4; weaponGroup5 = newWeaponList.weaponGroup5; weaponGroup6 = newWeaponList.weaponGroup6; weaponGroup7 = newWeaponList.weaponGroup7; weaponGroup8 = newWeaponList.weaponGroup8; updateUnusedWeapons(); } simulated function deleteWeaponList(string listName) { local WeaponManagerList newWeaponList; newWeaponList = new(none, listName) class'WeaponManagerList'; newWeaponList.clearConfig(); } // check if we have vanilla weapon slot system on or off static function bool checkVanillaSys(KFPlayerController kfpc, byte F) { local int i; // if its on, let the playercontroller original code do its job if (default.bUseVanillaManagement) return true; // otherwise start our shady functions else { i = clamp(int(F), 1, 9); kfpc.ConsoleCommand("getWeapon" $ i); return false; } } simulated function getWeapon(int groupNumber) { local Inventory inv; local int i, currentWeapon; local array weaponGroup; switch (groupNumber) { case 1: weaponGroup = weaponGroup1; break; case 2: weaponGroup = weaponGroup2; break; case 3: weaponGroup = weaponGroup3; break; case 4: weaponGroup = weaponGroup4; break; case 5: weaponGroup = weaponGroup5; break; case 6: weaponGroup = weaponGroup6; break; case 7: weaponGroup = weaponGroup7; break; case 8: weaponGroup = weaponGroup8; break; case 9: weaponGroup = weaponGroup9; break; default: return; } if (weaponGroup.length == 0) return; if ((kfpc.pawn == none) || (kfpc.pawn.inventory == none)) return; currentWeapon = -1; for (i = 0; i < weaponGroup.length; i++) { if (string(kfpc.pawn.weapon.class) ~= weaponGroup[i]) { currentWeapon = i; break; } } if (currentWeapon < weaponGroup.length - 1) { for (i = currentWeapon + 1; i < weaponGroup.length; i++) { for (inv = kfpc.pawn.inventory; inv != none; inv = inv.inventory) { if (string(inv.class) ~= weaponGroup[i]) { kfpc.pawn.pendingWeapon = Weapon(inv); if (bFastWeaponChanging) kfpc.pawn.changedWeapon(); else kfpc.pawn.weapon.putDown(); return; } } } } for (i = 0; i < currentWeapon; i++) { for (inv = kfpc.pawn.inventory; inv != none; inv = inv.inventory) { if (string(inv.class) ~= weaponGroup[i]) { kfpc.pawn.pendingWeapon = Weapon(inv); if(bFastWeaponChanging) kfpc.pawn.changedWeapon(); else kfpc.pawn.weapon.putDown(); return; } } } return; } simulated function reallyQuickHeal() { local Inventory inv; local Weapon oldWeapon; if (kfpc == none || kfpc.pawn == none || kfpc.pawn.inventory == none) return; for (inv = kfpc.pawn.inventory; inv != none; inv = inv.inventory) { if (ClassIsChildOf(inv.class, class'Syringe')) { oldWeapon = kfpc.pawn.weapon; kfpc.pawn.pendingWeapon = Weapon(inv); kfpc.pawn.changedWeapon(); // Syringe(kfpc.pawn.weapon).HackClientStartFire(); Syringe(kfpc.pawn.weapon).serverStartFire(1); kfpc.pawn.pendingWeapon = oldWeapon; // kfpc.pawn.changedWeapon(); kfpc.pawn.weapon.putDown(); } } } simulated function fullReset() { local KFLevelRules kflr; clearAllGroups(); foreach kfpc.dynamicActors(class'KFLevelRules', kflr) { break; } if(kflr == none) { kfpc.clientMessage("Can't access KFLevelRules. You are probably not in game."); return; } parseItemForSale(kflr.mediItemForSale); parseItemForSale(kflr.suppItemForSale); parseItemForSale(kflr.shrpItemForSale); parseItemForSale(kflr.commItemForSale); parseItemForSale(kflr.bersItemForSale); parseItemForSale(kflr.fireItemForSale); parseItemForSale(kflr.demoItemForSale); parseItemForSale(kflr.neutItemForSale); weaponGroup5[weaponGroup5.length] = "KFmod.Syringe"; weaponGroup5[weaponGroup5.length] = "KFmod.Welder"; updateUnusedWeapons(); prioritySortGroup(weaponGroup1); prioritySortGroup(weaponGroup2); prioritySortGroup(weaponGroup3); prioritySortGroup(weaponGroup4); } simulated function basicCleaning() { local Inventory inv; local array > inventoryWeapons; clearAllGroups(); if(kfpc.pawn.inventory == none) { kfpc.clientMessage("This function requires you inventory.(Needs Pawn)"); return; } for(inv = kfpc.pawn.inventory; inv != none; inv = inv.inventory) { if(KFWeapon(inv) != none) { inventoryWeapons[inventoryWeapons.length] = KFWeapon(inv).pickupClass; } } parseItemForSale(inventoryWeapons); updateUnusedWeapons(); } simulated function fullCleaning() { clearAllGroups(); updateUnusedWeapons(); } // part of fullReset() simulated function parseItemForSale(array > itemForSale) { local int i; local class tempKFWeapon; for(i = 0; i < itemForSale.length; i++) { tempKFWeapon = class(itemForSale[i].default.inventoryType); if(tempKFWeapon.default.inventoryGroup == 1) { weaponGroup1[weaponGroup1.length] = string(tempKFWeapon); continue; } if(tempKFWeapon.default.inventoryGroup == 2) { weaponGroup2[weaponGroup2.length] = string(tempKFWeapon); continue; } if(tempKFWeapon.default.inventoryGroup == 3) { weaponGroup3[weaponGroup3.length] = string(tempKFWeapon); continue; } if(tempKFWeapon.default.inventoryGroup == 4) { weaponGroup4[weaponGroup4.length] = string(tempKFWeapon); continue; } if(tempKFWeapon.default.inventoryGroup == 5) { weaponGroup5[weaponGroup5.length] = string(tempKFWeapon); continue; } } } // part of fullReset() simulated function prioritySortGroup(out array weaponGroup) { local int i,j; local string tempString; local class tempKFWeapon1, tempKFWeapon2; for(i = 0; i < weaponGroup.length; i++) { for(j = i; j < weaponGroup.length; j++) { tempKFWeapon1 = class(dynamicLoadObject(weaponGroup[i], class'Class', true)); tempKFWeapon2 = class(dynamicLoadObject(weaponGroup[j], class'Class', true)); if(tempKFWeapon1.default.priority < tempKFWeapon2.default.priority) { tempString = weaponGroup[i]; weaponGroup[i] = weaponGroup[j]; weaponGroup[j] = tempString; } } } } simulated function clearAllGroups() { weaponGroup1.remove(0, weaponGroup1.length); weaponGroup2.remove(0, weaponGroup2.length); weaponGroup3.remove(0, weaponGroup3.length); weaponGroup4.remove(0, weaponGroup4.length); weaponGroup5.remove(0, weaponGroup5.length); weaponGroup6.remove(0, weaponGroup6.length); weaponGroup7.remove(0, weaponGroup7.length); weaponGroup8.remove(0, weaponGroup8.length); weaponGroup9.remove(0, weaponGroup9.length); } simulated function updateUnusedWeapons() { local KFLevelRules kflr; local array > welderSyringe; updateAllUsedWeapons(); foreach dynamicActors(class'KFLevelRules', kflr) { break; } if(kflr == none) { if(kfpc != none) kfpc.clientMessage("Can't access KFLevelRules. You are probably not in game."); return; } weaponGroup9.remove(0, weaponGroup9.length); updateUnusedWeapons_Internal(kflr.mediItemForSale); updateUnusedWeapons_Internal(kflr.suppItemForSale); updateUnusedWeapons_Internal(kflr.shrpItemForSale); updateUnusedWeapons_Internal(kflr.commItemForSale); updateUnusedWeapons_Internal(kflr.bersItemForSale); updateUnusedWeapons_Internal(kflr.fireItemForSale); updateUnusedWeapons_Internal(kflr.demoItemForSale); updateUnusedWeapons_Internal(kflr.neutItemForSale); welderSyringe[welderSyringe.length] = class'SyringePickup'; welderSyringe[welderSyringe.length] = class'WelderPickup'; updateUnusedWeapons_Internal(welderSyringe); prioritySortGroup(weaponGroup9); } simulated function updateUnusedWeapons_Internal(array > parsedWeapons) { local int i, j; local class tempKFWeapon; for(i = 0; i < parsedWeapons.length; i++) { tempKFWeapon = class(parsedWeapons[i].default.inventoryType); if(tempKFWeapon == None) continue; if(allUsedWeapons.length == 0) { weaponGroup9[weaponGroup9.length] = string(tempKFWeapon); continue; } for(j = 0; j < allUsedWeapons.length; j++) { if(string(tempKFWeapon) == allUsedWeapons[j]) break; if(j == (allUsedWeapons.length - 1)) weaponGroup9[weaponGroup9.length] = string(tempKFWeapon); } } } simulated function updateAllUsedWeapons() { local int i; allUsedWeapons.remove(0, allUsedWeapons.length); for(i = 0; i < weaponGroup1.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup1[i]; } for(i = 0; i < weaponGroup2.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup2[i]; } for(i = 0; i < weaponGroup3.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup3[i]; } for(i = 0; i < weaponGroup4.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup4[i]; } for(i = 0; i < weaponGroup5.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup5[i]; } for(i = 0; i < weaponGroup6.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup6[i]; } for(i = 0; i < weaponGroup7.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup7[i]; } for(i = 0; i < weaponGroup8.length; i++) { allUsedWeapons[allUsedWeapons.length] = weaponGroup8[i]; } } simulated function array getAllPresetNames() { local array names; local int i; names = getPerObjectNames("HideMutWeapons", string(class'WeaponManagerList'.name)); for(i = 0; i < names.length; i++) { if (names[i] ~= "CurrentWeaponList") { names.remove(i, 1); } } return names; } simulated event destroyed() { kfpc = none; interaction = none; super.destroyed(); } defaultproperties { bHidden=True }