Standalone [1.3] tModLoader - A Modding API

You could probably make a custom field that stores the durability, decrease this custom field in the Shoot hook, check to make sure this durability is positive in the CanUse hook, and use the OnPickup hook to increase this field.
OK, that's really promising. So maybe now the vital question lie on something about how to indicate the durability on the throwing item like the ammo of a gun or bow?

EDIT: And the custom field... where am i supposed to put them? Can I add property to the item? Also, prefix is not working... I dunno whether it has something to do with the thrown or consumable or the stackable...
 
Last edited:
Hello everyone. How to always draw texture on screen using Main.spriteBatch.Draw? And in which method i must do this? When i'm trying, it's says "Begin must be called successfully before End can be called."
 
Welp, it fixed it... But what in the world does the state in which the buff is in have to do with my position in the world?
My guess is that you had a campfire or heart lantern or something along those lines. When you went far away from it, your buff became the only one left, which means it was placed in position 0. That made HasBuff return 0, which caused your kill-projectile code to run.

OK, that's really promising. So maybe now the vital question lie on something about how to indicate the durability on the throwing item like the ammo of a gun or bow?

EDIT: And the custom field... where am i supposed to put them? Can I add property to the item? Also, prefix is not working... I dunno whether it has something to do with the thrown or consumable or the stackable...
To indicate the durability you might have to use custom drawing. For prefixes you need to make the item unstackable.

Hello everyone. How to always draw texture on screen using Main.spriteBatch.Draw? And in which method i must do this? When i'm trying, it's says "Begin must be called successfully before End can be called."
You need to use one of the drawing hooks.
 
Could someone please help me? I keep getting this error when i try to build my mod and i can't figure out how to fix this (F.Y.I I am new to modding).
Here is my error :
" An error occurred while compiling a mod
error CS1703: An assembly with the same identity 'Ionic.Zip.Reduced, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' has already been imported. Try removing one of the duplicate references."
 
For accessories:
Code:
public override void UpdateAccessory(Player player, bool hideVisual)
{
    player.noKnockback = true;
    player.buffImmune[BuffID.<name>] = true; //without the <>
}

For armor:
Code:
public override void UpdateEquip(Player player)
{
    player.noKnockback = true;
    player.buffImmune[BuffID.<name>] = true; //without the <>
}
Ok that is the problem this is my first time moding and i don't know how to install the mod compile folder
[doublepost=1461117653,1461117604][/doublepost]sorry disregard that
 
I've found how to affect the global spawn rate of NPCs, both friendly and hostile, but I would like to change that to only affect hostile NPCs. Is there a way to set one spawn rate for the hostile NPCs and another for the friendly ones? Putting the below in my GlobalNPC is along the lines of what I was hoping for, but it doesn't work.

Code:
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            if (NPC.hostile)
            {
                spawnRate = 999999;
                maxSpawns = 0;
            }
        }


- Aerlock
 
My guess is that you had a campfire or heart lantern or something along those lines. When you went far away from it, your buff became the only one left, which means it was placed in position 0. That made HasBuff return 0, which caused your kill-projectile code to run.


To indicate the durability you might have to use custom drawing. For prefixes you need to make the item unstackable.


You need to use one of the drawing hooks.
What is "drawing hooks"? Can you write more, please..
 
What is "drawing hooks"? Can you write more, please..
There are currently drawing hooks on ModNPC, ModProjectile, ModPlayer and ModItem (and possibly some more).
Check the tModLoader wiki to see which draw hook you can override in the corresponding class.
There's no 'easy' way to draw persistent UI as of yet, since no 'official' UI/GUI hooks have been implemented yet.
 
There are currently drawing hooks on ModNPC, ModProjectile, ModPlayer and ModItem (and possibly some more).
Check the tModLoader wiki to see which draw hook you can override in the corresponding class.
There's no 'easy' way to draw persistent UI as of yet, since no 'official' UI/GUI hooks have been implemented yet.
I need to draw always on screen, without ModNPC, ModProjectile etc.
 
I need to draw always on screen, without ModNPC, ModProjectile etc.
Then the closest you can come to that (since there aren't any UI hooks) is to override the PreDraw or the PostDraw method of a class that derives from GlobalItem and draw in there.
 
SetDefaults: Main.projFrames[projectile.type] = 4;
AI: Non-cycling

projectile.frameCounter++;
if (projectile.frameCounter == 10)
{
projectile.frame = 1;
}
if (projectile.frameCounter == 20)
{
projectile.frame = 2;
}
if (projectile.frameCounter == 30)
{
projectile.frame = 3;
}

AI: Cycling:
projectile.frameCounter++;
if (projectile.frameCounter == 10)
{
projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type];
projectile.frameCounter = 0;
}

Image: frames stacked horizontally on top of each other
Where do I put AI: Non-cycling (or do I need to replace it with something?) and projectile.frameCounter++;?
 
I've found how to affect the global spawn rate of NPCs, both friendly and hostile, but I would like to change that to only affect hostile NPCs. Is there a way to set one spawn rate for the hostile NPCs and another for the friendly ones? Putting the below in my GlobalNPC is along the lines of what I was hoping for, but it doesn't work.

Code:
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            if (NPC.hostile)
            {
                spawnRate = 999999;
                maxSpawns = 0;
            }
        }


- Aerlock
That is not possible, due to the way Terraria's code works. What you can do, however, is edit the spawn pool:
https://github.com/bluemagic123/tMo...ctionaryint-float-pool-npcspawninfo-spawninfo
You can remove the 0 from the pool then add in the IDs of critters.
 
Guys, I have a weapon, that is supposed to work like a pickaxe or like a grenade launcher. It's supposed to switch from one mode to another with a press of a button, let's say, button Y. How do I do that?
 
Back
Top Bottom