Extracting Energy instead of metal from the ground?

Extracting Energy instead of metal from the ground?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Extracting Energy instead of metal from the ground?

Post by Erik »

My Question is:
Is it possible to have building extracting energy instead of metal from the ground? (the actual metal will be gathered different )
My only solution currently would be switching Energy and Metal but that would be a bit confusing i guess...
on the other hand i'm still in the early phase of the mod so it would be an option X_X
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Extracting Energy instead of metal from the ground?

Post by SinbadEV »

Short answer, "Yes, you can do anything you feel like with Lua!"... however if you are trying to do something like this with the built-in TAist basic TDF tags and such-like, no... this behavior is a hard-coded effect of the "This is a metal harvester" tag...

Also, been FOREVER since I've made a unit myself so I'm not the person to answer any questions on specifics like HOW to go about achieving this behavior with Lua etc.
User avatar
caldera
Posts: 388
Joined: 18 Oct 2005, 20:56

Re: Extracting Energy instead of metal from the ground?

Post by caldera »

Doesnt the geo plant "extract" energy from the ground? its just a different color in one of the map-layers
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Extracting Energy instead of metal from the ground?

Post by Beherith »

Its possible, and easily doable with geo vents. Ill elaborate if the need arises.
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Extracting Energy instead of metal from the ground?

Post by Master-Athmos »

In terms of Lua scripts there also is CA's windmill script which changes the energy production based on the windmill's height. It in the end includes all the logic needed to gather some info and overwrite the resource gains with the wanted values...
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Extracting Energy instead of metal from the ground?

Post by Erik »

So i can make it buildable only ontop a certain feature? That would also solve my problem i guess.
What do i need for that?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Extracting Energy instead of metal from the ground?

Post by zwzsg »

Only if that feature is geovent.

Also I have a gadget to plant a geovent on every metal spot.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Extracting Energy instead of metal from the ground?

Post by Beherith »

You need to make points of 255 green on your featuremaps to get geo vents. And you need to look at how geothermal plants are done in BA or similar.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Extracting Energy instead of metal from the ground?

Post by zwzsg »

Geothermal plant are not jus mexx that extract energy:
- Geothermal plant can only be build on the geovent geyser feature, mexx can be built anywhere.
- Every geo output the same energy, mexx output more or less depending on how rich is the soil.
- Mexx have extraction radius, geo not.
- ...


Instead, you should write a gadget that:
- Use Spring.GetGroundInfo to see how much metal there is at the unit position.
- Use Spring.SetUnitResourcing to make the unit produce more or less energy.

At least this way you're not forced to litter maps with geovent, and you can keep variation in production relative to variation in the metal map.

If you want to keep the extraction radius, instead of reading the ground metal concentration, read how much the mexx produce (if you can get a value small enough that it doesn't contribute significatively to metal economy yet large enough the number read is precise). Or maybe read how fast the mexx spin, or something.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Extracting Energy instead of metal from the ground?

Post by Erik »

Guess i will come back at that later when i can code a bit better.
User avatar
JohannesH
Posts: 1793
Joined: 07 Apr 2009, 12:43

Re: Extracting Energy instead of metal from the ground?

Post by JohannesH »

Erik wrote:My Question is:
Is it possible to have building extracting energy instead of metal from the ground? (the actual metal will be gathered different )
My only solution currently would be switching Energy and Metal but that would be a bit confusing i guess...
on the other hand i'm still in the early phase of the mod so it would be an option X_X
Use the metalmap to represent a resource thats gathered from the ground. Resource names shouldnt matter at all as long as they make sense
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Extracting Energy instead of metal from the ground?

Post by KDR_11k »

Shields can't be powered with metal.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Extracting Energy instead of metal from the ground?

Post by Erik »

Couldnt someone just copy paste the code in the engine and change it to energy/ a ressource of choice.
Doesn't sound that much work, on the other hand im not sure if anyone besides me will ever need that feature :o
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Extracting Energy instead of metal from the ground?

Post by Google_Frog »

CA's mex overdrive gadget has all the functions/examples you need to make a gadget that extracts energy from the metal map. Overdrive does this:
  • Reads the metal income of built mexes and sets the income to very near 0.
  • Does a lot of complex wackey stuff with energy creating metal, calculus for maximum output, pylons that activate mexes and have an energy limit, input energy from all teammates...
  • Gives the players metal income.
Take out the middle step, change "metal income" to "energy income" and you have what you want.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Extracting Energy instead of metal from the ground?

Post by zwzsg »

Code: Select all

function gadget:GetInfo()
	return {
		name = "Soil Energy",
		desc = "Energy production relative to ground metal",
		author = "zwzsg",
		date = "17 february 2010",
		version = "1.0",
		license = "Public Domain",
		layer = 0,
		enabled = true
	}
end

if (gadgetHandler:IsSyncedCode()) then


	-- Replace armllt and corllt by your units' name.
	-- Add similar new lines for new units.
	-- Replace 0.001 by how much energy they should extract.
	-- Expressed in the same units as in mexxes extractsMetal tag.
	local EnergyExtractors = {
			[UnitDefNames.armllt.id]=0.001,
			[UnitDefNames.corllt.id]=0.001,
		}


	-- This compensate for maps being made for mexx that have an area of effect
	-- That gadget only measure metal in the middle, while mexxes cover an area
	-- This factor make it the number are the same nonetheless
	-- Obviously won't work if you built just over a spike in the metal map
	local areafactor=Game.extractorRadius*Game.extractorRadius*math.pi/128


	function gadget:UnitFinished(u,ud)
		if EnergyExtractors[ud] then
			local x,_,z=Spring.GetUnitPosition(u)
			local _,metal=Spring.GetGroundInfo(x,z)
			Spring.SetUnitResourcing(u,"ume",metal*EnergyExtractors[ud]*areafactor)
		end
	end

end
If you remove comments and header info, that's ten lines of code. And the hardest part was to figure out the 128.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Extracting Energy instead of metal from the ground?

Post by Google_Frog »

That doesn't have mex radius. Or should I say eex radius.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Extracting Energy instead of metal from the ground?

Post by zwzsg »

That could be added. But I wanted to keep the gadget simple so as to be easy to read and understand.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Extracting Energy instead of metal from the ground?

Post by Erik »

Edit:
Why does the metalmap dissapear now with the script enabled?
Without the script i see the metalmap fine but with it it doesnt show up when building.

Sidnote:
Also why on earth is there music from kernel panic even when i play something else? Weird stuff...
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Extracting Energy instead of metal from the ground?

Post by zwzsg »

Why does the metalmap dissapear now with the script enabled?
The gadget I posted in this thread does not change anything with the metal map display.
Also why on earth is there music from kernel panic even when i play something else?
- Delete /music/*.ogg
- Convert your TA CD audio track to .ogg and place into /music/
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Extracting Energy instead of metal from the ground?

Post by Erik »

nvm i works fine
Last edited by Erik on 03 Mar 2010, 10:36, edited 1 time in total.
Post Reply

Return to “Game Development”