tAPI [Discontinued] tAPI - A Mod To Make Mods

Status
Not open for further replies.
"holdoutOffset" and "holdoutOrigin". I haven't played with them, but the origin is literally the origin for the spritebatch, and the offset is applied to the item's position. So I'm guessing origin is axis alined, and offset is sprite alined.

I should really try playing with those, my clockwork guns look absolutely ridiculous the default way :dryadtongue:
Using holdoutOffset and it's working pretty nicelly.
Code:
"holdoutOffset": [-20,5],
0fd41728fc.jpg


Only issue, the sprite actually covers the hand, which I don't want to happen. This seems to be an issue with how the hand is drawn tho as the bug also happens with vanilla guns and of course, armors and mod armors which don't show the player's hands actually work alright.
 
Using holdoutOffset and it's working pretty nicelly.
Code:
"holdoutOffset": [-20,5],
0fd41728fc.jpg


Only issue, the sprite actually covers the hand, which I don't want to happen. This seems to be an issue with how the hand is drawn tho as the bug also happens with vanilla guns and of course, armors and mod armors which don't show the player's hands actually work alright.
In the ModifyDrawLayerList hook you could always rearrange the layers if you're holding the right item so it draws correctly, if you wanted :dryadtongue:

EDIT: Wait, no you can't, why the hell are hands drawn with the body? :dryadwhat:
 
Last edited:
Even more so, it wont work because CheckConditions isn't run on global code, it's specifically run only for NPC's of a certain type. It works this way because it isn't run for an actual NPC all the time, it is used for spawning conditions as well, which means the actual NPC may not even exist yet. (so there's no instances of ModNPC created for it yet)
I may be going about my mod entirely wrong. Perhaps I could be pointed in a different direction.

I'm attempting to separate Spawning requirements from Housing requirements. All Vanilla Town NPCs would still have their original requirements (like possession of Dye material for Dye Trader, Queen Bee defeated for Witch Doctor). They would not require an available house though. If a house was not available once spawned they would be Homeless. Talking to a Homeless NPC would help you to find the necessary requirements for the NPC to move in. At a particular time, say 1 hour after nightfall, any NPCs that were still Homeless would leave similarly to the Traveling Merchant. Upon leaving in this fashion, they would have a random cooldown period of 1-3 days during which they would be unable to spawn.

Looking at some code, it seems like -
  • StartRoomCheck(int x, int y) - Returns whether an area is a proper house or not. (Floor, ceiling, walls and background wall checks, min & max number of house tiles) And fills an array with whether a particular tile was found in the house or not
  • RoomNeeds(int npcType) - Makes sure the house contains each of the required items. (Table, chair, torch, door)
  • CheckConditions(int type) - Looks at the area around a house, such as checking for an appropriate Biome. It also contains the call for ModNPC CheckConditions.
These seem to be ran in this order, StartRoomCheck -> RoomNeeds -> CheckConditions -> Custom NPC CheckConditions

Originally I thought I would be able to bypass the Housing portion of the Spawning Requirements by forcing StartRoomCheck or RoomNeeds to return True if no NPC of the type being checked for was active. The NPC would then spawn either near a random Town NPC who isn't homeless, or near the players original spawn point since the NPCs spawn location is supposed to be near the validated house.

With no access to StartRoomCheck or RoomNeeds, and ModNPC CheckConditions being available for custom NPCs only, that means a lot of hacky custom code to create alternatives.

Would moving ModNPC CheckConditions into ModWorld or ModBase circumvent the issue of not having an existing ModNPC instance yet?
Since I'm just checking to see if at this time a particular integer value (representing an NPC type) should return null or some string, does a ModNPC instance need to exist?
Would it be beneficial/safe to provide overrides for StartRoomCheck and/or RoomNeeds in addition to the existing CheckConditions?
 
I may be going about my mod entirely wrong. Perhaps I could be pointed in a different direction.

I'm attempting to separate Spawning requirements from Housing requirements. All Vanilla Town NPCs would still have their original requirements (like possession of Dye material for Dye Trader, Queen Bee defeated for Witch Doctor). They would not require an available house though. If a house was not available once spawned they would be Homeless. Talking to a Homeless NPC would help you to find the necessary requirements for the NPC to move in. At a particular time, say 1 hour after nightfall, any NPCs that were still Homeless would leave similarly to the Traveling Merchant. Upon leaving in this fashion, they would have a random cooldown period of 1-3 days during which they would be unable to spawn.

Looking at some code, it seems like -
  • StartRoomCheck(int x, int y) - Returns whether an area is a proper house or not. (Floor, ceiling, walls and background wall checks, min & max number of house tiles) And fills an array with whether a particular tile was found in the house or not
  • RoomNeeds(int npcType) - Makes sure the house contains each of the required items. (Table, chair, torch, door)
  • CheckConditions(int type) - Looks at the area around a house, such as checking for an appropriate Biome. It also contains the call for ModNPC CheckConditions.
These seem to be ran in this order, StartRoomCheck -> RoomNeeds -> CheckConditions -> Custom NPC CheckConditions

Originally I thought I would be able to bypass the Housing portion of the Spawning Requirements by forcing StartRoomCheck or RoomNeeds to return True if no NPC of the type being checked for was active. The NPC would then spawn either near a random Town NPC who isn't homeless, or near the players original spawn point since the NPCs spawn location is supposed to be near the validated house.

With no access to StartRoomCheck or RoomNeeds, and ModNPC CheckConditions being available for custom NPCs only, that means a lot of hacky custom code to create alternatives.

Would moving ModNPC CheckConditions into ModWorld or ModBase circumvent the issue of not having an existing ModNPC instance yet?
Since I'm just checking to see if at this time a particular integer value (representing an NPC type) should return null or some string, does a ModNPC instance need to exist?
Would it be beneficial/safe to provide overrides for StartRoomCheck and/or RoomNeeds in addition to the existing CheckConditions?
Honestly, for what you want, your best bet would be to manually summon / unsummon them yourself. Randomly spawn them near other town NPCs if they're condition is met (you'd probably have to rewrite all the checks in your code) then at night, check all town NPCs and check if they are homeless, if they are (and no player is near them) despawn them and do a leave message.

