Standalone [1.3] tModLoader - A Modding API

I have a problem building my mod, It says the type or namespace name Example player could not be found, I don't know what that means, the error is inside the cs file for the buff for my oshawott pet mod, can you find the error in the file?
sing Terraria;
using Terraria.ModLoader;

namespace Oshawottmod.Buffs
{
public class ExamplePet : ModBuff
{
public override void SetDefaults()
{
Main.buffName[Type] = "Oshawott";
Main.buffTip[Type] = "\"Don't be sad little guy!\"";
Main.buffNoTimeDisplay[Type] = true;
Main.vanityPet[Type] = true;
}

public override void Update(Player player, ref int buffIndex)
{
player.buffTime[buffIndex] = 18000;
player.GetModPlayer<ExamplePlayer>(mod).Oshawott = true;
bool petProjectileNotSpawned = player.ownedProjectileCounts[mod.ProjectileType("Oshawott")] <= 0;
if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer)
{
Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, mod.ProjectileType("Oshawott"), 0, 0f, player.whoAmI, 0f, 0f);
}
}
}
}
This a simple mod, it just adds a oshawott pet, it has 4 frames of animation, and copies Ai from the bunny pet, should I use other Ai for my pet?
--- Double Post Merged, Today at 8:57 PM, Original Post Date: Today at 8:54 PM --- forgot to mention, i used the Example mod's example pet as a template for this code, is their any problem with that too?

I don't know much about pet making, but I'd say 'sing Terraria;' should be 'using Terraria;'
 
i dont get this at all
so heres what i have


int BlueSlime = Item.NPCtoBanner(NPCID.BlueSlime);
int GreenSlime = Item.NPCtoBanner(NPCID.GreenSlime);
int PurpleSlime = Item.NPCtoBanner(NPCID.PurpleSlime);
int RedSlime = Item.NPCtoBanner(NPCID.RedSlime);
int YellowSlime = Item.NPCtoBanner(NPCID.YellowSlime);
int JungleSlime = Item.NPCtoBanner(NPCID.JungleSlime);
int Pinky = Item.NPCtoBanner(NPCID.Pinky);

this is what i have and it looks fine
but heres what it does

BlueSlime: 69
GreenSlime: 119
PurpleSlime: 155
RedSlime: 159
YellowSlime: 183
JungleSlime: 131
Pinky: 151

heres the real numbers of the world

BlueSlime: 1699
GreenSlime: 489
PurpleSlime: 141
RedSlime: 39
YellowSlime: 20
JungleSlime: 28
Pinky: 8

where does it get those top numbers from?
why does it not get the real banner numbers for the slimes not one was right only the purple was close

the wrong numbers seem to be fixed and does not change when killing more slimes
 
i dont get this at all
so heres what i have


int BlueSlime = Item.NPCtoBanner(NPCID.BlueSlime);
int GreenSlime = Item.NPCtoBanner(NPCID.GreenSlime);
int PurpleSlime = Item.NPCtoBanner(NPCID.PurpleSlime);
int RedSlime = Item.NPCtoBanner(NPCID.RedSlime);
int YellowSlime = Item.NPCtoBanner(NPCID.YellowSlime);
int JungleSlime = Item.NPCtoBanner(NPCID.JungleSlime);
int Pinky = Item.NPCtoBanner(NPCID.Pinky);

this is what i have and it looks fine
but heres what it does

BlueSlime: 69
GreenSlime: 119
PurpleSlime: 155
RedSlime: 159
YellowSlime: 183
JungleSlime: 131
Pinky: 151

heres the real numbers of the world

BlueSlime: 1699
GreenSlime: 489
PurpleSlime: 141
RedSlime: 39
YellowSlime: 20
JungleSlime: 28
Pinky: 8

where does it get those top numbers from?
why does it not get the real banner numbers for the slimes not one was right only the purple was close

the wrong numbers seem to be fixed and does not change when killing more slimes
NPCtoBanner gets the banner number from the npc. You still need to NPC.killCount[bannernumber] to ger the kill counts.
 
