Abandoned Force - Top View Strategy Game

Next Step is done: RESEARCHING.

Now its possible to research at the research-structure. Clicking on the structure opens a game-typical (generated) menu with all researches (receipes, which are in the global-list).

Three “Receipes” for testing are included and working well. The actually research-type/research/receipe looks like this:

-- RESEARCH TYPES
S.researchType = {
	-- INCREASE ammoMagazine Size
	{
	hash = hash("moreAmmo"),
	name = "Inc. unit magazine", -- Text shown in button
	researchResource = "iron",
	researchCost = 400,
	researchTime = 3, -- Seconds
	researchGroup = "unit",
	exec = function(self) 
		self.unit.ammoMagazine = self.unit.ammoMagazine + 5
		print("increased unit magazine size by 5")
	end
	},
	{
	hash = hash("moreMoveSpeed"),
	name = "Inc unit movespeed",
	researchResource = "gold",
	researchCost = 400,
	researchTime = 5, -- Seconds
	researchGroup = "unit",
	exec = function(self) 
		self.unit.moveSpeed = self.unit.moveSpeed + 50
		print("increased movespeed by 50")
	end
	},
	{
	hash = hash("moveMaxEnergy"),
	name = "Inc unit energy",
	researchResource = "artefact",
	researchCost = 400,
	researchTime = 10, -- Seconds
	researchGroup = "unit",
	exec = function(self) 
		self.unit.energyMax = self.unit.energyMax + 10
		print("increased max energy by 10")
	end
	}		
}

Looks ingame like this (menu):

Structure counting “down” until research is done:

Research is done, all units showing:

Technically after checking if there is enough resources given the GUi sends (using msg.post()) the research to the defined group of the receipe (actually only “unit”) - means to all existing units listed.
Every unit simply starts the function() given in the receipe.

Not sure if this is the best way but works. Not sure if it will be hard if there are maybe hundreds of units ? o.O
Need to do a stresstest :wink:

4 Likes

Update:

Sorry guys…

I am stuck at the GUIs (again). After some trouble displaying guis and handling the inputs I tried to recode the GUIs and GUI-scripts. Its a mess. Cant get a clue on the problem(s). I am simply stuck. Its complicated to handle inputs etc.

Pausing and rethinking the project.

Frustrated and lost in code. :worried:

Hmmm, do you have many GUIs and scripts? It can be a source of confusion if you break something up too much.

Update:

Back in business. GUI is working again after some improvements.

The new RESEARCH menu has a better look with more infos:

8 Likes

/ UPDATE

Huh. Here we go with a couple of new stuff and features I’ve coded.

1. ARCHIVEMENTS (I’ll call it like this):
Now its possible to get/find/research archivements. If found/researched player will get … new units to build (working), new buildings/structures etc

Archivements are actually some items with spawns or something the player can research at the research-structure.
Example: After researching “Knowledge of EMP” player can build/craft the unit “EMP Launcher”, later also the EMP-Defence-Structure etc.

Here some Screens:

Archivement-Item found:

Research-Structure (Building) with all entries (archivements also!):

…and here if you already researched the last ones (EMP, rockets):

…research-structure at work - now with info what job at work and timer of cause:

The unit-factory without any archivements (missing units):

…and here if player has archivements (EMP + ROCKET):

2. New unit/vehicle: Pioneer - this buddy can construct special kind of buildings called “defences”:

Pioneer building:

3. All structures, units and defences have a build-timer and a “under-construction-sprite” (no instant-building any more. In debug-mode its all set to 3 seconds):

4. Structure, units and defences now have health & energy bars (configurable in size, opaque etc at global-config-file, later at OPTIONS-Button :slight_smile: )

5. All Buttons have a tiny mouse-over-effect (zoom)

**6. Did lots of small improvements and bug-fixes of cause :wink: **

If someone is getting nervous :wink: here is a html5-link to the demo:
http://abandonedforce.trinium.de/

Keys:

  • arrow-keys to move the random-map
  • F9 - defold-collisions
  • F10 - defold sys-monitor
  • F11 - toggle debug-mode / infos :slight_smile: - ALSO fullscreen for browsers :smiley:

note: At HTML is running slow :frowning:

6 Likes

/UPDATE

Started to add particle-effects (particlefx).
As some of you may remember, I am new to defold :slight_smile: … so this are my first steps with particles here :slight_smile:

1. Particles for driving vehicles (with tyres, also have pfx for chain-based vehicles)…


