Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

[REQUEST] Script for custom weapon spawn chances + Ban some SupplyCrates

Custom scripts
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

[REQUEST] Script for custom weapon spawn chances + Ban some SupplyCrates

Post by Mighty Spirit the 2 » Sun Apr 04, 2021 5:19 pm

Simply put I need a script that can tweak the weapon spawn chances of weapons to my custom liking. Sure i could go into each and every map and tweak every single weapon spawn chance again and again, but that's honestly gonna take 1 hour probably. I already have a script to disable certain items from spawning, so i thought why not add to it and make a script that lets us tweak the spawn chance of remaining weapons.
There's also another problem i have, and which I'm sure other people that use scripts like this
Script that automatically replaces certain weapon/item spawns with other items/weapons"
(general description) That's what these scripts tend to do. Problem is that the other item/weapons that spawn then spawn excessively. In my server way too much hp and grenades tend to spawn, too many knives too and GL seems too common for my liking. I need a way to control this pollution over spawning.
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.
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Tue Apr 20, 2021 12:46 am

Its been 2 weeks and still no answers on any of my inquiries. I mean hell i knew the game was dying, but now the communities stone dead too.
Good job, devs 👏
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

User avatar
ebomb09
Fighter
Fighter
Posts: 13
Joined: Mon Apr 30, 2018 5:04 am
SFD Account: ebomb09
Location: Canada/BC
Age: 22

Post by ebomb09 » Tue Apr 20, 2021 5:26 am

Unfortunately it takes time to make scripts, and not a lot of people want to devote a ton of time to other's script ideas. I wouldn't blame the devs for the community not developing your script inquiries.
4 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Tue Apr 20, 2021 8:17 am

ebomb09 wrote:
Tue Apr 20, 2021 5:26 am
Unfortunately it takes time to make scripts, and not a lot of people want to devote a ton of time to other's script ideas. I wouldn't blame the devs for the community not developing your script inquiries.
Your right i shouldn't blame them for this, or perhaps the lack of interest the game gained resulted in fewer potential scripters. Anyway i was just trying to get an answer.

For 2 of my requests (no-throw, no-hard-scoping) i wasn't even asking for people to make scripts i know those scripts already exist, they just aren't publicly available. As for people being too busy, there's no excuse not to drop a reply for example where you saw the script last being used or who might have it.
And for this particular script, I'm not even sure if its possible so it would at least be great to have some confirmation of this. Who would not want to devote time to develop a script like this, which should have been an in-game option a long time ago in these final versions of the game (which the devs should have taken care of).
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

User avatar
KliPeH
Moderator
Moderator
Posts: 914
Joined: Sat Mar 19, 2016 3:03 pm
Title: [happy moth noises]
SFD Account: KliPeH
Started SFD: Pre-Alpha 1.4.2
Gender:
Contact:

Post by KliPeH » Tue Apr 20, 2021 11:54 am

Off Topic
Mighty Spirit the 2 wrote:
Tue Apr 20, 2021 8:17 am
For 2 of my requests (no-throw, no-hard-scoping) i wasn't even asking for people to make scripts i know those scripts already exist, they just aren't publicly available.
Either the script is private, or none of the forum readers have it, or none want to spend their valuable time making it (for free or for you). All three mean the same thing for the purposes of this thread - people can’t (or don’t want to) reply with meaningful information so the thread remains barren, as the rules require.

It’s not being buried under other threads or getting forgotten, there is simply no interest. “Me too” replies would be completely fine (to show interest in the script) but you got none of those either. Maybe try the Steam forums? Certainly beats crying about it in this post.
Mighty Spirit the 2 wrote:
Tue Apr 20, 2021 8:17 am
As for people being too busy, there's no excuse not to drop a reply for example where you saw the script last being used or who might have it.
Saying “there is no excuse” implies someone owes you a reasonable explanation, which they don’t. There is no interest in the script and people have so far not been able to make it. Nobody owes you a reply or a confirmation, or any work on your own script for that matter. Accusing the devs of killing the game will not convince anyone to help you. Script-makers in the past have been incredibly helpful in this community, and so have the devs (check other threads, in most of which at least 1 reply will be the answer) so this comes off as incredibly rude and disrespectful in my opinion.
Mighty Spirit the 2 wrote:
Tue Apr 20, 2021 8:17 am
Who would not want to devote time to develop a script like this, which should have been an in-game option a long time ago in these final versions of the game (which the devs should have taken care of).
Perhaps people who think there is nothing wrong with the game. People who don’t agree with your view of “balance”? People who don’t view this childish “hardscoping” term as valid. People who think implementing this would be a hassle, or time-consuming, or don’t have the skillset required to do so. People who don’t want to be taken for granted, made to feel as if they owe others code they have worked hard to learn and master.

