[Script] [Multiplayer] Monarchy

7 replies [Last post]
Tiotimolina
User offline. Last seen 5 weeks 6 days ago. Offline
Joined: 2011-12-25
Posts: 14

Monarchy_v3 (new)
Monarchy_v2
Monarchy_v1

Wuzzy
Wuzzy's picture
User offline. Last seen 10 hours 7 min ago. Offline
Joined: 2012-06-20
Posts: 935

Awesome! Thanks for posting it here.

It was fun playing this with you.

The ability name “karma” is misleading because in Hedgewars, karma normally means that the attacker gets damage by attacking any hog. Karma is something negative for the attacker if it has it.
The type of karma used in your script can be more seen as a defensive/revenge measure because its not hog with karma which gets damaged by attacking others. I would rename it to “Anti Karma”, “Revenge”, “Revenge Karma” or whatever.

I suggest you to add version numbers of the form “_v”, e.g. “Monarchy_v1”.
To avoid future confusion with future version. I do not believe in the concept of “final“ versions. :P

By posting this on hh.unit22.org, this script would theoretically automatically appear in DLC (indirectly) as well because there's a link to hh.unit22.org in DLC at the moment.
However, since bender doesn't seem to review regularily review anything, it is not visible. Probably poke bender about this.

I am currently still unable to add anything on DLC, sorry. Sad Smiley

Maybe I'll write a full review about this script later. No promises, however.

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

Wuzzy allegedly wrote:
I would rename it to “Anti Karma”, “Revenge”, “Revenge Karma” or whatever.
Thorns? That's the name usually used for such stuff.

Wuzzy
Wuzzy's picture
User offline. Last seen 10 hours 7 min ago. Offline
Joined: 2012-06-20
Posts: 935

Nemo pointed me to a questionable coding practice you used in the Monarchy script. First I quote the chat log:

Quote:

<nemo> Wuzzy2: he's using "free" values in the engine that could go away in future releases
<nemo> he should not do that
* Szkod has quit (Quit: Starting a real life... for now.)
<Wuzzy2> point me to a code line plz
* Szkodnix (~Szkodnix@87-206-152-210.dynamic.chello.pl) has joined
<nemo> local gstHHShore = 0x10000000 -- HedgeHog Shoring Up gear state
<nemo> local gstHHLand = 0x20000000 -- HedgeHog Landing gear state
<nemo> local gstHHDJump = 0x40000000 -- HedgeHog Doble Jump gear state
<nemo> local gstHHTJump = 0x80000000 -- HedgeHog Triple Jump gear state
<Wuzzy2> oh-oh-oh-oh
<nemo> elseif clanof[CurrentHedgehog] == "Merfolks" and band(GetState(CurrentHedgehog), gstHHShore) ~= 0 then
<Wuzzy2> not good. hardcoding fake gear states? :>
<Wuzzy2> this is evil
<nemo> getGearValue(CurrentHedgehog, gstHHShore) ~= 0

So basically the problem nemo (and I) have about this script is that you are using non-standard gear states and check against them. This is a bad idea because we reserve the possibility to later add new gear states into Hedgewars. As soon we release a new HW version with a new gear state, your script will almost certainly break.
In other words, your script is not forwards-compatible.

Also note it is NEVER neccessary to add fake gear states like you do.

I suggest to remove all “custom” gear states. To save and read values for gears, I suggest you use the Lua library “Tracker.lua” included in Hedgewars. Please read this:
https://hedgewars.org/kb/LuaLibraries#Tracker

So instead of saving the fake gear state “gstHHTJump”, you can use a gear value using this library instead, which you could just set to 1 or 0 (on or off). The same applies for the other fake states, of course.

Tiotimolina
User offline. Last seen 5 weeks 6 days ago. Offline
Joined: 2011-12-25
Posts: 14

Wuzzy allegedly wrote:

So basically the problem nemo (and I) have about this script is that you are using non-standard gear states and check against them.

I link here to the script without custom gear states. It also uses SetAmmoTexts() and GetAmmoName().

Edit This post had an old pastebin link that's no longer active.

Wuzzy
Wuzzy's picture
User offline. Last seen 10 hours 7 min ago. Offline
Joined: 2012-06-20
Posts: 935

Nice.

There's a small bug, however: The bottom part of the ammo panel still shows “Air Attack”, etc.
Sorry, there was incomplete documentation on SetAmmoTexts. I have updated it accordingly.

It is not allowed to call SetAmmoTexts before onGameStart has been fired. You can either call SetAmmoTexts in onGameStart, or at any later point. But not before.

In your case, simply move all SetAmmoTexts stuff into onGameStart and the bug is fixed.

I would also slightly rewrite the texts. First, add punctation / use complete sentences.
Second, write the ammo description it in this form to make it (hopefully) a bit clearer to the user:

Quote:
This is your current role.
Your goal: YYY.

Annoyingly, there is still this “unavailable” message at the bottom but currently there is not much you can do about it.

I think we can both agree that using this ammo menu to display the player's role is a hack. A clever hack, but still a hack. Big Grin
In the long future, I should probably look into ways to display information in a way so only one player can see it. But this is pretty low priority for me right now.

Tiotimolina
User offline. Last seen 5 weeks 6 days ago. Offline
Joined: 2011-12-25
Posts: 14

Wuzzy allegedly wrote:

I would also slightly rewrite the texts. First, add punctation / use complete sentences.

The problem are the sentences that should be localized but have a subject that varies. Example "hedgehog1 has killed an anarchist clan". It could be hedgehog1 or hedgehog2 or Crosby. That line has become "An anarchist clan died". Analogously the knights line.

The sentences in the end screen were like "Team_name (clan chosen) was royalty". It has become now "Team_name (clan): role" to avoid the loc("was") in the middle.

The former sentences in the mission were split in two lines, which makes them impossible to localize in some languages. They now lay in a single line.

Edit This post had an old pastebin link that's no longer active.

Wuzzy
Wuzzy's picture
User offline. Last seen 10 hours 7 min ago. Offline
Joined: 2012-06-20
Posts: 935

Tiotimolina allegedly wrote:

The former sentences in the mission were split in two lines, which makes them impossible to localize in some languages. They now lay in a single line.

String concatenation is the translator's worst enemy.

string.format is your friend. This solves all problems related to string ordering.

I used this function extensively in many of my own scripts, and used it to fix translation issues in the official scripts.

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