Neojin
Terrarian
Remove the '.png' from the female body texture line.I'm having a small problem with my mod, here's my code any help would be appreciated
View attachment 56328
here's the error i get: View attachment 56329
Remove the '.png' from the female body texture line.I'm having a small problem with my mod, here's my code any help would be appreciated
View attachment 56328
here's the error i get: View attachment 56329
Still ain't working
What does a DamageNPC hook look like?Could be an issue with dmgDealt as a value... It may be worth using the DamageNPC hook instead, see if that fixes anything.
What does a DamageNPC hook look like?
With solutions come more problems, it seems.-get snipped-
public class MProjectile : ModProjectile
{
Player player = Main.player[projectile.owner];
public override void DamageNPC(NPC npc, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult)
{
for (int i = 3; i < 8; i++)
{
if (player.armor[i].type == ItemDef.byName["Rektmod:VampiricEmblem"].type)
{
player.statLife += (int)(damage / 8);
}
}
}
}
Compiling code...
MProjectile.cs (31,16)
An object reference is required for the non-static field, method, or property 'TAPI.ModProjectile.projectile.get'
Player player = Main.player[projectile.owner];
With solutions come more problems, it seems.
Right now i have that going on, and the builder says this:Code:public class MProjectile : ModProjectile { Player player = Main.player[projectile.owner]; public override void DamageNPC(NPC npc, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult) { for (int i = 3; i < 8; i++) { if (player.armor[i].type == ItemDef.byName["Rektmod:VampiricEmblem"].type) { player.statLife += (int)(damage / 8); } } } }
How would i implement the same for melee?Try placing the Player definition after the hook, just before the for() loop.
It worked, then?How would i implement the same for melee?
One more thing that would be swood would be some green numbers telling you how much health you stole from whatever poor sob you managed to hit.It worked, then?
Melee is easier, no need for global mods. Just place the same code in the item's .cs file under this hook:
public override void DamageNPC(Player player, NPC npc, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult)
You don't need the player definition, since it's in the hook.
Pretty easy, actually.One more thing that would be swood would be some green numbers telling you how much health you stole from whatever poor sob you managed to hit.
So is that hard to do?
public class MPlayer : ModPlayer
{
public void PostHurt(bool pvp, bool quiet, int hitDirection, string deathText, bool crit, float critMultiplier, ref double parsedDamage)
{
for (int i = 3; i < 8; i++)
{
if (player.armor[i].type == ItemDef.byName["Rektmod:VengeanceEmblem"].type)
{
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, "Rektmod:AlienBlast", projectile.damage, projectile.knockBack, Main.myPlayer);
}
}
}
}
Validating Jsons...
Compiling code...
MPlayer.cs (15,14)
'Rektmod.MPlayer.PostHurt(bool, bool, int, string, bool, float, ref double)' hides inherited member 'TAPI.ModPlayer.PostHurt(bool, bool, int, string, bool, float, ref double)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
public void PostHurt(bool pvp, bool quiet, int hitDirection, string deathText, bool crit, float critMultiplier, ref double parsedDamage)
^
MPlayer.cs (31,20)
The name 'projectile' does not exist in the current context
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, "Rektmod:AlienBlast", projectile.damage, projectile.knockBack, Main.myPlayer);
^
MPlayer.cs (54,20)
The name 'projectile' does not exist in the current context
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, "Rektmod:AlienBlast", projectile.damage, projectile.knockBack, Main.myPlayer);
^
MPlayer.cs (105,20)
The name 'projectile' does not exist in the current context
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, "Rektmod:AlienBlast", projectile.damage, projectile.knockBack, Main.myPlayer);
^
MPlayer.cs (124,20)
The name 'projectile' does not exist in the current context
Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, "Rektmod:AlienBlast", projectile.damage, projectile.knockBack, Main.myPlayer);
So i'm trying to make an accessory that spawns projectiles around you when you get damaged.
And it's giving me thisCode:public override void PostHurt(bool pvp, bool quiet, int hitDirection, string deathText, bool crit, float critMultiplier, ref double parsedDamage) { for (int i = 3; i < 8; i++) { if (player.armor[i].type == ItemDef.byName["Rektmod:VengeanceEmblem"].type) { Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, "Rektmod:AlienBlast", projectile.damage, projectile.knockBack, Main.myPlayer); } } }
You might need to take a step back from modding for a moment. Try unpacking some of the more popular mods found in the forums and look through the code they use. Try to understand what each line is doing and how it effects things in the game. You also might want to visit some sites that review the basics of C# coding to familiarize yourself with coding. When errors pop up, try searching for the error message using Google.So i'm trying to make an accessory that spawns projectiles around you when you get damaged.
And it's giving me thisCode:public class MPlayer : ModPlayer { public void PostHurt(bool pvp, bool quiet, int hitDirection, string deathText, bool crit, float critMultiplier, ref double parsedDamage) { for (int i = 3; i < 8; i++) { if (player.armor[i].type == ItemDef.byName["Rektmod:VengeanceEmblem"].type) { Projectile.NewProjectile(projectile.position.X, projectile.position.Y, 0, 0, "Rektmod:AlienBlast", projectile.damage, projectile.knockBack, Main.myPlayer); } } } }
I'm not at a computer right now, but it should be something like -Is it possible to modify the values stored in .json via a .cs file for the same item? I'm looking to mess with autoReuse for a gun that will autofire 6 shots, then flip off autoReuse, forcing you to click again. That next shot turns autoReuse back on, and then you have this new kind of weapon that isn't painful/difficult to use like the Venus Magnum, but isn't quite as mindless as the megashark, and is distinct from burst-fire weapons like the clockwork assault rifle.
I'm not at a computer right now, but it should be something like -
ItemDef.byName["InternalName:ItemName"].autoReuse = false;
I think you're right. You might try -It seems weird to have to define the item within its own .cs file, but it compiles fine. I'll test it out in game once all the other assets are done.
I think you're right. You might try -
item.autoReuse = false;