Unit Morphing LuaRules Gadget

Unit Morphing LuaRules Gadget

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

Moderator: Moderators

Post Reply
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Unit Morphing LuaRules Gadget

Post by trepan » 25 Apr 2007, 23:32

Here's an example of a unit morphing gadget (LuaRules), and its config file.

12.5 MByte video
http://trepan.bzflag.bz/spring/morph.mpeg

LuaRules/Gadgets/unit_morph.lua
http://trepan.homelinux.net/spring/unit_morph.lua

LuaRules/morphdefs.lua (config file)
http://trepan.homelinux.net/spring/morphdefs.lua

Some points:

1. The config file data could be integrated into the FBI files. I much
prefer using lua files as config files (for testing), because their scripting
ability makes it much easier to change multiple entries with less typing.

2. The morph rendering effect is weak, it could be made a lot better.
One thing that I might add is the ability to completely disable the normal
unit rendering to allow some neat clip plane effects. The progress
indicator could be made to look more like the standard ones.

3. Attaching the new unit to a transporter should be possible.

4. This gadget is ".luarules reload" safe, although morphs are restarted.
It will remove and re-add the 'Morph' command to all applicable units
during a reload, and will return the used metal (with normal stopping
penalty) to the unit's team.
0 x

User avatar
Peet
Malcontent
Posts: 4381
Joined: 27 Feb 2006, 22:04

Post by Peet » 25 Apr 2007, 23:51

Trepan, I do believe I speak for many modders when I say THIS IS EPIC WIN.
0 x

User avatar
Noruas
XTA Developer
Posts: 1267
Joined: 24 Feb 2005, 02:58

Post by Noruas » 25 Apr 2007, 23:56

Now we can do evolution and upgrading certain units.
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6109
Joined: 29 Apr 2005, 01:14

Post by FLOZi » 26 Apr 2007, 00:30

Very cool. 8) :-)

Wonder if we can think of anyhting to use this for in S44.
0 x

User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf » 26 Apr 2007, 00:45

Okay, now... Can we make it to where a unit purchases the upgrade to morph itself... (I still can't watch the damned videos :evil: )
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 26 Apr 2007, 01:08

Try this one:
3.3 MByte AVI (ffmpeg -i morph.mpeg morph.avi)
http://trepan.bzflag.bz/spring/morph.avi
0 x

User avatar
jackalope
Posts: 694
Joined: 18 Jun 2006, 22:43

Post by jackalope » 26 Apr 2007, 01:11

hey guys this is a good feature.
Last edited by jackalope on 26 Apr 2007, 05:41, edited 1 time in total.
0 x

User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf » 26 Apr 2007, 01:19

Its not that problem.. Realplayer can't find its codecs, VLC kills my computer, windows media interprets everything as an audio file...
0 x

User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Post by Nemo » 26 Apr 2007, 03:38

Holy...awesome...speechless...

Trepan, you ROCK.
0 x

User avatar
Lolsquad_Steven
Posts: 488
Joined: 27 Jun 2006, 17:55

Post by Lolsquad_Steven » 26 Apr 2007, 04:23

jackalope wrote:EDIT by trepan: removed lame remark.

I will not have this thread go down the racial / political
path that other recent threads have been steered towards.
Hahahahaha, this made my day.
0 x

User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh » 26 Apr 2007, 07:10

I wish you'd just use a standard codec lol... ah well, I guess I'll have to just test this. The real trick is hooking a UI element (a button) to the unit, having the button execute the call. If in addition to this, we could track some other game states... hmm...
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan » 26 Apr 2007, 09:04

1. I used the 'standard' xvidcap codec. Does the AVI version not work?

2. The button is already hooked up. Scan through the code and look
for morphCmdDesc to see how it is done. Note that is works with both
the default control panel and LuaUI (and that an AI can even look for
it by searching through the CommandDescriptions).

You can use the SetUnitRulesParam() command to keep track of
unit states. If you go that route, the information will be maintained even
when LuaRules is shutdown. It can be queried by all lua scripts, and
will probably be made available to the AI interface in the future (once
I've cleaned up the lua scripts, made them easier to use (gadgets), and
finished some of the documentation).
0 x

User avatar
Zenka
Posts: 1235
Joined: 05 Oct 2005, 15:29

Post by Zenka » 26 Apr 2007, 13:41

great! now we can finnally make upgreadable mexes :) not to mention tons of other aspecs in mods.
0 x

MaDDoX
Posts: 53
Joined: 08 Jan 2006, 17:45

Re: Unit Morphing LuaRules Gadget

Post by MaDDoX » 14 Dec 2017, 05:01

Not sure if I should post it here or in a new thread, but here it goes. I've cooked up a new version of unit_morph.lua with the following improvements:

-- Default buildtime, buildcostenergy and buildcostmetal is now the difference between original and target unit values
-- Accepts and prioritizes definitions in customData.morphdef
-- Properly talks to multi_tech.lua (tech tree gadget by zwzsg)
-- 'require' entry now require techs instead of units
-- 'require' supports multiple tech requirements (comma-separated)
-- Morph button text now shown in red when requirements not fulfilled

PS.: This version doesn't require an unitdefs_data.lua file (big blob of all units .fbi which I use for Google Sheets integration), simply uncomment the first block within the AddCustomMorphDefs() method for the standard multi-file units definitions.

Hope it helps!
Attachments
unit_morph.lua
(47.4 KiB) Downloaded 5 times
0 x

User avatar
nixtux
TechA Developer
Posts: 100
Joined: 01 Mar 2009, 15:36

Re: Unit Morphing LuaRules Gadget

Post by nixtux » 14 Dec 2017, 11:11

Hey MaDDoX, which version of the gadget did you use a base?

Thanks nixtux
0 x

MaDDoX
Posts: 53
Joined: 08 Jan 2006, 17:45

Re: Unit Morphing LuaRules Gadget

Post by MaDDoX » 01 May 2018, 16:55

The latest I could find :)

Forboding Angel has added it successfully to a recent EvoRTS release.

My current dev version also includes morph pause (must have!) and a powerful morph queue, with which you can queue units/structures to be morphed and they're morphed one at a time, to prevent stalling your economy. Not ready for release though, some lingering errors to be fixed.

Other nice things are planned and/or under development, like prioritizing energy/metal/units morphs in the queue, highlight the units in queue (and show their index #) while holding the meta key, etc.
0 x

Post Reply

Return to “Lua Scripts”