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.
New to the forum? Say hello in this topic! Also make sure to read the rules.
How to change dud chance to 0?
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
- dsafxP
- Meatbag
- Posts: 9
- Joined: Fri May 08, 2020 5:16 am
- SFD Account: dsafxP
- SFD Alias: dsafxP
- Started SFD: 2020
- Location: Argentina
- Gender:
How to change dud chance to 0?
I'm doing a scene, where a Player throws a grenade to another player and explodes, how do i change or remove dud chance?
0 x
Who's gonna clean this mess?
- Odex64
- Superfighter
- Posts: 173
- Joined: Sat Jul 29, 2017 12:39 pm
- Title: Content Creator
- SFD Account: Odex64
- Started SFD: PreAlpha
- Location: Italy
- Gender:
- Age: 22
@Pricey is right, but if you want to do it through script you can use my code:
Now place any trigger when the scene starts, and assign it "GrenadeDud" on ScriptMethod and "on" in ObjectID box.
From now on any grenade you throw, it'll explode!
To disable it, place another trigger when your scene is over and assign it "GrenadeDud" on ScriptMethod and "off" in ObjectID.
Code: Select all
Events.ObjectCreatedCallback ObjectCreated = null;
public void GrenadeDud(TriggerArgs args) {
if (((IObject) args.Caller).CustomId == "on")
ObjectCreated = Events.ObjectCreatedCallback.Start(OnObjectCreated);
else if (((IObject) args.Caller).CustomId == "off")
ObjectCreated.Stop();
}
public void OnObjectCreated(IObject[] objs) {
foreach(IObject obj in objs)
if (obj.Name == "WpnGrenadesThrown")
((IObjectGrenadeThrown) obj).SetDudChance(0.0f);
}
From now on any grenade you throw, it'll explode!
To disable it, place another trigger when your scene is over and assign it "GrenadeDud" on ScriptMethod and "off" in ObjectID.
1 x
- Gurt
- Lead Programmer
- Posts: 1885
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 34
To always remove the dud chance from grenades for all grenades ever spawned:
Code: Select all
public void OnStartup(){
Events.ObjectCreatedCallback.Start(OnObjectCreated);
}
public void OnObjectCreated(IObject[] objs) {
foreach(IObject obj in objs)
if (obj.Name == "WpnGrenadesThrown")
((IObjectGrenadeThrown) obj).SetDudChance(0.0f);
}
0 x
Gurt
- KliPeH
- Moderator
- Posts: 919
- Joined: Sat Mar 19, 2016 3:03 pm
- Title: [happy moth noises]
- SFD Account: KliPeH
- Started SFD: Pre-Alpha 1.4.2
- Gender:
- Contact:
Off Topic
Does this work like any other script? Can it be posted on the Steam workshop?Gurt wrote: ↑Tue Jun 02, 2020 6:27 pmTo always remove the dud chance from grenades for all grenades ever spawned:Code: Select all
public void OnStartup(){ Events.ObjectCreatedCallback.Start(OnObjectCreated); } public void OnObjectCreated(IObject[] objs) { foreach(IObject obj in objs) if (obj.Name == "WpnGrenadesThrown") ((IObjectGrenadeThrown) obj).SetDudChance(0.0f); }
0 x
- Gurt
- Lead Programmer
- Posts: 1885
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 34
I suggest using the new Events.PlayerWeaponRemovedActionCallback and IPlayer.SetActiveThrowableTimer in v.1.3.6 to modify the explosive timer and modify the dud chance as the player weapon (a grenade) is removed (thrown or dropped) by the player. Just check if the object in the PlayerWeaponRemovedActionCallback event is a IObjectGrenadeThrown and call ((IObjectGrenadeThrown) obj).SetDudChance(0.0f);KliPeH wrote: ↑Tue Jun 02, 2020 9:34 pmOff TopicDoes this work like any other script? Can it be posted on the Steam workshop?Gurt wrote: ↑Tue Jun 02, 2020 6:27 pmTo always remove the dud chance from grenades for all grenades ever spawned:Code: Select all
public void OnStartup(){ Events.ObjectCreatedCallback.Start(OnObjectCreated); } public void OnObjectCreated(IObject[] objs) { foreach(IObject obj in objs) if (obj.Name == "WpnGrenadesThrown") ((IObjectGrenadeThrown) obj).SetDudChance(0.0f); }
But yes, all parts are there for a script to be utilized in the workshop if you like.
0 x
Gurt
- KliPeH
- Moderator
- Posts: 919
- Joined: Sat Mar 19, 2016 3:03 pm
- Title: [happy moth noises]
- SFD Account: KliPeH
- Started SFD: Pre-Alpha 1.4.2
- Gender:
- Contact:
Off Topic
I have no idea what any of this means. All I'm saying is I feel a reliable grenade script will be welcomed by the community with open arms and is something I'd even personally use in my own lobbies whenever I host.Gurt wrote: ↑Tue Jun 02, 2020 10:41 pmI suggest using the new Events.PlayerWeaponRemovedActionCallback and IPlayer.SetActiveThrowableTimer in v.1.3.6 to modify the explosive timer and modify the dud chance as the player weapon (a grenade) is removed (thrown or dropped) by the player. Just check if the object in the PlayerWeaponRemovedActionCallback event is a IObjectGrenadeThrown and call ((IObjectGrenadeThrown) obj).SetDudChance(0.0f);
[...]
I would highly appreciate it if this were to be uploaded to the Steam workshop.
0 x
- Odex64
- Superfighter
- Posts: 173
- Joined: Sat Jul 29, 2017 12:39 pm
- Title: Content Creator
- SFD Account: Odex64
- Started SFD: PreAlpha
- Location: Italy
- Gender:
- Age: 22
KliPeH wrote: ↑Tue Jun 02, 2020 11:13 pmOff TopicI have no idea what any of this means. All I'm saying is I feel a reliable grenade script will be welcomed by the community with open arms and is something I'd even personally use in my own lobbies whenever I host.Gurt wrote: ↑Tue Jun 02, 2020 10:41 pmI suggest using the new Events.PlayerWeaponRemovedActionCallback and IPlayer.SetActiveThrowableTimer in v.1.3.6 to modify the explosive timer and modify the dud chance as the player weapon (a grenade) is removed (thrown or dropped) by the player. Just check if the object in the PlayerWeaponRemovedActionCallback event is a IObjectGrenadeThrown and call ((IObjectGrenadeThrown) obj).SetDudChance(0.0f);
[...]
I would highly appreciate it if this were to be uploaded to the Steam workshop.
Off Topic
Time ago I was developing a "nerf" script which remove drones, reduce damage and criticals for some weapons and change some gameplay mechanics, but I never finished it. I could resume my work and add the grenades dud chance thing
2 x