I've found a lot more sounds that are bugged.
  • All desert creature noises
  • Mana/heart crystal use sounds
  • Bomb explosions
  • Any zombie cries
  • Basically a lot of NPC sounds
Seriously, is there no way to fix this?
 
NPCtoBanner method returns the banner number and the killCount array is indexed by the banner number, so probably something like this:
Code:
int BlueSlime = NPC.killCount[Item.NPCtoBanner(NPCID.BlueSlime)];
 
Still no projectile shows up

projectile
Code:
 public class SolarisP : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.name = "Solarius";
            projectile.width = 68;
            projectile.height = 64;
            projectile.friendly = true;
            projectile.penetrate = -1;
            projectile.aiStyle = 75;
            projectile.type = ProjectileID.Arkhalis;
            Main.projFrames[projectile.type] = 28;
            projectile.ownerHitCheck = true;
            projectile.melee = true;
            projectile.tileCollide = false;
            projectile.light = 2f;
        }

weapon
Code:
 public override void SetDefaults()
        {
            item.name = "Solarius";
            item.damage = 200;
            item.melee = true;
            item.width = 48;
            item.height = 48;
            item.useTime = 15;
            item.useAnimation = 1;
            item.useStyle = 5;
            item.noMelee = true;
            item.knockBack = 4f;
            item.noUseGraphic = true;
            item.channel = true;
            item.value = 100000;
            item.rare = 9;
            item.useSound = 1;
            item.autoReuse = false;
            item.shoot = mod.ProjectileType("SolarisP");
            item.shootSpeed = 15f;
        }

where's the fail at?
I'm thinking in the weapon, but... I have no idea

also, remember all my questions about homing and boomerangs? well, now I want a homing boomerang... It's half working. I want it to work like the possessed hatchet, but It doesn't. It tries to home on things through blocks, and homes on on thing and keeps returning till it's dead then goes to another. I want it to only hit 1 thing once then return to the player. also, if I try to shoot it left, for example, and there is a target on the right, it will go right with out going left at all. I want it to curve, not go abruptly.

the code
Code:
public NPC FindNearest(Vector2 pos)
        {

            NPC nearest = null;
            float oldDist = 1001;
            float newDist = 1000;
            for (int i = 0; i < Terraria.Main.npc.Length - 1; i++)
            {
                if (!Collision.CanHit(pos, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height))
                    continue;
                if (!Terraria.Main.npc[i].CanBeChasedBy(projectile))
                    continue;
                if (nearest == null)
                    nearest = Terraria.Main.npc[i];
                else
                {
                    oldDist = Vector2.Distance(pos, nearest.position);
                    newDist = Vector2.Distance(pos, Terraria.Main.npc[i].position);
                    if (newDist < oldDist)
                        nearest = Terraria.Main.npc[i];
                }
            }
            return nearest;
        }
        int maxSpeed = 16;
        public override void AI()
        {
            NPC nearest = this.FindNearest(projectile.Center);
            Vector2 acceleration;
            if (nearest != null) // extremely important
            {
                acceleration = (nearest.position - projectile.position);
            }
            else
            {
                acceleration = Vector2.Zero; // maintain speed -- or whatever else you want to do here
            }
            projectile.velocity += acceleration * 1.5f;
            projectile.velocity *= 0.95f;
            if (projectile.velocity.Length() > maxSpeed)
            {
                projectile.velocity.Normalize();
                projectile.velocity *= maxSpeed;
            }
        }
        public override void PostAI()
        {
            if (projectile.ai[0] == 1)
            {
                Player myOwner = Main.player[projectile.owner]; //find the owner of this projectile
                Vector2 toMe = Vector2.Normalize(myOwner.Center - projectile.Center); //find the distance from this projectile to it's owner and convert to a unit vector.
                projectile.velocity += toMe * 1f; //add the above vector to this projectile's velocity -- change 1f to change the return speed
            }

        }

also, can anyone help me with the boss ai?



