Recommended alternative to deprecated Fog Clearer

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.
User avatar
Gwledig
Posts: 569
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: Recommended alternative to deprecated Fog Clearer

Post by Gwledig »

I was able to fix this by just putting [units] around the [unit_type] item for a replacement fog clearer in it's own units directory and declare this in main.cfg, I renamed my custom version to 'Generic Unit' so it doesn't look as odd any more in the unit panel.
In the longer term I will prob start replacing on-the-fly units created from option lists with proper [unit_types] moreso now I can make a scenario required for download and the data downloads to the client automatically, dealing with images and other assets, so the whole business of unit creation with fog clearer is really redundant now anyway with that facility. However, the use of fog clearer was also useful for things like blocking off hexes when positioning units for special features, such as my ranged weapon method in places like conquest +/space, it's used to allow initial positioning around the unit as I recall, so I will prob end up using it still in some form.
The main issue I'm worried about is overlay in [unit] which I used with the fog clearer method for 100s of unit icons, again I can overcome this in time by using proper [unit_type] but in the short term I may need to try the variable method of loading an overlay.
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
User avatar
Gwledig
Posts: 569
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: Recommended alternative to deprecated Fog Clearer

Post by Gwledig »

So I made a custom fog clearer called "generic unit" and was all fine until playing on network, then it turnd out a custom unit_type isn't auto allocated a unique ID for units made with it, so at the point of all WML used to create or alter a unit from 'Generic Unit' (fog clearer copy) I have to assign a rnd ID, I know how to do this from similar stuff I do with projectiles for ranged, but it's going to be a mammoth task going thro all spawns and units to modify with rnd ID, does anyone know a way to force a unit_type to start with a unique ID by default?
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Recommended alternative to deprecated Fog Clearer

Post by vghetto »

I'm not sure why you're making this harder than it is.
Show your work here or tell us where to find it to be able to help you better.

Here are the steps to create your own fog clearer unit:
Copy the mainline data/core/units/fake/Fog_Clearer.cfg into your units folder.
Change the id from id=Fog Clearer to id=My Fog Clearer and remove the {DEPRECATED_UNIT line.
In your code, replace wherever you have type=Fog Clearer to type=My Fog Clearer.
User avatar
Gwledig
Posts: 569
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: Recommended alternative to deprecated Fog Clearer

Post by Gwledig »

Hi
thanks vghetto, i did all those things and the replacement generic unit was working at startup, however, when creating units onthefly during a turn, or spawning units based on this unit type at start of game, the subsequent units seem to be allocated a single, fixed ID related to the unit_type, not a unique ID. I think a wesnoth system unit type, i.e. one which is part of Wesnoth core, such as fog_clearer does generate a unique ID, but when I did the steps you mention, my subsequent units end up with duplicate IDs, causing out of sync errors. I've done a similar workaround before for ranged ordinance where I had to alocate a unique ID for each 'shot' (these use special units), so I know how to do this, but was just wondering if there was an easier way of using a custom unit_type where subsequent units made from it end up with unique IDs, it could be the way I am generating units from option lists vs normal ingame summoning on castles which is not generating a unique ID... So there is a workaround, I basically have to trace all WML where I use the replacement fog_clearer and insert a RND unique ID in each case. This is possible just a big job, I don't suppose there really is a way of doing this any other way.
You can see all my mods under my nick gwledig on 1.16 addon (they use old fog_clearer at the moment, until I sort this out).
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Recommended alternative to deprecated Fog Clearer

Post by vghetto »

I don't get what you mean about the ID.
In this screenshot, I created a custom fog clearer using [unit]type=My Fog Clearer[/unit] and recruited the rest. As you can see, each one got its own unique ID.

As far as I can tell, there is nothing special about the fog clearer. It is a regular unit with poor stats and a blank image.
If it is not working for the fog clearer, it shouldn't work for any other unit :/

Paste in here the code for how you're creating your fog clearer. The [unit] code. Are you including id=something with it?
Screenshot from 2021-12-15 13-06-13.png
User avatar
Gwledig
Posts: 569
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: Recommended alternative to deprecated Fog Clearer

Post by Gwledig »

Yep works fine in single player, but not in networked play, oddly, must be somehow replicating same sequence of IDs for player 2...
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Post Reply