tModLoader Official tModLoader Help Thread

Simple (hopefully) question on banners; I know how to add a modded NPC banner;

Code:
       banner = npc.type;
       bannerItem = mod.ItemType("ModNPC");

But how do I make it so a custom NPC shares a banner effect and drop with vanilla enemies? For example, my mod has a bunch of sharks, yet I'm lazy and want them all to just share the effect of the normal Shark Banner. How would I attain this result?
 
Still not working my username is correct
 

Attachments

  • 15075090925171603961547.jpg
    15075090925171603961547.jpg
    4.1 MB · Views: 161
  • 1507509118149584235712.jpg
    1507509118149584235712.jpg
    6.5 MB · Views: 187
  • 15075091792492023536055.jpg
    15075091792492023536055.jpg
    4 MB · Views: 164
I am having trouble loading tmodloader 10.1, my son has been playing the calamity mod and wanted me to update it. Whenever i try to load Tmodloader 10.1 or 10.2 i get an error- System.EntryPointNotFoundException: Unable to find an entry point named 'Init' in DLL 'CSteamworks". There is some more stuff after that that i can type if needed.

I can go back to the older versions of Calamity and the mod loader and it works fine but have not been able to find anything to help me get the new stuff working.

Any help would be appreciated as long as it is fairly simple, my computer knowledge is fairly limited.
 
I am having trouble loading tmodloader 10.1, my son has been playing the calamity mod and wanted me to update it. Whenever i try to load Tmodloader 10.1 or 10.2 i get an error- System.EntryPointNotFoundException: Unable to find an entry point named 'Init' in DLL 'CSteamworks". There is some more stuff after that that i can type if needed.

I can go back to the older versions of Calamity and the mod loader and it works fine but have not been able to find anything to help me get the new stuff working.

Any help would be appreciated as long as it is fairly simple, my computer knowledge is fairly limited.
That happens when you try to run the exe outside of the steam directory. For example, many people unzip the zip, then run the installer, then try to run the .exe that is in the unzipped folder they are still in. You need to install tmodloader to the steam folder, usually this is C:\Program Files (x86)\Steam\steamapps\common\Terraria . If you ran the installer, you actually probably did everything right, you just need to launch terraria normally not by clicking on that copy you made by unzipping the zip file.
 
Is it possible to interrupt the NPC decision-making process? I'm trying to "petrify" monsters, but this code in my GlobalNPC file isn't getting the job done:
Code:
if (Petrify)
            {
                npc.damage = 0;
                npc.defense = 75;
                npc.velocity.X =0;
               //This is an attempt to pull the target out of the air but get them to just stand still once they hit the ground
                if (npc.velocity.Y == 0)
                    {
                        npc.velocity.Y = 0;
                    }
                else
                    {
                        npc.velocity.Y = 10;
                    }
            }

Also, this seems to permanently render the monster's base damage and defense to 0 and 75, respectively, and I don't know how to get them to revert to normal on fade. It also allows NPCs with other attacks to continue acting (they cast, shoot, throw, etc for normal damage) even though they're supposed to be turned to stone. I figure just interrupting their decision-making process (maybe setting it to negative ticks based on duration) would be an effective way to "petrify" them for the duration simply. Other code elsewhere determines what monsters can be affected and what happens after.

(Re-Logic, could you PLEASE just put a vanilla monster stun in that we can spruce up as we'd like? Even if vanilla game doesn't use it!)

Edit: Sharing for the class, Luiafk tells me in Discord:
Luiafk said:
jabber, you want to override preai, then when the npc has the debuff you return false (stops normal ai code running), then you make the npc fall to the ground and do nothing until the debuff wears off


returning false in preai would mean that unless you tell the npc to do something, it will just sit there doing nothing, i think this is what you're wanting


might need to check if they're dead or not, that might normally be done in ai, not sure
 
Last edited:
Help whenever i go onto terraria then say click mods or mods sources etc i can go in it but when i click my mouse goes somewhere else on the screen please help. As in when im in mods and click my mouse goes somewhere random on the screen!
 
Last edited:
That happens when you try to run the exe outside of the steam directory. For example, many people unzip the zip, then run the installer, then try to run the .exe that is in the unzipped folder they are still in. You need to install tmodloader to the steam folder, usually this is C:\Program Files (x86)\Steam\steamapps\common\Terraria . If you ran the installer, you actually probably did everything right, you just need to launch terraria normally not by clicking on that copy you made by unzipping the zip file.

