[Scripts] Lyberta's scripts
So I wanted to make a dedicated thread for each script but found the Doomy's thread and decided to make the same thing. So here we go:
Standalone scripts
These scripts are used just like any other Hedgewars scripts.
Utility scripts
Debug logger
This is a simple logger that will output text if debugging is set. Usage:
local logger = DebugLogger(true); --false to disable logging logger.Output("Hi!");
Modular game style framework
Modular game style is a special game style that allows you to load any number of specially designed scripts (called modules) at once.
Modules
These scripts can be loaded by modular game style. You need to create a custom scheme and use the "script parameter" to activate them. You can activate any number of modules at once. Separate script parameters with spaces. For example: "CakeZooka NapalmNade".
Utility scripts
Timer
Executes a function after the specified delay. Usage:
function Foo() AddCaption("Hi!"); end local timer = Timer(500, Foo); --Execute Foo after 500 milliseconds
Spawner
Periodically spawns gears from the other gear.
Multiplayer game styles
No Water Death
Script parameter: NoWaterDeath
This script makes hogs respawn if they drown and still have health left. They keep the health they had before drowning so if 100 hp hog took 45 damage and drowned, he will respawn with 55 hp. There are modular version and standalone.
Explosive Death
Script parameter: ExplosiveDeath
Hogs will die with a big explosion.
Custom weapons
Demo video no.1
One MILLION damage video
CakeZooka
Script parameter: CakeZooka
Bazooka that spawns cakes while in air.
Ultimate Mudball
Script parameter: UltimateMudball
Mudball that spawns any useful weapon while in air. Use timer keys to change weapon. 3 prints current weapon, 4 goes one step forward, 5 goes 2 steps forward, 2 goes one step back and 1 goes 2 steps back.
NapalmNade
Script parameter: NapalmNade
Grenade that spawns molotovs while ticking.
MineCheese
Script parameter: MineCheese
Limburger that spawns mines while ticking.
Evil Poison
Script parameter: EvilPoison
Poison cloud that spawns sticky mines while active.
Hellish Pistol
Script parameter: Hellish Pistol
Pistol that spawns hellish bomb upon impact.
Nuclear Melon
Script parameter: NuclearMelon
The melon which spawns more melons on explosion which spawn more melons which spawn more melons...
Cheesy Melon
Script parameter: CheesyMelon
The melon that spawns limburgers on explosion.
MineCake
Script parameter: MineCake
Cake that spawns mines while ticking.
Poison Mine
Script parameter: PoisonMine
Mines will create a poison cloud on detonation.
Ultimate Strike
Script parameter: UltimateStrike
The air strike that spawns any useful weapon. Use timer keys to change weapon. 3 prints current weapon, 4 goes one step forward, 5 goes 2 steps forward, 2 goes one step back and 1 goes 2 steps back.
The latest versions are available on GitLab.
You the scripts master,,,
btw,,, can you coding about weapons and utility ???
Here to see the topic about New Weapon and Utility for next Update Suggestions :
https://hedgewars.org/node/6574
I have topic about Hedgewars update news that confirm about next,, if you already know it,,, sorry,,, just want rise spirit to the next update
here :
http://www.hedgewars.org/node/6548
If you can help to create Weapons or Utility scripts that can be added like other scripts packages,,, that can be combined with other scripts with your scripting skillz here,,,
please tell me,,, i can't coding (since WC3 TFT and SC2 WoL era of my gaming,,, i lost all coding things (and its not .Lua)),,,
can't coding !
maybe i can Make the Ideas (not just me obviously,,,) and other people implementing it to the real HW,,, like you as the experts
Please reply my suggestions
your call,,, sorry for being annoying
|{
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
No Water Death seems interesting, should be used as game config.
Right,,, combining it with another mode even interesting,,, This what Developers Should add into "To-Do-List" ,,,
Make an option like this available to set on in schemes or somewhere else,,, add-on that can be combined to another using only Hedgewars in-game options, that custom add-on (like this no water death) can be an other rule in the schemes (e.g Highlander with No Water Death option combination can be customized via hedgewars game) maybe sounds trouble too,,, just an idea though,,,
Set the No Water Death in schemes option instead is very promising
(hope my English would be better)
|{
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
Yeah, I would like to have a native way to combine scripts, we'll see if I will mess with the source code.
My stuff
Well,,, that we want (i want maybe ?) !!!
Hope not mess up with the source code,,,
this was the Devs need to do in the next release
|{
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
next time you try unc0rr's gravity script, try adding this to scheme options:
script2=Highlander
https://hg.hedgewars.org/hedgewars/file/bc5714636364/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua#l112
I think combining scripts will always take some custom handling and still have the potential for unexpected results.
Maybe scripts could specify which scripts they explicitly support though, and it would be nice to have a better UI for script params. So if FaTony wants to overall improve the config UI, that'd still be a win.
--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
Added some custom weapons. Use Modular game style to activate them.
My stuff
Added another weapon and more utilities.
My stuff
So, your scripts inspired me to try LUA. And I made this what I called "Ming Dynamite", based on your weapon mods: http://pastebin.com/M33ZZkpD
I wanted to use MelonPieces, but that wouldn't work with your Nuclear Melon, so I used balls instead. However, I don't know how to set starting velocity, so I made a "pre-ball" that ejects other balls. Still, nice for a first script.
Thanks for sharing your work
My themes / Theme Editor / Code contributions /
Dank
AddGear(x, y, gearType, state, dx, dy, timer)
dx and dy are velocity. You will need huge values. NapalmNade uses 400000 and it doesn't move very fast.
If someone knows how to pack HWPs, I'll be glad to hear it. Especially how Lua scripts load HWPs with other Lua scripts.
EDIT: Added Poison Mine.
My stuff
Eh, I knew it's this dx/dy, but I didn't know they have to be THAT big. Updated my script.
As for HWPs, when you download your scripts from GitLab, just put the contents of "Data" into empty HWP (they are zip files with .hwp extension), like this.
Info on the format: http://www.hedgewars.org/kb/HWPFormat
My themes / Theme Editor / Code contributions /
Dank
I don't know if stuffing all my scripts into single HWP is a good idea. I want people to downloads only scripts they need.
My stuff
Then just leave only single scripts. HedgeWars will automatically load them from multiple packages.
My themes / Theme Editor / Code contributions /
Dank
In case you guys are curious about the dx/dy thing...
Internally hedgewars uses 64 bit fixed precision w/ 32 bits on either side of the decimal point. This allows for 2³² X/Y and incredibly small dx/dy values... The slowest in-game "speed" is 0.000000233 pixels per second (7 pixels per year).
Lua uses floating point like javascript, so largest representable value as an integer is 2⁵³-1. I semi-arbitrarily set dX/dY to be an integer that is a million times larger than those dX/dY values, so that they can be represented as integers without losing *too* much precision. That means the slowest speed lua can set is 0.001 pixels per second, which means over the course of 15 minute match, it'd move a pixel. That seemed like more than enough. ☺
One use for a velocity of 1/-1 in lua is to turn a hog around without making it seem to move. The game uses ±0, but that doesn't work too well in lua, so we set -1 if the "velocity" is -0 so you know which way the hog is facing.
--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
Can't you just use IEEE floating point numbers everywhere?
My stuff
No...
http://m8y.org/hw/fp.html
0AD ran into this too and thoughtfully made a matrix.
--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
It's a responsibility of the server to make calculations and the clients should just follow what the server says.
Next, does Lua support 64 bit integers?
My stuff
I think you misunderstand how 0AD, Spring and Hedgewars work.
As open source games with limited resources, we use deterministic lockstep.
This avoids the need for a model on the server. The server is literally a relay at that point.
It drastically cuts down on network traffic. Traffic only consists of player actions, no state.
It also eliminates large categories of cheats because a cheating client would desynchronise.
In addition, since all clients have a full and complete model, saves/demos are simply the recorded network state.
So, no, not really the job of the server.
WRT 64 bit integers. The only way you can currently get those on Lua is using similar approach to javascript, that is, using a bignumber library.
AFAIK, the recent JS proposal for https://esdiscuss.org/topic/efficient-64-bit-arithmetic has no equivalent in lua.
You can also recompile lua with integer math only, but that's not really a great solution.
--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
Too bad. I would rather have the authoritative model and then all my custom scripts would work without a need to distribute.
I guess I've solidified my opinion of Lua as a terrible language.
My stuff
After seeing a function like
SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)
I wonder if it can't be done any better. It has lots of redundant parameters, and there are gears that don't use all of them probably.
Is maybe possible to keep gear values in a dictionary, so they can be set with a 3 argument function? Like SetGearValue(gearUid, valueName, newValue)
I wonder if it's maybe possible to embed mruby to Hedgewars and how much work would it require. But most of current scripts are written in LUA, so maybe HW would allow both languages? (but without mixing scripts)
My themes / Theme Editor / Code contributions /
Dank
I guess you can write a Ruby interpreter in Lua.
My stuff
Hmmm, interesting idea. Embedded Ruby interpreter could be called inside Lua script, to execute Ruby script and translate the output into Lua methods that interact with the engine.
It wouldn't break current scripts and allow people who don't like Lua to write more complex stuff.
My themes / Theme Editor / Code contributions /
Dank
The gear values functions were just me being lazy. I'm sure what you'd like could be done as well.
The set/get visual/regular gear values were me just throwing in stuff that no one wanted to bother making specific functions for, just "set everything" routines. The routine could certainly take a key that determined what structure value to poke into. Could do that with switch inside the function in uScript. But yeah, didn't bother and for most people probably doesn't matter much. Also, if you'd like this, you could pretty easily shove it into a small lua wrapper lib too. You could do either one.
As for your scripts, FaTony, while our distribution can certainly improved too, it has no impact on server-running-its-own-model-of-the-game.
So long there's some sort of review process, the client could definitely autofetch from DLC, or even based on server recommendations. After all, the server has enough familiarity w/ the game state to host the room. It's mostly no one has bothered to do it.
As for... Embed ruby interpreted in lua run on our poor hwengine... I really hope you're joking.
--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev
Ah, just add JavaScript so I can write C++ and compile it to JS using emscripten
Oh wait...
My stuff
Interesting idea for the "this" keyword. Using an empty table is quite clever.
However, I don't see that this is getting destroyed somewhere, is it not being recycled?
I've worked with the warcraft 3 scripting engine before (JASS, to be exact) and Vexorian did improve it to add classes (actually structs) and the this (and thistype for class) keywords. He did it in a way to create a stack of integers and pull/push from them whenever an object gets destroyed or created.
Happy coding!
Added Explosive Deaths and MineCake. Now you can have a bazooka which spawns cakes which spawn mines which spawn poison clouds! Fun.
My stuff
Added Demo video.
EDIT: One MILLION damage video
My stuff
@_@ !!!
One MILLION XP
Can somebody make "A Googol Damage" Demo ???
Really Cool ;D ! I want to make video too,,, named "How to Drowning with Style" which show a hog drowning using a Mudball that tossed to his own feet and blow him to the water,,, hmmm,,, maybe not ;/ ...
[Rating] +1 Star
]{
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
Added Explosive Mudball, Evil Poison and Hellish Pistol.
My stuff
Added HWP.
My stuff
Moved all modules into Scripts/Modules directory so they wouldn't be confused with regular scripts.
My stuff
Doom Plane!
Use CakeZooka script, but replace gtShell, gtCake in spawner with gtRCPlane, gtSineGunShot.
100% fun!
My themes / Theme Editor / Code contributions /
Dank
Ha, nice idea.
My stuff
Changed Explosive Mudball to Ultimate Mudball, now you can create your own weapons during the game.
My stuff
Really impressive scripts codes for the custom weapons, never tought about that..
Changed Melon Strike to Ultimate Strike and added Cheesy Melon. Also, fixed all links.
My stuff
How it looks like? The Ultimate Strike?
Can give a screenshot, please ?
Sound cool though...
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
You use number keys to change the projectile which is launched by airstrike. Want melons? Sure. Want hellish grenades? Sure. Want cakes? Sure, etc.
My stuff
Ohhhhhhh OOOO___OOOO !!!
I see!
Cool Ideas =D !!!
I though it was an Airstrike with Apocalyptic Uber Power to smash the entire landmass into dust!
Well, so silly though lol
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