Standalone [1.3] tModLoader - A Modding API

2091-320.png
Fixed the string error. Now i have this in my game.
[doublepost=1480110096,1480109993][/doublepost]Next project is gonna be hard, im gonna need Heros mod with it too.
A machine shotgun.
 
what about a HOMING machine shotgun?
...wonder if there is a way to remove the range limit? so, the bullets keep on going until they hit something?
 
what about a HOMING machine shotgun?
...wonder if there is a way to remove the range limit? so, the bullets keep on going until they hit something?
Chlorophyte bullets. The damage will only be 10 though, but 5, every like half a second, a definite moon lord drop
 
Any help?
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1514: { expected

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1519: Invalid token '-' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,30) : error CS1519: Invalid token '-' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,35) : error CS1519: Invalid token ':' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(10,5) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
This is my code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TestWeapon.Items.Weapons
{
public class Shot-Machine-Gun : ModItem
{
public override void SetDefaults()
{
item.name = "Shot-Machine-Gun";
item.damage = 10;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is the fastest shotgun we have.";
item.useTime = 1;
item.useAnimation = 38;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 7;
item.value = 10000;
item.rare = 2;
item.useSound = 14;
item.autoReuse = false;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = ProjectileID.Bullet;
}
public override void AddRecipes() //How to craft this gun
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HallowedBar, 12); //you need 1 DirtBlock
recipe.AddTile(TileID.WorkBenches); //at work bench
recipe.SetResult(this);
recipe.AddRecipe();

}
public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)(angle * 0.0174532925);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
return (Vector2[])posArray;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2[] speeds = randomSpread(speedX, speedY, 8, 6);
for (int i = 0; i < 5; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
}

[doublepost=1480117235,1480117149][/doublepost]
Any help?
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1514: { expected

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1519: Invalid token '-' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,30) : error CS1519: Invalid token '-' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,35) : error CS1519: Invalid token ':' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(10,5) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
This is my code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TestWeapon.Items.Weapons
{
public class Shot-Machine-Gun : ModItem
{
public override void SetDefaults()
{
item.name = "Shot-Machine-Gun";
item.damage = 10;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is the fastest shotgun we have.";
item.useTime = 1;
item.useAnimation = 38;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 7;
item.value = 10000;
item.rare = 2;
item.useSound = 14;
item.autoReuse = false;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = ProjectileID.Bullet;
}
public override void AddRecipes() //How to craft this gun
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HallowedBar, 12); //you need 1 DirtBlock
recipe.AddTile(TileID.WorkBenches); //at work bench
recipe.SetResult(this);
recipe.AddRecipe();

}
public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)(angle * 0.0174532925);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
return (Vector2[])posArray;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2[] speeds = randomSpread(speedX, speedY, 8, 6);
for (int i = 0; i < 5; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
}
When i copy and pasted, the spaces for different codes did not copy and paste.
In my original thing, they were all correct.
 
Trying to make wings emit light like a shine potion does but i get this error if i try to just use the shine potion buff

error CS1061: 'Terraria.Player' does not contain a definition for 'Buff' and no extension method 'Buff' accepting a first argument of type 'Terraria.Player' could be found (are you missing a using directive or an assembly reference?)

Im new to coding so i dont quite understand what this line means
If somone could tell me how to just make them emit light without the shine buff that would be very helpful too
 
Any help?
c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1514: { expected

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,22) : error CS1519: Invalid token '-' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,30) : error CS1519: Invalid token '-' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(9,35) : error CS1519: Invalid token ':' in class, struct, or interface member declaration

