tModLoader Turrets Mod [Work In Progress]

G4M3R57

Terrarian
TurretsMod_title.png

Welcome to my post, please enjoy your stay.

This mod is about turrets, sentries or whatever you want to call it, for Base/House Defense style. (or farming)

I thought about sharing this mod so that others could use it as well, so you can decompile it for see how it works, also you can use it for your own modding. (please, don't forget give me some credits) :)

This mod is open to suggestions, just reply below explaining your idea and I will see if I can introduce it.

Note: this mod still in progress, so it may have some inconveniences.

If you found any bug or smth weird, please report it as quickly as possible.

Important: before play in MP make sure to pickup all turrets, else these will behave buggy, actually this mod don't works properly in MP. I will try to fix it in next version. I apologize for this.

Watch this thread to receive notifications about new updates.

That being said, let's begin.

Updated to tModLoader v0.10.1.5!

WrenchIcon.png


Damage: 32
Knockback: 4
Use time: 48

Feature
Can repair certain amount turret HP with nearest ore in player inventory.

Price
Copper_Ore.png
/
Tin_Ore.png
= 20 HP
Iron_Ore.png
/
Lead_Ore.png
= 30 HP
Silver_Ore.png
/
Tungsten_Ore.png
= 40 HP
Gold_Ore.png
/
Platinum_Ore.png
= 50 HP
Palladium_Ore.png
/
Cobalt_Ore.png
= 60 HP

Use
Hit turret with wrench to repair, if need repair will consume, else will not.

Multicolor_Wrench.png
x1,
Mechanical_Ruler.png
x1,
Iron_Bar.png
/
Lead_Bar.png
x25,
Wire.png
x16,
Actuator.png
x8

@
Tinkerer's_Workshop.png
Make sure to read "Features" section before continue.

  • Can rotate & shoot automatically
  • Use ammo from player inventory or a neaby chest
  • Some turrets have rotation limit
  • Max 15 turrets can be spawned per world
  • Turrets have their own health & defense
  • Turrets can be damaged and destroyed to item again
  • Turrets are affected by some buff potions used by player
  • Deployed turrets will appear after rejoin to world (only works in SP)
Due to saving turrets only works in SP, deployed turrets in MP will disappear after rejoin to world
make sure know where are all deployed turrets before play in MP

sgItem.png


Health: 420
Defense: 38
Musket Ball (+7 damage)
Silver Bullet (+9 damage)
Meteor Shot (+9 damage)
Crystal Bullet (+9 damage)
Exploding Bullet (+10 damage)
Cursed Bullet (+12 damage)
Ichor Bullet (+13 damage)

Base damage: 60 (can't crit)
Knockback: 2
Shot time: 20
Distance: 50 tiles

Clockwork_Assault_Rifle.png
x1,
Illegal_Gun_Parts.png
x1,
The_Grand_Design.png
x1,
Iron_Bar.png
/
Lead_Bar.png
x50,
Wire.png
x40,
Junction_Box.png
x8,
Actuator.png
x9,
Cog.png
x10,
Soul_of_Might.gif
Soul_of_Sight.gif
Soul_of_Fright.gif
x20

@
Iron_Anvil.png
Sentry level 2 is a "non-permanent" upgrade.

Health: 500
Defense: 50
Base damage: 120 (can't crit)
Shot time: 10
Distance: 60 tiles

sentrygunlvl2.gif

Need 50 metal points (MP) to be upgraded.

Copper_Ore.png
/
Tin_Ore.png
+
Cog.png
= +7 MP
Iron_Ore.png
/
Lead_Ore.png
+
Cog.png
= +9 MP
Silver_Ore.png
/
Tungsten_Ore.png
+
Cog.png
= +11 MP
Gold_Ore.png
/
Platinum_Ore.png
+
Cog.png
= +13 MP
Palladium_Ore.png
/
Cobalt_Ore.png
+
Cog.png
= +15 MP
Ironskin_Potion.png
+8 defense
Thorns_Potion.png
thorns buff (50% dmg & +5 Kb)
Rage_Potion.png
+50% damage
Wrath_Potion.png
+15 damage
Ammo_Reservation_Potion.png
20% change to not consume ammo, +20% with Ammo Box
smItem.png


Health: 350
Defense: 30
Musket Ball (+7 damage)
Silver Bullet (+9 damage)
Meteor Shot (+9 damage)
Crystal Bullet (+9 damage)
Exploding Bullet (+10 damage)
Cursed Bullet (+12 damage)
Ichor Bullet (+13 damage)

Base damage: 45
Knockback: 5.25
Shot time: 35
Distance: 45 tiles

Musket.png
x1,
Mechanical_Lens.png
x1,
Radar.png
x1,
Iron_Bar.png
/
Lead_Bar.png
x40,
Wire.png
x30,
Junction_Box.png
x6,
Actuator.png
x6

@
Iron_Anvil.png
Ironskin_Potion.png
+8 defense
Thorns_Potion.png
thorns buff (50% dmg & +5 Kb)
Rage_Potion.png
+50% damage
Wrath_Potion.png
+15 damage
Ammo_Reservation_Potion.png
20% change to not consume ammo, +20% with Ammo Box
teslaItem.png


Health: 380
Defense: 35
Ammo: 1 mana/hit

Base damage: 35 in 1/7.5s (can't crit)
Knockback: 0 (10 if touch)
Shot time: 4
Distance: 40 tiles

Martian_Conduit_Plating.png
x40,
Chlorophyte_Bar.png
x20,
Wire.png
x 40,
Junction_Box.png
x8,
Actuator.png
x6,
Soul_of_Might.gif
Soul_of_Sight.gif
Soul_of_Fright.gif
x15,
Lihzahrd_Power_Cell.png
x1

@
Iron_Anvil.png
Attacking (old)
ezgif-1-6355a7056e.gif
Crystal_Ball.png
+10 secondary dmg in 1/15s
Magic_Power_Potion.png
+50% damage
wrItem.png
(can't be repaired)


Health: 375
Defense: 28
Wooden Arrow (+5 damage)
Flaming Arrow (+7 damage)
Unholy Arrow (+12 damage)
Jesters Arrow (+10 damage)
Hellfire Arrow (+13 damage)
Holy Arrow (+13 damage)
Cursed Arrow (+17 damage)

Base damage: 54
Knockback: 2
Shot time: 24
Distance: 45 tiles

Daybloom_Planter_Box.png
x1,
Living_Wood_Wand.png
x1,
Wood.png
x32,
Acorn.png
x15,
Sunflower.png
x10,
Mana_Crystal.png
x5

@
Living_Loom.png
Attacking (old)
ezgif-1-725c0670ca.gif


+12 defense & thorns effect with Dryad's blessing (50% dmg & +5 Kb)
Archery_Potion.png
+50% damage and arrows speed
Ammo_Reservation_Potion.png
20% change to not consume ammo, +20% with Ammo Box
flakCannon_Icon.png


Health: 420
Defense: 34
Ammo: Cannonball

Base damage: 300
Knockback: 6
Shot time: 45
Distance: 50 tiles

Cannon.png
x1,
Depth_Meter.png
x1,
Radar.png
x1,
Iron_Bar.png
/
Lead_Bar.png
x40,
Wire.png
x35,
Junction_Box.png
x7,
Actuator.png
x6,
Cog.png
x8,
Soul_of_Might.gif
x16,
Soul_of_Sight.gif
x28,
Soul_of_Fright.gif
x16

@
Iron_Anvil.png
flakCannon.gif


Ironskin_Potion.png
+8 defense
Thorns_Potion.png
thorns buff (10% dmg & +5 Kb)
Ammo_Reservation_Potion.png
20% change to not consume ammo, +20% with Ammo Box
hlItem.png
(can't fire in less than 10 tiles)

Health: 475
Defense: 42
Ammo: 15 mana/shot

Base damage: 82 (can't crit)
Knockback: 2
Shot time: 120 (2 seconds)
Distance: between 10-54 tiles

Heat_Ray.png
x1,
Black_Lens.png
x1,
1_Second_Timer_(placed).gif
x2,
Iron_Bar.png
/
Lead_Bar.png
x35,
Chlorophyte_Bar.png
x20,
Wire.png
x40,
Junction_Box.png
x8,
Actuator.png
x9,
Cog.png
x15,
Soul_of_Might.gif
Soul_of_Sight.gif
Soul_of_Fright.gif
x15,
Lihzahrd_Power_Cell.png
x1

@
Iron_Anvil.png
ezgif-1-057d9d8459.gif
(old)

ftItem.png


Health: 420
Defense: 36
Ammo: Gel

Base damage: 64
Knockback: 0.3
Shot time: 30
Distance: between 2-50 tiles

Flamethrower.png
x1,
Compass.png
x1,
Radar.png
x1,
Iron_Bar.png
/
Lead_Bar.png
x40,
Wire.png
x40,
Junction_Box.png
x8,
Actuator.png
x9,
Cog.png
x8,
Soul_of_Might.gif
Soul_of_Sight.gif
x20

@
Iron_Anvil.png
Not available.
Ironskin_Potion.png
+8 defense
Thorns_Potion.png
thorns buff (50% dmg & +5 Kb)
rlItem.png


Health: 450
Defense: 38
Rocket I (+40 dmg)
Rocket III (+65 dmg)

Base damage: 60
Knockback: 5
Shot time: 30
Distance: between 2-50 tiles

Rocket_Launcher.png
x1,
Radar.png
x1,
Iron_Bar.png
/
Lead_Bar.png
x40,
Wire.png
x50,
Junction_Box.png
x10,
Actuator.png
x9,
Cog.png
x6,
Soul_of_Might.gif
Soul_of_Sight.gif
Soul_of_Fright.gif
x15

@
Iron_Anvil.png
Not available.
Ironskin_Potion.png
+8 defense
Thorns_Potion.png
thorns buff (50% dmg & +5 Kb)
Ammo_Reservation_Potion.png
20% change to not consume ammo, +20% with Ammo Box

- In MP, If you rejoin to world, deployed turrets head will disappear.
- Basically this mod don't works properly in MP.

- If you put a dummy near turrets, these will shoot to it.
- Wooden Repeater don't use ammo from chests if are facing to left.
- Sometimes turrets crashes (like picked by a pickaxe) when they are in a heavy battle and have low health.
- All turrets are a bit inaccurate when shooting at small enemies (like Pinky Slimes)


ezgif-1-ee65186f60.gif
ezgif-1-1a81517643.gif
v1.0 - First release.
v1.1 - Minor tweaks & new turret introduced.
v1.2 - Turrets re-sprited.
v1.2.1 - Minor changes & new turret introduced.
v1.2.2 - Better aim for turrets & fixed "duplicated item" bug in MP.
v1.2.3 - Health to turrets introduced.
v1.2.4 - Minor fixes & changes.

- Defense to turrets introduced.
- 2 turrets introduced.
- New item introduced.

v1.2.5 - Minor changes, turrets are affected by buff potions.
v1.2.6 - Minor fixes & major changes.

- "only one per type" spawn limit lifted.
- Turrets can use ammo from a nearby chest.
- New turret introduced.

v1.2.7 - Minor MP fixes & major changes, this update is more for fix bugs.

- TF2 Sentry Gun can be upgraded (no permanently) to lvl 2 with Engie's Wrench using materials.
- Turrets can use multiple ammo. (will use from chests first if are nearby)
- Turrets re-sprited.
- Fixed a bug in MP.

v1.2.8.0 - New mechanics, minor fixes & major changes.

- Introduced a buff which can show any deployed or standby turret
- Spawn limit extended to 15 per world
- Major sprites changes
- Major recipes changes
- Turrets stats and buff effects changes
- 2 turrets introduced (flamethrower & rocket launcher)
- Engie's Wrench can use more type of ores for repair turrets
- Sentry, Musket & Repeater turrets can use more type of ammo
- Deployed turrets will appear after rejoin to world (only works in SP)

1.2.8.1-9.0 - Minor fixes & changes

- Introducing a dispenser which grants health, ammo and metal (for repair/upgrade turrets) to friendly players (will heal friendly NPCs too)

- Introducing a ceiling gun turret-type which are fast but inaccurate
(with "ceiling" I mean it can be deployed in roof)

- Reworking in Rocket Launcher turret, this update will make the turret shoot homing rockets, but will slow shot time and speed
(note: I will make this balance update due to the turret is hard to craft)

- Trying to fix MP issues.

- More in testing
Relogic team
for made this great game.

tModLoader team
without their work, mods can't live.

to SinCostan
for his really helpful Projectile tutorials.

to jopojelly
for help me alot with Tile related things.

to Jofairden
for his useful tutorials.

to coyotekins
for help me testing my mod.

Discord Help:
to DarkLight for help me with ConsumeItem method
(useful for using ammo)

to jopojelly for help me with detect a chest within a certain distance
using Vector2.Distance
 

Attachments

  • TurretsMod_v1.2.8.0.zip
    2.6 MB · Views: 1,518
Last edited:
*Buildin a Sentry*
But in all seriousness, that's just plain dynamite partner!

Hmmm, maybe while we're at it we could have dispensers ? (Bonus health regen and free basic ammo up to a capped level while standing near)
 
Is there a video without the lightning turret?


P.S. A bunch of these vs EoC would be cool(or other boss)
 
From the looks of it the sentry is a tile and the gun part is a projectile?
Yes, unlike sentry minions style, this is a Tile spawning a projectile as "head", you can see how works in source code.
Cool, what else you planning on adding?
Maybe make it upgradeable, add a health bar, limited ammo, colored teams for PvP, but I still learning about modding it can be a big work for me. :D
 
Imo turrets need to have health and can be destroyed.
Or at least an option to enable this.

Turret placement would be more crucial if there was a threat to them breaking. More strategy involved. More fun.
 
Might have found a bug.
Hosting a multiplayer game and when i place down a musket turret it also adds one into my inventory.
(so i end up with two every time i place one down and recover it)
Im playing with the latest version of Tmodloader. Hosted it via steam, Not playing with any other mods except this one.

Im not sure if this would happen with the other turret types or not. I only have been able to use musket so far as i am not yet in hard mode.
 
Can you add a lot more turrets? I have ideas for their crafts and the types, For example Wooden Peashooter, crafted via wooden turret legs, wooden turret body, wooden turret ammo box, and a wooden gun (wooden ammo box is crafted with 10 wood and 100 musketballs, and the wooden gun is crafted with Wooden Gun Parts made with 20 wood and a musketball just for measurement that will be returned), i actually think there could be more types of turrets like the rocket ones, flak, or magic ones!
 
Back
Top Bottom