Try privately messaging some of the scripters who have helped others in the past here and see if they have any answers for you. I would also strongly recommend a change in attitude, not as a Moderator but as a fellow Superfighter and human being.
4 x
 
Image

sfd
Meatbag
Posts: 7
Joined: Mon Sep 28, 2020 6:08 pm
Started SFD: Steam Release
Gender:
Age: 20
Contact:

Post by sfd » Tue Apr 20, 2021 8:53 pm

Try using Mythologic Interactive official discord: https://discord.gg/nECKnbT7gk
There is a lot of scripters and map-makers discussing there and they are almost 24/7 active there, try asking them. They probably know something.
1 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Sun Nov 28, 2021 3:13 am

After everyone was "busy" I got into some scripting and made one myself. Once you knew where to look this would take around 5 min. Literally.

Code: Select all

/*
* author: Mighty Spirit The 2.
* description: In-depth customization for spawns
* gamemodes: versus, custom
*/


public void OnStartup() {

    IObjectTimerTrigger Timer1 = (IObjectTimerTrigger)Game.CreateObject("TimerTrigger");
    Timer1.SetIntervalTime(1);
    Timer1.SetRepeatCount (0);
    Timer1.SetScriptMethod("SupplyCategory");
    Timer1.Trigger();


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, 35 },
		{ (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(TriggerArgs args)
{
///Supply Crate types
foreach (IObjectSupplyCrate f in Game.GetObjectsByName("SupplyCrate00"))
{
if(f.GetSupplyCategoryType().ToString() == "Supplies" || f.GetSupplyCategoryType().ToString() == "Any" || f.GetSupplyCategoryType().ToString() == "Powerup") { f.Remove(); }
//if(f.GetSupplyCategoryType().ToString() == "Thrown") { f.Remove(); }


/*
///////Remove OP Weapons, useful when running Beta 1.0.2c as the "UpdateWeaponSpawnChance" won't function.
if(f.GetWeaponItem() == WeaponItem.M60 || f.GetWeaponItem() == WeaponItem.BAZOOKA || f.GetWeaponItem() == WeaponItem.GRENADE_LAUNCHER) { f.Remove(); } */
}}
If anyone wants it there. You can mess around with it all you want.
1 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Mon Aug 15, 2022 1:30 am

So i recently found out that my script doesn't actually do a whole lot. I used to think that the supplycrate spawn system worked in the way that the game would select what type of crate it would spawn in random order. This seems to not be the case after all, some testing on my behalf seems to confirm this. All supply crates that spawn, if not spawned deliberately via a script, will be default (type). I'm sure some scripters already knew this...
The reason i thought my script was working was most likely bcs of the first part where i specified what weapons to spawn and in what chance.
There does not seem to be a way currently for the game to read what icon/logo/imagine is on the supplycrate that spawns, or else we could actually remove the one's with for example question-mark, health or knife image (aka melee). Just for your info.
Also yes, my attitude has changed.
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

phantom
Fighter
Fighter
Posts: 16
Joined: Sat Oct 22, 2022 2:36 pm
SFD Account: Phantom
Gender:
Age: 23
Contact:

Post by phantom » Sun Oct 23, 2022 2:56 pm

Mighty Spirit the 2 wrote:
Mon Aug 15, 2022 1:30 am
There does not seem to be a way currently for the game to read what icon/logo/imagine is on the supplycrate that spawns, or else we could actually remove the one's with for example question-mark, health or knife image (aka melee).
There's a way to check which type of supply crate it is,
Check the SFD ScriptAPI.
there's a GetSupplyCategoryType() method which speaks for itself what does it do.
It's in IObjectSupplyCrate class.
0 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Sat Nov 05, 2022 3:14 am

phantom wrote:
Sun Oct 23, 2022 2:56 pm
There's a way to check which type of supply crate it is,
Check the SFD ScriptAPI.
Did you read anything i even wrote? Or the code and tested it? The only part you need is the "public void SupplyCategory(TriggerArgs args)", remove the unnecessary rest above.
phantom wrote:
Sun Oct 23, 2022 2:56 pm
It's in IObjectSupplyCrate class.
Do you think I'm stupid? How do you think i even managed to make the script in the first place?
phantom wrote:
Sun Oct 23, 2022 2:56 pm
there's a GetSupplyCategoryType() method which speaks for itself what does it do.
No, in fact it is not self-explanatory. I've been making scripts for this game for more than a year. And there are certain things that are just never fully explained in the ScriptAPI, this being one of the examples. It might seem obvious, to me it did too at first, but if you spend a little bit of time experimenting with the relevant parts of the script i wrote (see above), you will see this as well.

See, i touched upon this in my last post, but i will explain it here:
- The spawn system in the game, unless specified via script, will always spawn a crate of the type "default". It does not matter if the object is a melee, gun, or health/supplies drop.


And do you know how i figured this out? I did it the painful way. An entire year went passed after i finished my script and thought "suck it scripters" in my head. I always assumed my script was working fine as it could be, but when i was experimenting with another script on the side, it happened to touch upon supplycrates once more. My eyes almost boggled out when my script wasn't doing it's intended use.
Then realization hit me, I even made a map to test my hypothesis and that's how i know that i am right and i now understand how the supply system functions. I would else never come back here and make such bold statements.
Still don't believe me? I would link the map and make it 1 min for you or anyone to test, but i can't upload it to here. I can give you a hint, make a wpn spawn area + wpn spawn ceiling. Then run my instructed script-extract above, or make your own. Try removing all melee or gun or anything else (in script), but don't touch the "default category". Be amazed that not a single supply crate is removed, and all type of stuff spawns.
In conclusion the game can't tell you for shit what icon is on the supply crate and filter them out.

I really don't mean to bash you down, I assume know more in coding than i do, but perhaps not how things behave in the game. Here's another example of smth probably few ppl know. Using the IObjectCameraAreaTrigger and filtering out all CPU players to ignore as secondary Targets is impossible. It works in offline mode, but there's a bug that was never fixed that makes it not work in online mode. That's 25 hours i won't get back.


So in the end i was the one who "sucked it", and meanwhile all scripters laughed their asses off no doubt, the joke was played on me all along. :twisted:
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

phantom
Fighter
Fighter
Posts: 16
Joined: Sat Oct 22, 2022 2:36 pm
SFD Account: Phantom
Gender:
Age: 23
Contact:

Post by phantom » Sun Nov 06, 2022 2:38 pm

Sorry, I can't read your entire post it's too time consuming I am saying just write in one line what kind of script you wanna create?

EDIT: Ok now I get your point GetSupplyCrateType() returns default if the supply crate is generated by map triggers.
But then don't use GetSupplyCrateType() and instead use GetWeaponItem();

Further EDIT: After getting my head into your script you made a mess just because of using loop instead use event.

Code: Select all

Events.ObjectCreatedCallback objectCreateEvent = null;

public void OnStartup()
{
    objectCreateEvent = Events.ObjectCreatedCallback.Start(OnObjectCreated);
}
public void OnObjectCreated(IObject[] objs)
{
    foreach (IObject obj in objs)
    {
        try
        {
            var a = (IObjectSupplyCrate)obj;
            Game.ShowChatMessage(Convert.ToString(a.GetWeaponItem()));
        }
        catch { }
    }
}
public void OnShutdown()
{
    Events.ObjectCreatedCallback.Stop(objectCreateEvent);
}
This code will send chat message whenever a new supply crate will spawn.
0 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Sun Nov 06, 2022 11:07 pm

phantom wrote:
Sun Nov 06, 2022 2:38 pm
Sorry, I can't read your entire post it's too time consuming
You do realize i wrote all that to try to inform you that not everything in ScriptAPI is properly documented? But ok, just ignore my helpful input, it'll save you a lot of headaches later on.
phantom wrote:
Sun Nov 06, 2022 2:38 pm
I am saying just write in one line what kind of script you wanna create?
I want exactly what i wrote in the original Post. I tried it myself, discovered it's not possible, thank you for your help.
phantom wrote:
Sun Nov 06, 2022 2:38 pm
EDIT: Ok now I get your point GetSupplyCrateType() returns default if the supply crate is generated by map triggers.
But then don't use GetSupplyCrateType() and instead use GetWeaponItem();
But that's specifically what i didn't want, if you read my original post: "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."
I only wanted to be able for the game to register what type of SupplyCrate has what icon on it, then restrict those with a certain icon. That's as I tried to explain you numerous times not possible.

phantom wrote:
Sun Nov 06, 2022 2:38 pm
Further EDIT: After getting my head into your script you made a mess just because of using loop instead use event.
My code is not pretty i know, with no formal training and just learning by reading previous shared community scripts, it's the simplest i could make.
phantom wrote:
Sun Nov 06, 2022 2:38 pm
This code will send chat message whenever a new supply crate will spawn.
Cool script, but as i said that's not at all what i wanted. Sorry for wasting your time i guess.

Oh, and a script to tweak Weapon Spawn chances already exists on Workshop for the last 2 years, I'm thinking people deliberately didn't tell me. Then again, it's not that difficult making your own, because that's what i did before i discovered it.
Off Topic
KliPeH, sorry for mentioning your name if you get a notification. Don't lock yet.
Last edited by Mighty Spirit the 2 on Mon Nov 07, 2022 11:52 pm, edited 2 times in total.
1 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

phantom
Fighter
Fighter
Posts: 16
Joined: Sat Oct 22, 2022 2:36 pm
SFD Account: Phantom
Gender:
Age: 23
Contact:

Post by phantom » Mon Nov 07, 2022 2:46 pm

I think the simple workout is this,
As soon as a supplycrate spawns which will obviously say default type the script will remove it and spawn a new type whatever you want with randomized weapon.
1 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Tue Nov 08, 2022 12:08 am

phantom wrote:
Mon Nov 07, 2022 2:46 pm
I think the simple workout is this,
As soon as a supplycrate spawns which will obviously say default type the script will remove it and spawn a new type whatever you want with randomized weapon.
Image
That's.... That's actually a good idea.
Just goes to show that new people have new ideas.

If you want you can develop a script with that idea and upload it to workshop, I will try making something similar and credit it as your Idea. :)
You can code much better than me so it will be prettier.
Dam... why didn't i think of that... ;c
1 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

phantom
Fighter
Fighter
Posts: 16
Joined: Sat Oct 22, 2022 2:36 pm
SFD Account: Phantom
Gender:
Age: 23
Contact:

Post by phantom » Fri Nov 11, 2022 2:08 pm

Mighty Spirit the 2 wrote:
Tue Nov 08, 2022 12:08 am
phantom wrote:
Mon Nov 07, 2022 2:46 pm
I think the simple workout is this,
As soon as a supplycrate spawns which will obviously say default type the script will remove it and spawn a new type whatever you want with randomized weapon.
Image
That's.... That's actually a good idea.
Just goes to show that new people have new ideas.

If you want you can develop a script with that idea and upload it to workshop, I will try making something similar and credit it as your Idea. :)
You can code much better than me so it will be prettier.
Dam... why didn't i think of that... ;c
Sorry, I only have this weekend free after that I am a little busy this month so after this month in December I will work on it.
You can carry on and work on it.

