[Code] My Hedgewars contributions
Some of you may noticed I started tinkering with the game's code and tried adding some features. Most of them were connected with themes, so I was posting it in the suggestion topic. However, it feels like it didn't get enough attention, so I'm making this new topic to keep a summary of my contributions.
List of my commits from the GitHub branch I created:
([X] means it was checked by a dev)
({A} means it was accepted for next release)
{A} Support for multiple inland rectangles
{A} Support for rising flakes
{A} Fixes to the two above
{A} Alternate sound paths
{A} Animated water
{A} Wind-mirrored flakes and clouds
{A} onVisualGearAdd/Delete and GetVisualGearType
[_] Locator system (alpha)(pre-beta)(beta)
{A} Objects on water
[X] Better placement
[_] Cofined spray areas
{A} onUsedAmmo hook
{A} Portable schemes (+fix)
And the summary of features these add:
(notes are some code details)
Theme objects can now have multiple rectangles covered by land. Just add an additional number when defining object, which will tell how many of these rectangles there are.
Trivia: Both my theme editors are forward-compatible with this feature.
_
Flakes can now rise, not only fall. Previously, such flakes would fly forever and never appear again.
_
Sounds in themes can now be customized. Particularly, I allowed to replace splash and droplet sounds. If you replace them with silent sounds, you can remove water and make "abyss". Or replace splash with e.g. evil laugh or whatever, etc.
_
Water can be animated. Also, you can change the speed of water flowing. There's a new key for themes that does this:
water-animation = frames, frame ticks, movement speed
Default values are 1, 0, 1
Note: Sprites that use getDimensions flag have always initial height of 0. So using this fact, -1 means it's BlueWater and -2 is SDWater. Thanks to this, these sprites can be divided into given number of equal-sized frames. Also, new theme values for water animation are watFrames, watFrameTicks, watMove, watSDFrames, watSDFrameTicks and watSDMove.
_
You can add FlakeL and CloudsL images to your theme. These will display when the wind is flowing to the left.
Note: I added getSpriteByWind function. It looks neat, but I'm not sure about efficiency.
-
You can now track creation and deletion of visual gear, by using onVisualGearAdd(vgear) / onVisualGearDelete(vgear). Also, you can use GetVisualGearType(vgUID).
Note: I added the onVisualGearDelete for the sake of completion. I also don't know if they won't impact performance, as they are additional script calls, and visual gear is created/deleted more frequently than normal gear.
-
It's possible to provide URL downloads for your DLCs, so they are transferred if someone joins your room and doesn't have them.
See this for more details: https://www.hedgewars.org/node/5957#comment-32520
-
You can make theme objects that stand on water. This can be achieved by making the first inland rectangle being 0,0,0,0.
-
Object/spray generation is changes, so they are distributed more equally across the map.
-
You can specify rectangles of LandTex within whose spray objects should generate.
Do it like:
spray = name, number, rect1x, rect1y, rect1w, rect1h, rect2x, ...
so basically just add four arguments for each rectangle. Sprays will be placed so they center is forced to appear inside random one of these rectangles.
Blue rectangles can appear only on red and black bars, centered vertically, but horizontally on the whole bar.
Purple circles can appear anywhere in white bars.
-
Added a LUA call when you make a complete action (onUsedAmmo).
-
Game/ammo scheme files are now portable and you can easily share them for other players.
Really ??? i think it was get "Great" Attention for the Contribution
And these contribution is Highly, Support the game... bah ! im just talking XD
]{
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
Also, some devs posted on other topics at this time.
It's... heartbreaking.
My themes / Theme Editor / Code contributions /
Dank
I maybe MUST NOT Make this "Long" ... GL For the TRUE Help for Hedgewars
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
https://hg.hedgewars.org/hedgewars/rev/60c8bb8bc1d7
Thank you
EDIT: Can you link me to the example theme using the multiple anchors theme objects? ^^
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Np
https://www.dropbox.com/s/if9q7gmq8gjxqpx/Factory.tar.gz?dl=1
My themes / Theme Editor / Code contributions /
Dank
https://hg.hedgewars.org/hedgewars/rev/7db5aef27e8d
Thanks again ^^
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Ok, I know this might be useless, but I added more visual gear handlers and they happen to work. You can now e.g. "disable" damage tags or speech bubbles using a script. Too bad there's no way to change text of speech bubbles (or is there?)
My themes / Theme Editor / Code contributions /
Dank
My newest commit is out:
https://github.com/KoBeWi/myHedgewarsBranch/commit/af359f59843f709bad711582d75f8f71c31dcf3f
(ignore the change in visualGearsList)
This is the biggest commit I did so far.
It implements file transfer if you are missing themes/maps from net room.
The code is probably not perfect, and of course it's missing some features.
Firstly, it needs some cleanup. I couldn't rebuild the server for some reason, so I'm handling communication via special chat messages. These messages start with "hackyMessage,," and every instance of this hack is marked with comment //CHATHACK
The server handlers needed for this are LOCATOR_REQUEST and LOCATOR. First one needs to pass user nick and name of the resource, second one needs to pass user name, resource and the url for download. Of course this can be simplified, but I don't know if it's possible to e.g. respond directly to the specific client.
Secondly, I added some methods/hacks/modifications I needed. For example, there's getUser() in chat widget, which returns name of the current client. Also, I added amReady to PageNetGame to store ready status. The btnGo was remapped to btnGoPressed instead directly changing the ready state.
It is also possible that commit is missing the "download.png" icon. It can be found here: http://imgur.com/a/u2Xmw
It should go to QTfrontend/res
If there are other important notes I forgot about, I'll edit this. Or just ask if you find something strange.
BUT, most important is of course that this code works as expected ( ͡° ͜ʖ ͡°)
My themes / Theme Editor / Code contributions /
Dank
And another rather big commit: https://github.com/KoBeWi/myHedgewarsBranch/commit/ac6b4f0430bce848f8288da9b6a17a8b0fc6be47
This adds handlers for transferring the remaining resources. It's a bit more lacking in polish than the previous one, but gets the job done. I'm not finished yet, so cleaning is possibly coming too.
I had to add roomChief to newnetclient, because I didn't see other way to get the room owner. I also added cachedScriptName for GameCFGWidget, because I had to remember the script that failed to load. I hope these "hacks" aren't actually that bad. Just working with frontend requires changing things in many places at once, and I'm not that familiar with it.
Also, the missing icon is now included.
btw, more info on locators here: http://www.hedgewars.org/node/5957#comment-32520
My themes / Theme Editor / Code contributions /
Dank
It's done:
https://github.com/KoBeWi/myHedgewarsBranch/commit/9258f323b6a26e6bec18acbbb867c6c4607b27cc
File transfer works.
You can specify restrictions in options.
Map and theme updates on download.
Lots of bugs fixed.
It's now ready for testing, so if someone has time, he/she can try to break the system and report any bugs.
My themes / Theme Editor / Code contributions /
Dank
So, I just made my theme suggestion #7:
https://github.com/KoBeWi/myHedgewarsBranch/commit/2cc697ba790ce4edb7905692ab0f78c10dedd2f6
When object's first inland rectangle has x = y = w = h = 0, then it's y is forced at water level when trying to place. This allows for boats or anything on the water.
Fun fact is that game actually doesn't complain when rectangle has no size. It's effectively ignored while checking, so making an only one inland with no size allows for floating objects. However, it doesn't work good, because the object placement is biased.
I'm going to try to fix the placement, so it's not focused on one corner. After I've seen the algorithm, I now know why it looked bad for big maps.
Then I'll also try to make the Wuzzy's suggestion about sprays.
Also, screenshot:
(that beanstalk to the right)
EDIT:
Ok, fixed.
This:
vs this:
As you can see, bottom-right corner on the first image is quite empty, while top-left is full of everything. On second image, both of them are somewhat equally populated.
Original algorithm started from top-left and moved slowly to bottom-right, stopping if found good spot.
After my modification, it randomly selects one of four corners and moves towards the opposite. Thanks to this, objects are distributed more equally across the map. However, the center is still quite empty
Anyways, I'll do the same for sprays, but not today.
My themes / Theme Editor / Code contributions /
Dank
My Respones : "Wth a Great Job !!! I can't do that ;/ "
Is what can i say for these Outstanding Contribution
Keep it up !!! Devs should happy see these
And i should learn more from ye ;v
This what support might be (?) ... Vote + Rating 5 Stars + Like + Tag + And Subscribe these ...
]{
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
lol Ulti, you broke my 5 post combo XD
Anyways:
https://github.com/KoBeWi/myHedgewarsBranch/commit/0459c2645edb473e7322e117cb038bcbf2666e8b
This makes object/spray placement (possibly) better. There's also one change to my previous commit.
Now, onto the spray thing requested by Wuzzy.
EDIT:
Quick proof of concept.
I managed to make cyan squares aligned to red lines. Right now everything is hardcoded, but I know it's possible at least.
EDIT2:
https://github.com/KoBeWi/myHedgewarsBranch/commit/7c16978aa400c67de6ac5f6f964bb2a894036e6b
Code uses my improved generation. Remove the dx/dy part if you want to use it with normal placement.
My themes / Theme Editor / Code contributions /
Dank
ROFL XD !!!
Sorry then... have Send a Private Massage to you...
╓──────────────────╖ ╓──────────────────╖
⠀HP: ██████████ 1E9/1E91E9/1E9 ██████████ :MP
╙──────────────────╜ ╙──────────────────╜
These are now implemented.
Hi, I am a Hedgewars developer.
I added onUsedAmmo hook, which is called when you actually make a full attack, like two shotgun shots or such.
It can be maybe changed to even pass the ammo which was used, but I don't need it right now and it's not completely straight-forward, so it doesn't pass anything for now.
https://github.com/KoBeWi/myHedgewarsBranch/commit/de9bf6fa09976b19b1f72bed002333fb77b61e58
My themes / Theme Editor / Code contributions /
Dank
I have reviewed the wind-mirrored flakes code. Looks alright. I'll hopefully have a chance to test/merge it this evening
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
I have tested the animated water. I think the idea is interesting, but I don't like the implementation so far. It needs some improvements before I would merge it.
Comments/observations:
I will test your other features soon.
Hi, I am a Hedgewars developer.
OK, comments on your other contributions:
I've added onUsedAmmo. I changed it so that it also includes the ammoType as a parameter. I also fixed a bug in which it was called even if you didn't use any ammo (you press attack when you have no weapon selected).
Documentation of this function is here: https://hedgewars.org/kb/LuaAPI
I already commented on your Locator system earlier, you know my opposition to this.
Objects on water: This looks OK, but you said that it is not very good, so don't merge it for now, unless you change your mind. Could you please elaborate?
The balanced spray/object placement is a nice change, but I feel reluctant to merge it. This is a breaking change, it will break pretty much ALL old demos and random map seeds because the object positions of ALL random maps are changed. Sheepluva, nemo, unC0Rr, what do you think about this?
I would obviously love to merge the confined spray areas, but this commit depends on the previous thing. I also didn't test it so far.
Hi, I am a Hedgewars developer.
The code for this could be done better tho.
Objects on water are actually fine.
It should be possible to keep the old code and execute it on old demos, so the generation would remain backward-compatible.
Anyways, thanks that someone looked into it finally. I'd really like to have these in game ASAP, so I could continue work on my new themes.
My themes / Theme Editor / Code contributions /
Dank
https://hg.hedgewars.org/hedgewars/rev/4d1250ca68ace6259d7d5e70b591b714d08ba8b8
Thank you.
What theme would you suggest to demonstrate this change?
Also: Any ideas by anybody regarding existing themes making use of this are welcome.
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Ok, here's the original formula for the water movement:
-TextureBuffer[3].X:= shift + ((LongInt(RealTicks shr 6) * Dir + dX) mod spriteWidth) / (spriteWidth - 1);
I'm not really sure why it uses shr function, and it's the one that gave me problems. I think I will try again to remove if and see if there is something wrong otherwise.
My themes / Theme Editor / Code contributions /
Dank
Sheepluva wants to know if you have an idea which one of the existing theme (preferably one of the official ones) should be modified so it actually makes use of the flipped flakes or clouds.
For example: Halloween with flipped bats.
Sheepluva likes to see this feature in actual use in one of the official themes. But hasn't found any compelling use case so far.
It is not really important.
Hi, I am a Hedgewars developer.
In this sentence I was also referring to KoBeWi's themes.
KoBeWi: Some of your themes use this feature, right? Which one would you recommend if someone wants to see wind-flipped flakes in action?
Oh and "shr 6" (shifting the value by 6 bit to the right) effectively is the same as "div 64".
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
As for official themes, I'd recommend fish flakes for Underwater.
In my previous commit I made it weirdly non-linear and assumed you should use values between 1 and 16.
My themes / Theme Editor / Code contributions /
Dank
I quite like the jellyfish.
Hi, I am a Hedgewars developer.
Update on water:
(LongInt((RealTicks * waterSpeed) shr 6)
^ this doesn't work ;_;
That would be the simplest way otherwise.
My themes / Theme Editor / Code contributions /
Dank
Water objects are now included in Hedgewars, with a slightly changed code.
https://hg.hedgewars.org/hedgewars/rev/666e18b1ca32
It actually works out quite nicely.
Okay, KoBeWi. If you want the other things to get merged, just poke me when you have have reworked them in a usable state.
Can you also please try to rework the confined spray commit so it is independent from the rest? Ideally just make sure you work on HEAD.
That would make my life easier.
EDIT:
And finally, can you please explain how the multiple in-land rectangles are supposed to work? Just give some example theme.cfg so I know the syntax. I want to update the HWKB entry (https://hedgewars.org/kb/Theme).
Hi, I am a Hedgewars developer.
Uh, I think I did it wrong. I still can't run 0.9.23 properly, so I reverted the code to older version and added new code on top of it. If you don't feel like copying these in correct places, I can make one more commit, but later ;_;
Also, I'm not sure if I did the border part right.
Reupload of modified Factory theme: http://www.mediafire.com/file/5yfbzubdj7d7y2d/Factory.tar.gz
You just have to add one more number before you specify covered rectangle bounds.
EDIT:
btw Wuzzy, it's not that important, but you are merging my code under your name.
My themes / Theme Editor / Code contributions /
Dank
Oops. I will be more careful next time.
Sorry, I still don't get how or why multiple in-land rectangles work. Doesn't your change mean that all existing custom themes break because almost all of the existing numbers have to shift by 1 to the right?
Or is this number optional? But if it is optional, how does your code know the difference between X of first inland rectangle and the number of inland rectangles?
Just out of curiosity.
Hi, I am a Hedgewars developer.
EDIT:
Ok, I found the problem I had with water. Seems like the speed was loaded wrongly. It didn't accept -1 and did weird stuff above 9. My source build is totally messed up right now, but I should be able to fix this soon, so water-animation can be merged too.
EDIT2:
@Wuzzy
Here's the commit that fixes water animation:
https://github.com/KoBeWi/myHedgewarsBranch/commit/0f760a31f40df93c34145368b82bddb96a3d1b6d
Apply it to previous water animation code and it should work.
Water speed functionality has changed. 1 means normal speed, 2 is double speed, 3 triple etc. so it's now scaled linearly like it should in the beginning.
EDIT3:
And here's a theme, that shows the water feature well. (I didn't test it though) (also, theme has just land texture and water right now)
My themes / Theme Editor / Code contributions /
Dank
Animated water works great now. The water speed is now much more logical and practical to use.
This features has been merged into Hedgewars. Thanks for your contribution!
https://hg.hedgewars.org/hedgewars/rev/31184d9b9bfc
https://hg.hedgewars.org/hedgewars/rev/4d818abdc00f
The HWKB page has been updated accordingly.
https://hedgewars.org/kb/Theme
Note I have deleted some minor coding style changes from your commits (e.g. indentation in uSound.pas) as they were not relevant. I consider it best practice to keep "coding style commits" separate from "feature commits".
Hi, I am a Hedgewars developer.
KoBeWi, your animated water fails badly when the Ocean world edge is used. The water animation is completely wrong at the edge.
Can you please reclone the current repository or just update your own repository and try to fix this bug?
Hi, I am a Hedgewars developer.
Any ideas how to fix my problem from that topic? It would be much easier for me to run the newest build, instead of juggling the code between versions
EDIT:
Now that I think of it, you can make the water faster, but you can't make it slower. Maybe the value should get divided, so default one is 100 or 1000, so you can set a lower one? (if it's possible ofc)
My themes / Theme Editor / Code contributions /
Dank
This fixes water edge:
https://bitbucket.org/Tomasz_Chabora/random-hedgewars-branch/commits/ecb81cef0297a4a58afb8e6c7e80133c8b2d60f4
And this changes the way water speed works:
https://bitbucket.org/Tomasz_Chabora/random-hedgewars-branch/commits/420da2d7d064c069c3bd4a7e283c2b858acd81c8
It's now given in percents, so default value is 100. Ignore this commit if you don't want this behavior.
Also, ignore that I changed my repo to Bitbucket, while my account shouldn't really be used for stuff like Hedgewars, lol
My themes / Theme Editor / Code contributions /
Dank
Thanks. Both of these are merged.
I'll try to priotorize on important Hedgewars bugfixes from now on (the release is overdue), and less on new features.
Hi, I am a Hedgewars developer.
KoBeWi, if you want to really help us out, can you please try to fix a very annoying bug we have in the current developer version?
Flakes randomly flicker at cloud level. It's not fun to look at.
See here for more information:
http://issues.hedgewars.org/show_bug.cgi?id=157
I would really appreciate that if you could help here, I almost consider this bug to be a release blocker.
Hi, I am a Hedgewars developer.
Does it block beta/pre-release though? I'll try to look into it this week.
EDIT:
Looks like I won't be needed: http://hg.hedgewars.org/hedgewars/rev/83131d0e747b
My themes / Theme Editor / Code contributions /
Dank
Well, I made this:
https://bitbucket.org/Tomasz_Chabora/random-hedgewars-branch/commits/c8d8caf2a3d6176593d6c1950c9dccc9f11cbe70
https://bitbucket.org/Tomasz_Chabora/random-hedgewars-branch/commits/f4906eed41c03f0cd140e068909d1db36ef83aad
It's in response to issue #173.
My themes / Theme Editor / Code contributions /
Dank
Oh, thanks for the work on scheme files. This is very much appreciated!
Some comments: On your first commit you made many, many indentation things. Please don't do this. If you want to fix code styling, please only do it in a separate commit. I don't like diffs in which serious code changes are mixed with tones of code-styling changes.
It is hard to navigate the diffs otherwise.
Also, there seems to be a bug: On the first start, Hedgewars still creates weapons.ini. This doesn't seem right.
I haven't tested this too much for now. What happens with the existing weapons.ini / schemes.ini files?
As this is quite a significant change, I feel reluctant to include this for 0.9.23 at this stage. We are already sitting on a huge mountain of unreleased features; and I don't want to mess it up. My main concern now is to fix bugs and get the release done, it's already LONG overdue.
Hi, I am a Hedgewars developer.
The ini creation isn't a bug. I made it automatically detect old configuration and create new files. However, I didn't make it capable of creating configuration on it's own, so instead it creates the old format and imports it into new one (less work this way). Maybe if I make it remove the old config after that, it would be alright?
My themes / Theme Editor / Code contributions /
Dank
I don't understand the point of automatically creating weapons.ini. It's completely redundant. The point of this is to move away from these .ini files.
Basically I think weapons.ini should not be created at all.
Note that I tested this on an completely empty config directory. This is for testing how HW acts on the first start.
You can test this on your own with hedgewars --config-dir=/path/to/an/empty/directory
Hi, I am a Hedgewars developer.
Well, seems like it's a problem with how QSettings work. It creates the config file if it not exists, and I need it to load old ini file if such appears.
Interestingly, schemes.ini works in a different way. Unlike weapons.ini, it contains only non-default schemes. More interestingly, when I created the new system, it created .hwa files with default weapon schemes, but no default .hwg files.
Well, I'll try to sort this out.
EDIT:
https://bitbucket.org/Tomasz_Chabora/random-hedgewars-branch/commits/c8d8caf2a3d6176593d6c1950c9dccc9f11cbe70
https://bitbucket.org/Tomasz_Chabora/random-hedgewars-branch/commits/f4906eed41c03f0cd140e068909d1db36ef83aad
I completely messed it up XD
I made a wrong commit, then I did local rollback, then I force-pushed new commit, which created a new head. When I tried to strip that wrong commit, it stripped too much. So use these two commits here ONLY (the first one is the old one, and the second one is merged of old second one with new changes, because that one is gone).
Anyways, old ini files are successfully loaded and left as they were. No redundant ini files are created and no ammo scheme files for default schemes either.
Small note. New system instead of QSettings(ini file) uses QSettings("Hedgewars", "Hedgewars"), which creates some config file in a secret Qt directory. Since QSettings was used in-game, I didn't change it into anything new to avoid too much changes. So this file, wherever it's created, is just a conventional dummy and it's cleared on each load, filled with stuff from /Schemes directory.
EDIT2:
Is it possible this new system makes it into Alpha 2 for testing, or that's not what alpha is for? I mean, I didn't test it extensively, but it correctly imported my old ini files, and it doesn't create anything unnecessary, so seems like it works already.
My themes / Theme Editor / Code contributions /
Dank
Sorry, no new features before release.
KoBeWi, how would you like to be credited in the credits list for your (much appreciated) code contributions?
I need a name and an e-mail address.
Hi, I am a Hedgewars developer.
^
I was asked this once, and I already said to just use my forum name without email.
My themes / Theme Editor / Code contributions /
Dank
Wow progress of this really good, any plans to add this features in official repo?
Well, not before release.
But afterwards, I'm pretty positive to include the scheme file rework (as I have requested this myselves) and maybe the confined spray areas.
Note that the features marked with an “A” are already included.
And before I forget: I've added you, KoBeWi, to the credits a while ago.
Hi, I am a Hedgewars developer.
I have finally applied your scheme file patches!
https://hg.hedgewars.org/hedgewars/rev/c0320d66310d
https://hg.hedgewars.org/hedgewars/rev/305f3667af20
https://hg.hedgewars.org/hedgewars/rev/48b9f15859b0
https://hg.hedgewars.org/hedgewars/rev/7a54bda7b6d1
Merging this was surprisingly hard. The main reason was because you agressively changed the code style. This confuses the merging tools.
I'm not against coding style or indent changes, but please keep them in a separate commit. Do NOT mix them with complex code changes in the same commit. This makes such commits very hard to merge when time passes.
I also found 2 small bugs in your code, and I fixed them already (see last 2 commits above).
Anyway, the new file format will make things MUCH easier in future. Thank you!
Hi, I am a Hedgewars developer.
I had once mentioned that I deleted my old repo and so the unmerged commits got lost, but now I just found out that someone forked it before deletion and the code is still intact:
https://github.com/bravesoftdz/myHedgewarsBranch/commits/master/
The code for locator system and improved object placement is still there. I'll fix the links in the OP.
My themes / Theme Editor / Code contributions /
Dank