@phantom
Yooooo, nice work! Yeah we all have stuff to do at times, so no problem.
I did a Script very similar to you, and i thought it worked good, then i merged it with my older script with the
"Game.ClearWeaponSpawnChances();" and merged the old list
"Game.UpdateWeaponSpawnChances(update);" i had into my new Script to test it out.
At first i thought everything was going well, but then an unexpected thing occurred.
The problem is that when we replace the "Default" SupplyCrate with another category,
the SpawnChances are ignored.
So even if you cleared "Bazooka, Grenade Launcher, Chainsaw.... etc" it will
still spawn.
Apparently SpawnChances only affect "Default" type SupplyCrates.
After 1 hour i was trying to get a complicated work-around to function, but then i found a solution.
For every "Default" type SupplyCrate (S), you write "S.SetWeaponItem(
[the weapon item of the crate])". This will remove the question mark icon from the Crate, without changing the weapon inside and affecting the spawn Chance selected by the player.
Now for what i wrote originally back in 2021 ->
"There's another thing i'd like to happen. Be able to disable certain supply Crates from spawning entirely, like the blue ones and the question mark ones."
Well the question mark problem is fixed now. As for the Blue icon what frustrated me was the "Supplies" Crate that included ("Thrown, Health, and Powerup"), but that is also fixed now, Health will always spawn in a Green cross box.
Here's the script i finished.
Code: Select all
/*
* author: Mighty Spirit The 2.
* description: Standard customization for Spawn chances, with addition of removing all question mark SupplyCrateTypes and separates "Supplies" Crate into respected categories (Better for Competitive-SFD).
* gamemodes: versus, custom
*/
//////////////***************INFO*****************//////////////
// Credit for Idea to "phantom" from forums, after i had given up on my first attempt. Attempt #3 15.11.2022
Random rnd = new Random();
public void OnStartup() {
Events.UpdateCallback.Start(SupplyCategory,0); ///No Point to use timer, because SupplyCrateType customization became available first in Beta 1.0.2c
Game.ClearWeaponSpawnChances(); //////Clears all Weapon Spawn chances, adds back weapons manually
Dictionary<short, int> update = new Dictionary<short, int>()
{
///List 1, I use this.
{ (short)WeaponItem.PISTOL45, 35},
{ (short)WeaponItem.GRENADES, 25},
{ (short)WeaponItem.LAZER, 10 },
{ (short)WeaponItem.MOLOTOVS, 25 },
{ (short)WeaponItem.UZI, 25 },
{ (short)WeaponItem.MACHETE, 20 },
{ (short)WeaponItem.SUB_MACHINEGUN, 12 },
{ (short)WeaponItem.PILLS, 15 },
{ (short)WeaponItem.MEDKIT, 20 },
{ (short)WeaponItem.AXE, 10 },
{ (short)WeaponItem.TOMMYGUN, 8 },
{ (short)WeaponItem.ASSAULT, 12 },
{ (short)WeaponItem.M60, 5 },
{ (short)WeaponItem.SNIPER, 5 },
{ (short)WeaponItem.SHOTGUN, 14 },
{ (short)WeaponItem.MAGNUM, 12 },
{ (short)WeaponItem.SAWED_OFF, 12 },
{ (short)WeaponItem.REVOLVER, 30 },
{ (short)WeaponItem.KATANA, 8 },
{ (short)WeaponItem.BOW, 10 },
{ (short)WeaponItem.CARBINE, 15 },
{ (short)WeaponItem.FLAMETHROWER, 8 },
{ (short)WeaponItem.FLAREGUN, 13 },
{ (short)WeaponItem.MINES, 22 },
{ (short)WeaponItem.CHAIN, 25 },
{ (short)WeaponItem.KNIFE, 10 },
{ (short)WeaponItem.C4, 15 },
{ (short)WeaponItem.BAT, 25 },
{ (short)WeaponItem.PIPE, 25 },
{ (short)WeaponItem.BATON, 14 },
{ (short)WeaponItem.WHIP, 6 },
//Alternative List, doesn't clear all weapons, just the ones you state below. Neutralise "Game.ClearWeaponSpawnChances();" and the list above first when running this. Disabled by default
/*
{ (short)WeaponItem.SLOWMO_10, 0 },
{ (short)WeaponItem.SLOWMO_5, 0 },
{ (short)WeaponItem.STRENGTHBOOST, 0},
{ (short)WeaponItem.SPEEDBOOST, 0}
{ (short)WeaponItem.LAZER, 0 },
{ (short)WeaponItem.PISTOL, 0 },
{ (short)WeaponItem.BAZOOKA, 0 },
{ (short)WeaponItem.GRENADE_LAUNCHER, 0 },
{ (short)WeaponItem.SUB_MACHINEGUN, 0 },
{ (short)WeaponItem.HAMMER, 0 },
{ (short)WeaponItem.SILENCEDPISTOL, 0 },
{ (short)WeaponItem.SILENCEDUZI, 0 },
{ (short)WeaponItem.SHURIKEN, 0 },
{ (short)WeaponItem.MACHINE_PISTOL, 0 },
{ (short)WeaponItem.DARK_SHOTGUN, 0 },
{ (short)WeaponItem.MP50, 0 },
{ (short)WeaponItem.LEAD_PIPE, 0 },
{ (short)WeaponItem.SHOCK_BATON, 0 },
{ (short)WeaponItem.CHAINSAW, 0 },
{ (short)WeaponItem.BOUNCINGAMMO, 0 },
{ (short)WeaponItem.FIREAMMO, 0 },
{ (short)WeaponItem.STREETSWEEPER, 0 },
*/
};
Game.UpdateWeaponSpawnChances(update);
}
public void SupplyCategory(float ms){
foreach (IObjectSupplyCrate S in Game.GetObjectsByName("SupplyCrate00"))
{
if(S.GetSupplyCategoryType().ToString()=="Default")
{ var WPN = S.GetWeaponItem(); S.SetWeaponItem(WPN); //This gets rid of question mark SupplyCrates, and breaks up "Supplies" into their own Categories.
}} }
//////*************Available Supply Crate types************/////////// --> No longer needed
/*
SupplyCategoryType.Supplies
SupplyCategoryType.Secondary
SupplyCategoryType.Primary
SupplyCategoryType.Melee
SupplyCategoryType.Health
SupplyCategoryType.Powerup
SupplyCategoryType.Thrown
*/
Do you think it is better to add --> public void OnShutdown(){ ?