I have wanted a some changes to the poll system for for a while now, and I was hoping they would be added to the official game. Unfortunately the requests on the bug tracker were all denied, so decided to have a go myself with the module system; and along the way I added a few other ideas from around the forums that seemed good. It is released freely for anyone to use in their mod; and I don't care much about whether I get credited or not, as long as nobody falsely credits themselves or someone else for it.
Features:
To test it out: PollMod.zip
If people just want to try the features out with the Native module, just make a copy of of the directory named something like PollMod, then extract the above zip file and move the contained files into it. Bear in mind that when you start a server from in game ("Host a game" in MP menu) your player ID will be 0, i.e. the server, which will not show up in the player lists for messaging, kicks, or bans; and also that admin players can't be kicked or banned. You can test those parts by copying the dedicated server executable to the main warband install, along with a pair of config and .bat files; follow the instructions in the config file to set it up, then run the server (selecting this mod), start the game, and choose LAN from the drop down in the server selection screen; this way your player will show up in the lists. In unmodified native 1.126 there seems to be a bug: when a player is kicked or banned, they will not automatically leave the server with a message saying they were kicked - as it was in 1.113 - their client will stay connected, but won't be able to do much apart from sliding around slowly, as if the connection was lost.
Unfortunately none of the features are compatible with Native except the poll layout and keys changes, though (it seems) things should work fine when applied to a client as long as you don't use the new admin features - the poll parts were designed to still work. My original idea was to make a small tweak that, when applied to the server and your client, would show the name of the player that started the poll: this works apart from with the "change map and factions" poll (the most common one), which uses up all the available network message values, requiring two values to be packed into one integer, breaking compatibility with unpatched clients. The code has been tested on a dedicated server with two local clients connected, though there are probably still unfixed bugs.
To apply the changes to your mod:
I don't know much about how most mod creators work with the code - whether this is a useful way to release it or not; but I decided to post on the forums so it should be easily accessible for as long as the game is played. I personally use a local git repository to save my various tweaks and merge them with new versions easily, so I can push to a git mirror if anyone else uses that; another option is a set of "diffs", if someone wants to use some sort of "patch" utility to attempt automatic patching, like in TortoiseSVN. Instructions in the format that seems usual on these forums follow in the next posts; don't worry about how long it took, as it's just the output of git diff run through a perl script.
Open each file listed on the spoiler buttons, go to the line numbers on the purple lines starting and ending with @@ (the first number is the line in the original version, second is the line it will end up on), find the uncoloured lines of context, then remove any red lines, adding the adjacent blue ones in their place. Obviously if you have added more constants, adjust the values of any that conflict to be unique; also if your mod makes any use of the string registers s36 and s37, you should change all occurrences in this code to another two unused registers, to prevent the chance of people getting strange admin messages or custom polls. I couldn't figure out any other better way (that worked) to store strings between script invocations.
Features:
- The name of the player who requested the poll is shown on it to everyone; so people who abuse the system can be detected and dealt with, or at least polls by known griefers can be easily ignored.
- Ban and kick polls called by players include one of a list of preset reasons; so if a kick poll is called by dead spectating players, the other players still alive can more easily know how to vote; and to make it easy for players to call a vote for a common reason with the minimum of distraction to other players. More reasons can easily be added to the list (or changed) by simply adding lines to module_strings.py, in between "poll_reason_team_killing" and "poll_reason_end". Polls to ban or kick admins will not be started, since they would have no effect anyway.
- Change poll voting keys from 1 and 2 to F8 and F9; this is because I have weapon selection controls on the first 4 number keys, which has caused me to accidentally vote yes on ban polls, and caused me to get shot after pressing 2 to vote no, which also puts away my shield. I chose F8 and F9 because they are far away from the wasd keys, not used for any of the controls, so require an intentional movement to press them. The keys can be changed in the script very easily.
- The escape key does not vote no for the poll any more, so you can change equipment or close windows without needing to vote first. I added the F10 key as "Abstain" which will hide the poll and give the same result as ignoring it until the timer runs out, in case you have no opinion either way. Unfortunately bringing up the log window to see chat history seems to hide the poll presentation, forcing you to abstain; I don't know if there is a way to change this.
- Admin votes on a poll override the result right away, so they can cancel bad polls or force their own poll to be accepted. The admin will be warned and must confirm their vote, except when abstaining. Possibly it should be replaced with a dedicated "override poll" feature; but I quite like the side effect that admins can start a poll and immediately accept it, for example to change the bot numbers without using the admin panel and restarting the map.
- Admins can start polls repeatedly, without having to wait a certain amount of time in between like other players.
- Admins can send a message to a particular player or to all players, which shows up in big red letters in the middle of the screen, whether alive, dead, or spectating. This could be used for unambiguously warning players that are breaking rules, or to inform all players of something you require them to do. Unfortunately the text box for your message is not automatically selected, you have to click on it before typing. To bring up the text entry box to send a message to the last player selected in the list, press F11.
- Admins can choose to ban players temporarily, like a successful ban poll, rather than adding them to the permanently banned list. The time a temporary ban lasts seems to be an hour, from my testing, rather than the half hour of popular rumour.
- Admins can start a poll with a custom question that has no effect when it ends; this can be used to administrate the server according to the player vote.
- Changed the visual style of the poll presentation to be smaller and use outlined text; this was partly so the larger messages due to some of the above features would fit, and partly to try make it less obstructive. I wanted to somehow allow the name of the player being spectated to be seen while still deciding how to vote, but unfortunately that seems to be hardcoded, and I didn't find a way to detect the player being followed using the module system. I wondered about shifting the poll message somewhere else, like the top of the screen, but I decided that would be even more obnoxious. I also fixed the layout in the root escape menu to scroll properly and line up the text with the other menus.
- Some of these features require you to select a player from the list, then choose some other action like click a reason or type a message; if the player disconnects the command will fail with an error message - even if they have reconnected meanwhile - as the server seems to assign to joining clients a random number from the available slots. This is to guard against innocent players being targeted unintentionally - it might seem far fetched, but if the server is full, the target of a ban command leaves, and a waiting player joins... oops.
To test it out: PollMod.zip
If people just want to try the features out with the Native module, just make a copy of of the directory named something like PollMod, then extract the above zip file and move the contained files into it. Bear in mind that when you start a server from in game ("Host a game" in MP menu) your player ID will be 0, i.e. the server, which will not show up in the player lists for messaging, kicks, or bans; and also that admin players can't be kicked or banned. You can test those parts by copying the dedicated server executable to the main warband install, along with a pair of config and .bat files; follow the instructions in the config file to set it up, then run the server (selecting this mod), start the game, and choose LAN from the drop down in the server selection screen; this way your player will show up in the lists. In unmodified native 1.126 there seems to be a bug: when a player is kicked or banned, they will not automatically leave the server with a message saying they were kicked - as it was in 1.113 - their client will stay connected, but won't be able to do much apart from sliding around slowly, as if the connection was lost.
Unfortunately none of the features are compatible with Native except the poll layout and keys changes, though (it seems) things should work fine when applied to a client as long as you don't use the new admin features - the poll parts were designed to still work. My original idea was to make a small tweak that, when applied to the server and your client, would show the name of the player that started the poll: this works apart from with the "change map and factions" poll (the most common one), which uses up all the available network message values, requiring two values to be packed into one integer, breaking compatibility with unpatched clients. The code has been tested on a dedicated server with two local clients connected, though there are probably still unfixed bugs.
To apply the changes to your mod:
I don't know much about how most mod creators work with the code - whether this is a useful way to release it or not; but I decided to post on the forums so it should be easily accessible for as long as the game is played. I personally use a local git repository to save my various tweaks and merge them with new versions easily, so I can push to a git mirror if anyone else uses that; another option is a set of "diffs", if someone wants to use some sort of "patch" utility to attempt automatic patching, like in TortoiseSVN. Instructions in the format that seems usual on these forums follow in the next posts; don't worry about how long it took, as it's just the output of git diff run through a perl script.
Open each file listed on the spoiler buttons, go to the line numbers on the purple lines starting and ending with @@ (the first number is the line in the original version, second is the line it will end up on), find the uncoloured lines of context, then remove any red lines, adding the adjacent blue ones in their place. Obviously if you have added more constants, adjust the values of any that conflict to be unique; also if your mod makes any use of the string registers s36 and s37, you should change all occurrences in this code to another two unused registers, to prevent the chance of people getting strange admin messages or custom polls. I couldn't figure out any other better way (that worked) to store strings between script invocations.