In one of the pieces of armour:I am currently trying to make a modded armor set that has a set bonus which lets you shoot projectiles when taking damage, but I don't know how to make the set bonus do that.
public override void UpdateArmorSet(Player player)
{
player.setBonus = "Shoots projectiles");
player.GetModPlayer<ModPlayerFile>(mod).onHitProj= true;
}
public bool onHitProj = false;
public override void ResetEffects()
{
onHitProj= false;
}
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
{
if(onHitProj == true)
{
Projectile.NewProjectile(...);
}
return base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource);
}
Alright, so I am making a mod, and I need to know if this... works? The problem is that at the bottom, it says vector two, and I need that fixed.
Can anyone help me? (Yes I'm a nub at this kind of stuff)
[doublepost=1534989664,1534989600][/doublepost]Code:using Terraria.ID; using Terraria.ModLoader; namespace FuryMod.Projectiles { public class FireBolt : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("FireBolt"); //The English name of the projectile ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; //The length of old position to be recorded ProjectileID.Sets.TrailingMode[projectile.type] = 0; //The recording mode } public override void SetDefaults() { projectile.width = 8; //The width of projectile hitbox projectile.height = 8; //The height of projectile hitbox projectile.aiStyle = 1; //The ai style of the projectile, please reference the source code of Terraria projectile.friendly = true; //Can the projectile deal damage to enemies? projectile.hostile = false; //Can the projectile deal damage to the player? projectile.magic = true; //Is the projectile shoot by a ranged weapon? projectile.penetrate = 5; //How many monsters the projectile can penetrate. (OnTileCollide below also decrements penetrate for bounces as well) projectile.timeLeft = 6000; //The live time for the projectile (60 = 1 second, so 600 is 10 seconds) projectile.alpha = 255; //The transparency of the projectile, 255 for completely transparent. (aiStyle 1 quickly fades the projectile in) projectile.light = 0.5f; //How much light emit around the projectile projectile.ignoreWater = false; //Does the projectile's speed be influenced by water? projectile.tileCollide = true; //Can the projectile collide with tiles? projectile.extraUpdates = 20; //Set to above 0 if you want the projectile to update multiple time in a frame aiType = ProjectileID.WaterBolt; //Act exactly like default Bullet } public override bool OnTileCollide(Vector2 oldVelocity) { //If collide with tile, reduce the penetrate. //So the projectile can reflect at most 5 times projectile.penetrate--; if (projectile.penetrate <= 0) { projectile.Kill(); } else { if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; } if (projectile.velocity.Y != oldVelocity.Y) { projectile.velocity.Y = -oldVelocity.Y; } Main.PlaySound(SoundID.Item10, projectile.position); } return false; } } }
Oh yeah, also this is the last thing, please somebody help me (I really need it)
Thanks, adding that now (It is taking a long time I have a slow computer lol)In one of the pieces of armour:
In your ModPlayer file:Code:public override void UpdateArmorSet(Player player) { player.setBonus = "Shoots projectiles"); player.GetModPlayer<ModPlayerFile>(mod).onHitProj= true; }
Hope that helpsCode:public bool onHitProj = false; public override void ResetEffects() { onHitProj= false; } public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if(onHitProj == true) { Projectile.NewProjectile(...); } return base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource); }
[doublepost=1535911288,1535910850][/doublepost]
You'll need to add:
using Terraria;
using Microsoft.Xna.Framework;
Hope that helps![]()
Check all your files; There might be another file with public DraconianMod() in it that’s causing the issue.I am currently making a mod called 'Draconian Mod', but when I try to build the latest version, an error pops up saying "c:\Users\User\Documents\My Games\Terraria\ModLoader\Mod Sources\DraconianMod\VanillaItemRecipes.cs(10,11) : error CS0101: The namespace 'DraconianMod' already contains a definition for 'DraconianMod'
Here is the code for the location of the error:
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace DraconianMod
{
class DraconianMod : Mod
{
public DraconianMod()
{
Properties = new ModProperties()
{
Autoload = true,
AutoloadGores = true,
AutoloadSounds = true
};
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.IronBar, 5);
recipe.AddIngredient(ItemID.Silk, 10);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(ItemID.RocketBoots);
recipe.AddRecipe();
recipe = new ModRecipe(this);
recipe.AddIngredient(ItemID.ChlorophyteBar, 18);
recipe.AddIngredient(ItemID.BeetleHusk, 6);
recipe.AddTile(TileID.MythrilAnvil);
recipe.SetResult(ItemID.Picksaw);
recipe.AddRecipe();
}
}
}
Well, my first mod and already I feel like I'm biting off more than I can chew.
I'm wanting to create a set of accessories for my mod, which so far I'm doing alright with, but I have a few questions related to debuffs that they'd apply.
How would I make it so that an accessory would slow down the player by a set amount when equipped (like being over-encumbered in skyrim)? And, is it possible to make the accessory apply knockback to the player, the amount applied being determined by the damage taken in a hit?
My issue is really that, once again, this is my first mod, and really my first experience in c#.
It did end up helping, it lead me to the code in the terraria game files to find the moveSpeed variable (or whatever you call it here, I'm too used to Python)For slowing the player, I think you would just do player.velocity * 0.5 (that would half it, replace with whatever) in your UpdateAccessory(...) hook. As for the knockback, I can't really help with that, sorry. Good concept idea, though.
Hope that helps, anyway![]()
I need help, My friend keeps joining and when he joins his character is frozen.
projectile.penetrate = -1;?Hewwo, I'm trying to "code" a melee projectile. The melee work, projectile pops up, the only problem is that, the projectile is just /there/.
The projectile phases through enemies, doesn't do much except fly away..
Can anyone show me a script I can reference to?
My current script:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace YinBlade.Projectiles
{
public class Lightning : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Lightning");
projectile.width = 200;
projectile.height = 200;
projectile.friendly = true;
projectile.melee = true;
projectile.tileCollide = true;
projectile.penetrate = -1;
projectile.timeLeft = 200;
projectile.light = 20f;
projectile.extraUpdates = 1;
projectile.ignoreWater = true;
}
public override void AI()
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 90f;
}
}
}
Nothing yet, it still phases through entities, tiles causes them to disappear which I pressume is normal.. although I have tried tileCollide = false but didn't work.projectile.penetrate = -1;?
Try setting that to at least 1