[Script] [Multiplayer] Monarchy

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

Monarchy is a hedgewars minigame intended for a group of 4 or more players. The rules are based on classic card games.

Abilities
On game's first round, players are asked to choose 1 out of 2 randomly given abilities. The abilities are unique and apply to all the hedgehogs of a team. The chosen ability is displayed at the screen bottom, next to the health bars. The description of the ability can be read during the selection phase and later in the mission, either by pressing Esc or holding M.

Weapons
At the end of your turn, you get 2 random weapons. Weapons are retained between turns. Teams are limited to 5 weapons.
Room host can set which weapons are available during the game and which not through the weapon settings. Weapons with 1 or more bullets will be available during the game. This is similar as to how Higlander and BRW (other minigames) ammo is configured. Delay of weapons and content of crates can be customized as usual in the corresponding tabs.

Roles
If there are 4 or more players, Monarchy is played with roles.
Each player receives a secret role at the start of the game. Players only know their role and who is the monarch. The goal of the game is determined by your role.

  • Monarch: Eliminate all the assassins and traitors.
  • Assassins: Eliminate the monarch.
  • Guards: Same goal as the monarch.
  • Traitors: Become the last standing player, eliminating the monarch at last.
The monarch takes the first turn, starts with one more weapon and hedgehogs get some extra health.
When a player is eliminated, if the player was an assassin, the current player is rewarded with 3 extra weapons, even if the current player is another assassin. Otherwise, if the player was a guard and the current player is the monarch, the monarch loses all the weapons.

Score

 4-5 players      | monarchy wins | assassins win
------------------+---------------+---------------
 monarch          |      300      |       0
 guard (alive)    |      200      |       0
 guard (dead)     |      140      |       0
 assassin (alive) |       0       |      200
 assassin (dead)  |       0       |      160

 6+ players       | monarchy wins | assassins win
------------------+---------------+---------------
 monarch          |      450      |       0
 guard (alive)    |      300      |       0
 guard (dead)     |      210      |       0
 assassin (alive) |       0       |      300
 assassin (dead)  |       0       |      240

Traitor score
If traitor wins, gets 150 for each player (eg. with 6 players gets 900).
If monarchy wins alone (guards are dead) and traitor was last to die, gets 40 for each player.
If assassins win and traitor is alive, gets 30 for each player.

Tips

  • The monarch is always the first player, but if you have already been the monarch in a previous game and do not want to do again, you can press the Switch key (which is tab by default) to pass up. You will receive a new role and the next player will play as monarch.
  • If you are 4 or more players yet you all like better to play a free for all game, that is, with no roles, all you have to do is input ffa as script parameter in the scheme.

Download
This script is in the DLC.

Wuzzy
Wuzzy's picture
User offline. Last seen 58 min 16 sec ago. Offline
Joined: 2012-06-20
Posts: 1062

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.

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

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

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 58 min 16 sec ago. Offline
Joined: 2012-06-20
Posts: 1062

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.

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

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

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 58 min 16 sec ago. Offline
Joined: 2012-06-20
Posts: 1062

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.

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

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

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 58 min 16 sec ago. Offline
Joined: 2012-06-20
Posts: 1062

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.

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

Plarf
User offline. Last seen 36 min 20 sec ago. Offline
Joined: 2013-11-16
Posts: 9

We tried today.
Was nice
Got some LUA ERROR a few turn before the end of game.

Here you can get game log, demo and even chat text.
https://envoi.zaclys.com/remise/795ae6620ee1017374e1fce4b53ea350/2019-01-29_game0_log_and_chat_text_and_demo.zip

Why can't we wrap the border?

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

The error was due to an attempt to check if dead hogs with amphibious were in water during water rise on sudden death. This is done comparing coordinate Y of hogs: if it is below water line, it relocates the hog on land. Since dead hogs have no Y coordinate, Lua interpreter whines. Already fixed.

I noticed in this demo that I overlooked switcher + ice coat. Fixed that too. I will upload the next version within a few days.

With regard to border, it was set to none in the scheme according to game log, line 154.

Quote:
0: [Cmd] $worldedge 0

It should say:
Quote:
0: [Cmd] $worldedge 1

Just change it to wrap, should work. Wink Smiley

Thanks for the report. And glad you like the mode.

Plarf
User offline. Last seen 36 min 20 sec ago. Offline
Joined: 2013-11-16
Posts: 9

Tiotimolina allegedly wrote:

With regard to border, it was set to none in the scheme according to game log, line 154.
Quote:
0: [Cmd] $worldedge 0

It should say:
Quote:
0: [Cmd] $worldedge 1

Just change it to wrap, should work. Wink Smiley

Thanks, about wrap border I wasn't host and didn't check before telling you what host told me, sorry.

Monarchy is fun, thanks to you Tiotimolina.
Waiting to play it again, maybe with you.

Plarf
User offline. Last seen 36 min 20 sec ago. Offline
Joined: 2013-11-16
Posts: 9

AC and I complain about the lack of fine tuning advices:
[19:22] plarf: gimme your "Mona" scheme settings
[19:22] AC: pas encore!
[19:22] AC: oh
[19:23] AC: i dont know
[19:23] plarf: thx
[19:23] AC: they are probably original
[19:23] AC: timolina has not been very good on teaching out how to set this game up

Thanks bro

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

Done. New version will suggest Default as the scheme and One of Everything as the weapons. Balanced Random Weapons and Highlander are good options too.

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