Thank you for your reply. After trying a few more things i read the readme and realized i had not verified the files. That was the problem. Great mod by the way, I play terraria on console with my son and wish we could use Calamity there. Keep up the good work.

EDIT * just realized i was posting on the Tmodloader section and not Calamity, great work to you guys also
 
hi, im trying to give player buff when i right click while holding weapon, but it doesnt seem to work

public virtual bool AltFunctionUse(Item item, Player player)
{
return true;
}

public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
{
player.AddBuff(mod.BuffType("Berserk"), 600 );
}
return true;
}

any help would be appreciated :)
 
hi, im trying to give player buff when i right click while holding weapon, but it doesnt seem to work

public virtual bool AltFunctionUse(Item item, Player player)
{
return true;
}
Hey, I'm still not sure on this, but I got called on it yesterday... I think that "virtual" needs to be "override", since you're overriding vanilla code with this function.
(Yes, I know I'm coming at C# sideways.)
 
Hey, I'm still not sure on this, but I got called on it yesterday... I think that "virtual" needs to be "override", since you're overriding vanilla code with this function.
(Yes, I know I'm coming at C# sideways.)
no, still not working, its says: error CS0115: 'Warcraft.Items.Weapons.WarswordsOfTheValarjar.AltFunctionUse(Terraria.Item, Terraria.Player)': no suitable method found to override.

any other tips? :(
 
no, still not working, its says: error CS0115: 'Warcraft.Items.Weapons.WarswordsOfTheValarjar.AltFunctionUse(Terraria.Item, Terraria.Player)': no suitable method found to override.

any other tips? :(
That was largely a shot in the dark based on my recent experience. What does it say if you try to use your version?
 
no, still not working, its says: error CS0115: 'Warcraft.Items.Weapons.WarswordsOfTheValarjar.AltFunctionUse(Terraria.Item, Terraria.Player)': no suitable method found to override.

any other tips? :(
Can you copy-paste the segment of code for the Alternate function? I think you may be missing something, but I'm not sure.
 
That was largely a shot in the dark based on my recent experience. What does it say if you try to use your version?
nothing, it just does nothing. theres no error but still no buff

Can you copy-paste the segment of code for the Alternate function? I think you may be missing something, but I'm not sure.
here is the code:

public virtual bool AltFunctionUse(Item item, Player player)
{
return true;
}

public override bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
{
player.AddBuff(mod.BuffType("Berserk"), 600 );
}
return true;
}
 
[...]
here is the code:
Code:
public virtual bool
AltFunctionUse(Item item, Player player)
        {
            return true;
        }
     
        public override bool CanUseItem(Player player)
        {
            if (player.altFunctionUse == 2)  
            {
                player.AddBuff(mod.BuffType("Berserk"), 600 );
            }
            return true;
        }
Try adding a 'void' inbetween the 'override' and the 'bool'.
 
Try adding a 'void' inbetween the 'override' and the 'bool'.
i did this:
public override void bool CanUseItem(Player player)
{
if (player.altFunctionUse == 2)
{
player.AddBuff(mod.BuffType("Berserk"), 600 );
}
return true;
}

and it showed this error: error CS1519: Invalid token 'bool' in class, struct, or interface member declaration
 
i did this:
Code:
public override void bool CanUseItem(Player player)
        {
            if (player.altFunctionUse == 2)     //2 is right click
            {
                player.AddBuff(mod.BuffType("Berserk"), 600 );
            }
            return true;
        }
and it showed this error: error CS1519: Invalid token 'bool' in class, struct, or interface member declaration
Well, I'm sorry, but I can't really help more than that. My knowledge of tModLoader's ways or even C# itself is severely limited. I'll try and look into it later by cross-referencing it to another mod's source, but all I can say now it that I hope someone else here can help. :/

Edit: Maybe you could make some sense of this.
 
Well, I'm sorry, but I can't really help more than that. My knowledge of tModLoader's ways or even C# itself is severely limited. I'll try and look into it later by cross-referencing it to another mod's source, but all I can say now it that I hope someone else here can help. :/

thx for all the help, but i still dont understand why its not working, i took the code from blueshiemagics ExampleDualUseWeapon.cs
 
Last edited:
if that was the probelm it would have said error, but im not getting error, its just not doing anyting when im right clicking.

sry for not being very clear :)
It's fine.

I'd recommend looking over the ExampleDualUseWeapon.cs file again. I can't look at it myself right now (away from computer), but I'll try and get to it when I get the chance.
 
Back
Top Bottom