Standalone [1.3] tModLoader - A Modding API

Could you show the error it's throwing?
It throws all of these my way.
c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(282,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(290,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(315,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(319,33) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(320,20) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(321,34) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(322,21) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(323,4) : error CS1022: Type or namespace definition, or end-of-file expected
 
It throws all of these my way.
c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(282,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(290,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(315,19) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(319,33) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(320,20) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(321,34) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(322,21) : error CS1518: Expected class, delegate, enum, interface, or struct

c:\Users\Samson\Documents\my games\Terraria\ModLoader\Mod Sources\ThoriumMod\ThoriumPlayer.cs(323,4) : error CS1022: Type or namespace definition, or end-of-file expected
Oh dear, that looks an afwul lot like a syntax error.
You may want to double check your code. If you're unable to find anything, could you show me the code (either here on in a private conversation) so I can have a look at it? ;)
 
Oh dear, that looks an afwul lot like a syntax error.
You may want to double check your code. If you're unable to find anything, could you show me the code (either here on in a private conversation) so I can have a look at it? ;)
Turns out am as dumb as a sack of bricks. :sigh: You were definitely right though. I put a } instead of a {
 
I need some quick help. I need to edit this code so the monster:
1. Moves a lot faster and
2. faces the direction its moving...
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System;

namespace SpiritMod.NPCs
{
    public class ShootingStar : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Shooting Star";
            npc.displayName = "Shooting Star";
            npc.width = 30;
            npc.height = 24;
            npc.damage = 200;
            npc.defense = 30;
            npc.lifeMax = 5000;
            npc.soundHit = 1;
            npc.soundKilled = 1;
            npc.value = 60f;
            npc.knockBackResist = 0.5f;
        }
            public override bool PreAI()
{

    npc.noGravity = true;
    // The following handles the collision:
    if (!npc.noTileCollide)
    {
        if (npc.collideX)
        {
            npc.velocity.X = npc.oldVelocity.X * -0.5f;
            if (npc.direction == -1 && (double) npc.velocity.X > 0.0 && (double) npc.velocity.X < 2.0)
                npc.velocity.X = 2f;
            if (npc.direction == 1 && (double) npc.velocity.X < 0.0 && (double) npc.velocity.X > -2.0)
                npc.velocity.X = -2f;
        }
        if (npc.collideY)
        {
            npc.velocity.Y = npc.oldVelocity.Y * -0.5f;
            if ((double) npc.velocity.Y > 0.0 && (double) npc.velocity.Y < 1.0)
                npc.velocity.Y = 1f;
            if ((double) npc.velocity.Y < 0.0 && (double) npc.velocity.Y > -1.0)
                npc.velocity.Y = -1f;
        }
    } 
 
    npc.TargetClosest(true); // Gets a valid player to target.
    //The 'true' means that we want the NPC to look at the player.

    // The following is plucked right from the 'Demon Eye' AI, so you may want to take a look, but you might not understand it all:
 
    float num1 = 4f;
    float num2 = 1.5f;
    float num3 = num1 * (float) (1.0 + (1.0 - (double) npc.scale));
    float num4 = num2 * (float) (1.0 + (1.0 - (double) npc.scale));
    if (npc.direction == -1 && (double) npc.velocity.X > -(double) num3)
    {
        npc.velocity.X = npc.velocity.X - 0.1f;
        if ((double) npc.velocity.X > (double) num3)
            npc.velocity.X = npc.velocity.X - 0.1f;
        else if ((double) npc.velocity.X > 0.0)
            npc.velocity.X = npc.velocity.X + 0.05f;
        if ((double) npc.velocity.X < -(double) num3)
         npc.velocity.X = -num3;
    }
    else if (npc.direction == 1 && (double) npc.velocity.X < (double) num3)
    {
        npc.velocity.X = npc.velocity.X + 0.1f;
        if ((double) npc.velocity.X < -(double) num3)
            npc.velocity.X = npc.velocity.X + 0.1f;
        else if ((double) npc.velocity.X < 0.0)
            npc.velocity.X = npc.velocity.X - 0.05f;
        if ((double) npc.velocity.X > (double) num3)
            npc.velocity.X = num3;
    }
    if (npc.directionY == -1 && (double) npc.velocity.Y > -(double) num4)
    {
        npc.velocity.Y = npc.velocity.Y - 0.04f;
        if ((double) npc.velocity.Y > (double) num4)
            npc.velocity.Y = npc.velocity.Y - 0.05f;
        else if ((double) npc.velocity.Y > 0.0)
            npc.velocity.Y = npc.velocity.Y + 0.03f;
        if ((double) npc.velocity.Y < -(double) num4)
            npc.velocity.Y = -num4;
    }
    else if (npc.directionY == 1 && (double) npc.velocity.Y < (double) num4)
    {
        npc.velocity.Y = npc.velocity.Y + 0.04f;
        if ((double) npc.velocity.Y < -(double) num4)
            npc.velocity.Y = npc.velocity.Y + 0.05f;
        else if ((double) npc.velocity.Y < 0.0)
            npc.velocity.Y = npc.velocity.Y - 0.03f;
        if ((double) npc.velocity.Y > (double) num4)
            npc.velocity.Y = num4;
    }
 
    if(!npc.wet)
        return false;
 
    if ((double) npc.velocity.Y > 0.0)
        npc.velocity.Y = npc.velocity.Y * 0.95f;
    npc.velocity.Y = npc.velocity.Y - 0.5f;
    if ((double) npc.velocity.Y < -4.0)
        npc.velocity.Y = -4f;
    npc.TargetClosest(true);
 
    return false;
}           
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
    if (NPC.downedMechBossAny)
    {
        return spawnInfo.sky ? 3f : 0f;
    }
    return 0f;
}

}}
 
Uhh i dont know if this is dumb of me but can anyone help? When i play with more mods i get then after every save and exit an error message That says out of memory but i have 128 GB of RAM for terraria. Every time i need to at least reinstal terraria 3 times before it is OK to be played. Thanks for answear.
 
I need some quick help. I need to edit this code so the monster:
1. Moves a lot faster and
2. faces the direction its moving...
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System;

namespace SpiritMod.NPCs
{
    public class ShootingStar : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Shooting Star";
            npc.displayName = "Shooting Star";
            npc.width = 30;
            npc.height = 24;
            npc.damage = 200;
            npc.defense = 30;
            npc.lifeMax = 5000;
            npc.soundHit = 1;
            npc.soundKilled = 1;
            npc.value = 60f;
            npc.knockBackResist = 0.5f;
        }
            public override bool PreAI()
{

    npc.noGravity = true;
    // The following handles the collision:
    if (!npc.noTileCollide)
    {
        if (npc.collideX)
        {
            npc.velocity.X = npc.oldVelocity.X * -0.5f;
            if (npc.direction == -1 && (double) npc.velocity.X > 0.0 && (double) npc.velocity.X < 2.0)
                npc.velocity.X = 2f;
            if (npc.direction == 1 && (double) npc.velocity.X < 0.0 && (double) npc.velocity.X > -2.0)
                npc.velocity.X = -2f;
        }
        if (npc.collideY)
        {
            npc.velocity.Y = npc.oldVelocity.Y * -0.5f;
            if ((double) npc.velocity.Y > 0.0 && (double) npc.velocity.Y < 1.0)
                npc.velocity.Y = 1f;
            if ((double) npc.velocity.Y < 0.0 && (double) npc.velocity.Y > -1.0)
                npc.velocity.Y = -1f;
        }
    }

    npc.TargetClosest(true); // Gets a valid player to target.
    //The 'true' means that we want the NPC to look at the player.

    // The following is plucked right from the 'Demon Eye' AI, so you may want to take a look, but you might not understand it all:

    float num1 = 4f;
    float num2 = 1.5f;
    float num3 = num1 * (float) (1.0 + (1.0 - (double) npc.scale));
    float num4 = num2 * (float) (1.0 + (1.0 - (double) npc.scale));
    if (npc.direction == -1 && (double) npc.velocity.X > -(double) num3)
    {
        npc.velocity.X = npc.velocity.X - 0.1f;
        if ((double) npc.velocity.X > (double) num3)
            npc.velocity.X = npc.velocity.X - 0.1f;
        else if ((double) npc.velocity.X > 0.0)
            npc.velocity.X = npc.velocity.X + 0.05f;
        if ((double) npc.velocity.X < -(double) num3)
         npc.velocity.X = -num3;
    }
    else if (npc.direction == 1 && (double) npc.velocity.X < (double) num3)
    {
        npc.velocity.X = npc.velocity.X + 0.1f;
        if ((double) npc.velocity.X < -(double) num3)
            npc.velocity.X = npc.velocity.X + 0.1f;
        else if ((double) npc.velocity.X < 0.0)
            npc.velocity.X = npc.velocity.X - 0.05f;
        if ((double) npc.velocity.X > (double) num3)
            npc.velocity.X = num3;
    }
    if (npc.directionY == -1 && (double) npc.velocity.Y > -(double) num4)
    {
        npc.velocity.Y = npc.velocity.Y - 0.04f;
        if ((double) npc.velocity.Y > (double) num4)
            npc.velocity.Y = npc.velocity.Y - 0.05f;
        else if ((double) npc.velocity.Y > 0.0)
            npc.velocity.Y = npc.velocity.Y + 0.03f;
        if ((double) npc.velocity.Y < -(double) num4)
            npc.velocity.Y = -num4;
    }
    else if (npc.directionY == 1 && (double) npc.velocity.Y < (double) num4)
    {
        npc.velocity.Y = npc.velocity.Y + 0.04f;
        if ((double) npc.velocity.Y < -(double) num4)
            npc.velocity.Y = npc.velocity.Y + 0.05f;
        else if ((double) npc.velocity.Y < 0.0)
            npc.velocity.Y = npc.velocity.Y - 0.03f;
        if ((double) npc.velocity.Y > (double) num4)
            npc.velocity.Y = num4;
    }

    if(!npc.wet)
        return false;

    if ((double) npc.velocity.Y > 0.0)
        npc.velocity.Y = npc.velocity.Y * 0.95f;
    npc.velocity.Y = npc.velocity.Y - 0.5f;
    if ((double) npc.velocity.Y < -4.0)
        npc.velocity.Y = -4f;
    npc.TargetClosest(true);

    return false;
}          
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
    if (NPC.downedMechBossAny)
    {
        return spawnInfo.sky ? 3f : 0f;
    }
    return 0f;
}

}}
If you want your NPC to be able to move faster, you'll want to change the value of the num1 variable (higher value = higher speed).
If you want your NPC to look at the direction it's heading, put the following code right before the if(!npc.wet) check:
Code:
if (npc.velocity.X > 0.0)
{
    npc.spriteDirection = 1;
    npc.rotation = (float) Math.Atan2(npc.velocity.Y, npc.velocity.X);
}
if (npc.velocity.X < 0.0)
{
    npc.spriteDirection = -1;
    npc.rotation = (float) Math.Atan2(npc.velocity.Y, npc.velocity.X) + 3.14f;
}
 