pls help me
H'ok... The Solarius item wasn't working because item.useAnimation was 1. I don't know how small it can be, but vanilla uses 25 there. Also, in the projectile, you've got 'projectile.type = ProjectileID.Arkhalis;' which will make the item a cosmetic clone of Arkhalis. If you want to use your own sprite, you'll need 'aiType = ProjectileID.Arkhalis;' instead.

Now, if you want to delay the projectile from homing in on enemies, then create an int to use as a timer, then place your homing code inside an if statement that checks if your int is above a specific value, and if it isn't, increase the timer. To adjust how quickly your projectile accelerates, change the 1.5f in the line 'projectile.velocity += acceleration * 1.5f;'

To make the projectile return to the player when it hits something, set 'projectile.ai[0]' to 1. The hooks onHitNPC, onHitPVP and onTileCollide are where you'll want to do this.
 
I have the GOG version and when i try to install it i do all like it said in the instructions!But when i try to launch the game it says Terraria.exe is not a valid win32 application!
HELP!?
 
i have quite much no idea how to make a mod so i edited examplemod, and i want to add the effects from "adamantite armor" and "ancient cobalt armor" to the mod's armor...how do i do it
 
I've found a lot more sounds that are bugged.
  • All desert creature noises
  • Mana/heart crystal use sounds
  • Bomb explosions
  • Any zombie cries
  • Basically a lot of NPC sounds
Seriously, is there no way to fix this?
There is a workaround available. It is described in the related git issue, here: https://github.com/bluemagic123/tModLoader/issues/28
This issue is known and there is no known underlying cause of it. Use the workaround for now, it's worked fine for me (also an OSX user).
 
Just a little question, but is it possible to increase the usetime/useanimation of items and weapons through Global Item with formulas? I had tried
public override void UpdateInventory(Item item, Player player) with a requirement of a ModPlayer bool and the formula item.useAnimation = (int)(item.useAnimation * .15); but the results weren't in my favor... Setting the useTime and useAnimation to whole numbers worked fine, but unfortunately, that's not my intention.

Any help would be much appreciated!
 
Just a little question, but is it possible to increase the usetime/useanimation of items and weapons through Global Item with formulas? I had tried
public override void UpdateInventory(Item item, Player player) with a requirement of a ModPlayer bool and the formula item.useAnimation = (int)(item.useAnimation * .15); but the results weren't in my favor... Setting the useTime and useAnimation to whole numbers worked fine, but unfortunately, that's not my intention.

Any help would be much appreciated!
They have to be whole numbers. It doesn't make sense to have a fraction of a frame. As for using UpdateInventory to do it, it runs every tick, so eventually it gets to 0 pretty quick. I'm actually not sure the best approach, but maybe in the canuse hook to modify the useTimes. You still need to figure out how to change it temporarily.
 
Hello, I have a small modding question. I'm trying to make a script that will activate an event once per day. Something like this:
Code:
if (Main.time % #ofticksperday = 0)
    { do stuff }

but I'm not sure where I need to put this snippet to have it run continuously, like I want. Where does this need to go?
 
Hello, I have a small modding question. I'm trying to make a script that will activate an event once per day. Something like this:
Code:
if (Main.time % #ofticksperday = 0)
    { do stuff }

but I'm not sure where I need to put this snippet to have it run continuously, like I want. Where does this need to go?
Probably ModWorld.PostUpdate is best for this type of thing.
 
Probably ModWorld.PostUpdate is best for this type of thing.

Thanks, I'll try that. Follow up: in a previous reply, you talked about looping through chests at world gen and adding items. (Basically, I'm trying to do this once per day for certain chests). http://forums.terraria.org/index.php?threads/1-3-tmodloader-a-modding-api.23726/page-372#post-921068 Some of the replies expressed concern at using a fixed number for the upper bound of chestindex. Do you know what the actual ramifications are for attempting to access more chests than exist in the world are? And is there a better way to find the number of chests in the world? Thanks again for your help.
 
Back
Top Bottom