<< Back to Programming Forum   Search

Posts 1 - 18 of 18   
Mods v0.06 are live!: 6/2/2017 19:37:32

Fizzer 
Level 58

Warzone Creator
Report
A new version of the mod framework was just released! This adds a bunch of new stuff mods can take advantage of:

1. Data storage! Mods can now store data in a game that will be persisted for the lifetime of that game. This allows mods to remember things, such as who is allied with who, what turn the zombies break out, or what each AI is thinking, etc.

Mods can store this data in three buckets. Mod.PublicGameData stores public information that is shared with players in the game (plus spectators), Mod.PrivateGameData is not shared with any players and is only readable by the mod, and Mod.PlayerGameData is shared only to specific players the mod deems worthy of each piece of information.

See https://www.warlight.net/wiki/Mod_Game_Data_Storage for details.

2. Custom messages! Mods can now communicate between the client and server at will, instead of having to wait for a turn to advance like before. A client can, at any time, initiate a call to the server by calling Game.SendGameCustomMessage. The server can then handle that call with the new server hook, Server_GameCustomMessage.

3. Mods can now use the new Client_GameRefresh hook to run code whenever the client gets new data about a game from the server. This includes when the Server_GameCustomMessage hook changes some stored data clients can see. See https://www.warlight.net/wiki/Mod_Hooks

4. More improvements!:
- Mods can now store tables into the Mod.Settings object, as well as the new data storage buckets.
- Mods can now see each player's income by calling the GamePlayer.Income function.
- Mods can now call Game.CreateDialog in client hooks to create new windows, similar to what the menu button did previously.
- Mods that use the Client_PresentMenuUI hook now get passed a 5th argument which is a callback to close the dialog.

I have written a new example mod, the Diplomacy mod, to show off these features. Its code can be seen here: https://github.com/FizzerWL/ExampleMods/tree/master/DiplomacyMod

The way it works is that whenever a player (A) proproses an alliace with another (B), it sends a custom message to the server. The server then writes the proposal into player B's Mod.PlayerGameData, so only they know about it.

Then, the Client_GameRefresh hook is invoked on player B's client. It can read the proposal and ask the player if they accept or not. B's client then sends another custom message, with either AcceptProposal or RejectProposal. If it's rejected, it's simply removed from B's GamePlayerData. If it's accepted, it's removed and also written into Mod.PublicGameData as an alliance.

Writing into Mod.PublicGameData invokes a refresh on all player's clients, so everyone gets a pop-up message letting them know about the alliance.

Then in the Server_AdvanceTurn_Order hook, we simply skip attacks between players who are allied (similiar to how the Safe Start mod works). Finally, in Server_AdvanceTurn_End, we remove alliances that have expired.

This is a simple example of how to write a diplomacy mod. It could be improved with many more features, such as breaking alliances, stopping cards attacks, sharing armies, etc. The possibilities are endless!
Mods v0.06 are live!: 6/2/2017 19:43:09


Жұқтыру
Level 55
Report
When v1.0?
Mods v0.06 are live!: 6/2/2017 20:39:03

DanWL 
Level 62
Report
So diplo mods are now possible?

^whenever it arrives.
Mods v0.06 are live!: 6/2/2017 20:40:39


TBestLittleHelper
Level 47
Report
This is awesome
Mods v0.06 are live!: 6/2/2017 21:38:11


ps 
Level 60
Report
lots of cool stuff!
Mods v0.06 are live!: 6/2/2017 21:52:30


ViralGoat 
Level 59
Report
WOOO! DIPLO!

One thing though. People will use this mod in 40 player FFA diplo games. Getting a popup for every diplomacy pact (there will be hundreds!) will be very annoying.
Mods v0.06 are live!: 6/3/2017 04:02:06

Fizzer 
Level 58

Warzone Creator
Report
When v1.0?

It will be officially released along with the Unity client, whenever that is.