If I remember right, the hook for modifying the NPCs chat menu won't work for vanilla NPCs either, so it's probably best to do it the way above anyways :dryadtongue:

I'd say the only issue is ones with really specific requirements, like Truffle. Maybe check if the area you try spawning him at is at the right height and has X amount of the right block? (I think the wiki had the numbers, atleast 250 blocks within a certain range or something like that)

Oh, and mod NPCs I guess, although that one isn't too hard to get around. (just call the CanTownNPCSpawn method yourself :dryadtongue: )
 
Anyway of changing terraria logo using this code?
Code:
        public override void OnAllModsLoaded()
         {
            // Replace vanilla Timer textures
            if(!Main.dedServ) {
                Main.itemTexture[4] = textures["Vanilla/CopperBroadsword"];
            }
 
I have confirmed a few errors with tAPI:
- Town NPCs Can spawn multiple times, under certain circumstances
- With tAPI installed, the traveling merchant can actually be assigned to a house/room in the player's village
- When talking to the dryad, her status text about the crimson/corruption and the hollow are completely off, and are normally very sporadic or exaggerated, or in some cases, dramatically underestimated.
 
Is anyone else who uses tAPI having trouble with Adhesive Bandages? I've been farming Rusty Armored Bones for HOURS and I've gotten many, MANY drops of everything else in the Slab Wall region, things that are far rarer than the bandages, and no dice. Is something bugged with the Rusty Armored Bones coding? I noticed sometimes they're inflicting Slow instead of Bleed, which seems... incorrect.

If not, I'll check with Eikester (as I am only using his furniture mod, I can't see how that'd affect monsters though), but he hasn't answered any issues that arose with his mod that have been brought up on that thread yet...

Also notice that there hasn't been an update to fix the weird lava luminosity bug or the Dryad's wonky readings. Is this because Yorai is busy with 1.3?
 
I've found some issues regarding tAPI and its dedicated server. If an older version of a mod exists on a client computer, and a newer one on the server, the older one isn't updated. This means that the older version often conflicts with the newer version. Would it be possible for the server to compare the client and server version number and update the server if required? If this isn't practical, could we simply have the option to delete a mod through the mods menu so that it would be synced next time the server is joined.

On the topic of servers, if I leave a server and then try to reload mods, tAPI will crash without fail. This happens regardless if the server is on the same PC or not. The only way to avoid this is to quit and reload tAPI.

On a side note, I've used the code "if (Main.netMode == 2) return;" in my MPlayer.cs file several times. Is this necessary? Does any script in the MPlayer.cs file happen on a server?

Thank you for your time.
 
Is anyone else who uses tAPI having trouble with Adhesive Bandages? I've been farming Rusty Armored Bones for HOURS and I've gotten many, MANY drops of everything else in the Slab Wall region, things that are far rarer than the bandages, and no dice. Is something bugged with the Rusty Armored Bones coding? I noticed sometimes they're inflicting Slow instead of Bleed, which seems... incorrect.

If not, I'll check with Eikester (as I am only using his furniture mod, I can't see how that'd affect monsters though), but he hasn't answered any issues that arose with his mod that have been brought up on that thread yet...

Also notice that there hasn't been an update to fix the weird lava luminosity bug or the Dryad's wonky readings. Is this because Yorai is busy with 1.3?
Try off of the other 2 enemies that drop it for now, or wait for R15. Apparently when drops were re-written that one was forgotten. And are you sure it's them inflicting Slow? As far as I know, the NPC code has barely been touched by tAPI (it's a nightmare, I don't think any of us would want to rewrite it heh)

Yorai is busy with 1.3, most the others are busy with school/work/life, me included, but I seem to have the most free time available so I try to put some work in. God there are way too many bugs though x.x

I've found some issues regarding tAPI and its dedicated server. If an older version of a mod exists on a client computer, and a newer one on the server, the older one isn't updated. This means that the older version often conflicts with the newer version. Would it be possible for the server to compare the client and server version number and update the server if required? If this isn't practical, could we simply have the option to delete a mod through the mods menu so that it would be synced next time the server is joined.

On the topic of servers, if I leave a server and then try to reload mods, tAPI will crash without fail. This happens regardless if the server is on the same PC or not. The only way to avoid this is to quit and reload tAPI.

On a side note, I've used the code "if (Main.netMode == 2) return;" in my MPlayer.cs file several times. Is this necessary? Does any script in the MPlayer.cs file happen on a server?

Thank you for your time.
That... I'll have to take a look.

Also, ya I noticed and put the report on our Mantis(bug tracker) already. I have mostly ignored it, because I've always thought it would be a rare case someone would have to reload after joining a server. It'll be looked at eventually.

As far as I remember, the Update stuff is run on all clients and the server, maybe some others. Anything damage related is only on that players client though.

...Err...
View attachment 25426
There is... uh... no opening into the golem's chamber... I guess I'm SOL?
I'm pretty sure I've seen this happen in vanilla as well. If you'd rather stick to the same world, follow the instructions from my post on the previous page about using the developer console, and fill an empty slot with a picksaw, dig through to the room, then trash the picksaw and disable the dev console :dryadtongue:
 
Why my Pulse Tsunami uses arrows and shoots arrows instead of white pulse bolts?
Code:
{
    "displayName": "Pulse Tsunami",
    "size": [38,58],
    "maxStack": 1,
    "value": [0,0,0,0],   
    "rare": 7,
    "tooltip": "",
    "useStyle": 5,
    "useAnimation": 20,
    "holdoutOffset": [-8,-2],
    "useTime": 20,
    "damage": 95,
    "knockback": 3,
    "useSound": 5,
    "autoReuse": true,
    "noMelee": true,
    "ranged": true,   
    "useAmmo": 1,
    "shoot": 357,
    "shootSpeed": 15,
    "recipes":[{
        "items": { "Vanilla:Pulse Bow": 1, "Vanilla:Tsunami": 1, "Tremor:Cybermite": 25 },
        "tiles": [ "Mythril Anvil" ],
        "creates": 1
    }]
}
 
Why my Pulse Tsunami uses arrows and shoots arrows instead of white pulse bolts?
Code:
{
    "displayName": "Pulse Tsunami",
    "size": [38,58],
    "maxStack": 1,
    "value": [0,0,0,0],  
    "rare": 7,
    "tooltip": "",
    "useStyle": 5,
    "useAnimation": 20,
    "holdoutOffset": [-8,-2],
    "useTime": 20,
    "damage": 95,
    "knockback": 3,
    "useSound": 5,
    "autoReuse": true,
    "noMelee": true,
    "ranged": true,  
    "useAmmo": 1,
    "shoot": 357,
    "shootSpeed": 15,
    "recipes":[{
        "items": { "Vanilla:Pulse Bow": 1, "Vanilla:Tsunami": 1, "Tremor:Cybermite": 25 },
        "tiles": [ "Mythril Anvil" ],
        "creates": 1
    }]
}
Because your useAmmo is set to arrows, change it to your ammo.
 
Whenever i try to setup a server. I can run it just fine and get on but when my friend joins his game crashes and my server crashes aswell, making it impossible to play multiplayer. Is this caused by specific mods or is it a tapi server issue?
 
Whenever i try to setup a server. I can run it just fine and get on but when my friend joins his game crashes and my server crashes aswell, making it impossible to play multiplayer. Is this caused by specific mods or is it a tapi server issue?
Hard to say without you sharing the logs. There are a few bugs with tAPI's multiplayer right now, but if you are using fresh characters/worlds using identical mods, it SHOULD be fine.
I'm having trouble uninstalling tAPI, every time I uninstall and pull up the game it reinstalls it! Can you help?
If you're trying to "uninstall" it by removing the tAPI folder in your documents, you're doing it wrong. Uninstall Terraria, then reinstall it, and tAPI will be gone.
 
Hard to say without you sharing the logs. There are a few bugs with tAPI's multiplayer right now, but if you are using fresh characters/worlds using identical mods, it SHOULD be fine.

If you're trying to "uninstall" it by removing the tAPI folder in your documents, you're doing it wrong. Uninstall Terraria, then reinstall it, and tAPI will be gone.
EDIT: Found them.
System.NullReferenceException: Object reference not set to an instance of an object.
at Shockah.AccSlots.MBase.<OnModCall>b__4(Terraria.Player player)
at BaseMod.BasePlayer.HasAccessory(Terraria.Player player, System.Int32 type, System.Boolean normal, System.Boolean vanity, System.Boolean& social, System.Int32& index)
at BaseMod.BasePlayer.HasAccessory(Terraria.Player player, System.Int32 type, System.Boolean normal, System.Boolean vanity)
at GRealm.Items.ShroomShell.GetActiveShell(Terraria.Player player, System.Boolean visual = False)
at GRealm.MPlayer.<.ctor>b__7(TAPI.PlayerLayer layer, Terraria.Player drawPlayer, Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
at TAPI.PlayerLayer+Action.OnDraw(Terraria.Player drawPlayer, Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
at TAPI.PlayerLayer.Draw(Terraria.Player drawPlayer, Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
at Terraria.Main.DrawPlayer(Terraria.Player drawPlayer, Microsoft.Xna.Framework.Vector2 Position, System.Single rotation, Microsoft.Xna.Framework.Vector2 rotationOrigin, System.Single shadow = 0)
at Terraria.Main.Draw(Microsoft.Xna.Framework.GameTime gameTime)

Appears to be because I have basemod and Accslots + so it looks like one of them has to go
The mods work loosely together in single player though
 
Status
Not open for further replies.
Back
Top Bottom