Magic damage is a floatso i'm making an armour set and here's my c# file for it but for some reason it's not registering as an armour set and i need to change the magic damage to +15% and i cant below 1 for it and that adds +100% does anyone know how to fix this?View attachment 56603
The only way I can think of is this.How Would I Make My Mod Test To See If The World Is Corruption Or Crimson
I Want My Mod To Make It So If There World Is Corruption The Texture For My Weapon Is This
View attachment 57304
I Want It To Make It Look Like This On Crimson Worlds
View attachment 57305
public override void PostUpdate()
{
if(!Main.dedServ) //dedicated servers don't store textures, so they don't need to do anything
{
int type = ItemDef.byName["ModName:ItemName"].type;
ModBase modBase = Mods.GetMod("ModName").modBase;
if(WorldGen.corruption)
{
Main.itemTexture[type] = modBase.textures[CorruptionTextureName"]; //for the texture names, include the folders that contain the texture
}
else if(WorldGen.crimson)
{
Main.itemTexture[type] = modBase.textures["CrimsonTextureName"];
}
}
}
AwesomeThe only way I can think of is this.
First make a class that overrides ModWorld. Override the PostUpdate() hook. Then you'll need to do something like this:
Code:public override void PostUpdate() { if(!Main.dedServ) //dedicated servers don't store textures, so they don't need to do anything { int type = ItemDef.byName["ModName:ItemName"].type; ModBase modBase = Mods.GetMod("ModName").modBase; if(WorldGen.corruption) { Main.itemTexture[type] = modBase.textures[CorruptionTextureName"]; //for the texture names, include the folders that contain the texture } else if(WorldGen.crimson) { Main.itemTexture[type] = modBase.textures["CrimsonTextureName"]; } } }
It Doesnt WorkThe only way I can think of is this.
First make a class that overrides ModWorld. Override the PostUpdate() hook. Then you'll need to do something like this:
Code:public override void PostUpdate() { if(!Main.dedServ) //dedicated servers don't store textures, so they don't need to do anything { int type = ItemDef.byName["ModName:ItemName"].type; ModBase modBase = Mods.GetMod("ModName").modBase; if(WorldGen.corruption) { Main.itemTexture[type] = modBase.textures[CorruptionTextureName"]; //for the texture names, include the folders that contain the texture } else if(WorldGen.crimson) { Main.itemTexture[type] = modBase.textures["CrimsonTextureName"]; } } }
That probably means that the corruption and crimson texture names are wrong. Depending on the folders they're in, I imagine they would be something like this:It Doesnt Work
View attachment 57381
Nvm I Just Had To Add Textures/EyeRenderer_Crimson And Textures/EyeRenderer_CorruptionThat probably means that the corruption and crimson texture names are wrong. Depending on the folders they're in, I imagine they would be something like this:
"Items/OtherFoldersYouHave/TextureName"
Make sure you don't include the ".png" in the texture name, since the game already adds that for you.
You would do a similar thing to the buff shown in the original post, except you won't need an End method, instead of using Effects(Player player, int index) you'll be using Effects(NPC npc, int index), and you'll be incrementing npc.lifeRegen in this method.Hello. I have a question regarding buffs, can you say give an NPC (a slime for example) a buff like health regen?
So something like this?You would do a similar thing to the buff shown in the original post, except you won't need an End method, instead of using Effects(Player player, int index) you'll be using Effects(NPC npc, int index), and you'll be incrementing npc.lifeRegen in this method.
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using TAPI;
using Terraria;
namespace enhancedenemies.Buffs
{
public class liferegen : TAPI.ModBuff
{
public override void Effects(NPC npc, int index)
{
npc.lifeRegen;
}
}
}
Right now, you're not actually doing anything with npc.lifeRegen. You need to actually increment it. So you would replaceSo something like this?
Would I have to add the lifeRegenCount; in there too?Code:using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using TAPI; using Terraria; namespace enhancedenemies.Buffs { public class liferegen : TAPI.ModBuff { public override void Effects(NPC npc, int index) { npc.lifeRegen; } } }
npc.lifeRegen;
npc.lifeRegen += 1;
Thank you so much. I know this is a small problem for an experienced modder to help with, but I really do appreciate it.Right now, you're not actually doing anything with npc.lifeRegen. You need to actually increment it. So you would replace
withCode:npc.lifeRegen;
That will increment npc.lifeRegen by 1, which corresponds to 1 health every 2 seconds.Code:npc.lifeRegen += 1;
Since this is code for a buff, it will affect all enemies that have the buff. So what you can do is make a class that extends ModNPC, give it the GlobalMod attribute, then use if statements checking for the NPC's type to apply the buff.Thank you so much. I know this is a small problem for an experienced modder to help with, but I really do appreciate it.
EDIT: Also will this affect all NPC's globally, or do I have to assign it in an npc's code? (the latter is what I want so not all npc's have this buff)
Alright, I got my buff code:Since this is code for a buff, it will affect all enemies that have the buff. So what you can do is make a class that extends ModNPC, give it the GlobalMod attribute, then use if statements checking for the NPC's type to apply the buff.
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using TAPI;
using Terraria;
namespace enhancedenemies.Buffs
{
public class RegenBasic : TAPI.ModBuff
{
public override void Effects(NPC npc, int index)
{
npc.lifeRegen += 1;
}
}
}
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using TAPI;
using Terraria;
namespace ModInternalName
{
[GlobalMod]
public class MNPC : ModNPC
{
public override void OnSpawn()
{
if (npc.type == 3)
{
npc.lifeMax = 160;
npc.life = 16;
}
}
}
}