s25client icon indicating copy to clipboard operation
s25client copied to clipboard

[LUA] enhancements

Open Spikeone opened this issue 10 years ago • 7 comments

  • [x] Save Lua State - Save the Lua state to savegames so you can load and continue
  • [x] Increase Lua filesize - currently 8192b which isn't enough for making enhanced scripts
  • [ ] Take ware - you should be able to wares of a player
  • [ ] Add ware to building / Take ware from building - adds/takes wares from a specific building (includes non store houses)
  • [x] Set addons - control addon settings
  • [x] Set options - control options
  • [ ] Post message with picture (also picture and location) - give an id for an image displayed
  • [ ] Mission statement with picture - same as post message with picture but for mission statement
  • [ ] Add Ship - adds a ship at given position for given player
  • [ ] Set ship dest - sets a ships destination (by Add ware to building / Take ware from building - adds/takes wares from a specific building (includes non store houses) ship and player id)
  • [ ] Set ship wares - sets wares of a ship by given id
  • [ ] Destroy ship - destroy a ship by given player and ship Id, add fire at position
  • [ ] Add building at - adds a building at a given position for given player ( if military building also set soldiers and rank)
  • [ ] Destroy building at - destroys a building at a position
  • [ ] Building finished - called when a building was finished, gives position, player id, type
  • [ ] Animate bob - takes any moved bob ingame, set way by coordinates, player by id, movement types: circle (if last waypoint, start move to first and restart(not teleport)), patrol (if last, restart in reversed order(last =first, first =last), strop and inform (informs the script that an animated bob reached its destination)
  • [ ] Show information - adds up to n info texts in the upper right corner (eg for counters, short quest text)
  • [ ] Set relation - set relation between players/ai by ID and type
  • [x] Get military strength - returns military strength of player by id
  • [ ] Get player Input - open Dialoge where the player can press yes / no - maybe as well Choice Input (by number) so you can Interact with the player a bit
  • [ ] Open Input - Player can (if allowed by Script) also open his currently Input (e.g. If he Holds a shop, he can buy something)
  • [ ] BuildRoad (only if building a building works) - maybe same as ai command connecting two flags
  • [ ] SetLandOwner - give land to a specific player held by anything (e.g. Like the harbor)
  • [ ] SetBQ(x, y, BQ, ...) - sets the building quality of a specific map point
  • [ ] SetTexture(x, y, Texture, ...) - sets the texture of a specific map point (hexagon)
  • [ ] FindBuildingNear(x, y, BLD, search_radius) - returns x and y of first building found, if there is none return -1, -1
  • [ ] SetResouceAt(x, y, Type, ...)
  • [ ] JustPlaced(Player, x, y, BLD) - called when the player placed a building
  • [ ] JustBuilt(Player ,x ,y, BLD) - called when a building was finished
  • [ ] JustOccupied(Player ,x ,y , BLD) - called when a building is occupied
  • [x] EnteredCombat(Player1, Player2) - Called when 2 player enter combat state with any building
  • [ ] SoldierLost(Player, Type) - called when a player loses a soldier
  • [ ] CustomStatiaticTab(ID, Player, Icon, y_min, y_max, y1, y2, y3, y4) - creates a custom statistics showing values, may not be affected by time settings, Player defines just an ID and color, may also be divided into name, color / Icon defines an icon used to click on
  • [ ] RemoveCustomStatistics(ID) - removes a custom statistic by ID
  • [ ] PlayDirectSound(Player, Sound) - plays a sound for given player, may also be a custom sound
  • [ ] PlayDirectSoundToMap(Sound) - Plays a direct sound for all players, may also be a custom sound
  • [ ] AddBuildingWithoutFunction(Player, Name, req_BQ, FirstGraphic, req_res1, req_res1_value, ...)
  • [ ] SendDialoguePostMessage(Player, Text, Text_btn01, Text_btn02) - Sends a post message to a player with answer options (like those from diplomacy)
  • [ ] JustDecided(Player, decision) - Called when a player decides something
  • [ ] JustFocused( Player, x, y) - Called whenever any node gains focus by any player (including enemy buildings, buildings etc), but may not work for ships
  • [ ] GetNodeObject(Player, BLD, object, list) - returns an object, building, road, flag etc. of a given position
  • [ ] AddLabel(Player, x, y, Text) - Adds a label at given position visible for player with text, may be overwritten by an other AddLabel
  • [ ] RemoveLabel(x, y) - May do the same as calling AddLabel with text ""
  • [ ] DisablePlayerControl(Player) - Player actions are ignored until this function is called again
  • [ ] SetBuildingSetting(x, y, Setting, bool) Sets a Setting in a Building at given position (e.g. stopping)
  • [ ] DisablePlayerBuildingControl(Player, x, y) - Disables player control at given position (May still check wares)
  • [ ] DisablePlayerBuildingTypeControl(Player, BLD) - disables building control over all buildings of a type
  • [ ] SetVisible(Player, x, y, radius) - Player got vision for specific position
  • [ ] SetMaxRank(Player, Rank) Sets the maximum rank soldiers can currently advance for a player
  • [ ] DisableMap(Player) - Disables the map for player
  • [ ] player:setReserve(count, rank)

Spikeone avatar Jul 29 '15 05:07 Spikeone

Some of those are quite useful. E.g. save/load and increase lua size (currently there is probably even a bug, when the lua size exceeds tcp packet size...) However note that making those functions adds quite some complexity and using it in multiplayer games requires careful design by the script creator or there will be asyncs. I think, if the script purely depends on events and GF numbers, then even adding wares would work without asyncs, but I'm not sure.

I'd make save/load, lua size and option settings (player faces, addon settings etc) top priority as this is required for good missions. Maybe easiest: Ask the player, if he wants to start map as mission, and if he does, make most things readonly and call the lua script.

Flamefire avatar Mar 15 '16 10:03 Flamefire

However note that making those functions adds quite some complexity and using it in multiplayer games requires careful design by the script creator or there will be asyncs.

All gameplay related functions should be realised as GameCommands or do I miss something here? Then there should be no (additional) danger for asyncs, right?

jhkl avatar Mar 16 '16 20:03 jhkl

Adding wares did not create any async (maqs said something like "when every player has the same script, there can't occur an async). Idont get how this is mapcreator related, if a function is not multiplayer compatible (and will never be) the game shouldn't start at all.

Spikeone avatar Mar 16 '16 21:03 Spikeone

Maqs is right. If the same script runs on every client, it is fine as long as nothing player-dependant is done. The script is synchronized as long as only events based on the game itself are used. This includes GameFrames, discovered territory, actually placed buildings or orders (opposite to the intermediate showing of a buildings placement or e.g. change coins visual indicator) but excludes player dialogues, pc specific stuff (local time, files,...) or direct influence of player actions (clicking somewhere,...)

So I would not add any such function to lua or if they are added, prohibit them in multiplayer matches. This is possible with the C++ wrapper by simply not exporting those functions in multiplayer mode. However this would result in errors during the game if a map maker did use them...

Flamefire avatar Mar 17 '16 09:03 Flamefire

Register player clicks and add some basic input should also work in multiplayer.

Something like vbs should be enough. For example one could add a bridge builder where. You could purchase a bridge. If any player clicks on that building a window should open open up asking the player if he wants to buy a bridge, if 1 is returned an other window opens with a simple input asking for x,y, length as example. As the result is for every player the same this shouldn't async. How this could work - I don't know. But I still think that this would be great (eg for shops or trade posts).

Maybe one could add objects so every player bows how that object behaves?

Spikeone avatar Mar 17 '16 12:03 Spikeone

Nope. This would not be the same for all players. Player clicks are player-only, clicks are not sent to other players so no player will know, if he bought the bridge. This would need to be sent via a GameCommand. But then we would need 2 functions for each action: One that sends a GC and one that does not. Also adding GCs is a bit work...

I also think, if you want to add shops etc: Use the WC3 editor and import some textures ;) This is SPARTA! (aehm, settlers 2 :D)

Flamefire avatar Mar 17 '16 13:03 Flamefire

Point is interaction. Without player interaction it would be quite sad. I still think that it is a good thing we should add if we could.

If it's hard to add... Mhh.

Spikeone avatar Mar 17 '16 14:03 Spikeone