The particles are mostly transparent. Just a very small graphic goodie while moving a vehicle (hard to see on screenshot):

2. Particles for rockets…

…in action… (looks also little lame at screenshot :frowning: … ingame little more nice :slight_smile:

2 Likes

Great to see such progress. Keep it up! Looking forward to see the game grow into an even more playable game :slight_smile:

/UPDATE

There had to be “recoded” a couple of functions for implementing new stuff. And of cause some improvements are done, small bugs found etc. Normal coding-stuff :slight_smile:

1. Recoded the weapons to be more “handy” and universal with the existing weapons (actually just 3 types).

2. Added kind of “radar” for defences to have a self-defending-system which engages automaticly. At the moment its realized with collisions (circles). Not very handy, maybe recoding this. This circles cant be resized etc. :frowning:

3. Defences now engages by themselfs if an enemy is in range. (Screenshot: Gun and rocket are attacking after tank gets in range (collider))

4. Radar-Range can be extended by researching at the researchlab. Added some “resarches” (too much) :slight_smile: - will re-organize that later and maybe split this to different buildings

5. Every unit, structure and defence now store the owner (here: CPU - for multiplayer later)

6. 3rd type of defence: rocket-launcher

7. Enemies (units, structures, defences) are displayed red :slight_smile:

8. Defences are using a reload-timer (yellow-bar)

//EDIT (forgot something)
9. New researches (working of cause :slight_smile: ) for upgrading weapons for a) more range b) more speed c) more damage :slight_smile:

If anyone like to try:
The slow HTML-Version :frowning: … HTML is really slow. Dont know why

http://abandonedforce.trinium.de

INFO:
Keys: Arrows for moving map, F9-F11 for some debug-stuff
All structures and units are spawning and every X seconds some items randomly.

5 Likes

/UPDATE

Between all the work there was some time for coding :slight_smile:

Whats new?

  1. New technology: Raycast. Has to be researched. Brings new weapon and new unit.
    research menu with raycast

  2. New Unit: Raycaster using the raycast weapon (also new):
    unit raycaster with new raycast-weapon

  3. Requirements / Dependencies. Already done for building units etc - now for researching. You just can research the new RAYCAST units/weapons if you already have researched EMP-Knowledge

  4. New weapon-feature “spray”. Now bullets are not spawn at same point which looks poor. Little more “real” feeling now. Spawnpoint are little randomly.
    defence turret gettling firing

  5. Rounds per shot. Some weapons now spawn not just 1 bullet, they shot a couple of rounds!
    unit sprayfire5

  6. New turrets: EMP, Gettling, Hellfire. They firing the new weapons with rounds and spay. Deadly. Of cause damage of the bullets are low.
    pioneer buildmenu new turrets
    EMP:
    defence structure emp firing
    Gettling (shots 10 rounds):
    defence turret gettling firing
    Hellfire (infinite fire with 1 hp):
    defence turret hellfire

  7. Reload-timer for units also! Every unit now needs a few moments/seconds to reload after each shot/round (yellow bar over unit)
    unit reloading

  8. New weapon: doublebullet (for turret-gun):
    defence turret gun with doublebullet

  9. Units will be reloaded at base/headquater. Also “self” healing increased (10x) if near the base:
    unit reloading at base

unit at base full reloaded

  1. Added a button top-right to open the menu (for touch / gaming without keyboard)

  2. Also added some new sounds like driving-tank. raycast-shot etc.
    (Note: Finding free to use sounds is a hard thing …)

Seeing the new raycaster with raycast-bullets and the new rounds and spray effect in action looks like this :smiley: (also hitting a second unit):

6 Likes

Packed with nice-looking updates – great work! :slight_smile:

1 Like

Hey, @stephenkalisch. I’m new to defold and to game dev in general. Trying to start my first game prototype and struggling with the health bars implementation.

How did you implement health bars in your game? I tried to implement em like in one of the @britzl examples (gui object, render script, detached material), but it seems like a huge overhead for me. Would be very grateful to hear, how you did those configurable and resizeable healthbars?

Thanks in advance.

Hey @BazZy.

I am using GUI Objects for this. I am cloning a prototype of it. Of cause - for a new one in game-dev and this engine - it may be a little confusing and hard to understand.

