Upgradable gun turrets w/coins possible?

Place to get help with not working mods / modding interface.
MegaMech
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Mar 22, 2016 10:02 pm
Contact:

Upgradable gun turrets w/coins possible?

Post by MegaMech »

Hello,

Is the following possible or feasible? If not, can you suggest a similar idea that would be? I am new to modding Factorio but not new to programming. It has several modding limits, specifically with editing the UI, so I don't want to waste time if what I want to do is not possible. I want to create more interesting defenses like in StarCraft II's "Mineralz".

I want to add an upgrade button to the original ammo-turret UI or create a copy of gun-turret with the added button to its click-UI.

The upgrade button contains preset increases of all stats such as damage and armour. Each turret can be individually upgraded ten times and only one turret can be upgraded to level 10. Each upgrade perhaps changes the ammo-turrets display name/tooltip name to have cool names like "Phase Turret", "Perfect Turret", etc. (I would also do this to the laser turret and walls)

I also want to add two buildings. A "generator" and a "healer". Instead of powering laser turrets with electricity, they would be powered through a "gen" which can be upgraded to be more efficient. It converts electricity to a medium that laser turrets can use. Perhaps the gen could use the laser turrets beam to shoot laser turrets making it look like its powering them. In Starcraft buildings have a "magic" stat that was used to do this. When a turret ran out of magic it stops shooting or does no damage.

The healer, also upgradable, heals nearby buildings.

Thanks for your advice in advance. I am looking at the code of other mods that do UI, such as cyberchest.
Last edited by MegaMech on Sat Dec 14, 2019 7:42 pm, edited 1 time in total.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3733
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Upgradable gun turrets w/coins possible?

Post by DaveMcW »

Sounds easy enough. You obviously need to create 10 different turret entities.

After you build the gui and check if the upgrade is legal, the upgrade code is:

Code: Select all

turret.surface.create_entity{
  name = upgraded_turret.name,
  position = turret.position,
  direction = turret.direction,
  force = turret.force,
  target = turret.target,
  source = turret.source,
  fast_replace = true,
}
MegaMech
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Mar 22, 2016 10:02 pm
Contact:

Re: Upgradable gun turrets w/coins possible?

Post by MegaMech »

Do I have to create new types of ammo to change damage output? I do not see a "damage" option in the ammo-turret entity information on the wiki.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3733
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Upgradable gun turrets w/coins possible?

Post by DaveMcW »

The damage option is hidden behind some nested defines.

Search this page for "damage_modifier" https://gist.githubusercontent.com/Bilk ... 3c1ae7/raw
Post Reply

Return to “Modding help”