View Full Version : Making gems unique... like tiberium.
dlane2155
14th Dec 2011, 08:31 PM
So I am trying to make it so that a certain gem has different characteristics than all the other gems. What I have found is that there are two tiberium objects, one large and one regular sized, also two spawners for tiberium. I have also found that all gems are the same object however there are many different spawners for the gems besides tiberium.
Also each gem, no matter what cut or type is the same, ie the resource key is always 0x319E4F1D-0x00000000-0x0000000000000BDE.
I have compared a tiberium spawner to another gem spawner and found no real differences between the two.
I have also compared the tiberium gem object to the other gem object (ie. all other gems) and also found no real differences.
I've been messing around with the gems for that last week trying have a specific gem add or remove a buff when in a sims inventory and so far I've concluded that this can't be done; however I'm new to scripting and maybe I'm missing something.
So, I'd just like a second opinion from someone with more modding/scripting experience than me. Here are my questions.
1. Has anyone done any scripting mods to gems? (From what I've found... no)
2. What in the tiberium gem spawners tells it to create tiberium?
3. Is it possible, with a scripting mod, to separate the gems and make them unique?
-Perhaps by replacing an in game gem spawner's code with something that tells it to make a gem with a different instance number?
PS. The specific gem I am trying to make unique for now is Lapis Lazuli found in China, but I think knowing how to do this for any gem could be useful.
Thanks!
Sims MX
15th Dec 2011, 02:56 AM
I've been messing around with the gems for that last week trying have a specific gem add or remove a buff when in a sims inventory and so far I've concluded that this can't be done; however I'm new to scripting and maybe I'm missing something.
I'm pretty sure it can be done. However, instead of making a new gem class, I would simply use two event listeners ("kInventoryObjectAdded" and "kInventoryObjectRemoved").
Here's an example for the first event listener:
public static ListenerAction OnInventoryObjectAdded(Event evt)
{
Sim a = evt.Actor as Sim;
Gem gem = evt.TargetObject as Gem;
if ((a != null) && (gem != null) && (gem.Guid == RockGemMetal.Lazuli))
{
// do stuff here
}
return ListenerAction.Keep;
}
dlane2155
15th Dec 2011, 03:50 AM
I'm pretty sure it can be done. However, instead of making a new gem class, I would simply use two event listeners ("kInventoryObjectAdded" and "kInventoryObjectRemoved").
Thanks! I will give what you suggest a try.
dlane2155
16th Dec 2011, 05:05 PM
I'm pretty sure it can be done. However, instead of making a new gem class, I would simply use two event listeners ("kInventoryObjectAdded" and "kInventoryObjectRemoved").
I'm not exactly sure what is wrong with my code, but it isn't working. Everything works in VS but it is not working in the game. Here is exactly what my code looks like. Do you know what is wrong with it?
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Objects.Spawners;
using Sims3.Gameplay.Abstracts;
namespace dlane2155
{
public class dlane2155_Lapuzi
{
public static ListenerAction OnInventoryObjectAdded(Event evt)
{
Sim owner = evt.Actor as Sim;
Gem gem = evt.TargetObject as Gem;
if ((owner != null) && (gem != null) && (gem.Guid == RockGemMetal.Lazuli))
{
owner.BuffManager.PauseBuff(BuffNames.HeatingUp);
}
return ListenerAction.Keep;
}
public static ListenerAction OnInventoryObjectRemoved(Event evt)
{
Sim owner = evt.Actor as Sim;
Gem gem = evt.TargetObject as Gem;
if ((owner != null) && (gem != null) && (gem.Guid == RockGemMetal.Lazuli))
{
owner.BuffManager.UnpauseBuff(BuffNames.HeatingUp);
}
return ListenerAction.Keep;
}
}
}
Odistant
17th Dec 2011, 04:12 AM
One reason I can see is that you arent institating the script. Take a look at the first part of this tutorial:
http://simswiki.info/wiki.php?title=Tutorial:Sims_3_Pure_Scripting_Modding
dlane2155
17th Dec 2011, 05:34 AM
One reason I can see is that you arent institating the script. Take a look at the first part of this tutorial:
http://simswiki.info/wiki.php?title=Tutorial:Sims_3_Pure_Scripting_Modding
Are you talking about where he adds "protected static bool kInstantiator = false;"
Sims MX
17th Dec 2011, 11:41 PM
Yep, you're missing that step.
Don't forget to add the event listeners to your "OnWorldLoadFinished" method. Here's an example:
EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, new ProcessEventDelegate(OnInventoryObjectAdded));
dlane2155
23rd Dec 2011, 02:34 AM
Yep, you're missing that step.
Don't forget to add the event listeners to your "OnWorldLoadFinished" method. Here's an example:
EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, new ProcessEventDelegate(OnInventoryObjectAdded));
Do I literally add the event listeners to "OnWorldLoadFinished"? Here is the last code I tried and it also did not work. I have also made sure to remove the Lapis Lazuli from the vampire sims inventory and replace it.
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Objects.Spawners;
using Sims3.Gameplay.Abstracts;
using Sims3.SimIFace;
namespace dlane2155_Lazuli
{
public class dlane2155_Lazuli
{
private static void OnWorldLoadFinished(object sender, EventArgs e)
{
EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, new ProcessEventDelegate(OnInventoryObjectAdded));
EventTracker.AddListener(EventTypeId.kInventoryObjectRemoved, new ProcessEventDelegate(OnInventoryObjectRemoved));
}
public static ListenerAction OnInventoryObjectAdded(Event evt)
{
Sim owner = evt.Actor as Sim;
Gem gem = evt.TargetObject as Gem;
if ((owner != null) && (gem != null) && (gem.Guid == RockGemMetal.Lazuli))
{
owner.BuffManager.PauseBuff(BuffNames.HeatingUp);
}
return ListenerAction.Keep;
}
[Tunable]
protected static bool kInventoryObjectRemoved = false;
public static ListenerAction OnInventoryObjectRemoved(Event evt)
{
Sim owner = evt.Actor as Sim;
Gem gem = evt.TargetObject as Gem;
if ((owner != null) && (gem != null) && (gem.Guid == RockGemMetal.Lazuli))
{
owner.BuffManager.UnpauseBuff(BuffNames.HeatingUp);
}
return ListenerAction.Keep;
}
}
}
I'm not really sure what is wrong with my code.
Buzzler
23rd Dec 2011, 06:08 PM
You need a static constructor for your class - the one with the tunable field. Like that
static dlane2155_Lazuli()
{
World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished);
}
If it doesn't work then, make sure that you have a proper XML for the tunable field.
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.