tModLoader How to make a boss spawn minions after a certain amount of time

So in game, you have 60 ticks per second. Any timer will go up by 60 for every 1 second, so timer == 600 would be at 10 seconds.
 
wait why wont this code work

private int timer = 600;
private int framecount = 0;

public new void OnUpdate(Player player)
{
bool npcExists = NPC.AnyNPCs(mod.NPCType("Desertwormhead"));

if (npcExists)
{
framecount++;
if (framecount <= 60)
{
framecount = 0;
timer--;

if (timer <= 0)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Bruhmouth"));
Main.PlaySound(SoundID.Roar, player.position, 0);
}
}
}
}
 
Where in your NPC code are you actually calling your OnUpdate() method?
 
in the mod world
 
Why would you not put it in the NPC's AI?
 
idk because im a noob lol

um its not still not working
 
Last edited:
You should ask for help on the TML Discord.
 
can u help me in the forums plz?
any help will be appreciated in the thread
 
Last edited:
Hello welcome to my Why wont this code work thread. here you can post code that is not working for you and maybe someone will help you here is some code that is not working for me also this code is in my npc code
private int timer = 600;
private int framecount = 0;

public new void OnUpdate(Player player)
{
bool npcExists = NPC.AnyNPCs(mod.NPCType("Desertwormhead"));

if (npcExists)
{
framecount++;
if (framecount <= 60)
{
framecount = 0;
timer--;

if (timer <= 0)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Bruhmouth"));
Main.PlaySound(SoundID.Roar, player.position, 0);
}
}
}
}
 
Hello welcome to my Why wont this code work thread. here you can post code that is not working for you and maybe someone will help you here is some code that is not working for me also this code is in my npc code
private int timer = 600;
private int framecount = 0;

public new void OnUpdate(Player player)
{
bool npcExists = NPC.AnyNPCs(mod.NPCType("Desertwormhead"));

if (npcExists)
{
framecount++;
if (framecount <= 60)
{
framecount = 0;
timer--;

if (timer <= 0)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Bruhmouth"));
Main.PlaySound(SoundID.Roar, player.position, 0);
}
}
}
}
Hey @Some Troll Guy,

There's no need to have a single thread for people to post their non-functional code, as that would very quickly become messy. As this technically constitutes a bump (seeing how the code is identical), I've moved the post into your original thread. :)

As for why the code doesn't work, it's a bit difficult to tell from just that snippet (although I can already see a few potential issues). Can you upload all the relevant files?
 
sorry:) im kinda new to the forums

um do u know why the code wont work also do u know where to put the code i put it in my desertworm npc
 
Last edited:
do i put the code in the regular ai
 
Back
Top Bottom