tModLoader Official tModLoader Help Thread

So what should I put if Forest and Underworld don't have flags?
I looked into Terrarias code and this is approximately how it checks biomes for mob drops/spawns:
Code:
NPC npc = this.npc;
Player player = Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)];
int tileX = (int)(player .Center.X / 16f);
int tileY = (int)(player .Center.Y / 16f);
bool inSky = (double)tileY < Main.worldSurface * (Main.hardMode? 0.44999998807907104 : 0.34999999403953552);

if ((tileX < 250 || tileX > Main.maxTilesX - 250) && tileY < Main.rockLayer && !inSky)
{
    //In the Ocean biome
}
if (tileY > Main.maxTilesY - 190)
{
    //In the Underworld
}
if (tileY < Main.worldSurface && !inSky && !player.ZoneCorrupt && !player.ZoneCrimson && !player.ZoneHoly && !player.ZoneJungle && !player.ZoneSnow && !player.ZoneDesert && !player.ZoneGlowshroom)
{
    //In the Forest
    if (!player.ZoneMeteor && !player.ZoneTowerSolar && !player.ZoneTowerVortex && !player.ZoneTowerNebula && !player.ZoneTowerStardust)
    {
        //Strictly no other biomes
    }
}
Note, that this code is intended to work inside of a class deriving from ModNPC (for example in the NPCLoot() method of your custom mob). If you want to check biomes elsewhere in your code, you will have to adjust the first two lines to fit your situation.
 
Is it possible to use this tool to change the number of songs associated with each biome?

Say I wanted to increased the number of songs of Underworld from 1 to 2 (which would play randomly), or to change the number of songs of Forest from 2 to 4.
 
If it's not working, or you're unsure of what you're doing, do leave a message here!
And happy to help.
help please (bad english coming)
You knows how make a custom NPC Spawn in events,like blood moon? and how make to put the Spawn only to Hardmode or only to pre hardmode?If possible give me a code with this example
I try make a cool mod,but I dont knows much of codes,I like to make sprites :)
Thanks to read!Bye.
 
help please (bad english coming)
You knows how make a custom NPC Spawn in events,like blood moon? and how make to put the Spawn only to Hardmode or only to pre hardmode?If possible give me a code with this example
I try make a cool mod,but I dont knows much of codes,I like to make sprites :)
Thanks to read!Bye.

Use VisualStudio for that: I have just put Main.h and he give me : Main.hardMode who is a bool for know if yes or not, we are in hardmode. After, you need just put in item who spawn event: public override bool CanUseItem(Player player)
For NPC spawn in events like blood Moon, i have not idea for the moment.
 
Use VisualStudio for that: I have just put Main.h and he give me : Main.hardMode who is a bool for know if yes or not, we are in hardmode. After, you need just put in item who spawn event: public override bool CanUseItem(Player player)
For NPC spawn in events like blood Moon, i have not idea for the moment.
I will try but... you knows a mod that I can "open" in tModRead to "study",because I dont know make a complete code :( The mod that I make is 80% make based in ExempleMod ans I using the codes found him
Sorry for my poor english
 
You talk what, so, if you are not english?

ExempleMod is the best for that , he have all example. (Except events, but same the best mod for me(thorium) have not events.)

After, if you do not use visualstudio, this is normal than this is hard for you.

Oh, i talk also bad english because i am not english
 
You talk what, so, if you are not english?

ExempleMod is the best for that , he have all example. (Except events, but same the best mod for me(thorium) have not events.)

After, if you do not use visualstudio, you cannot have a good mod, for me ^^'. (A mod without IDE, this is very too hard...)
I am Brazilian and I never study english,only in high school but with bad teacher,80% of my english I learned with RPG games and music :)
anyway...the most part of the mods dont open in tModReader because the modder creators dont want:( it is the only thing that make to my TAPI better,Tapi mods open with winrar x)
 
I am Brazilian and I never study english,only in high school but with bad teacher,80% of my english I learned with RPG games and music :)
anyway...the most part of the mods dont open in tModReader because the modder creators dont want:( it is the only thing that make to my TAPI better,Tapi mods open with winrar x)
Its good that these isnt is Possible
its more secure that people dont steal Code or Sprites
the Example mod + Youtube Videos are good Enough for LEarning basic mod making
 
Its good that these isnt is Possible
its more secure that people dont steal Code or Sprites
the Example mod + Youtube Videos are good Enough for LEarning basic mod making
Yeah,I understand that this is to "protect" mods,bu I'm not a thief! I only read the codes find in other mods and say" hum...then so is!" not Ctrl+C Ctrl+V!
Anyway...I will try my best,because make mods is a hooby ! anyway thanks !
 
Yeah,I understand that this is to "protect" mods,bu I'm not a thief! I only read the codes find in other mods and say" hum...then so is!" not Ctrl+C Ctrl+V!
Anyway...I will try my best,because make mods is a hooby ! anyway thanks !
But there are some,and having the possiblity to protect your mods is good
you cold realy simple change mod Name and Creator name and Mod homepage link and upload it on Tmodloader,and people whould think its not stolen
 
I looked into Terrarias code and this is approximately how it checks biomes for mob drops/spawns:
Code:
NPC npc = this.npc;
Player player = Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)];
int tileX = (int)(player .Center.X / 16f);
int tileY = (int)(player .Center.Y / 16f);
bool inSky = (double)tileY < Main.worldSurface * (Main.hardMode? 0.44999998807907104 : 0.34999999403953552);

if ((tileX < 250 || tileX > Main.maxTilesX - 250) && tileY < Main.rockLayer && !inSky)
{
    //In the Ocean biome
}
if (tileY > Main.maxTilesY - 190)
{
    //In the Underworld
}
if (tileY < Main.worldSurface && !inSky && !player.ZoneCorrupt && !player.ZoneCrimson && !player.ZoneHoly && !player.ZoneJungle && !player.ZoneSnow && !player.ZoneDesert && !player.ZoneGlowshroom)
{
    //In the Forest
    if (!player.ZoneMeteor && !player.ZoneTowerSolar && !player.ZoneTowerVortex && !player.ZoneTowerNebula && !player.ZoneTowerStardust)
    {
        //Strictly no other biomes
    }
}
Note, that this code is intended to work inside of a class deriving from ModNPC (for example in the NPCLoot() method of your custom mob). If you want to check biomes elsewhere in your code, you will have to adjust the first two lines to fit your situation.
Thank you seems like its what I'm looking for. Haven't had a chance to test it yet though.
 
But there are some,and having the possiblity to protect your mods is good
you cold realy simple change mod Name and Creator name and Mod homepage link and upload it on Tmodloader,and people whould think its not stolen
I had never thought so!But you are right! I can not get a code of other mods, change some numbers or words and use in my mod.:( I will make only things that I know make.
Anyway,I dont find any mod to open in tModReader
[doublepost=1466442973,1466442916][/doublepost]
Thank you seems like its what I'm looking for. Haven't had a chance to test it yet though.
this is to Spawn NPCs?
 
I had never thought so!But you are right! I can not get a code of other mods, change some numbers or words and use in my mod.:( I will make only things that I know make.
Anyway,I dont find any mod to open in tModReader
[doublepost=1466442973,1466442916][/doublepost]
this is to Spawn NPCs?

You can find Tutorials on these Channels

https://www.youtube.com/channel/UCd51TwsyMeAkZjWYkJp-cKQ
https://www.youtube.com/channel/UCIi11PQXlpAT2-8iE4mYYHg

And the Example mod
Thats enough for Basics
 
I had never thought so!But you are right! I can not get a code of other mods, change some numbers or words and use in my mod.:( I will make only things that I know make.
Anyway,I dont find any mod to open in tModReader
[doublepost=1466442973,1466442916][/doublepost]
this is to Spawn NPCs?
Well right now its for drops but I do also want to do NPC spawns that are boime specific soon aswell.
 
How would I make my set bonus for my armour make any weapon give the frostburn effect to any enemy?

public override void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit){
if (this.ArmorSetBonus){
if(Main.rand.Next(20) == 0) target.AddBuff(24, 300, true);
}
}

I put here in my custom modplayer, ArmorSetBonus is set true when you equip set armor.



So cannot help me for my problem of custom rocket? :x
Hey, i have a small problem:

I have a rocket launcher, a rocket launched modded and a modded rocket.

So, with modded weapon where:
item.shoot = mod.ProjectileType("ArmoredRocket");
item.useAmmo = mod.ProjectileType("ArmoredRocket");
and same style for modded rocket.
item.shoot = mod.ProjectileType("ArmoredRocket");
item.ammo = mod.ProjectileType("ArmoredRocket");
I have a correctly rocket(explosion, same aistyle, aitype, etc ). But i want than this rocket can be shoot per vanilla rocket launcher.
So i put
item.shoot = mod.ProjectileType("ArmoredRocket");
item.ammo = 771; (< id of the type rocket)
But here, if vanilla rocket launcher detect ammo, he do not shoot projectile... so, question: I have missed where?


Thank you
 
Last edited:
So cannot help me for my problem of custom rocket? :x
I don't really understand what your problem is. It would help if you could explain again and post the relevant code aswell.

Also, thy to use those neat [C0DE] tags
Code:
//like this
 
I got three questions:
  1. How can I make them hover when S is pressed (Hoverboard)?
  2. How can I make them get a ascend speed boost when W is pressed (Jetpack)?
  3. Can I make them do things other accessories can do?
Can Someone Please Answer my questions?
 
Back
Top Bottom