If you want your NPC to be able to move faster, you'll want to change the value of the num1 variable (higher value = higher speed).
If you want your NPC to look at the direction it's heading, put the following code right before the if(!npc.wet) check:
Code:
if (npc.velocity.X > 0.0)
{
    npc.spriteDirection = 1;
    npc.rotation = (float) Math.Atan2(npc.velocity.Y, npc.velocity.X);
}
if (npc.velocity.X < 0.0)
{
    npc.spriteDirection = -1;
    npc.rotation = (float) Math.Atan2(npc.velocity.Y, npc.velocity.X) + 3.14f;
}
what about a item dropping by chance? because so far I can only make monsters drop it 100%, but I want to control it
 
what about a item dropping by chance? because so far I can only make monsters drop it 100%, but I want to control it
This has been discussed very frequently, but I'll say it again.. Use Main.rand.Next:
Code:
// Inside your NPCLoot function:
if(Main.rand.Next(4) == 0) // 25% chance.
{
    // Drop your item with 25% drop chance.
}

EDIT:
Ninja'd
 
  • Q: I can't play multiplayer with this mod! NPCs, mobs and bosses are disappearing after being hit! What to do!?
  • A: First, stop posting this dumb questions in this thread. Second, it's a tModLoader glitch and it will be fixed in next update. If you really want to post this question - go and do it in tModLoader thread.

    Me and my cousin are playing Tremor mod in multiplayer but the new bosses and new npc from the Tremor mod cant spawn for us in Multiplayer so we thought theres gonna be a fix for that in future?
 
  • Q: I can't play multiplayer with this mod! NPCs, mobs and bosses are disappearing after being hit! What to do!?
  • A: First, stop posting this dumb questions in this thread. Second, it's a tModLoader glitch and it will be fixed in next update. If you really want to post this question - go and do it in tModLoader thread.

    Me and my cousin are playing Tremor mod in multiplayer but the new bosses and new npc from the Tremor mod cant spawn for us in Multiplayer so we thought theres gonna be a fix for that in future?
