As part of a game mode I'm working on I'm attempting to modify what weapons spawn on maps but have come to a roadblock of sorts. My main question is how this should be done? Below are what I've tried and why, in case of TL;DR.
Far as I can tell, the weapons and armor chosen to spawn on the map are located in KFGameContent\KFPickupFactory_ItemDefault.uc. At some point this class is used in KFGameInfo's ItemPickups array, although I don't see where in the code that happens. KFGameInfo simply declares it as an array and begins using it in the InitAllPickups() function expecting it to hold valid data.
1st Attempt:
My guess is that the array is populated as part of the map loading process but I have no clue how I would get my hands into that section of code. Due to this I started off modifying the PickupFactories externally. Playing with their PickupIndex and PickupItems I managed to get everything working perfectly... In single player. When testing on a server, the items get the wrong mesh or in most cases no mesh at all. Doing some testing I found that while changes to PickupIndex were being replicated to the clients the changes to PickupItems were not, causing errors inside the KFPickupFactory_Item.SetPickupMesh() function where the vanilla array is being accessed by the modified index. I *think* this is because arrays can't be replicated, not that it matters anyways because I haven't tried replacing the vanilla PickupFactories with custom ones extending the originals. Speaking of...
2nd Attempt:
This time around I wipe out the existing ItemPickups array in KFGameInfo, replacing each member with a copy Spawned using a version that extends the original class. Problem is this causes them all to use the ar-15's mesh and become un-pickupabble (is that even a word?). I'm pretty sure this is the default state of a KFPickupFactory_Item due to it using the ar-15's mesh in the default properties for its appearance and other code being required to activate them for pickup. Despite appearances, a couple dozen `log()s reveal everything is working as intended, even down to the SetPickupMesh() function choosing the correct mesh for me spawning eviscerators, centerfires, flamethrowers, and etc everywhere. Further testing reveals that if you only wipe out the KFGameInfo's ItemPickups array (ItemPickups.length = 0) you get the exact same result- intangible ar-15s everywhere despite those item factories no longer existing. Ditto for the AmmoPickups array (they render as ammo boxes though).
Is there a way I can get Attempt 1 or Attempt 2 to work, or am I missing a completely obviously simpler way of changing what spawns on the map? A PickupFactoryItemClass default property would be lovely. I can post code if needed, I just feel it's unnecessary to post a bunch of code if its entire purpose is off-base.
Far as I can tell, the weapons and armor chosen to spawn on the map are located in KFGameContent\KFPickupFactory_ItemDefault.uc. At some point this class is used in KFGameInfo's ItemPickups array, although I don't see where in the code that happens. KFGameInfo simply declares it as an array and begins using it in the InitAllPickups() function expecting it to hold valid data.
1st Attempt:
My guess is that the array is populated as part of the map loading process but I have no clue how I would get my hands into that section of code. Due to this I started off modifying the PickupFactories externally. Playing with their PickupIndex and PickupItems I managed to get everything working perfectly... In single player. When testing on a server, the items get the wrong mesh or in most cases no mesh at all. Doing some testing I found that while changes to PickupIndex were being replicated to the clients the changes to PickupItems were not, causing errors inside the KFPickupFactory_Item.SetPickupMesh() function where the vanilla array is being accessed by the modified index. I *think* this is because arrays can't be replicated, not that it matters anyways because I haven't tried replacing the vanilla PickupFactories with custom ones extending the originals. Speaking of...
2nd Attempt:
This time around I wipe out the existing ItemPickups array in KFGameInfo, replacing each member with a copy Spawned using a version that extends the original class. Problem is this causes them all to use the ar-15's mesh and become un-pickupabble (is that even a word?). I'm pretty sure this is the default state of a KFPickupFactory_Item due to it using the ar-15's mesh in the default properties for its appearance and other code being required to activate them for pickup. Despite appearances, a couple dozen `log()s reveal everything is working as intended, even down to the SetPickupMesh() function choosing the correct mesh for me spawning eviscerators, centerfires, flamethrowers, and etc everywhere. Further testing reveals that if you only wipe out the KFGameInfo's ItemPickups array (ItemPickups.length = 0) you get the exact same result- intangible ar-15s everywhere despite those item factories no longer existing. Ditto for the AmmoPickups array (they render as ammo boxes though).
Is there a way I can get Attempt 1 or Attempt 2 to work, or am I missing a completely obviously simpler way of changing what spawns on the map? A PickupFactoryItemClass default property would be lovely. I can post code if needed, I just feel it's unnecessary to post a bunch of code if its entire purpose is off-base.
Last edited: