[Script] [Multiplayer] Monarchy

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

Monarchy

Monarchy is a hedgewars minigame based on a traditional card game.

At the beginning of the game, if there are four or more players, every team will receive a role. Teams sharing a color receive the same role. With two and three players there are no roles. Roles can be disabled for any number of players with the parameter 'noroles' in the scheme.

Roles

All roles except royalty are hidden. Every player knows the roles of his or her clans but not the roles of other players clans.

There are four roles:

  • Royalty.

    Their goal is to defeat the usurpers and the anarchists.
    There is always a clan being the royalty.
    Royal hogs start with extra health.
    The first player (which by default becomes the royalty) may skip this role by pressing [backspace]. I added this feature to avoid that the same player becomes the royalty twice in a row.

  • Anarchists.

    Their goal is to defeat the royalty.
    With five or four players there are two anarchists. Otherwise, with six or more players, there are three anarchists.

  • Usurpers.

    Their goal is to defeat every other clan but the royal clan, then dethrone the royalty.
    Usually there is only one usurper, however with eight players there are two. Usurpers are not teammates.

  • Knights.

    Knights win if the royalty wins.
    With four players there are no knights, with five and six there is a single knights clan and with seven and eight there are two knights clans.

If the royalty kills a knight team, it loses all the weapons.
Whenever anyone kills an(other) anarchist team, it gets 3 random weapons.

Clans

At the beginning of the game, each player will be given randomly two clans to choose among. Each clan has their own seven weapon stock and some abilities.