Yeah, the idea is to make everything function correctly of course.
Thing is, I think blue and (maybe also) jopo are quite busy atm, so I'm guessing the update that will solve this will still take some time.
You can track the progress for the next version in the OP if you want to stay updated :)
 
I get an immediate crash when trying to launch the mac version of this. Is this the best place to address errors/issues? Should I post to github? Here's the error messages I see in the console at the time of the crash:

Code:
3/16/16 10:55:15.618 AM launchservicesd[88]: SecTaskLoadEntitlements failed error=22
3/16/16 10:55:15.635 AM launchservicesd[88]: SecTaskLoadEntitlements failed error=22
3/16/16 10:55:15.735 AM Terraria.bin.osx[11478]: WARNING: The Gestalt selector gestaltSystemVersion is returning 10.9.3 instead of 10.11.3. This is not a bug in Gestalt -- it is a documented limitation. Use NSProcessInfo's operatingSystemVersion property to get correct system version number.
Call location:
3/16/16 10:55:15.735 AM Terraria.bin.osx[11478]: 0   CarbonCore                          0x9a0ca913 ___Gestalt_SystemVersion_block_invoke + 135
3/16/16 10:55:15.735 AM Terraria.bin.osx[11478]: 1   libdispatch.dylib                   0x97a38763 _dispatch_client_callout + 50
3/16/16 10:55:15.735 AM Terraria.bin.osx[11478]: 2   libdispatch.dylib                   0x97a3863f dispatch_once_f + 78
3/16/16 10:55:15.735 AM Terraria.bin.osx[11478]: 3   libdispatch.dylib                   0x97a39ec9 dispatch_once + 31
3/16/16 10:55:15.736 AM Terraria.bin.osx[11478]: 4   CarbonCore                          0x9a046576 _Gestalt_SystemVersion + 1047
3/16/16 10:55:15.736 AM Terraria.bin.osx[11478]: 5   CarbonCore                          0x9a0456a5 Gestalt + 154
3/16/16 10:55:15.736 AM Terraria.bin.osx[11478]: 6   libSDL2-2.0.0.dylib                 0x0c0a2613 Cocoa_CreateDevice + 99
3/16/16 10:55:16.242 AM coreaudiod[203]: SecTaskLoadEntitlements failed error=22
3/16/16 10:55:16.277 AM Terraria.bin.osx[11478]: 10:55:16.277 WARNING:  140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.
3/16/16 10:55:17.000 AM kernel[0]: 176316.414626 IOUSBHostHIDDevice@fa142000,3: IOUSBHostHIDDevice::interruptRetry: resetting device due to IO failures
3/16/16 10:55:17.000 AM kernel[0]: 176316.457905 AppleUSB20HubPort@fa142000: AppleUSBHostPort::resetGated: retrying enumeration in 100 ms
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.000 AM kernel[0]: USB Sound assertion in /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleUSBAudio/AppleUSBAudio-302.15/AppleUSBAudioDevice.cpp at line 3440
3/16/16 10:55:17.233 AM Google Chrome[11323]: [10:55:17.232] <<<< AVCaptureHALDevice >>>> -[AVCaptureHALDevice _removePropertyListeners]: Removing alive observer for device <AVCaptureHALDevice: 0x7fe8d7566b00 [DELL UZ2715H][AppleUSBAudioEngine:DELL:DELL UZ2715H:000000000000:1,2]> failed (560947818)
3/16/16 10:55:17.233 AM Google Chrome[11323]: [10:55:17.233] <<<< AVCaptureHALDevice >>>> -[AVCaptureHALDevice _removePropertyListeners]: Removing format observer for device <AVCaptureHALDevice: 0x7fe8d7566b00 [DELL UZ2715H][AppleUSBAudioEngine:DELL:DELL UZ2715H:000000000000:1,2]> failed (560947818)
3/16/16 10:55:17.233 AM Google Chrome[11323]: [10:55:17.233] <<<< AVCaptureHALDevice >>>> -[AVCaptureHALDevice _removePropertyListeners]: Removing data source observer for device <AVCaptureHALDevice: 0x7fe8d7566b00 [DELL UZ2715H][AppleUSBAudioEngine:DELL:DELL UZ2715H:000000000000:1,2]> failed (560947818)
3/16/16 10:55:17.233 AM Google Chrome[11323]: [10:55:17.233] <<<< AVCaptureHALDevice >>>> -[AVCaptureHALDevice _removePropertyListeners]: Removing data sources observer for device <AVCaptureHALDevice: 0x7fe8d7566b00 [DELL UZ2715H][AppleUSBAudioEngine:DELL:DELL UZ2715H:000000000000:1,2]> failed (560947818)
 
4qpXB6g.png


Get this message once every 10-30 minutes while playing a 2 person multiplayer server using the mods Ersion, Quality of Life, Tremor, and Thorium. Game closes and needs a restart, server is fine and the other person playing is fine (though they also crash randomly as well, seperate from my crashes), any ideas on how to fix this?
 
Back
Top Bottom