Dragonpriest4
Skeletron Prime
How would I make a custom ore generate in a world?
How would I make a custom ore generate in a world?
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes"));
if (ShiniesIndex == -1)
{
// Shinies pass removed by some other mod.
return;
}
tasks.Insert(ShiniesIndex + 1, new PassLegacy("Example Mod Ores", delegate (GenerationProgress progress)
{
progress.Message = "Example Mod Ores";
for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
}));
}
where would i find NPC.csLook in NPC.cs for the setdefaults of the NPC you are interested in. You'll see the type and aistyle for that NPC. Then, look for aistyle == (number here) and you should find the ai code for that ai style. Within that block of code there may be if statements to further refine the aistyle due to the type (aka NPCid) of the NPC. You'll need to look through it and attempt to understand the code.
where would i find NPC.cs
how do you decompile and is it NPC.cs or NPCIt's one of Terraria's classes that you get when you decompile it. It's pretty hard to miss, really.
how do you decompile and is it NPC.cs or NPC
where "mod.TileType("ExampleBlock")" is the tile, 6E-05 is a multiplier on the number of loops, and I forget all the parameters for TileRunner right now.Code:public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight) { int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes")); if (ShiniesIndex == -1) { // Shinies pass removed by some other mod. return; } tasks.Insert(ShiniesIndex + 1, new PassLegacy("Example Mod Ores", delegate (GenerationProgress progress) { progress.Message = "Example Mod Ores"; for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++) { WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true); } })); }
using System.IO;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using System;
namespace EpicnessMod
{
public class EpicnessWorld : ModWorld
{
private const int saveVersion = 0;
public static bool downedDarkNebula = false;
public static int DarkNebulaDefeated;
public const int MSG_BLESS = 1;
//public struct EpicnessMsgs
//{
public static string[] misc = {"Your world has been infected with Corrupt Ore!"};
//}
public override void Initialize()
{
downedDarkNebula = false;
}
public override void SaveCustomData(BinaryWriter writer)
{
writer.Write(saveVersion);
byte flags = 0;
writer.Write(DarkNebulaDefeated);
if (downedDarkNebula)
{
flags |= 1;
}
writer.Write(flags);
}
public override void LoadCustomData(BinaryReader reader)
{
reader.ReadInt32();
DarkNebulaDefeated = reader.ReadInt32();
byte flags = reader.ReadByte();
downedDarkNebula = ((flags & 1) == 1);
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes"));
if (ShiniesIndex == -1)
{
// Shinies pass removed by some other mod.
return;
}
tasks.Insert(ShiniesIndex + 1, new PassLegacy("Corrupt Ore", delegate (GenerationProgress progress)
{
progress.Message = "Corrupt Ore";
for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("Corrupt Ore"), false, 0f, 0f, false, true);
}
}));
}
}
}
When I inserted that code into my world file I got this error
c:\Users\Julian Romero\Documents\My Games\Terraria\ModLoader\Mod Sources\EpicnessMod\EpicnessWorld.cs(55,48) : error CS0246: The type or namespace name 'PassLegacy' could not be found (are you missing a using directive or an assembly reference?)
Here is the code of the world file:
Code:using System.IO; using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.World.Generation; using Microsoft.Xna.Framework; using System; namespace EpicnessMod { public class EpicnessWorld : ModWorld { private const int saveVersion = 0; public static bool downedDarkNebula = false; public static int DarkNebulaDefeated; public const int MSG_BLESS = 1; //public struct EpicnessMsgs //{ public static string[] misc = {"Your world has been infected with Corrupt Ore!"}; //} public override void Initialize() { downedDarkNebula = false; } public override void SaveCustomData(BinaryWriter writer) { writer.Write(saveVersion); byte flags = 0; writer.Write(DarkNebulaDefeated); if (downedDarkNebula) { flags |= 1; } writer.Write(flags); } public override void LoadCustomData(BinaryReader reader) { reader.ReadInt32(); DarkNebulaDefeated = reader.ReadInt32(); byte flags = reader.ReadByte(); downedDarkNebula = ((flags & 1) == 1); } public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight) { int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes")); if (ShiniesIndex == -1) { // Shinies pass removed by some other mod. return; } tasks.Insert(ShiniesIndex + 1, new PassLegacy("Corrupt Ore", delegate (GenerationProgress progress) { progress.Message = "Corrupt Ore"; for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++) { WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("Corrupt Ore"), false, 0f, 0f, false, true); } })); } } }
If you aren't using Visual Studio yet, you should really try.
Anyway, the using statement is "using Terraria.GameContent.Generation;"
If you aren't using Visual Studio yet, you should really try.
Anyway, the using statement is "using Terraria.GameContent.Generation;"
Here is the method signature.This might be a stupid question but where would the ore appear now that it is generates (so that I have a reference point to find it)
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
Player player = Main.player[Main.myPlayer];
int x = spawnInfo.spawnTileX;
int y = spawnInfo.spawnTileY;
int tile = (int)Main.tile[x, y].type;
return (ThoriumMod.NormalSpawn(spawnInfo)) && spawnInfo.spawnTileY < Main.worldSurface - 250 && (int)(player.position.Y / 16) < Main.maxTilesY - 200 && Main.evilTiles < 100 && Main.snowTiles < 100 && Main.sandTiles < 100 && Main.bloodTiles < 100 && Main.jungleTiles < 100 && Main.dungeonTiles < 100 ? 0.20f : 0f;
}
Could you explain a bit more?can some one help me i would like my Helmet to shoot a laser in a enemy direction but not going after it
The following is an example:How do I make custom wings (I would like to make infinite)?
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Wings);
return true;
}
public override void SetDefaults()
{
item.name = "ings";
item.width = 24;
item.height = 30;
item.toolTip = "Allows for infinite flight";
item.value = Item.sellPrice(5, 0, 0, 0);
item.rare = 10;
item.accessory = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.wingTimeMax = 18000; // 5 minutes flight.
}
public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}
public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 10f;
acceleration *= 3f;
}
// NOTE: The following function is used to allow for infinite flight. This is UNTESTED so keep that in mind.
// If you want to add effects when using your wings, this is also the place to do that.
public override void WingUpdate(Player player, bool inUse)
{
if (inUse)
{
player.wingTime = 10;
}
}
public override void AddCraftGroups()
{
AddCraftGroup("CraftGroupName", Lang.misc[37] + " " + "Craft Group Display Name",
ItemType("MyItem1"), ItemType("MyItem2"), ItemType("MyItem3"), ItemType("MyItem4"));
}