Standalone [1.3] tModLoader - A Modding API

That's pretty easy to do. At least, pretty easy if you know how to program.
That's also the kind of thing where you have to know how to program.


You need to set Main.npcFrameCount[npc.type] to the total number of frames your NPC has. Then ExtraFramesCount needs to be set to the number of frames that are below the walking frames.

24 total frames, 9 frames below walking and 5 attacking frames.
Code:
        Main.npcFrameCount[npc.type] = 24;
        NPCID.Sets.ExtraFramesCount[npc.type] = 9;
        NPCID.Sets.AttackFrameCount[npc.type] = 5;
Still getting that problem.
 
Well, given that the method signature is

public static int NewProjectile(float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float KnockBack, int Owner = 255, float ai0 = 0f, float ai1 = 0f)

I'm not sure why you have most of those, especially Main.npc. What are you trying to do? Are you sure you don't want to override Shoot?
I am trying to spawn a stationary projectile like the electrosphere at the cursor position.
 
So with 0.5 out, I'll re-ask my question: how to add things to an existing NPC's shop? I looked through the example mod and didn't find it. I also tried to copy the code from the town npc in the example mod to the ItemDrop file in my mod, but that didn't work either.
 
24 total frames, 9 frames below walking and 5 attacking frames.
Code:
        Main.npcFrameCount[npc.type] = 24;
        NPCID.Sets.ExtraFramesCount[npc.type] = 9;
        NPCID.Sets.AttackFrameCount[npc.type] = 5;
Still getting that problem.
I didn't count 24 frames in your animation file.

Will you add linux support as well? 0.5.0.1 changelog says you're 80% done with adding mac support.
Well, the problem is, I don't have a Linux. So I don't have any way to get the Linux exe unless someone has both the Windows and Linux versions and makes a patch file for me. And even if I do have the Linux exe I have no way to test it (although I still would be able to get it to work eventually).

So with 0.5 out, I'll re-ask my question: how to add things to an existing NPC's shop? I looked through the example mod and didn't find it. I also tried to copy the code from the town npc in the example mod to the ItemDrop file in my mod, but that didn't work either.
You'll need to use this hook in GlobalNPC:
https://github.com/bluemagic123/tMo...setupshopint-type-chest-shop-ref-int-nextslot
 
Hey - I have a problem with the banner drops. Type 0 works fine, but the others aren't working. "Kill count unavailable", it says. Here's the coding;
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace Matter.Tiles {
public class MonsterBanner : ModTile
{
    public override void SetDefaults()
    {
        Main.tileFrameImportant[Type] = true;
        Main.tileNoAttach[Type] = true;
        Main.tileLavaDeath[Type] = true;
        TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top);
        TileObjectData.newTile.Height = 3;
        TileObjectData.newTile.CoordinateHeights = new int[]{16, 16, 16};
        TileObjectData.newTile.StyleHorizontal = true;
        TileObjectData.newTile.StyleWrapLimit = 111;
        TileObjectData.addTile(Type);
        dustType = -1;
        mapColor = new Color(13, 88, 130);
        mapName = "Banner";
    }

    public override void KillMultiTile(int i, int j, int frameX, int frameY)
    {
        int style = frameX / 18;
        string item;
        switch(style)
        {
        case 0:
            item = "StalkerBanner";
            break;
        case 1:
            item = "LivingShadowBanner";
            break;
        case 2:
            item = "PlasmaSpectreBanner";
            break;
        default:
            return;
        }
        Item.NewItem(i * 16, j * 16, 16, 48, mod.ItemType(item));
    }

    public override void NearbyEffects(int i, int j, bool closer)
    {
        if(closer)
        {
            Player player = Main.player[Main.myPlayer];
            int style = Main.tile[i, j].frameX / 18;
            string type;
            switch(style)
            {
            case 0:
                type = "Stalker";
                break;
            case 1:
                type = "LivingShadow";
                break;
            case 2:
                type = "PlasmaSpectre";
                break;
            default:
                return;
            }
            player.NPCBannerBuff[mod.NPCType(type)] = true;
            player.hasBanner = true;
        }
    }
}}
 
I didn't count 24 frames in your animation file.


Well, the problem is, I don't have a Linux. So I don't have any way to get the Linux exe unless someone has both the Windows and Linux versions and makes a patch file for me. And even if I do have the Linux exe I have no way to test it (although I still would be able to get it to work eventually).


You'll need to use this hook in GlobalNPC:
https://github.com/bluemagic123/tMo...setupshopint-type-chest-shop-ref-int-nextslot

And, the binding a NPC to another NPC has been rough. Do you have the decompiled coding for the Creeper enemy and/or Riders and their mounts?
 
And, the binding a NPC to another NPC has been rough. Do you have the decompiled coding for the Creeper enemy and/or Riders and their mounts?
Alright, GUIDE TO MOUNTED NPCs!!!!
Here is something I made from looking at the Scutlix. Note that these types of NPC seem to consist of 3 NPCs, lets call them Top, Bottom, and TopAlone.
  • Top is the only one that is spawned naturally through CanSpawn. When it is spawned, it immediately spawns a Bottom to go with it. The AI code from then on just mimics the Bottoms position, velocity, and spriteDirection. When bottom is dead, the AI code tells it to transform into TopAlone npc.
  • Bottom controls how the NPCs move as a unit. When it moves, Top moves with it automatically. Can be programmed in a similar manner to any other NPC.
  • TopAlone is the NPC that is created when Bottom dies. Can be programmed in a similar manner to any other NPC.
So really, the only special considerations is that
  1. Bottom and TopAlone don't spawn naturally (well, you can if you want, doesn't matter either way.)
  2. Top's AI code must spawn Bottom, mimic it's behavior, and transform into a self moving NPC on Bottoms death.
Here is a download to my test mounted NPC. Remember to place these in the NPC folder and to change the namespace to match your mod's. You should be able to build off these. Also note that Top will shoot lasers at you, yay. You can learn from this example. I've commented the code as well as I saw fit, but if you can't figure things out, just ask.

Here it is in action.
anUpox1.png
 
This looks useful, and erm... lovely sprites
Haha, I try.
Do the expert mode zombies use a different AI to the normal ones?
They still use aistyle 3, but seem to have some some extra coding. It's not immediately clear to me what the code does though, but it probably is for the Expert only "claw attack"
Also is it possible to have an accessory give a buff but make it so the buff icon doesn't show?
Not really, all buffs should show up. Are you trying to actually give a buff? or just give the effects of the buff? I think if you wanted to give the effects of a buff it might be possible.
 
I like that items shows up if the mod is disabled.
But when you disable a mod, load the game, get an disabled item, update the mod to a new version, load the game again, the disabled items wont be upgraded/linked to the new version of the mod and is lost forever.
 
I like that items shows up if the mod is disabled.
But when you disable a mod, load the game, get an disabled item, update the mod to a new version, load the game again, the disabled items wont be upgraded/linked to the new version of the mod and is lost forever.
Are you sure that neither the mod's internal name nor the item's internal name has changed in updating the mod?
 
Back
Top Bottom