Page 1 of 1

Lua Script to automatically reimburse the cost of a unit ?

Posted: 24 Aug 2007, 11:51
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 !

Posted: 24 Aug 2007, 23:24
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 :?

Posted: 25 Aug 2007, 05:09
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...

Posted: 25 Aug 2007, 06:16
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.

Posted: 25 Aug 2007, 07:16
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)

Posted: 25 Aug 2007, 11:25
by Argh
Good for a design using a points system to bound unit-limits, instead of UnitLimited. Maybe I'll use that someday :-)

Posted: 25 Aug 2007, 12:12
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 !

Posted: 25 Aug 2007, 15:33
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.