LUA and scripting fun
#1
Posted 15 January 2009 - 01:36 PM
So if you have a cool LUA script or would like help with one post here.
(This is another one of my everything goes here topics that I like)
LUA is a very powerful modding tool that can expand what is possible from coding and really expands what mods can do.
LUA is used for simple things like hiding subobjects like Forged Blades.
It can be used to randomise weapons or models or used to trigger fear the possibilities are vast,I hope by having a topic like this we can learn more about LUA and it's capabilities.
I have been playing with a scripting that allows Gimli to get temporarily stronger when facing lots of enemies.
I haven't got the script ready yet but basically it works like this.
The script reads the amount of nearby enemies and when it surpasses a certain number it triggers a special power similar to
Blade Master that makes him stronger.
For this check out Gandalf's Telekinetic push script.
Another script I am working on is a random critical damage weapon.
I will get into that once I worked it out more fully.
Another cool thing is using map scripts to trigger power.
These allow a lot of freedom in coding adding a lot of different options I got this idea from RJ's camera power thing and the Day/Night transition thing.
Basically a script is made in worldbuilder that when triggered will fire a special power.
Using "fake" special powers that trigger map script events can create a lot of great things.
Just think of firing of a spawning spell at a special waypoint or having a special power that evacuates all units from transports all instakills everything.
Script/Coding (we should come up with a name for it) of course has to be added to all maps for it to be universal a drawback but if your power is really cool it is worth the extra effort.
I don't think mapping and modding are seperate things and the 2 can really support each other.
So let's see what we can come up with.
(can someone pin this one,this can be an important resource for coders it's always good to have a one stop shop for these things)
Break dancing into the hearts of millions
#2
Posted 15 January 2009 - 07:01 PM
I myself once planned to expand on the typical random-subobject scripts and create truly random units by assigning units upgrades (something you can do in LUA), so you can have random skins, subobjects, weapons, armors, powers, etc. Still a very limited use, but already interesting gameplay-wise.
The other idea I had involved a chain of LUA broadcasts, states and upgrades. Unfortunately all I remember is that it involved Frodo and the Nazgûl
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#3
Posted 15 January 2009 - 07:11 PM
I actually believe nobody here has fully taken advantage of LUA scripting. From a technical point of view the possibilities are very limited, however the options it adds to the (limited) pool of overall possibilities in BFME are interesting. The point is though that LUA alone cannot do much... the power it gives you is only useful if you can combine it with standard items like powers, upgrades and model states.
But i did!
SuperModding
SuperDuperModding
Thanks to you, remember?
Credits:
Dark Lord of the Sith For hinting at the 'scriptevents.xml'
Edit: of course i didn't use everything. But i am using everything useful to me. Broadcasting can also be done by coding for example.
Axed Head and A.I. Coder for S.E.E. and ... stuff
".. coding is basically boring. What's fun is finding out how things work, take them apart and then put them together in ways that were not intended nor even conceived."
#4
Posted 15 January 2009 - 07:19 PM
They are the whole basis for what I'm doing with the ring and many other ideas I've had. Blast you, CAH, and your 500 object ugprades that I need to re-do!!!
Seriously, there is so much that you can do along the lines that Sul has outlined in his articles that really is so very tempting
Robert J.
#5
Posted 15 January 2009 - 07:26 PM
I tried to nail a broadcast Mount for the slave Guards for a hero, when he mounts, they mount... problem was, only 2 out of 4 did
LUA's still great great fun though, but may I ask, is it possible to change skin via it? I've never looked into that
The 4th Age version 0.8 has been released: Link
#6
Posted 15 January 2009 - 08:16 PM
Gee, I'm so sorryI actually believe nobody here has fully taken advantage of LUA scripting. From a technical point of view the possibilities are very limited, however the options it adds to the (limited) pool of overall possibilities in BFME are interesting. The point is though that LUA alone cannot do much... the power it gives you is only useful if you can combine it with standard items like powers, upgrades and model states.
But i did!
SuperModding
SuperDuperModding
Seriously, I totally forgot about that first article of yours. I've never even read the second because working with the AI never interested me. So I'll take back most of what I said about LUA not being used effectively. Still, I believe that there is a lot more potential.
My Political Compass
Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.
#7
Posted 17 January 2009 - 04:06 AM
function GimliUseMadAxes(self, other, delay, amount) -- Or, if we are being hit and there are alot of guys arround, do our cool pushback power if tonumber(ObjectCountNearbyEnemies(self, 50)) >= 4 then ObjectDoSpecialPower(self, "SpecialAbilityGimliMadAxe") return end end
<EventList Name="GimliFunctions" Inherit="InfantryFunctions"> <EventHandler EventName="DamageIncoming" ScriptFunctionName="GimliUseMadAxes" DebugSingleStep="false"/> </EventList>
The AI Update all looks right and the special power too it's a simple modified Blade master power.
It looks right to me but i'm not sure.
Break dancing into the hearts of millions
#8
Posted 20 January 2009 - 09:42 PM
#9
Posted 21 January 2009 - 04:02 PM
function EldaravirSummon(self) --This spawns Citadel Guards when Eldaravir is near death... despite the power name ObjectDoSpecialPower(self, "SuperweaponSpawnOrcs") end
<EventList Name="EldaravirFunctions" Inherit="BaseScriptFunctions"> <EventHandler EventName="ReallyDamaged" ScriptFunctionName="EldaravirSummon" DebugSingleStep="false"/> </EventList>that works
Then again, it could be your tonumber thingy that's got problems...
The 4th Age version 0.8 has been released: Link
#10
Posted 21 January 2009 - 05:18 PM
self:ObjectDoSpecialPower('"SpecialAbilityGimliMadAxe')but from what Lauri posted, it looks like your syntax is fine, so I don't know.
I really don't do requests and my Arnor Soldier is not fit for BFME. Don't ask me for either.
#11
Posted 26 July 2009 - 06:29 PM
I really don't do requests and my Arnor Soldier is not fit for BFME. Don't ask me for either.
#12
Posted 11 August 2009 - 10:55 PM
https://www.twitch.tv/vileartist - Yes shameless self-promotion
----------------------------------------------------------------------------------------------------------------------
"Old modders never die, they just fade away" ~ Hostile
#13
Posted 12 August 2009 - 01:55 AM
Try that one
CODE
function EldaravirSummon(self)
--This spawns Citadel Guards when Eldaravir is near death... despite the power name
ObjectDoSpecialPower(self, "SuperweaponSpawnOrcs")
end
CODE
<EventList Name="EldaravirFunctions" Inherit="BaseScriptFunctions">
<EventHandler EventName="ReallyDamaged" ScriptFunctionName="EldaravirSummon" DebugSingleStep="false"/>
</EventList>
that works wink.gif
Then again, it could be your tonumber thingy that's got problems...
I forgot to try that out I am now looks like it should work
I tried it worked thanks Lauri.
Edited by Radspakr, 12 August 2009 - 02:17 AM.
Break dancing into the hearts of millions
#14
Posted 18 November 2009 - 07:59 AM
Writing random model code just got a whole lot easier for me...
I really don't do requests and my Arnor Soldier is not fit for BFME. Don't ask me for either.
#15
Posted 15 March 2010 - 02:25 PM
At the moment it doesn't work I haven't yet figured out if it's the code or the Lua.
Here's how it works.
When Thorin gets hit there is a 1/4 chance that he will counter hit with the Counterhit spell.
As far as I can tell everything looks alright.
As for the power it's a simple weapon fire type based on Word of power.
I'm going to run some more tests but I thought it'd be good to have my Lua a looking over by you guys.
function Counterhit (self, other, delay, amount) if tonumber(delay) > 1 then if tonumber(amount) >= 10 then if counterhit <= 0.25 then ObjectDoSpecialPower(self, "SpecialAbilityCounterhit") return elseif counterhit <= 0.4 then nil return elseif counterhit <= 0.6 then nil return elseif counterhit <= 0.8 then nil return end end
Break dancing into the hearts of millions
#16
Posted 15 March 2010 - 03:30 PM
Code-wise, a few problems. One is that counterhit is not defined anywhere, so if counterhit <= 0.25 then won't work. You're also missing some trailing Ends, a lua if statement goes
if elseif end
Your structure has, essentially
if -if --if --elseif --elseif --elseif --end -end
So you're missing an end for the first If statement, then also the End for your function. I'd also like to note that I've never got the DamageIncoming flag to work reliably, so I've used OnDamaged instead for a similar function:
function DainDoSuper(self,other) local chance = GetRandomNumber() if chance <= 0.25 then ObjectBroadcastEventToEnemies(self, "BeTerrified", 250) ObjectDoSpecialPower(self, "SpecialPowerBlockAttack" ) end end
This I know works .
I really don't do requests and my Arnor Soldier is not fit for BFME. Don't ask me for either.
#17
Posted 16 March 2010 - 12:09 AM
I'll post back with the results.
Thanks Nert I got it working now I can start on all the other new powers
Edited by Radspakr, 16 March 2010 - 12:52 AM.
Break dancing into the hearts of millions
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users