So diplo mods are now possible?

Yep! And a lot more.

Getting a popup for every diplomacy pact (there will be hundreds!) will be very annoying.

Possibly. I don't think it will be that bad. But anyone can fork the mod and modify that behavior to whatever they'd like.
Mods v0.06 are live!: 6/3/2017 05:06:37


dabo1 
Level 56
Report
if(Mod.PublicGameData.War == nil)then attempts to call a nil value, I don't think that should be so.

Edit: There was a download problem. I downloaded an old version

Edited 6/3/2017 07:16:38
Mods v0.06 are live!: 6/3/2017 08:36:49

melwei [PG] 
Level 56
Report
Yeah! Finally!
I think we have now reached the point when almost EVERY suggested Mod is possible :-)
Mods v0.06 are live!: 6/3/2017 09:49:27


Buns157 
Level 67
Report
Yeah! Finally!
I think we have now reached the point when almost EVERY suggested Mod is possible :-)


I don't know much about this kind of thing, so is it now possible to make a mod where your opponents/teammates usernames are hidden? Like how players are hidden in coin games before you join them, but this carries on until the game is finished.
Mods v0.06 are live!: 6/3/2017 22:00:31

strongkillaz
Level 47
Report
Yaaaay! Hey by the way Fizzer a cool idea is that you could create alliance groups or whatever like NATO and you could make like a group chat for it. I know the idea is rough and not specific but just an idea haha. Goodluck!
Mods v0.06 are live!: 6/5/2017 09:23:35


dabo1 
Level 56
Report
I tried to make my own peace offer system. For that, I show every peace offer in one UI element with a button for accepting and declining per offer. But every button has the same function and as the function Accept gets called when I set .SetOnClick to (Accept(button)), I can't use this way. So is there any way to do something like that without invoking Accept, when I set it or should I make something like show just one order at the same time?

Edit: A friend of mine found a way to solve this problem the solution looks strange, but seems to work

Edited 6/5/2017 09:26:37
Mods v0.06 are live!: 6/5/2017 09:52:24

melwei [PG] 
Level 56
Report
"Looks strange"?

What's your problem with function Arrays? :P
Mods v0.06 are live!: 6/5/2017 14:25:08

Fizzer 
Level 58

Warzone Creator
Report
I show every peace offer in one UI element with a button for accepting and declining per offer. But every button has the same function and as the function Accept gets called when I set .SetOnClick to (Accept(button))

Are you saying you want to include an argument to the function per each one? You could try wrapping it in a closure:

function BtnClicked(i)
  print('Passed ' .. i);
end

for i=1,10 do
  UI.CreateButton(parent).SetOnClick(function() BtnClicked(i) end);
end


If this isn't what you mean, please post code showing off the problem.
Mods v0.06 are live!: 6/5/2017 15:43:39


dabo1 
Level 56
Report
I already have a solution, that works(see edit of my question and thanks to melwei)

Edited 6/6/2017 10:01:26
Mods v0.06 are live!: 6/6/2017 21:46:08

linberson 
Level 60
Report
Nice!

Finally no more traitors. Wait, does this mean I have to play game of thrones without backstabbing now???
Mods v0.06 are live!: 6/7/2017 09:34:08

linberson 
Level 60
Report
I don't know much about this kind of thing, so is it now possible to make a mod where your opponents/teammates usernames are hidden? Like how players are hidden in coin games before you join them, but this carries on until the game is finished.


wouldnt this also be possible with a userscript?
Mods v0.06 are live!: 6/7/2017 10:05:40


dabo1 
Level 56
Report
I don't know much about this kind of thing, so is it now possible to make a mod where your opponents/teammates usernames are hidden? Like how players are hidden in coin games before you join them, but this carries on until the game is finished.


wouldnt this also be possible with a userscript?


It's not possible with a userscript cause userscripts will never be able to change stuff of WebGL
Posts 1 - 18 of 18