View Full Version : Changing a Buff's Origin/Description
Sims MX
3rd Aug 2010, 08:21 PM
Hello!
I'm new to scripting mods and I started my first project. What I wanted to do is to add and remove buffs (Saving and Wasting the Environment respectively) to Eco-Friendly Sims that drive the Reanult Twizy or Toyota Prius. Because they are eco-friendly cars, aren't they?
After following Kolipoki's tutorial and looking at the .dlls with the Reflector, I was able to add and remove the buffs to the two cars. However the buff says "From Riding a Bike". Is there a way to change this to "From Driving an Electric Car" or "From Driving an Hybrid Car"? (Twizy and Prius respectively).
See the second screenshot, is there a way to change the buff's description?
twallan
3rd Aug 2010, 09:41 PM
Is there a way to change this to "From Driving an Electric Car" or "From Driving an Hybrid Car"? (Twizy and Prius respectively).
The Buff you mentioned is normally set in the Vehicle.OnCarEntered() function. In that routine is this line:
s.BuffManager.AddElementPaused(BuffNames.SavingTheEnvironment, Origin.FromRidingBike);
The "Origin.FromRidingBike" defines the description you are attempting to change.
However, the Core does not have a FromRidingHybrid or FromRidingElectricCar origin available.
One could try adding your own custom Origin, never tried it myself. The trick is whether the Core will provide a proper translation key for you to use in your STBL.
Good Luck. :)
Sims MX
4th Aug 2010, 01:14 AM
Thanks for the answer! I'll try to do that. However I'm not sure how to implement it.
In order to remove the Wasting Natural Resources and add the Saving the Environment moodlets, I wrote this script:
namespace Sims3.Gameplay.Objects.Vehicles
{
public class CarPriusV : CarSedan
{
// Properties
public override bool AddSavingTheEnvironmentBuff
{
get
{
return true;
}
}
public override bool AddWastingNaturalResourcesBuff
{
get
{
return false;
}
}
}
}
The first part is copied from the "Sims3.Gameplay.Objects.Vehicles.Bicycle" script and the second is from "Sims3.Gameplay.Objects.Vehicles.Car". I just changed the last part to "return false".
The Twizy's script is the same.
:here: Edit:
I've checked, this is the part of the code I have to change:
if (s.HasTrait(TraitNames.EnvironmentallyConscious))
{
[…]
else
{
if (this.AddWastingNaturalResourcesBuff)
{
s.BuffManager.AddElementPaused(BuffNames.WastingNaturalResources, Origin.None | Origin.FromDrivingAlone);
}
if (this.AddSavingTheEnvironmentBuff)
{
s.BuffManager.AddElementPaused(BuffNames.SavingTheEnvironment, Origin.FromRidingBike);
}
}
}
I just have to add another if and put my custom buff origin there. Something like this:
if (s.HasTrait(TraitNames.EnvironmentallyConscious))
{
[…]
else
{
if (this.AddWastingNaturalResourcesBuff)
{
s.BuffManager.AddElementPaused(BuffNames.WastingNaturalResources, Origin.None | Origin.FromDrivingAlone);
}
if (this.AddSavingTheEnvironmentBuff)
{
if (this.IsElectric) {
s.BuffManager.AddElementPaused(BuffNames.SavingTheEnvironment, CustomOrigin.FromDrivingElectricCar);
}
else
{
if (this.IsHybrid)
{
s.BuffManager.AddElementPaused(BuffNames.SavingTheEnvironment, CustomOrigin.FromDrivingHybridCar);
}
else
{
s.BuffManager.AddElementPaused(BuffNames.SavingTheEnvironment, Origin.FromRidingBike);
}
}
}
}
}
Is it possible if I create a custom origin enum? Or do I have to modify the existing one? If I have to modify an existing "enum", do I just include it in my script or what do I have to do in order for it to override the original one?
Custom Origin example:
public enum CustomOrigin : uLong {
FromDrivingElectricCar = 10086937407548655473L,
FromDrivingHybridCar = 10086937407548655474L
}BTW how are those large "numbers" determined? I made those up. Are they random or is there something like a hash function somewhere?
And as Twallan said, determining the STBL key would not be easy.
twallan
4th Aug 2010, 06:20 PM
Is it possible if I create a custom origin enum? Or do I have to modify the existing one? If I have to modify an existing "enum", do I just include it in my script or what do I have to do in order for it to override the original one?
To inject a new Origin value, I would do the following:
1) Run FNV64 on the name you intend to use to produce a large unique number.
2) Then force convert that number into an Origin value, using:
(Origin)yourreallylargenumber
The value doesn't actually need to be a true element of the "Origin" enum in the Core, provided the number you use is brand new.
From there, use a SimIFace core-mod that displays you untranslated keys. My ScriptError mod will do such for instance.
In the game you will then see the untranslated key in the description. Something that looks like:
"Gameplay/Excel/buffs/BuffOrigins:<something>"
I know the key prefix is such, since that is the element used in HudModel.GetBuffDescription().
However, I don't know what the <something> will be in your case.
Good Luck. :)
Sims MX
5th Aug 2010, 12:46 AM
Thanks! I'll try that! What I did was to change the default string to something general: "From Eco-Friendly Vehicle". But I'll see if I can add a custom origin so each one (bike, electric and hyrbid car) has a custom origin.
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.