These are the clans:

  • Zombies.

    Abilities: Regenerate and infect.
    Weapons: Bazooka, Drill Rocket, Shotgun, Desert Eagle, Sticky Mine, Cleaver and Birdy.

  • Vampires.

    Abilities: Vampirism, levitate, double and triple jump.
    Weapons: Bazooka, Drill Rocket, Grenade, Cluster Bomb, Shotgun, Mine and Seduction.

  • The Hivemind.

    Abilities: Ubiquity and extra resources.
    Weapons: Homing Bee, Grenade, Cluster Bomb, Baseball Bat, Mine, Sticky Mine and Construction.

  • Cyborgs.

    Abilities: Portable Portal Device (let's count this as an ability)
    Weapons: Drill Rocket, Shotgun, Desert Eagle, Sniper Rifle, Construction, Laser Sight and Extra Time.

  • Faeries.

    Abilities: Flying.
    Weapons: Mudball, Shoryuken, Whip, Baseball Bat, Seduction, Hammer and Mine.

  • Demons.

    Abilities: Shady bargain
    Weapons: Mortar, Cluster Bomb, Molotov Cocktail, Flamethrower, Hammer, Mine and Resurrector.

  • Shamans.

    Abilities: Lifelink and karmic retribution.
    Weapons: Shotgun, Desert Eagle, Sniper Rifle, RC Plane, Sticky Mine, Land Spray and Cleaver.

  • Puppeteers.

    Abilities: Mind control.
    Weapons: Grenade, Mine, Pick Hammer, Blow Torch, Construction, Switch Hedgehog and Extra Time.

  • Merfolks.

    Abilities: Swimming and hydroteleport.
    Weapons: Mortar, Mudball, Old Limburger, Desert Eagle, Shoryuken, Whip and Pick Hammer.

  • Fire Elementals.

    Abilities: Blazing weapons and pyroteleport.
    Weapons: Bazooka, Mortar, Drill Rocket, Grenade, Cluster Bomb, Shotgun and Hammer.

Abilities

Some of them are self-explanatory so I will try to explain in deep the more puzzling.

  • Karmic retribution.

    Damage done to this hog causes the aggressor to lose that much life.

  • Infect.

    All damage done during the turn of a hog with infect will poison.

  • Lifelink.

    When a hog with lifelink does damage to another hog, it creates a bond with that hog. At the end of the turn the hog with lifelink will drain 5 hp from all the linked hogs.

  • Vampirism.

    Gain 80% of the damage done to other hogs.

  • Regenerate.

    At the end of the turn, restore the health.

  • Double/Triple jump.

    Double long jump and triple high jump.

  • Levitate.

    If a hog with levitate would hit the ground with enough velocity to be damaged, instead it will perform a soft-landing.

  • Flying.

    If the hog is in middle air it can fly. Controls are the same as ufo.

  • Swimming.

    Hog is immune to water and can swim and dive.

  • Ubiquity.

    At the beginning of the game, place the whole clan. The clan receives infinite switches.

  • Extra resources.

    Three more weapons the first turn and 50% more time all turns.

  • Shady Bargain.

    At the start of each turn or whenever a hog dies during this turn, the hog will steal a weapon from a random clan or the killed hog clan.
    The hog gets a hellish grenade if the victim has no weapons.

  • Mind control.

    The nearest hog will repeat all moves.

  • Hydroteleport.

    This is a weapon. It behaves like a teleport but it only works over the water.

  • Pyroteleport.

    This is also a weapon. And it is also like teleport but makes fire in the place the hog is being teleported from. The destination place is ranged to a 300 px radius circle with its center in the current hedgehog.

  • Blazing weapons.

    These weapons make fire.

  • Portable Portal Device.

    This is hardly an ability. It consists on having two Portable Portal Devices each turn.

Initial weapons

At the beginning of the game, every team receives 4 weapons. These weapons are random except for zombies and puppeteers. Zombies get 3 random weapons and a resurrector, while puppeteers get 3 random weapons and a kamikaze. Note that resurrector and kamikaze are not among the weapons of these clans, so, once used, that's all. Demons cannot seize them.

Crates

These are the weapons available in crates: Pick Hammer, Blow Torch, Birdy, Construction, Land Spray, Rubber, Rope, Parachute, Flying Saucer, Portable Portal Device and Low Gravity

Ranking

Even though teams sharing a color will get different clan, they will have the same role and will be considered the same team for the ranking.

If the royalty (and knights, if any) wins:
the royalty wins 15 points for every anarchist;
the knights win 10 points for every anarchist if they are alive and 7 points for each anarchist if they are dead;
the usurpers win 4 points for every player if they were the last team to die besides the royalty.

If the anarchists win:
the anarchists win 10 points for each anarchist if they are alive and 8 points for each anarchist if they are dead;
the usurpers win 3 points for each player if they are alive;
the knights lose 50 points if they kill the royalty.

If the usurpers win:
the usurpers win 15 points for each player (different usurpers are not teammates);
the royalty wins 1 point for each player.

Download

Monarchy_v2 (new)
Monarchy_v1

Wuzzy
Wuzzy's picture
User offline. Last seen 1 week 4 days ago. Offline
Joined: 2012-06-20
Posts: 802

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 3 hours 39 min ago. Offline
Joined: 2010-12-25
Posts: 318

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.

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

Wuzzy
Wuzzy's picture
User offline. Last seen 1 week 4 days ago. Offline
Joined: 2012-06-20
Posts: 802

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 7 weeks 5 days ago. Offline
Joined: 2011-12-25
Posts: 13

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().

https://pastebin.com/TaXH81ZG

I have made custom icons for the weapons that are used to tell players their role. I am gonna upload the images somewhere and link them here later.

Edit: I cannot upload the sidecar hwp with the pics to unit22. I will search a place to upload it and post the link here once I found one.

Edit 2: I have finally uploaded the sidecar hwp with the images to pastebin in base64. Run this

'curl https://pastebin.com/raw/ZuZgiesx | base64 -di > Monarchy.hwp'

to download it.

Wuzzy
Wuzzy's picture
User offline. Last seen 1 week 4 days ago. Offline
Joined: 2012-06-20
Posts: 802

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 7 weeks 5 days ago. Offline
Joined: 2011-12-25
Posts: 13

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.

Also the param "hatehavingfun" (to disable roles) is now "noroles" because I am noone to judge what others enjoy and what not.

By the way, the icons for the roles doesn't fit the hedgewars style. If someone wants to try make them look more like hedgewars I still have all the svg or maybe someone would like to make them from scratch.

https://pastebin.com/YvChHEAk

Wuzzy
Wuzzy's picture
User offline. Last seen 1 week 4 days ago. Offline
Joined: 2012-06-20
Posts: 802

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 ]