You may ask if you’re in trouble with it.

  1. The GUI elements in my ingame.gui:
    (the small 2 bars you see left with the arrows, or right in the outline highlighted. These are simple GUI-boxes)
    Note that all “un-sprited” boxes have their own layer! This is important to prevent to many drawcalls!

  1. In the ingame.guiscript I have several functions for.
    2.1. If a unit (in my case) has build/spawned it will call (message) the ingame.gui for creating (cloning) the unit-bar-templates (seen at the screen above).

The code (at UNIT.SCRIPT) looks like this:

		-- initiate UNIT-BARS (energy + hp)
		msg.post("main:/ingamegui#ingame", "unit_bar", {create = true, unitid = go.get_id(), pos = self.pos + vmath.vector3(-16, 16, 0), energy = GLOBAL.TILESIZE / self.unit.energyMax * self.unit.energy, health = GLOBAL.TILESIZE / self.unit.hitpointsMax * self.unit.hitpoints, busy = 1})

At the INGAME.GUISCRIPT it will receive the message with a code like this:
The trick is to clone the “handmade” bars.
Now there are several important steps to do:

  • Set them to the right layers to prevent the call-explosion (I’ve needed weeks to check that why I had 170 drawcalls and got it to this point as I was new to defold/lua)
  • give every GUI a UNIQUE Id to pick and update them later!
  • and of cause give each bar the right “value”

And… of cause the is a way to delete the bars if the unit has been destroyed. Also “called” with a message from the UNIT.SCRIPT


	-- UNIT-BARS
	if message_id == hash("unit_bar") then

		-- create a new one?
		if message.create == true then
			-- New unit-bars? Clone templates
			local newHealth = gui.clone(gui.get_node("unit_bar_health"))
			local newEnergy = gui.clone(gui.get_node("unit_bar_energy"))
			local newBusy = gui.clone(gui.get_node("unit_bar_busy"))

			-- set them to the right layer (better for drawcalls and performance)
			gui.set_layer(newHealth, "box")
			gui.set_layer(newEnergy, "box")
			gui.set_layer(newBusy, "box")

			-- give them a unique-id
			gui.set_id(newHealth, "unit_bar_health_" .. message.unitid)
			gui.set_id(newEnergy, "unit_bar_energy_" .. message.unitid)
			gui.set_id(newBusy, "unit_bar_busy_" .. message.unitid)

			-- store them into the unitbars table
			if newHealth and newEnergy and newBusy then
				table.insert(unitbars, {unitid = message.unitid, pos = message.pos, healthnode = newHealth, health = message.health, energynode = newEnergy, energy = message.energy, busynode = newBusy, busy = message.busy})
			end

			--print("Unit-bar created for " .. message.unitid .. " healthid " .. tostring(gui.get_id(newHealth)) .. " energyid " .. tostring(gui.get_id(newEnergy)) .. " busyid " .. tostring(gui.get_id(newBusy)))
			--print(" - VALUES: energy=" .. message.energy .. " health=" .. message.health .. " busy=" .. message.busy)
		end

		-- update bar - infos
		for i,v in ipairs(unitbars) do
			if unitbars[i].unitid == message.unitid then
				-- do we have to remove?
				if message.remove then
					--print("INGAMEGUI: unitbar: removed from list: " .. message.unitid)
					gui.delete_node(unitbars[i].healthnode)
					gui.delete_node(unitbars[i].energynode)
					gui.delete_node(unitbars[i].busynode)
					table.remove(unitbars, i)
					break
				-- update unit-bar-infos
				else
					--print("INGAMEGUI: unitbar-update for " .. message.unitid .." hp=" .. message.health .. " nrg=" .. message.energy)
					unitbars[i].pos = message.pos
					unitbars[i].health = message.health
					unitbars[i].energy = message.energy
					unitbars[i].busy = message.busy
				end
			end
		end
	end

To update the bars there are a simple line at the UPDATE()-function in the UNIT.SCRIPT . Called every second:

			-- UPDATING Unit-Bar
			msg.post("main:/ingamegui#ingame", "unit_bar", {
				unitid = go.get_id(), pos = self.pos + vmath.vector3(-16, 16, 0),
				energy = GLOBAL.TILESIZE / self.unit.energyMax * self.unit.energy,
				health = GLOBAL.TILESIZE / self.unit.hitpointsMax * self.unit.hitpoints,
				busy = GLOBAL.TILESIZE / self.unit.ammoReloadSpeed * self.reloadTimer})
2 Likes

Wow! Thanks a lot for such detailed answer. I’ll try to make it like this.