distribution of units from a host?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

distribution of units from a host?

Post by SlowThinker »

I want to use a custom unit (custom stats + custom image) in a MP scenario. Is there any way how to send it from the host to other players? (I don't want the players that are joining a game are forced to download anything).

I was also speculating whether I can use a mainline unit (and so to preserve its id), and to change its image?
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
User avatar
Kapoue_II
Posts: 203
Joined: October 11th, 2010, 9:41 am

Re: distribution of units from a host?

Post by Kapoue_II »

SlowThinker wrote: I was also speculating whether I can use a mainline unit (and so to preserve its id), and to change its image?
I can tell you that that's not a good idea, because then you would have multiple unit id's kicking around, which makes wesnoth practically fall to it's knees. I doubt this can be done without any downloads, but I am no expert in WML.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: distribution of units from a host?

Post by zookeeper »

SlowThinker wrote:I want to use a custom unit (custom stats + custom image) in a MP scenario. Is there any way how to send it from the host to other players? (I don't want the players that are joining a game are forced to download anything).
Nope, not possible. Nothing outside the [multiplayer] and [era] tags can get sent to the other players.
SlowThinker wrote:I was also speculating whether I can use a mainline unit (and so to preserve its id), and to change its image?
Well, no, but you can of course apply whatever regular unit modifications you want to all units of a given type which appear in the scenario. Remove attacks, add new ones, change other stats, etc.
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: distribution of units from a host?

Post by SlowThinker »

Kapoue_II wrote:I can tell you that that's not a good idea, because then you would have multiple unit id's kicking around, which makes wesnoth practically fall to it's knees. I doubt this can be done without any downloads, but I am no expert in WML.
I would use only unused mainline units.
zookeeper wrote:Well, no, but you can of course apply whatever regular unit modifications you want to all units of a given type which appear in the scenario. Remove attacks, add new ones, change other stats, etc.
I tried [store_unit] and to change unit.image, but it looks according to InternalActionsWMLUnitTags image is one of the attributes that cannot be manipulated.


So it looks if I want to have fully customized units (including their pictures), I must force players to download an era that will contain at least "empty units" with their pictures? (I think unit stats are better to be distributed from [multiplayer], because it is better the era is not updated and stays fixed - no OOS due to era differences).
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: distribution of units from a host?

Post by zookeeper »

SlowThinker wrote:
zookeeper wrote:Well, no, but you can of course apply whatever regular unit modifications you want to all units of a given type which appear in the scenario. Remove attacks, add new ones, change other stats, etc.
I tried [store_unit] and to change unit.image, but it looks according to InternalActionsWMLUnitTags image is one of the attributes that cannot be manipulated.
Right, but you can give each unit a new set of animations (which you'd have to do in any case unless you wanted the base frame to mismatch the animation frames...) which have enough filtering criteria to make them always be picked instead of the unit type -defined animations. For a simple example, look at how Dacyn is given a different standing animation in EI:05.
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: distribution of units from a host?

Post by SlowThinker »

At present I know nothing about animations...
My goal is to override the standard unit image. Can I do it with the new set of animations?
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
User avatar
Gwledig
Posts: 598
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: distribution of units from a host?

Post by Gwledig »

You can do the stuff i did with new races in Conquest, by using [unit] to wipe all existing stats, abilities etc. then add new ones, you can re-name the "name" of the unit and make it perma, so it can't be changed by a player.
The unit will still have the "type" of the base unit "type" you chose for the unit, and the same portrait and animations, but you can wipe pretty much everything else.
You can use a basic overtlay tag to display a new animation over the existing one, but this doesn't replace it, it needs to be larger than the one below, if you use comma separated list you can add multiple overlays and even create a totally new looking unit, I do this with the towers, which are really an Elvish Shaman with a lighthouse and rubble overlay.
I think you can use variables to override the animations on-the-fly, using the kind of code used for the caravel/ dhow, so I think you would need to specify the PNG animation for various kinds of action/ stance/ fighting, I haven't tried this but it might also be a useful idea.
One thing I might do is create a Wose faction using actual tree tiles, so you could have a shed load of wose units, or blend normal wose with overlay of objects, sceptre, etc.
I have also looked into distributing a single image PNG in a multiplayer game and you can't do it, no hacks, nothing.
One idea however that might work is to run a python script at game start which copies the PNGs from a remote server to the user's userdata folder.. just a concept no idea if it will work.
Yes the only real way is to do the Mabuse method and use a [unit_type] approach or make player download an era as far as I know.
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: distribution of units from a host?

Post by SlowThinker »

Gwledig wrote:Yes the only real way is to do the Mabuse method and use a [unit_type] approach
So - new animations override original animations, but not the original image. Correct?

For completeness... I found unit_type.variation in the wiki ... but I don't think it could work and be left out by experienced WMLers...

------------------------------------------------
A bit off topic
I have a concrete unit type (i.e. its ID), and I need its image: must I create a fake unit in memory by [unit] and then retrieve the image from this fake unit? No simpler way? (I don't want to use lua)
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
User avatar
Kapoue_II
Posts: 203
Joined: October 11th, 2010, 9:41 am

Re: distribution of units from a host?

Post by Kapoue_II »

SlowThinker wrote: A bit off topic
I have a concrete unit type (i.e. its ID), and I need its image: must I create a fake unit in memory by [unit] and then retrieve the image from this fake unit? No simpler way? (I don't want to use lua)
Well, you might be able to do a [unit_type] in the scenario file (since presumably, if its in the scenario file then it gets sent-even though it can't be in the [scenario] tag), and use base_unit=your_unit.id.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: distribution of units from a host?

Post by zookeeper »

Kapoue_II wrote:
SlowThinker wrote: A bit off topic
I have a concrete unit type (i.e. its ID), and I need its image: must I create a fake unit in memory by [unit] and then retrieve the image from this fake unit? No simpler way? (I don't want to use lua)
Well, you might be able to do a [unit_type] in the scenario file (since presumably, if its in the scenario file then it gets sent-even though it can't be in the [scenario] tag), and use base_unit=your_unit.id.
No, you can't. Nothing outside the [multiplayer] and [era] tags can get sent to the other players.
SlowThinker wrote:My goal is to override the standard unit image. Can I do it with the new set of animations?
No, but you can give the unit a standing animation. Whether that's good enough is for you to decide.
User avatar
pauxlo
Posts: 1049
Joined: September 19th, 2006, 8:54 pm

Re: distribution of units from a host?

Post by pauxlo »

zookeeper wrote:
Kapoue_II wrote: Well, you might be able to do a [unit_type] in the scenario file (since presumably, if its in the scenario file then it gets sent-even though it can't be in the [scenario] tag), and use base_unit=your_unit.id.
No, you can't. Nothing outside the [multiplayer] and [era] tags can get sent to the other players.
... and, neither [multiplayer] nor [era] allow for a [unit_type] tag as child.
User avatar
DEATH_is_undead
Posts: 960
Joined: March 4th, 2007, 3:00 pm
Location: Northern United States

Re: distribution of units from a host?

Post by DEATH_is_undead »

A simple overide of this, if the image is mainline, is to use the Fog Clearer unit and change it accordingly, then use unit_overlay to change the image, and use events to change the overlay for attack, move, ect.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: distribution of units from a host?

Post by Anonymissimus »

pauxlo wrote: ... and, neither [multiplayer] nor [era] allow for a [unit_type] tag as child.
Not quite true. 8)
Now I'm using such code in SoW

Code: Select all

	
[multiplayer]
   [event]
        name=sow_transfer_data
        [set_variables]
            name=sow_units
            [value]
                {~add-ons/Settlers_of_Wesnoth/units/}
            [/value]
        [/set_variables]
to transfer unit data at preprocessing time, since the scenario is preprocessed on the host and then sent to the remote clients. Whenever a unit of custom type is attempted to be created, I create a Fog Clearer and modify by the transferred wml code. This transfer works with any kind of data packable into wml tables, meaning also maps and terrain_types (less useful for them though and of course you still can't use the custom [terrain_type]string=)

I found another hackish way to transfer wml data over the network using wesnoth.synchronize_choice but it does it from the active client to the others and you usually don't know whether the currently active client is the host (or has the required files). This unfortunately doesn't work for lua code since it consists of functions which makes the tables no longer wml tables. So lua code needs to be embedded and thereby looses its ability to allow for quick testing of changes. Unless there is a way to load a lua file as a complete string...

Of course any binary data (images, sounds, music) can't be sent over the network since the data type sent by the wesnoth engine is (I think) config/wml table/"blocks of wml like can be put into [set_variables]". ([unit_type] data is a wml table/config, but the images it references is not).
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
SlowThinker
Posts: 876
Joined: November 28th, 2008, 6:18 pm

Re: distribution of units from a host?

Post by SlowThinker »

Anonymissimus wrote:Now I'm using such code in SoW
...
to transfer unit data at preprocessing time, since the scenario is preprocessed on the host and then sent to the remote clients. Whenever a unit of custom type is attempted to be created, I create a Fog Clearer and modify by the transferred wml code.
How do you modify it? You modify some internal (unvisible by WML) structures via lua?
Anonymissimus wrote:Of course any binary data (images, sounds, music) can't be sent over the network since the data type sent by the wesnoth engine is (I think) config/wml table/"blocks of wml like can be put into [set_variables]". ([unit_type] data is a wml table/config, but the images it references is not).
If image data could be sent over the network, how would it help? I believe a unit image must be stored in a file on the disk, and so image data within WML would be useless.

SoW says "no download needed", so how did you solve the problem with unit images?
I work on Conquest Minus • I use DFoolWide, Retro Terrain Package and the add-on 'High Contrast Water'
I moved to Nosebane's corner (Doc Paterson's signature); I am spending my time there, so PM me if I don't answer your post in forums
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: distribution of units from a host?

Post by Anonymissimus »

SlowThinker wrote:If image data could be sent over the network, how would it help? I believe a unit image must be stored in a file on the disk, and so image data within WML would be useless.

SoW says "no download needed", so how did you solve the problem with unit images?
Every time it is tried to create a custom unit, I "analyse" the [unit] (or the parameters passed to wesnoth.put_unit) block. For each custom type I manually define a replacement image which is a core one, so I actually don't "solve" the problem, I work around it.
Most of the code should be doable in wml as well but I would expect it to become a lot more complicated.
There is probably not much additional cleverness in the structure over what your addon already has; I'm using an overlay for the image as well. Most of the code is in lua/no_era_mods.lua, function sow_put_unit, which is what I use every time a custom unit should be created (in place of [unit] or wesnoth.put_unit).
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Post Reply