Lua Script to automatically reimburse the cost of a unit ?

Lua Script to automatically reimburse the cost of a unit ?

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

Moderator: Moderators

Post Reply
User avatar
Makhoaay
Posts: 13
Joined: 30 Jun 2007, 13:42

Lua Script to automatically reimburse the cost of a unit ?

Post by Makhoaay »

Hello everyone,

I'm working on my first mod attempt... It's a mod about teamplay. Hmpf, sorry, I don't think it's the good place to tell about it. Some minutes ago, I've been to the #moddev channel to ask if I could add a line to a unit's fbi file to reimburse the player (For example, if I need one metal unit and one hundred energy units to build Juan, if Juan dies, I'm given metal unit and one hundred energy units.). KDR told me I could "Make Lua check if a unit died and give the player the resources for the unit". As I don't know how to code in Lua language, could someone of you (My saviour.) create it for me ? I allow myself to ask you it because KDR also said : "Should be really easy though".

Thank you !
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post by LathanStanley »

sounds more like a hack, that will just desync games terribly... :|

I suppose I can see reasons for such a wish though....

good luck, best I can say is read about it...

I don't have a clue either :?
j5mello
Posts: 1189
Joined: 26 Aug 2005, 05:40

Post by j5mello »

actually what he wants is basically the same thing as how gold gets issued in TD abeit instead of a "gold" value he just wants the exact cost in resources of the unit back...

shouldn't be that hard to modify the code in TD, once it's released, to do just that...
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Indeed, the TD mod code would work perfectly in this situation. If you give me a minute, ill modify what I have here to reimburse its cost upon death.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Image

Unzip to the LuaRules folder of your mod (assuming you have one already set up), and change the units to repay in LuaRules/Configs/unit_death_repay_defs.lua

Hope this works for you 8)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

Good for a design using a points system to bound unit-limits, instead of UnitLimited. Maybe I'll use that someday :-)
User avatar
Makhoaay
Posts: 13
Joined: 30 Jun 2007, 13:42

Post by Makhoaay »

LathanStanley said : "sounds more like a hack, that will just desync games terribly..."
H├â┬®h├â┬®... Actually, I read somewhere on the forum that "food" was not supported, i.e. there's no way to set a unit limitation. In the to-be-released Allianz Arena mod, you'll have to play with your teammates, you won't win by yourself, even if you're really great (Unlike in AA-based mods, where a single player can make the difference.). You'll have to choose if you want to play as a Striker or as a Defenser. Each team's goal will be to kill the opponent's Keeper (H├â┬®h├â┬®... You also find it sounds like football :) ?), who will be the only unit producing resources to build your army and will share it with his mates (As Keeper will be a quite boring job, I hope a bot will work to play it !). What I wouldn't like would be something like : the Defenser takes all the resources and leave nothing to the Striker. With all these resources, he builds several heavy units and blocks the opponent striker's way with them. But if I set for instance 100 energy units as a cost for a Oliver Calm unit and the players have no energy income, he won't be able to buy more than 10 Olli. But what would happen if a unit died ? To unblock the situation, I need something to reimburse these costs... Thank you, I hope your thing will work !

Edit : It works, thanks for all ! The problem is, as I didn't know how to set up a LuaRules folder, I copied the one from CA, and, now, I've got a lot of new options I don't want :) ! Nevermind, I'll find how to clean it all by myself, thank you !
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

To clean it, just delete everything from the Gadgets and Config folder. Then, unzip the death repay back into them, and it should work fine. I can upload a blank LuaRules folder if thats easier.
Post Reply

Return to “Lua Scripts”