EDIT: As I said I am busy (actually more than a little) I can just make this in this short interval of time.

Code: Select all

SupplyCategoryType[] Category = {
	SupplyCategoryType.Melee,
        SupplyCategoryType.Primary,
        SupplyCategoryType.Secondary,
        SupplyCategoryType.Thrown,
        SupplyCategoryType.Powerup,
        SupplyCategoryType.Health
};
public void OnStartup()
{
	Events.ObjectCreatedCallback.Start(OnObjectCreated);
}
public void OnObjectCreated(IObject[] objs)
{
	Random rand = new Random();
	foreach (IObject obj in objs)
	{
		try
		{
                	var temp = (IObjectSupplyCrate)obj;
                	temp.SetSupplyCategoryType(Category[rand.Next(6)]);
                    	Game.ShowChatMessage(Convert.ToString(temp.GetSupplyCategoryType()));
                }
                catch { }
        }
}
It uses this array:
SupplyCategoryType[] Category = {
SupplyCategoryType.Melee,
SupplyCategoryType.Primary,
SupplyCategoryType.Secondary,
SupplyCategoryType.Thrown,
SupplyCategoryType.Powerup,
SupplyCategoryType.Health


It just displays chat msg of the category type you can remove this line so that it won't display the type.
Game.ShowChatMessage(Convert.ToString(temp.GetSupplyCategoryType()));
Then do whatever you wanna do with supply categories.
1 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Tue Nov 15, 2022 1:34 am

@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. 🤔 :idea:

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. :geek:

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(){ ?
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

User avatar
Odex64
Superfighter
Superfighter
Posts: 172
Joined: Sat Jul 29, 2017 12:39 pm
Title: Content Creator
SFD Account: Odex64
Started SFD: PreAlpha
Location: Italy
Gender:
Age: 22

Post by Odex64 » Tue Nov 15, 2022 10:07 am

@Mighty Spirit the 2 I didn't read the full conversation but here's a few notes...
You should use the same event as @phantom stated above (OnObjectCreated). Your code unnecessarily loops every frame causing a slight performance loss. I also "tweaked" some stuff in your code - this should work as intended.

Code: Select all

private static SupplyCategoryType[] ExcludedCategories =
{
	SupplyCategoryType.Default,
	SupplyCategoryType.Thrown,
	SupplyCategoryType.Powerup,
	SupplyCategoryType.Health
};

private static Dictionary<short, int> CustomSpawnChances = new Dictionary<short, int>()
{
	{ (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 }
};

public void OnStartup()
{
	Game.ClearWeaponSpawnChances();
	Game.UpdateWeaponSpawnChances(CustomSpawnChances);
	Events.ObjectCreatedCallback.Start(OnObjectCreated);
}

public void OnObjectCreated(IObject[] objs)
{
	foreach (IObject obj in objs)
	{
		var supplyCrate = obj as IObjectSupplyCrate;
		if (supplyCrate != null && ExcludedCategories.Contains(supplyCrate.GetSupplyCategoryType()))
		{
			supplyCrate.SetWeaponItem(supplyCrate.GetWeaponItem());
		}
	}
}
Also no, you don't need to use OnShutdown.
3 x
Image

phantom
Fighter
Fighter
Posts: 16
Joined: Sat Oct 22, 2022 2:36 pm
SFD Account: Phantom
Gender:
Age: 23
Contact:

Post by phantom » Wed Nov 16, 2022 2:33 pm

@Odex64 great work!

I am a self taught programmer I currently study in college so I didn't knew that you can use obj as IObjectSupplyCrate instead I used try and catch.

@Mighty Spirit the 2 I think this is the best solution for your problem.
2 x

User avatar
Mighty Spirit the 2
Superfighter
Superfighter
Posts: 187
Joined: Mon Jun 25, 2018 5:02 pm
Title: Wasted potential
SFD Account: ake004
SFD Alias: Retired SFD player
Started SFD: When melee was good
Location: SFD Veteran trauma hospital
Gender:
Age: 22

Post by Mighty Spirit the 2 » Wed Nov 16, 2022 9:56 pm

@phantom Ok, thank's to you this all finally was resolved. 💻🖥 👍

@Odex64 With looping you mean the repeat of UpdateCallback? I don't have any experience using the ObjectCreation event, although it looked more efficient. I usually only make scripts that run for Beta. Thanks for the script.
0 x
🎶I will tell your story if you die
I will tell your story and keep you alive the best i can
...
But I've always had the feeling we would die young
Some die young
🎵
https://i.imgur.com/D479VLi.png

Post Reply