tModLoader Official tModLoader Help Thread

Help
How I can use knockback resistance in my shield?
Because I use item.knockBackResist anddont work
I use in effects player.knockBackResist without success
Please help and sorry for bad English
 
I know i made a thread asking this question and i really didn't mean to but i'm not too sure how to delete it :p but i thought i would most likely get more help here. All i'm really looking for is the code for King Slime or the Eoc and just a simple slime npc code the abomination's code is hard for me to work with(again i am really sorry for pasting a thread about this and then posting this here i just thought it would be a better idea and i am not sure how to delete that thread :p)
 
I know i made a thread asking this question and i really didn't mean to but i'm not too sure how to delete it :p but i thought i would most likely get more help here. All i'm really looking for is the code for King Slime or the Eoc and just a simple slime npc code the abomination's code is hard for me to work with(again i am really sorry for pasting a thread about this and then posting this here i just thought it would be a better idea and i am not sure how to delete that thread :p)
The best thing you can do is the following:
  1. Download a program called 'IlSpy'.
  2. Drag and drop your Terraria.exe file (from the steam folder) into the IlSpy program.
  3. Look in the Terraria namespace and double click NPC.cs (might take a little while to decompile).
  4. [OPTIONAL] Copy + paste all the code from the NPC.cs into a file, which you can then open with notepad++ (makes scrolling and searching easier).
  5. Search for King Slime and you'll get to see the SetDefaults of the KingSlime NPC.
  6. In there you'll see the type check (else if (type == blabla)) take note of the value that is displayed there.
  7. You'll also see something like 'this.aiStyle = ' take note of the value of that too.
  8. You can then search for aiStyle == theTypeAIStyleYouNotedEarlier to search for the aiStyle that corresponds with the one from King Slime.
  9. This will contain the code of the King Slime, so now you can just scroll through this.
You can use this for all different NPCs.
 
I use the same code of h "exemple shield" found in exemple mod by bluemagic123,but I put the code " player.knockBackResist = of;"
sorry but i dont have here my code,because i work in mod for tmodloader in other pc,not that i'm using Sorry
 
The best thing you can do is the following:
  1. Download a program called 'IlSpy'.
  2. Drag and drop your Terraria.exe file (from the steam folder) into the IlSpy program.
  3. Look in the Terraria namespace and double click NPC.cs (might take a little while to decompile).
  4. [OPTIONAL] Copy + paste all the code from the NPC.cs into a file, which you can then open with notepad++ (makes scrolling and searching easier).
  5. Search for King Slime and you'll get to see the SetDefaults of the KingSlime NPC.
  6. In there you'll see the type check (else if (type == blabla)) take note of the value that is displayed there.
  7. You'll also see something like 'this.aiStyle = ' take note of the value of that too.
  8. You can then search for aiStyle == theTypeAIStyleYouNotedEarlier to search for the aiStyle that corresponds with the one from King Slime.
  9. This will contain the code of the King Slime, so now you can just scroll through this.
You can use this for all different NPCs.
I could not seem to find it the one i did not(not sure if it's the right one or not) seems to freeze my pc or the program stops responding. This only happens when it starts to decompile the npc and nothing else lol
 
I could not seem to find it the one i did not(not sure if it's the right one or not) seems to freeze my pc or the program stops responding. This only happens when it starts to decompile the npc and nothing else lol
Hmm, you might want it to keep 'not responding' for a little while then (it freezes on me too :p ).
 
one more thing. Is there any way you can get a vanilla NPC to drop a custom Item. I could not find this in the example mod(sorry if i am asking too many questions or if they are stupid. Don't wanna be a bother :p)
 
one more thing. Is there any way you can get a vanilla NPC to drop a custom Item. I could not find this in the example mod(sorry if i am asking too many questions or if they are stupid. Don't wanna be a bother :p)
I guess you do like the example item dropping but specify npc for it.
 
Last edited:
you know, i saw the ExambleGlobalNPC.ce file but i really thought it was for the ExampleNPC and not a global code. Thanks i would of never figured that out XD but how do you get a specific mob to drop something or is that in the GlobalNpc.cs file as well?
What I linked you shows specific drops for DukeFishron. If you are doing a ModNPC you can do that in it's own NPCDrop method.
 
Help me, how to make custom ranged weapon and magic weapon?
To add new modded items you'll need to make your own ModItem. Feel free to look at the .cs files inside ExampleMod/Items for examples.
You can set a weapon's damage type by setting it's property for it to true. There is: item.melee, item.ranged, item.magic and item.summon. You'll want to do this in it's SetDefaults()
 
Back
Top Bottom