Dan the man
Terrarian
Apologies if I am posting this in the wrong spot, I thought this might be a good place to ask, but there might be somewhere better! I just got back into modding and have been messing around with the example mod. I had one idea for a weapon I would like to try and make but had a few questions!
Firstly, as the title suggests, I want to make a melee weapon that relies on creating a projectile to swing (e.g. a spear) shoot a it's own projectile! Bonus points if you can show me how to make it consume bullets when it shoots and ONLY shoot one if I have them in my inventory (but still be able to normally swing the spear regardless). I can provide reference code but it is basically the same as the example mod's spear code (item .cs file :: projectile .cs file)
My initial thought process for this problem was to spawn a bullet in the projectile code, which seems to work I just don't know how to even start going about the part where it ONLY shoots if the player has a bullet in their inventory and then consumes the bullet.
Any help is greatly appreciated
Secondly— and maybe this should go in a seperate post, but here I am— I was looking through the custom swing sword projectile .cs and I was curious about a few things:
Firstly, as the title suggests, I want to make a melee weapon that relies on creating a projectile to swing (e.g. a spear) shoot a it's own projectile! Bonus points if you can show me how to make it consume bullets when it shoots and ONLY shoot one if I have them in my inventory (but still be able to normally swing the spear regardless). I can provide reference code but it is basically the same as the example mod's spear code (item .cs file :: projectile .cs file)
My initial thought process for this problem was to spawn a bullet in the projectile code, which seems to work I just don't know how to even start going about the part where it ONLY shoots if the player has a bullet in their inventory and then consumes the bullet.
Any help is greatly appreciated
Secondly— and maybe this should go in a seperate post, but here I am— I was looking through the custom swing sword projectile .cs and I was curious about a few things:
- In set static defaults,
PHP:public override void SetStaticDefaults() { ProjectileID.Sets.HeldProjDoesNotUsePlayerGfxOffY[Type] = true; }
This 'ProjectileID.Sets.HeldProjDoesNotUsePlayerGfxOffY[Type]' just returns an error (Visual Studio says "'ProjectileID.Sets' does not contain a definition for this item" can't remember the tmodloader error message off the top of my head but I can update this when I get around to checking again) every time I try to use it. Commenting it out seems to work but then what is it even used for?).
- I see a similar issue in the 'ModifyHitNPC' function:
PHP:public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { { // Make knockback go away from player modifiers.HitDirectionOverride = target.position.X > Owner.MountedCenter.X ? 1 : -1; // If the NPC is hit by the spin attack, increase knockback slightly if (CurrentAttack == AttackType.Spin) modifiers.Knockback += 1; } }
For this one, Visual Studio gives me "The type name 'HitModifiers' does not exist in the type 'NPC.'"
I am just confused and would like to understand better why these errors are happening!
Last edited: