Welcome to
Mod The Sims
Online: 1340
News:
Have an account? Sign in:
pass:
If you don't have an account, why not sign up now? It's free!
Other sites: SimsWiki
Reply  Replies: 52 (Who?), Viewed: 2716 times.
Search this Thread
Old 15th May 2020, 7:35 AM #26
zoe22
Trainee Moderator

Join Date: Aug 2014
Posts: 325
Thanks: 993 in 8 Posts
12 Achievements


If you look at the pure modding tutorial (Here) it explains this:
Quote:
Now might be a good moment to explain why we do this. C# or better the .NET framework has some concrete rules. We will "exploit" one of these rules to get our script up and running in TS3. This rule goes as follows: The first time a static field, property or method of a class gets accessed, the static constructor of that class will be called. That is to make sure that everything is in decent shape before the class has to interact with the rest of the world.

S3 on the other hand parses all XML resources, and assigns the tunable values it finds in there to the related variables in the related classes.

And this means custom code can be run, because the game can find it when it is assigning the values of tunable variables that it finds in the the xml files. When the variable in the class is being accessed to be assigned the value found in the xml, the constructor of the class is called, which means the class is made and put into action, and so your code will be run.
At least that's what I understand of it, and sorry if this is actually more confusing!

So basically your tunable instantiator variable in the Instantiator class (neither actually need to be called Instantiator I'm pretty sure, but I guess the name just describes what it's doing) can be assigned a value by an xml file (because it's tunable) and so you make your xml file (in the pure scripting tutorial) which the game will read, and because the game assigns all variables found in xmls, it will access the Instantiator variable in your code, and in turn the Instantiator class will be "instantiated", running your code basically.

Basically you need two things, a variable in your code (can be any thing but for example a bool called Instantiator), and an xml file in your package file that assigns the variable some value (so like kinstantiator = true). And the tutorial tells you how to make your xml resource

Hope this makes sense, the tutorial I linked does explain how it actually works but it took me a while to get it and I think it's easier to do stuff when you actually understand what's happening, so I thought id try to explain it in more detail
Old 15th May 2020, 10:47 AM #27
Lyralei
Virtual gardener



Join Date: Dec 2013
Posts: 3,095
Thanks: 3443 in 22 Posts
24 Achievements


(Here's also a part in the tutorial, see "Writing the XML"┬*http://www.modthesims.info/wiki.php...ripting_Modding )

Also make sure to add something like:
[Tunable] protected static bool kInstantiator = false;
(Or name it anything else, like Zoe mentioned ┬*but then in the XML you also need to change the kInstantiator' part:┬* <kInstantiator value="True" /> To something you added in your C# code
Old 5th Sep 2020, 8:40 PM #28
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


*walks into this thread 3 months later, but with starbucks this time*

Hey...hey...how y'all doin'?

Long story short, I took a break from this project due to personal reasons and this project, while very loved and wanted to be seen to completion, was not helping me cope with those personal reasons. So I'm pretty stable now and ready to open it up and take it back on. I've reread this thread a few times to refresh myself and I think I'm getting somewhere now, I just need to go very, very slow. While I'm here though, I wanted to ask how I could get ILSpy working with SharpDevelop? It says to install the ILSpy Addin but I can't find that specific file anywhere; on the internet or on my computer.

Oh c'mon. There better be a point to all this stress I'm under.
Old 5th Sep 2020, 10:43 PM #29
zoe22
Trainee Moderator

Join Date: Aug 2014
Posts: 325
Thanks: 993 in 8 Posts
12 Achievements


You don't actually need to get them working together as far as I know. There is also a ILSpy addon for Visual Studio though I haven't worked out how it works :P
IlSply just decompiles the game dlls so you can see the game code and copy paste/use as a reference etc. The you use Sharp Develop to write your code and compile it ┬*
Honestly I'm not sure what the ILSpy plugins actually do.
Old 6th Sep 2020, 12:46 AM #30
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Quote:
Originally Posted by zoe22
You don't actually need to get them working together as far as I know. There is also a ILSpy addon for Visual Studio though I haven't worked out how it works :P
ILSpy just decompiles the game dlls so you can see the game code and copy paste/use as a reference etc. The you use Sharp Develop to write your code and compile it ┬*
Honestly I'm not sure what the ILSpy plugins actually do.


That's why I want to get it to work with SharpDevelop!

Oh c'mon. There better be a point to all this stress I'm under.
Old 6th Sep 2020, 1:34 PM #31
zoe22
Trainee Moderator

Join Date: Aug 2014
Posts: 325
Thanks: 993 in 8 Posts
12 Achievements


Quote:
Originally Posted by LittleCheshire
That's why I want to get it to work with SharpDevelop!
I'm confused :p
What exactly do you need to get it working with SharpDevelop for?
You should just be able to open the game dlls with IlSpy to see all the game code, which you can then use to write your own script in SD - I'm not sure why you would need the plugin for that to work?

Adding the references to your project is a separate thing - when I meant use as a reference, I just meant see how the game code works so you can work out what you need to do to get your own code to function how you want it. Sorry if that was what confused you
Old 6th Sep 2020, 2:23 PM #32
Battery
Field Researcher

Join Date: Dec 2008
Posts: 385
Thanks: 827 in 5 Posts
8 Achievements


Im not completely sure since my setup dates back some time by now but as far as i know SD already has the ilspy functionality included by default.
To test my hypothesis just write a simple Test.
Code:
[Tunable] internal static bool kInstantiator = false;


do a right click on [Tunable] and see if you can select Go to Definition this should show you the decompiled version from the source dll

other than that im also puzzled why you dont use ilspy directly.
Last edited by Battery : 6th Sep 2020 at 2:54 PM.
Old 6th Sep 2020, 3:38 PM #33
Lyralei
Virtual gardener



Join Date: Dec 2013
Posts: 3,095
Thanks: 3443 in 22 Posts
24 Achievements


Quote:
Originally Posted by Battery
Im not completely sure since my setup dates back some time by now but as far as i know SD already has the ilspy functionality included by default.
To test my hypothesis just write a simple Test.
Code:
[Tunable] internal static bool kInstantiator = false;


do a right click on [Tunable] and see if you can select Go to Definition this should show you the decompiled version from the source dll

other than that im also puzzled why you dont use ilspy directly.
This is btw the same for Visual studio as well, if you happen to use that instead ┬*It's quite nifty though! Personally I only use ILSpy when i'm searching through multiple dlls, rather than one class. Else it's indeed what battery suggested.
Old 6th Sep 2020, 7:10 PM #34
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Quote:
Originally Posted by zoe22
I'm confused. What exactly do you need to get it working with SharpDevelop for? You should just be able to open the game dlls with IlSpy to see all the game code, which you can then use to write your own script in SD - I'm not sure why you would need the plugin for that to work? Adding the references to your project is a separate thing - when I meant use as a reference, I just meant see how the game code works so you can work out what you need to do to get your own code to function how you want it. Sorry if that was what confused you.


Nope! I understood what you meant perfectly. ILSpy works separately, but I wanted to have it in SharpDevelop as a plugin as it would save me some time. But hey, If I can't use it as a plugin that's fine! Water off a ducks back, honestly.

Quote:
Originally Posted by Battery
Im not completely sure since my setup dates back some time by now but as far as i know SD already has the ilspy functionality included by default.
To test my hypothesis just write a simple Test.
Code:
[Tunable] internal static bool kInstantiator = false;


do a right click on [Tunable] and see if you can select Go to Definition this should show you the decompiled version from the source dll. other than that im also puzzled why you dont use ilspy directly.


That actually doesn't work for me, unfortunately. We might be using different versions of SharpDevelop! I wanted to use ILSpy from the plugin in SharpDevelop to save time and space, but using it directly is fine as well and that's what I'm going to start doing from this point onwards.

I'll come back here if I need help with anything else or want to ask more questions!

Oh c'mon. There better be a point to all this stress I'm under.
Old 7th Sep 2020, 3:40 AM #35
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


*coughs*

Quick question @Lyralei

Does the Object Modding (Interactions) tutorial also apply to adding interactions to terrains like grass, sand, and the ocean, instead of objects? Are there any differences at all that I should know of?

Oh c'mon. There better be a point to all this stress I'm under.
Old 7th Sep 2020, 10:40 AM #36
Lyralei
Virtual gardener



Join Date: Dec 2013
Posts: 3,095
Thanks: 3443 in 22 Posts
24 Achievements


Quote:
Originally Posted by LittleCheshire
*coughs*

Quick question @Lyralei

Does the Object Modding (Interactions) tutorial also apply to adding interactions to terrains like grass, sand, and the ocean, instead of objects? Are there any differences at all that I should know of?
It uses the same concept, but it actually requires 'finding the objects' (even sims and terrain┬*┬*) and 'injecting' the interaction. I always open this tutorial for that:┬*http://www.simlogical.com/ContentUp..._script_mod.pdf

The tutorial you linked though is if you make your own object and want it to do particular things ┬*Now, if you were to want to do stuff for water/sand or anything terrain like, it's actually good practise to first see what the existing interactions link to, or even do for that matter . EA made a TON of different interaction variations (think, immediate interaction, actorless interaction, etc), and half of them are really just used for 5 interactions or so.┬*

Let me know though if you need some more help with that though! Since the first few reads it tends to be a bit overwhelming to fully understand all of that
Old 7th Sep 2020, 11:41 AM #37
zoe22
Trainee Moderator

Join Date: Aug 2014
Posts: 325
Thanks: 993 in 8 Posts
12 Achievements


And here I was completely clueless about the ILSpy plugin and just using it separately all this time :P
Old 19th Sep 2020, 10:11 PM #38
aino
Test Subject

Join Date: Mar 2005
Posts: 10


Got my little hello world working and it was much less hassle than I expected. The build succeeded in the first try but I had to tweak a little the code to get the message showing.

My experiences about getting simple hello world to run:
1. Project configurations seem to be in .csproj -file. I took advantage of the csproj-files of other sims mods and didn't bother to find all the right settings from visual studio 2019 user interface. My project file could probably use some fine tuning. For example, I don't know if you need all the sims sources, unless you use them.
2. I skipped the part with reflector and took sims dlls from Nraas github. They had some differences to the original version, but they seem to be working... at least for Hello World -purposes.
3. The hello world was written without Reflector or IlSpy, but I installed IlSpy after making it. I couldn't get IlSpy Visual Studio add-on working out of the box. Standalone version seems to be fine. I would be nice to find smarter workflow to view the code, though.
4. Visual studio is either clunky or I can't use it. Next step might be looking for nicer IDE.
Screenshots
Click image for larger version

Name:  hello.jpg
Views: 0
Size:  11.4 KB  
Old 1st Nov 2020, 5:25 AM #39
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Okay so basically, I have three coding projects I'm working on and I'm bouncing between the three of them like a kangaroo on crack because I have nothing too serious on my plate at the moment that will keep me away from coding and learning how to do it. Right now I'm dedicating time to the second project; which is me adding a new social interaction into the game that requires me to modify an existing social interaction in the game. I was wondering how I could give this existing interaction a new definition? I can post what little code I already have, if that helps as well.

There are mods out there that would be very helpful to me if I could like, see their code and see how they Do The Thing, but every time I run them through S3PE all I see is gibberish!

Oh c'mon. There better be a point to all this stress I'm under.
Old 6th Nov 2020, 12:26 AM #40
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Okay actually, I retract that upper statement! I'm pretty sure I got that new definition thing down. I only have a very quick question: are internal sealed classes derivable? I'm trying to derive from an interaction that is an internal sealed class but IntelliSense or whatever autofill feature SharpDevelop has isn't picking it up. Can I use the internal sealed class anyway and the autofill feature not picking it up isn't a problem?

Oh c'mon. There better be a point to all this stress I'm under.
Old 6th Nov 2020, 8:11 AM #41
Battery
Field Researcher

Join Date: Dec 2008
Posts: 385
Thanks: 827 in 5 Posts
8 Achievements


No you cant
The sole purpose of the sealed keyword is to prevent Inheiretance (there is a "funny" statement that says that people who use the sealed keyword should be sealed away themselfs because its just stupid in most cases )
Old 6th Nov 2020, 8:40 AM #42
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Oh, I see! Thanks.

GODDAMNIT EA.

Oh c'mon. There better be a point to all this stress I'm under.
Old 7th Nov 2020, 12:53 AM #43
PuddingFace
Scholar

Join Date: Aug 2014
Posts: 1,065
Thanks: 1565 in 30 Posts
9 Achievements


@LittleChesire Modify an existing social interaction? Which interaction cause a lot of them are coded differently. Some of the social interactions are just all SocialInteractionA or something.

If you like my mods. Consider supporting me on Patreon

Follow me on
Twitter
Instagram
Old 7th Nov 2020, 8:52 AM #44
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Hello @PuddingFace

The interaction I want to modify is indeed a SocialInteractionA interaction; it's the Pet Fight interaction and I want to have it to where it has a chance of killing the target. I also want this action to be autonomous for pets with specific traits, and for the Sims being attacked to have a chance of surviving depending on traits, athletic skill, or both.

Oh c'mon. There better be a point to all this stress I'm under.
Old 7th Nov 2020, 8:58 AM #45
PuddingFace
Scholar

Join Date: Aug 2014
Posts: 1,065
Thanks: 1565 in 30 Posts
9 Achievements


Do you see the interaction's ITUN file or code? If not then you can't modify.

I will instead recommend that you disable this interaction with an ITUN and create a new fight interaction for pets. And then you can do what you want with this new interaction.

If you like my mods. Consider supporting me on Patreon

Follow me on
Twitter
Instagram
Old 7th Nov 2020, 11:48 AM #46
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Well let's see, lookin' through S3PE I can see the ITUN file for the interaction and lookin' through ILSpy I can see the interaction's code. So going of your words I can modify the interaction into a custom one.

Although, creating a new interaction? That sounds excellent, I would love to do that except...I don't know how. I'm just barely grasping how to use existing interactions and code to cobble together an interaction by going off these tutorials:

https://modthesims.info/wiki.php?ti...Depth_Scripting

https://modthesims.info/showthread.php?t=491875

Also, disabling the Fight Pet interaction with an ITUN? I don't want to replace the Fight Pet interaction with my own.

Oh c'mon. There better be a point to all this stress I'm under.
Old 7th Nov 2020, 1:42 PM #47
Lyralei
Virtual gardener



Join Date: Dec 2013
Posts: 3,095
Thanks: 3443 in 22 Posts
24 Achievements


Quote:
Originally Posted by LittleCheshire
Hook into the custom buff code that is used for store buffs, got it. I understand that. As for having an instantiator xml, I actually don't think I have that? I have an instantiator, "Cheshirefrown", but not an instantiator xml I don't think. How do I get that? I looked around and the links to the example instantiator class and instantiator xml to import into S3PE are dead.
Dead as in... they don't react to 'true/false'? :p┬*Because if you got an instantiator called 'Cheshirefrown' in your C# script, you also need to name it 'Cheshirefrown' where the tutorials would have used 'kInstantiator'

So:
(C# code snippet:
Code:
[Tunable]
protected static bool Cheshirefrown = false;
XML:
Code:
´╗┐<?xml version="1.0" encoding="utf-8"?>
<base>
┬* <Current_Tuning>
┬* ┬* <Cheshirefrown value="True">
┬* ┬* ┬* <!-- Scripting Mod Instantiator, value does not matter, only its existence -->
┬* ┬* </Cheshirefrown>
┬* </Current_Tuning>
</base>
I also usually hash the XML file like so: "NAMEPSPACE.CLASSNAME". With has I mean, you double click on the XML file in S3PE, you see the 'name' input field. You paste in the correct Namespace + Classname and click 'FNV64' ┬*Because if I recall correctly, else the code can't find the right XML file for the tunable?

Else, which is a super rare thing to happen, it's really just the website's encoding that notepad (or notepad++, whatever text editor you're using) that isn't compatible with the sims 3. And therefore it wouldn't read it. At least I had that happen to me after I copied it from another file I downloaded... But I doubt it's that. Just a heads up that it COULD be that.┬*

Hope this helps!
Old 7th Nov 2020, 3:48 PM #48
PuddingFace
Scholar

Join Date: Aug 2014
Posts: 1,065
Thanks: 1565 in 30 Posts
9 Achievements


Quote:
Originally Posted by LittleCheshire
Well let's see, lookin' through S3PE I can see the ITUN file for the interaction and lookin' through ILSpy I can see the interaction's code. So going of your words I can modify the interaction into a custom one.

Although, creating a new interaction? That sounds excellent, I would love to do that except...I don't know how. I'm just barely grasping how to use existing interactions and code to cobble together an interaction by going off these tutorials:

https://modthesims.info/wiki.php?ti...Depth_Scripting

https://modthesims.info/showthread.php?t=491875

Also, disabling the Fight Pet interaction with an ITUN? I don't want to replace the Fight Pet interaction with my own.


Oh you will have to create a new interaction anyway if you want to change an EA interaction with script. You will have to replace the EA interaction with yours using script. If the interaction didn't have ITUN or code then you will have to remove the interaction with tuning and add your custom interaction in.

It's not too hard to create your own interaction.

If you like my mods. Consider supporting me on Patreon

Follow me on
Twitter
Instagram
Old 8th Nov 2020, 1:27 AM #49
LittleCheshire
Original Poster

Lab Assistant

Join Date: Aug 2018
Posts: 188
Thanks: 105 in 1 Posts
3 Achievements


Thanks for the explanation, Lyralei! I figured that out a while ago, and have learned a lot since then, but I genuinely thank you for laying the information out like that; I understand Instantiators and XMLs completely now!

It's not too hard to create a custom interaction? So does this mean I'm on the right track of following this tutorial?

Oh c'mon. There better be a point to all this stress I'm under.
Old 8th Nov 2020, 2:35 PM #50
PuddingFace
Scholar

Join Date: Aug 2014
Posts: 1,065
Thanks: 1565 in 30 Posts
9 Achievements


Yea that tutorial will help you get started. You will learn to make an immediate interaction. And then with that you can make a regular interaction with animations as well.

If you like my mods. Consider supporting me on Patreon

Follow me on
Twitter
Instagram
Reply


Section jump:


Powered by MariaDB Some icons by http://dryicons.com.