Linked Units

Linked Units

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Linked Units

Post by kalda341 »

Is it possible to have it when you build a powerplant (or a turret like in c&c 3) you build a hub, then several nodes coming off it (preferably joint by wires or something). If you destroy the hub, all nodes are destroyed too. If you destroy a node, only that node is destroyed.
User avatar
Cheesecan
Posts: 1571
Joined: 07 Feb 2005, 21:30

Re: Linked Units

Post by Cheesecan »

Yes.
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Linked Units

Post by kalda341 »

Cheesecan wrote:Yes.
How would I do it?
User avatar
Cheesecan
Posts: 1571
Joined: 07 Feb 2005, 21:30

Re: Linked Units

Post by Cheesecan »

kalda341 wrote:
Cheesecan wrote:Yes.
How would I do it?
Start hacking lua scripts. Begin somewhere small, say a script that prints out something in the console. Then maybe a script that detects when you built a specific building. Then work your way up to more complex things. In your Spring/LuaUI/Widgets directory is a ton of samples to get you started.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Linked Units

Post by hoijui »

i do not know if it is still in ZK, but CA had shields that were linked together by some energy beam thing, when they were close, so you may copy&paste from them.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Linked Units

Post by knorke »

a powerplant (or a turret like in c&c 3)
I think you misunderstand what he meant by linked units:
http://cnc.wikia.com/wiki/Component_Tower wrote:The tower itself was just a plug into which a a defensive weapon could be installed. This allowed a GDI commander to place a number of empty towers and install the actual defenses later on.
Afaik the only way to do this in spring is that the base unit has to be a transporter and loads the other unit. The UI would be a bit complicated to do...

If you really mean something like this:
There is a "defense center" that can build turrets in some radius around it.
If the defense center is destroyed, all its turrets also explode.

Then that is easier to do ie like this:

Code: Select all

local turret_belongs_to = {} --for each turret store which defense center built it

UnitCreated(unitID, unitDefID, teamID, builderID)
	local new_unit_is_turret = blablabla
	if (new_unit_is_turret==true) then
		turret_belongs_to[unitID] = builderID
	end
end

UnitDestroyed(unitID, unitDefID, teamID, attackerID)
	local destroyed_unit_is_defense_center = blabla
	if (destroyed_unit_is_defense_center==true) then
	loop (through turret table)
		if  (turret_belongs_to[turretUnitID]= unitID) then 
			destroyedUnit (turret[turretUnitID)
			turret_belongs_to[turretUnitID] = nil
		end
	end
end
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Linked Units

Post by FLOZi »

You can do it with movectrl or even just show/hide pieces too, depending on what is really wanted.
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: Linked Units

Post by SeanHeron »

Answer for a casual player: Yes this is possible, but it isn't built-in functionality (I know of no such structure existing at the moment - though that doesn't mean noone has it..) , so there's a bit of scripting / coding you'd have to do to get it to work.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Linked Units

Post by Google_Frog »

Would I be right in saying you want to be able to build one structure which can then deploy a fixed number of sub structures around it? Like Nod towers in c&c3?

This is pretty simple to do with minimal gadget work. Your hub structure can have the node structures in it's buildlist and a certain build range that dictates how far away the sub structure can be. The hub and nodes need to be non-assistable to prevent them taking part in other built in economy things that you might have. From here the player can simply select the hub and place nodes, you can control the cost and buildtime of nodes.

The only lua gadgetting required would be to destroy all nodes when the hub is destroyed, disable the hubss build options when it is controlling the maximun number of nodes and optionally to draw wires between the hub and nodes.

The gadget side of this is far easier than others would have you think.
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Linked Units

Post by kalda341 »

Google_Frog wrote:Would I be right in saying you want to be able to build one structure which can then deploy a fixed number of sub structures around it? Like Nod towers in c&c3?

This is pretty simple to do with minimal gadget work. Your hub structure can have the node structures in it's buildlist and a certain build range that dictates how far away the sub structure can be. The hub and nodes need to be non-assistable to prevent them taking part in other built in economy things that you might have. From here the player can simply select the hub and place nodes, you can control the cost and buildtime of nodes.

The only lua gadgetting required would be to destroy all nodes when the hub is destroyed, disable the hubss build options when it is controlling the maximun number of nodes and optionally to draw wires between the hub and nodes.

The gadget side of this is far easier than others would have you think.
When you put it like that, it does sound quite simple. I should be able to manage that.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Linked Units

Post by knorke »

Image

And it really is that simple.
See my previous posting with the pseudo code.
So anyway, I decided to do this because I wanted something similiar.

For every unitname you can define several other unitnames. Those "linked"
Units will explode if their builder dies. In this example there is a "turret center" that
Controlls the turrets it built. If this "turret center" is
Killed, all its turrets also die.

By writing this sentence I
Add a hidden message.
Attachments
tp_linked_unit_explo.lua
(2.83 KiB) Downloaded 162 times
Post Reply

Return to “Lua Scripts”