[Scripts] Lyberta's scripts

35 replies [Last post]
Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

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:

Download full package [HWP]

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...
MineCake
Script parameter: MineCake
Cake that spawns mines while ticking.
Poison Mine
Script parameter: PoisonMine
Mines will create a poison cloud on detonation.
Melon Strike
Script parameter: MelonStrike
The air strike with melons. Lots of damage.

The latest versions are available on GitLab.

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 17 hours 37 min ago. Offline
Joined: 2016-06-26
Posts: 207

You the scripts master,,, Heart

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 Smile
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 Big Grin

Please reply my suggestions Cake
your call,,, sorry for being annoying

|{

Gamer Curses
[ I Have Play MANY Games from Strategy to FPS. Such as :
-Hedgewars ; -WC ; -DoTA ; DoTA 2 ; -COD : Any ; -SC ; -Endless Space ; -Spore ; -God Of War ; -Mortal Combat ; -Skyrim ; -Final Fantasy ; -GTA ; --Tons in Computer ; -Tons of PS3 ; -Really Tons of PS2 ; -Also XBox ; -Mobile ; -Mario Too >_< ; -And More
xD ...
Its just simply Overdose ;/
Those are The Curses of Me ;-|
But I improved to get RID OF EM' ^^ !!! Except this one :DDD
]

francot514
User offline. Last seen 1 week 6 days ago. Offline
Joined: 2015-03-20
Posts: 126

No Water Death seems interesting, should be used as game config.

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 17 hours 37 min ago. Offline
Joined: 2016-06-26
Posts: 207

francot514 allegedly wrote:

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 Big Grin

(hope my English would be better)
|{

Gamer Curses
[ I Have Play MANY Games from Strategy to FPS. Such as :
-Hedgewars ; -WC ; -DoTA ; DoTA 2 ; -COD : Any ; -SC ; -Endless Space ; -Spore ; -God Of War ; -Mortal Combat ; -Skyrim ; -Final Fantasy ; -GTA ; --Tons in Computer ; -Tons of PS3 ; -Really Tons of PS2 ; -Also XBox ; -Mobile ; -Mario Too >_< ; -And More
xD ...
Its just simply Overdose ;/
Those are The Curses of Me ;-|
But I improved to get RID OF EM' ^^ !!! Except this one :DDD
]

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Yeah, I would like to have a native way to combine scripts, we'll see if I will mess with the source code.

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 17 hours 37 min ago. Offline
Joined: 2016-06-26
Posts: 207

FaTony allegedly wrote:

Yeah, I would like to have a native way to combine scripts, we'll see if I will mess with the source code.

Well,,, that we want (i want maybe ?) !!! Love Eyes!

Hope not mess up with the source code,,, Annoyed

this was the Devs need to do in the next release Cake

|{

Gamer Curses
[ I Have Play MANY Games from Strategy to FPS. Such as :
-Hedgewars ; -WC ; -DoTA ; DoTA 2 ; -COD : Any ; -SC ; -Endless Space ; -Spore ; -God Of War ; -Mortal Combat ; -Skyrim ; -Final Fantasy ; -GTA ; --Tons in Computer ; -Tons of PS3 ; -Really Tons of PS2 ; -Also XBox ; -Mobile ; -Mario Too >_< ; -And More
xD ...
Its just simply Overdose ;/
Those are The Curses of Me ;-|
But I improved to get RID OF EM' ^^ !!! Except this one :DDD
]

nemo
nemo's picture
User offline. Last seen 19 hours 59 min ago. Offline
Joined: 2009-01-28
Posts: 1483

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

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Added some custom weapons. Use Modular game style to activate them.

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Added another weapon and more utilities.

KoBeWi
KoBeWi's picture
User offline. Last seen 14 hours 33 min ago. Offline
Joined: 2010-12-25
Posts: 248

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 Wink Smiley

Theme Editor / Code contributions / WIP
"Official" themes:
Crystal | Belly | Dreamland | Sky | Factory
"Unofficial" themes:
Chalk | Bowser | GIRDERZZZ!!! | Mirage | Sudra |
| Zombie

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

KoBeWi allegedly wrote:

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 Wink Smiley

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.

KoBeWi
KoBeWi's picture
User offline. Last seen 14 hours 33 min ago. Offline
Joined: 2010-12-25
Posts: 248

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

Theme Editor / Code contributions / WIP
"Official" themes:
Crystal | Belly | Dreamland | Sky | Factory
"Unofficial" themes:
Chalk | Bowser | GIRDERZZZ!!! | Mirage | Sudra |
| Zombie

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

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.

KoBeWi
KoBeWi's picture
User offline. Last seen 14 hours 33 min ago. Offline
Joined: 2010-12-25
Posts: 248

Then just leave only single scripts. HedgeWars will automatically load them from multiple packages.

Theme Editor / Code contributions / WIP
"Official" themes:
Crystal | Belly | Dreamland | Sky | Factory
"Unofficial" themes:
Chalk | Bowser | GIRDERZZZ!!! | Mirage | Sudra |
| Zombie

nemo
nemo's picture
User offline. Last seen 19 hours 59 min ago. Offline
Joined: 2009-01-28
Posts: 1483

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

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Can't you just use IEEE floating point numbers everywhere?

nemo
nemo's picture
User offline. Last seen 19 hours 59 min ago. Offline
Joined: 2009-01-28
Posts: 1483

FaTony allegedly wrote:

Can't you just use IEEE floating point numbers everywhere?

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

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

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?

nemo
nemo's picture
User offline. Last seen 19 hours 59 min ago. Offline
Joined: 2009-01-28
Posts: 1483

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

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

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.

KoBeWi
KoBeWi's picture
User offline. Last seen 14 hours 33 min ago. Offline
Joined: 2010-12-25
Posts: 248

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)

FaTony allegedly wrote:
I guess I've solidified my opinion of Lua as a terrible language.
My first programming language was Ruby, so any other language I learned was terrible for me XD
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)

Theme Editor / Code contributions / WIP
"Official" themes:
Crystal | Belly | Dreamland | Sky | Factory
"Unofficial" themes:
Chalk | Bowser | GIRDERZZZ!!! | Mirage | Sudra |
| Zombie

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

I guess you can write a Ruby interpreter in Lua. Big Grin

KoBeWi
KoBeWi's picture
User offline. Last seen 14 hours 33 min ago. Offline
Joined: 2010-12-25
Posts: 248

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.

Theme Editor / Code contributions / WIP
"Official" themes:
Crystal | Belly | Dreamland | Sky | Factory
"Unofficial" themes:
Chalk | Bowser | GIRDERZZZ!!! | Mirage | Sudra |
| Zombie

nemo
nemo's picture
User offline. Last seen 19 hours 59 min ago. Offline
Joined: 2009-01-28
Posts: 1483

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

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Ah, just add JavaScript so I can write C++ and compile it to JS using emscripten Big Grin

Oh wait...

Anachron
User offline. Last seen 6 weeks 14 hours ago. Offline
Joined: 2014-11-08
Posts: 41

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!

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Added Explosive Deaths and MineCake. Now you can have a bazooka which spawns cakes which spawn mines which spawn poison clouds! Fun.

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99
UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 17 hours 37 min ago. Offline
Joined: 2016-06-26
Posts: 207

@_@ !!!

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

]{

Gamer Curses
[ I Have Play MANY Games from Strategy to FPS. Such as :
-Hedgewars ; -WC ; -DoTA ; DoTA 2 ; -COD : Any ; -SC ; -Endless Space ; -Spore ; -God Of War ; -Mortal Combat ; -Skyrim ; -Final Fantasy ; -GTA ; --Tons in Computer ; -Tons of PS3 ; -Really Tons of PS2 ; -Also XBox ; -Mobile ; -Mario Too >_< ; -And More
xD ...
Its just simply Overdose ;/
Those are The Curses of Me ;-|
But I improved to get RID OF EM' ^^ !!! Except this one :DDD
]

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Added Explosive Mudball, Evil Poison and Hellish Pistol.

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Added HWP.

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Moved all modules into Scripts/Modules directory so they wouldn't be confused with regular scripts.

KoBeWi
KoBeWi's picture
User offline. Last seen 14 hours 33 min ago. Offline
Joined: 2010-12-25
Posts: 248

Doom Plane!

Use CakeZooka script, but replace gtShell, gtCake in spawner with gtRCPlane, gtSineGunShot.

100% fun!

Theme Editor / Code contributions / WIP
"Official" themes:
Crystal | Belly | Dreamland | Sky | Factory
"Unofficial" themes:
Chalk | Bowser | GIRDERZZZ!!! | Mirage | Sudra |
| Zombie

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Ha, nice idea.

Lyberta
Lyberta's picture
User offline. Last seen 8 hours 14 min ago. Offline
Joined: 2016-09-10
Posts: 99

Changed Explosive Mudball to Ultimate Mudball, now you can create your own weapons during the game.

francot514
User offline. Last seen 1 week 6 days ago. Offline
Joined: 2015-03-20
Posts: 126

Really impressive scripts codes for the custom weapons, never tought about that..

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]