- Site Map >
- Modding and Creation >
- Creator Feedback Forum >
- Sims 3 >
- Other - FireproofFireplacesAndCo
- Site Map >
- Modding and Creation >
- Creator Feedback Forum >
- Sims 3 >
- Other - FireproofFireplacesAndCo
Replies: 2 (Who?), Viewed: 1157 times.
#1
16th Jan 2015 at 11:08 PM
Last edited by Arsil : 7th Jun 2015 at 4:29 PM.
Posts: 997
Thanks: 22101 in 95 Posts
FireproofFireplacesAndCo
Hello,This is a pure scripting mod that should take care of making fireproof all
- fireplaces
- firepits
- stoves
- grills
- bonefires
- [did I forget something?]
This can't conflict with any XML override mod, but it will override the common tunings
(those about setting sims on fire).
It's XML tunable, you can choose which categories of objects to make fireproof and also
fine tune the single settings for every category. All default values are "0" (meaning 0%)
so if all works correctly there should be no chance at all that the objects start a fire.
I'd like some help to test if it works as it's supposed to do. I'm clumsy and I've used a lot
of copy/pasting, I could have made some mistakes or missed something, so having
someone else doing a double check would be nice.
This is the XML tuning file, please check if I forgot a tag/field that can start a fire.
Code:
<?xml version="1.0" encoding="utf-8"?> <base> <Current_Tuning> <kInstantiator value="True" /> <!-- MAIN SETTINGS: just put true or false --> <kOverrideFireplacesSettings value="true"/> <kOverrideFirepitsSettings value="true"/> <kOverrideStovesSettings value="true"/> <kOverrideGrillsSettings value="true"/> <!-- If you put -1 as value for one of the following setting, then that setting wont be overridden and every class will keep its own settings--> <!-- FIREPLACEs SETTINGS (applied only if enabled in the main settings) --> <fireplaceChanceCatchFire value="0"/> <!-- range 0..100, percentage, use a dot for decimals (e.g. 0.25) --> <fireplaceChanceCatchFireWhenNoSimsInRoom value="0"/> <!-- range 0..100, percentage, use a dot for decimals (e.g. 0.25) --> <!-- FIREPITS SETTINGS (applied only if enabled in the main settings) --> <firepitChanceCatchFire value="0"/> <!-- range 0..100, percentage, use a dot for decimals (e.g. 0.25) --> <firepitChanceCatchFireWhenNoSimsInRoom value="0"/> <!-- range 0..100, percentage, use a dot for decimals (e.g. 0.25) --> <!-- STOVEs SETTINGS (applied only if enabled in the main settings) --> <stoveChanceOfRandomFireAfterFailure value="0"/> <!-- range 0..100, percentage, use a dot for decimals (e.g. 0.25) --> <stoveCanCatchFire value="0"/> <!-- use -1 to not override, 0 for false and 1 for true --> <!-- GRILLs SETTINGS (applied only if enabled in the main settings) --> <grillChanceOfRandomFireAfterFailure value="0"/> <!-- range 0..100, percentage, use a dot for decimals (e.g. 0.25) --> <grillCanCatchFire value="0"> <!-- use -1 to not override, 0 for false and 1 for true --> <!-- BONFIREs SETTINGS --> <bonfireChanceToStartFireSpread value="0"/> <!-- range 0..100, percentage, use a dot for decimals (e.g. 0.25) --> </Current_Tuning> </base>
Sourcecode (based on Buzzler's Same Energy Gain For Every Bed, with his permission)
Code:
using Sims3.Gameplay; using Sims3.Gameplay.Abstracts; using Sims3.Gameplay.Actors; using Sims3.Gameplay.Autonomy; using Sims3.Gameplay.Core; using Sims3.Gameplay.EventSystem; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Objects.Beds; using Sims3.Gameplay.Objects.TombObjects; using Sims3.Gameplay.Utilities; using Sims3.SimIFace; using Sims3.UI; using System; using System.Collections.Generic; using Sims3.Gameplay.Objects.Fireplaces; using Sims3.Gameplay.Objects.CookingObjects; using Sims3.Gameplay.Objects.Appliances; using Sims3.Gameplay.Objects.Environment; using Sims3.Gameplay.Interfaces; namespace Arsil.FireProofFireplacesAndCo { public class Instantiator { [Tunable] protected static bool kInstantiator; // main settings [Tunable] protected static bool kOverrideFireplacesSettings = true; [Tunable] protected static bool kOverrideStovesSettings = true; [Tunable] protected static bool kOverrideGrillsSettings = true; [Tunable] protected static bool kOverrideFirepitsSettings = true; // fireplace settings [Tunable] protected static float fireplaceChanceCatchFire = 0; [Tunable] protected static float fireplaceChanceCatchFireWhenNoSimsInRoom = 0; // firepits settings [Tunable] protected static float firepitChanceCatchFire = 0; [Tunable] protected static float firepitChanceCatchFireWhenNoSimsInRoom = 0; // stove settings [Tunable] protected static float stoveChanceOfRandomFireAfterFailure = 0; [Tunable] protected static int stoveCanCatchFire = 0; // grill settings [Tunable] protected static float grillChanceOfRandomFireAfterFailure = 0; [Tunable] protected static int grillCanCatchFire = 0; // bonfire settings [Tunable] protected static float bonfireChanceToStartFireSpread = 0; // variable used to remove the listener private static EventListener listenerOnObjectBought; static Instantiator() { World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler); World.OnWorldQuitEventHandler += new EventHandler(OnWorldQuitHandler); } private static void ApplySettingsToObject(IGameObject obj) { if (obj is Fireplace) { Fireplace fp = obj as Fireplace; if (fireplaceChanceCatchFire != -1f) fp.TuningFireplace.kChanceCatchFire = fireplaceChanceCatchFire; if (fireplaceChanceCatchFireWhenNoSimsInRoom != -1f) fp.TuningFireplace.kChanceCatchFireWhenNoSimsInRoom = fireplaceChanceCatchFireWhenNoSimsInRoom; } else if (obj is FirePit) { FirePit fp = obj as FirePit; if (firepitChanceCatchFire != -1f) fp.TuningFireplace.kChanceCatchFire = firepitChanceCatchFire; if (firepitChanceCatchFireWhenNoSimsInRoom != -1f) fp.TuningFireplace.kChanceCatchFireWhenNoSimsInRoom = firepitChanceCatchFireWhenNoSimsInRoom; } else if (obj is Stove) { Stove fp = obj as Stove; if (stoveChanceOfRandomFireAfterFailure != -1f) fp.StoveTuning.ChanceOfRandomFireAfterFailure = stoveChanceOfRandomFireAfterFailure; if (stoveCanCatchFire != -1f) { if (stoveCanCatchFire == 0) fp.StoveTuning.CanCatchFire = false; else fp.StoveTuning.CanCatchFire = true; } } else if (obj is Grill) { Grill fp = obj as Grill; if (grillChanceOfRandomFireAfterFailure != -1f) fp.GrillTuning.ChanceOfRandomFireAfterFailure = grillChanceOfRandomFireAfterFailure; if (grillCanCatchFire != -1) { if (grillCanCatchFire == 0) fp.GrillTuning.CanCatchFire = false; else fp.GrillTuning.CanCatchFire = true; } } } protected static ListenerAction OnObjectBought(Event e) { try { if (e.TargetObject is Fireplace) { if (kOverrideFireplacesSettings) ApplySettingsToObject(e.TargetObject as Fireplace); } else if (e.TargetObject is FirePit) { if (kOverrideFirepitsSettings) ApplySettingsToObject(e.TargetObject as FirePit); } else if (e.TargetObject is Stove) { if (kOverrideStovesSettings) ApplySettingsToObject(e.TargetObject as Stove); } else if (e.TargetObject is Grill) { if (kOverrideGrillsSettings) ApplySettingsToObject(e.TargetObject as Grill); } } catch (Exception) { } return ListenerAction.Keep; } public static void OnWorldLoadFinishedHandler(object sender, EventArgs e) { List<IGameObject> list = new List<IGameObject>(); if (kOverrideFireplacesSettings) list.AddRange(Sims3.Gameplay.Queries.GetObjects<Fireplace>()); if (kOverrideFirepitsSettings) list.AddRange(Sims3.Gameplay.Queries.GetObjects<FirePit>()); if (kOverrideStovesSettings) list.AddRange(Sims3.Gameplay.Queries.GetObjects<Stove>()); if (kOverrideGrillsSettings) list.AddRange(Sims3.Gameplay.Queries.GetObjects<Grill>()); foreach (IGameObject current in list) { ApplySettingsToObject(current); } if (bonfireChanceToStartFireSpread != -1f) BonFire.kChanceToStartFireSpread = bonfireChanceToStartFireSpread; listenerOnObjectBought = EventTracker.AddListener(EventTypeId.kBoughtObject, new ProcessEventDelegate(OnObjectBought)); } public static void OnWorldQuitHandler(object sender, EventArgs e) { EventTracker.RemoveListener(listenerOnObjectBought); } } }
EDIT: The code applies the settings only to regularly bought items, those placed while
in Edit Town Mode won't be affected until the game is saved and reloaded. This could
be fixed though. As soon as I recover the solution I'll update this message.
EDIT2: One possible solution, suggested by Sims_MX, is to use OnObjectPlacedInLotEventHandler.
Code:
private static void OnWorldLoadFinished(object sender, EventArgs e) { World.sOnObjectPlacedInLotEventHandler += new EventHandler(Main.OnObjectPlacedInLot); } private static void OnObjectPlacedInLot(object sender, EventArgs e) { World.OnObjectPlacedInLotEventArgs args = e as World.OnObjectPlacedInLotEventArgs; if (args != null) { GameObject o = GameObject.GetObject(args.ObjectId); if (o != null) { // Do the same things done in OnObjectBought } } }
The script in the package still uses the first version,
I quoted the alternate solution only for learning purposes.
EDIT3: I've updated the mod, now the settings are always applied to "new" objects.
Attached files:
Arsil_FireProofFireplacesAndCo.package.zip (3.4 KB, 16 downloads) - View custom content | ||||||||||
9014 06-07-2015 17:24 Arsil_FireProofFireplacesAndCo.package --------- ------- 9014 1 file |
Advertisement
Mad Poster
#2
19th Jan 2015 at 2:54 AM
Posts: 2,790
Thanks: 5029 in 40 Posts
Just a thought but is the spell Fire Blast involved in setting fires on objects/sims?
#3
19th Jan 2015 at 9:01 AM
Posts: 997
Thanks: 22101 in 95 Posts
I don't have Supernaturals and I've found no clear answer with a quick search. Let me check the code...
There are other factors and side effects (like removing the frozen and cold moodlets) to keep into
consideration, but it will take me too much time to list every condition and consequence, let's focus
on catching fire and death hazard.
If used on sims:
* if the cast doesn't fail, there's a 25% chance (XML tunable) that the targeted sims will catch on fire,
otherwise they will be singed. If the spell epic-fails then the caster will be singed.
If used on statue of frozen sims:
* If the spell doesn't fail, there's a 1% chance (XML tunable) that the targeted sims will catch on fire
If used on terrain:
if the spell doesn't fail, the spot where the spell was cast is set on fire and sims and objects are in
jeopardy to catch fire following the general fire spreading/catching rules of the game.
There are other factors and side effects (like removing the frozen and cold moodlets) to keep into
consideration, but it will take me too much time to list every condition and consequence, let's focus
on catching fire and death hazard.
If used on sims:
* if the cast doesn't fail, there's a 25% chance (XML tunable) that the targeted sims will catch on fire,
otherwise they will be singed. If the spell epic-fails then the caster will be singed.
If used on statue of frozen sims:
* If the spell doesn't fail, there's a 1% chance (XML tunable) that the targeted sims will catch on fire
If used on terrain:
if the spell doesn't fail, the spot where the spell was cast is set on fire and sims and objects are in
jeopardy to catch fire following the general fire spreading/catching rules of the game.
Who Posted
|