c:\Users\Matthew\Documents\My Games\Terraria\ModLoader\Mod Sources\TestWeapon\Items\Weapons\Shot-Machine-Gun.cs(10,5) : error CS1519: Invalid token '{' in class, struct, or interface member declaration
This is my code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TestWeapon.Items.Weapons
{
public class Shot-Machine-Gun : ModItem
{
public override void SetDefaults()
{
item.name = "Shot-Machine-Gun";
item.damage = 10;
item.ranged = true;
item.width = 40;
item.height = 20;
item.toolTip = "This is the fastest shotgun we have.";
item.useTime = 1;
item.useAnimation = 38;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 7;
item.value = 10000;
item.rare = 2;
item.useSound = 14;
item.autoReuse = false;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 14f;
item.useAmmo = ProjectileID.Bullet;
}
public override void AddRecipes() //How to craft this gun
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.HallowedBar, 12); //you need 1 DirtBlock
recipe.AddTile(TileID.WorkBenches); //at work bench
recipe.SetResult(this);
recipe.AddRecipe();

}
public static Vector2[] randomSpread(float speedX, float speedY, int angle, int num)
{
var posArray = new Vector2[num];
float spread = (float)(angle * 0.0174532925);
float baseSpeed = (float)System.Math.Sqrt(speedX * speedX + speedY * speedY);
double baseAngle = System.Math.Atan2(speedX, speedY);
double randomAngle;
for (int i = 0; i < num; ++i)
{
randomAngle = baseAngle + (Main.rand.NextFloat() - 0.5f) * spread;
posArray = new Vector2(baseSpeed * (float)System.Math.Sin(randomAngle), baseSpeed * (float)System.Math.Cos(randomAngle));
}
return (Vector2[])posArray;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2[] speeds = randomSpread(speedX, speedY, 8, 6);
for (int i = 0; i < 5; ++i)
{
Projectile.NewProjectile(position.X, position.Y, speeds.X, speeds.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
}

[doublepost=1480117235,1480117149][/doublepost]
When i copy and pasted, the spaces for different codes did not copy and paste.
In my original thing, they were all correct.
UPDATE:I fixed the "-" problems. I still have the other ones.
 
Im trying to make a crafting station. I made one already but this one gives a different result. Any ideas? The original items look like this.
 

Attachments

  • Screenshot (45).png
    Screenshot (45).png
    76.2 KB · Views: 221
  • BlessedAlter.png
    BlessedAlter.png
    723 bytes · Views: 232
  • BlessedAlter.png
    BlessedAlter.png
    717 bytes · Views: 166
I imagine your looking for this... If you place that in UpdateEquip, you'll have a constant shine buff active on you. As for capturing that effect without the buff active, place the latter in UpdateEquip and change the 1f values to what you see fit. higher values = more bright and its in an RGB format.
Code:
player.AddBuff(BuffID.Shine), 30);

Code:
Lighting.AddLight(player.position, 1f, 1f, 1f);
 
Last edited:
Fixed all of the problems but one. THE GUN CANT SHOOT
Sorry. have been working on the Shot-Machine-Gun for HOURS
It has been finished. Ill wake up early and make a boss.
Man, coding requires alot of patience.

While the occasional double post is not a big deal, constantly posting multiple times in a row is spammy and against the rules. Please use the edit button if you have something to add before the next person posts. Additionally, this thread is for questions and discussion about tModLoader, not to announce your progress on coding, so please keep posts on topic and relevant to the thread.
 
While the occasional double post is not a big deal, constantly posting multiple times in a row is spammy and against the rules. Please use the edit button if you have something to add before the next person posts. Additionally, this thread is for questions and discussion about tModLoader, not to announce your progress on coding, so please keep posts on topic and relevant to the thread.

Is there a specific forum to ask for assistance on coding a mod?
 
how would i make a modded item use a modded item? aka, i have souls of magic and want to make a magic arrow, but what do i put in the recipe.AddIngredient();?
 
While the occasional double post is not a big deal, constantly posting multiple times in a row is spammy and against the rules. Please use the edit button if you have something to add before the next person posts. Additionally, this thread is for questions and discussion about tModLoader, not to announce your progress on coding, so please keep posts on topic and relevant to the thread.
Sorry. Ill post on this help forum i found. Sorry again.
 
Back
Top Bottom