dabber's questions: vision to location

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.
Post Reply
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: recruit list

Post by dabber »

It is in the initial side definition, not something else.

[side]
blah blah blah
canrecruit=yes
recruit=Poacher,Thug,Bandit,Trapper,Footpad,Outlaw,Thief,Rogue
{GOLD 500 450 400}
income=2
blah blah blah
[/side]

But the actual recruit list has bunches more units available.


I found the next layer of the cause, but not the root. The save file has previous_recruit=other stuff. If I edit that in the save file, the extra recruits go away. But what sets previous_recruit, why is previous_recruit used for current recruiting, and how should it be cleaned up without hand editing the save file?
Last edited by dabber on July 23rd, 2015, 8:20 pm, edited 2 times in total.
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: dabber's questions: recruit list

Post by beetlenaut »

Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: dabber's questions: recruit list

Post by tekelili »

beetlenaut wrote:[disallow_recruit]
Yes, just note can be slighty more comfortable use [set_recruit] to new ones, as this tag totally clears previous list.

edit: with "this tag" I mean [set_recruit]
Last edited by tekelili on September 24th, 2014, 7:00 pm, edited 1 time in total.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: dabber's questions: recruit list

Post by beetlenaut »

tekelili wrote:this tag totally clears previous list.
No, it doesn't. It has a type tag:
Wiki wrote:type: the types of units that the side can no longer recruit.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: recruit list

Post by dabber »

I guess I conclude is that using the [side] definition to set scenario recruiting inside a complicated campaign is a bad idea. That method of coding ADDS to an existing list, instead of creating the list. The better implementation is to use [set_recruit] in the prestart event.
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: dabber's questions: recruit list

Post by iceiceice »

Dabber: I checked the code. Here's how it works.

When a level ends, sides that are supposed to continue into the next level are stored in a place called "carryover". You can see what the carryover is in a save file, in the [carryover] tag. Carryover can include units, side settings, gold, and other stuff.

When the next level begins, there is a step called "team construction", this happens even before prestart events. It is after the map has been generated and stored into memory, and this is when teams are configured and their initial units are placed into the map. One of the steps of team construction is, merging in the "previous recruits" data from carryover into the team. So whatever you type in [side] recruit = ... [/side], you are still always going to get the previous recruits as well, after team construction.

Either of tekelili's or beetlenaut's suggestions will work. With [set_recruit], the side's recruit list will be exactly whatever list you specify. With [disallow_recruit], that list will be modified by removing whatever unit types you list there. You could use this in a start or prestart event and it will happen after the carryover is applied.

Carryover can sometimes be confusing, if the game isn't doing what you think it should, one way that you can get info to help debug is to turn on the logging for the team construction phase. You have to give wesnoth the command line option --log-debug=engine/team_construction. Then you will get output like this (this is from transitioning in heir to the throne.)

Code: Select all

20140924 14:49:12 info engine/team_construction: team 1 construction: init
20140924 14:49:12 debug engine/team_construction: snapshot: false
20140924 14:49:12 info engine/team_construction: team 1 construction: gold
20140924 14:49:12 debug engine/team_construction: set gold to '100'
20140924 14:49:12 info engine/team_construction: team 1 construction: new team
20140924 14:49:12 info engine/team_construction: team 1 construction: objectives
20140924 14:49:12 info engine/team_construction: team 1 construction: previous recruits
20140924 14:49:12 debug engine/team_construction: adding previous recruit: Elvish Archer
20140924 14:49:12 debug engine/team_construction: adding previous recruit: Elvish Fighter
20140924 14:49:12 debug engine/team_construction: adding previous recruit: Elvish Scout
20140924 14:49:12 debug engine/team_construction: adding previous recruit: Elvish Shaman
20140924 14:49:12 info engine/team_construction: team 1 construction: leader
20140924 14:49:12 debug engine/team_construction: unit from leader_cfg: type=[Commander] id=[Konrad] placement=[map,leader] x=[] y=[]
20140924 14:49:12 debug engine/team_construction: unit from side_cfg: type=[Fighter] id=[Konrad] placement=[] x=[] y=[]
20140924 14:49:12 debug engine/team_construction: unit from side_cfg: type=[Elder Mage] id=[Delfador] placement=[] x=[] y=[]
20140924 14:49:12 info engine/team_construction: team 2 construction: init
20140924 14:49:12 debug engine/team_construction: snapshot: false
20140924 14:49:12 info engine/team_construction: team 2 construction: gold
20140924 14:49:12 debug engine/team_construction: set gold to '75'
20140924 14:49:12 info engine/team_construction: team 2 construction: new team
20140924 14:49:12 info engine/team_construction: team 2 construction: objectives
20140924 14:49:12 info engine/team_construction: team 2 construction: previous recruits
20140924 14:49:12 info engine/team_construction: team 2 construction: leader
20140924 14:49:12 debug engine/team_construction: unit from leader_cfg: type=[Grand Knight] id=[Kaylan] placement=[map,leader] x=[] y=[]
20140924 14:49:12 info engine/team_construction: team 3 construction: init
20140924 14:49:12 debug engine/team_construction: snapshot: false
20140924 14:49:12 info engine/team_construction: team 3 construction: gold
20140924 14:49:12 debug engine/team_construction: set gold to '150'
20140924 14:49:12 info engine/team_construction: team 3 construction: new team
20140924 14:49:12 info engine/team_construction: team 3 construction: objectives
20140924 14:49:12 info engine/team_construction: team 3 construction: previous recruits
20140924 14:49:12 info engine/team_construction: team 3 construction: leader
20140924 14:49:12 debug engine/team_construction: unit from leader_cfg: type=[Orcish Warrior] id=[Mokolo Qimur] placement=[map,leader] x=[] y=[]
20140924 14:49:12 info engine/team_construction: team 1 construction: place units
20140924 14:49:12 info engine/team_construction: team 2 construction: place units
20140924 14:49:12 info engine/team_construction: team 3 construction: place units
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: recruit list

Post by dabber »

Thanks for the details ice.

New question. After giving an object to a unit, is it possible to come back later, find the object, and modify its properties? My research only hits some stuff from Legend of the Invincibles saying this is very complicated, but maybe I'm using the wrong key words to search.
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: dabber's questions: modify object?

Post by tekelili »

If I have no clue how remove an object (wich is true right now), my approach would be store a control variable in unit and use it in the [effect] tags attached. something like this

Code: Select all

[object]
    [effect]
                    [filter_wml]
                        [variables]
                            this_effect_is_active=yes
                        [/variables]
                    [/filter_wml]
    [/effect]
[/object]
When you want "remove" object just store unit, change $this_effect_is_active to "no" and unstore unit
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: dabber's questions: modify object?

Post by Dugi »

@tekelili That will not work. The filter_wml is checked only when the object is first applied on the unit and when it advances to some other unit, so it will not make any changes if you just change some of the unit's variables. This is a common misconception and many people believe that this works.

@dabber
It isn't so hard, and it isn't done much in Legend of the Invincibles (surprisingly).

You should use the :inspect debug command to see the internals of units in memory. Then, you just store the unit, cycle through the [object]s it has using FOREACH or something, find the one you want and edit it. Then you unstore the unit and force the game to reroll the changes from its modifications (otherwise it will happen only if it advances into another unit). You can do that either via the ADVANCE_UNIT macro or by recreating the unit instead of unstoring it. Example:

Code: Select all

# Store the unit
[store_unit]
 [filter]
  id=murderer
 [/filter]
 variable=murd_store
 kill=yes
[/store_unit]
# Set the first effect's increase attribute of each object named Blood Dagger to 60% (if the first effect is damage, the object will increase damage by 60%)
{FOREACH murd_store.modifications.object i}
 [if]
  [variable]
   name=murd_store.modifications.object[$i].name
   # Something else than name should be used for identification because name is translatable, id might be bad too
   equals=_"Blood Dagger"
  [/variable]
  [then]
   {VARIABLE murd_store.modifications.object[$i].effect.increase 60%}
  [/then]
 [/if]
{NEXT i}
# Recreate the unit instead of unstoring to force recalculate the properties
[unit]
 id=$murd_store.id
 name=$murd_store.name
 x,y=$murd_store.x,$murd_store.y
 side=$murd_store.side
 hitpoints=$murd_store.hitpoints
 moves=$murd_store.moves
 attacks_left=$murd_store.attacks_left
 experience=$murd_store.experience
 canrecruit=$murd_store.canrecruit
 extra_recruit=$murd_store.extra_recruit
 [instert_tag]
  name=status
  variable=murd_store.status
 [/insert_tag]
 [instert_tag]
  name=variables
  variable=murd_store.variables
 [/insert_tag]
 [instert_tag]
  name=modifications
  variable=murd_store.modifications
 [/insert_tag]
[/unit]
The code is just an example how to do it, I haven't tested it, so there might be some minor typos.
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: dabber's questions: modify object?

Post by tekelili »

Dugi wrote:@tekelili That will not work.
Hum... may be you are right, after think about it I always used unit leveling as relevant [filter] check, and could be [unstore_unit] doesnt have same effect (wich btw is a little counterintituive wml behavior :doh: )

edit: If dugi is right, a wink for developers: If leveling a unit involves reevaluate all [filter] in [effect] attached to unit, what is the logic to not do it also after beign [unstore_unit]? When a unit is unstored is quite probable have been changed in as meaningfull ways as when it levels.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: dabber's questions: modify object?

Post by pyrophorus »

tekelili wrote:edit: If dugi is right, a wink for developers: If leveling a unit involves reevaluate all [filter] in [effect] attached to unit, what is the logic to not do it also after beign [unstore_unit]? When a unit is unstored is quite probable have been changed in as meaningfull ways as when it levels.
That's right. And maybe this should be a feature request: adding a tag 'apply_changes=yes/no, default no' to [unstore_unit] (to avoid breaking old code relying on the current behavior). This could give an easy way to really remove an object.

Friendly,
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: dabber's questions: modify object?

Post by Dugi »

You can store a unit and modify some of its properties, then you unstore it to apply the changes. These changes usually aren't done by modifying [object]s, but by directly changing some properties, because some properties can't be changed with [object]s (though some can't be changed without them). If the objects were reapplied, these changes would be lost and thus impossible to perform. [object] is designed for permanent modifications, not for things that change a lot.

Also, there are some very common effects you don't want to apply every time you modify a unit, for example if you have [effect] apply_to=hitpoints heal_full=yes - every time it is reapplied, the unit is fully healed, that doesn't matter when the unit advances but otherwise it does.

If I was to say what do I think about it, I'd say that the logic is okay just it's annoying that some changes aren't doable by [object].
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: dabber's questions: modify object?

Post by ChaosRider »

You may not like my way of coding tekelili but in newest addon RGM_MWC i tried to make it much more clear. Why do I mention about this addon? If you start one of two (as for now) scenarios you found on map labeled places like +3hp, 23% heal and many other. They are add to unit (if it move to this labeled hex) at turn end.
Bonus types which you can find there (some are by object and effect tags, some by storing unit and changing it stats):
- increasing unit hp (with max)
- increasing unit hp (without max, and cant be higher than max, also here its coded by percent value of unit max (percent value is picked randomly))
- increasing terrain defense (max 75% i guess)
- decreasing movement_cost (on one of picked randomly terrain type)
- increasing gold
- increasing xp (but unit cant lvlup by this bonus, to not make any oos, if with added xp bonus its higher than max then its changed to max_xp decreased by 1)
- adding weapons (randomly picked, from attack icon, to weapon dmg/strikes and all things, also they are set to get more dmg with unit lvlup)
- adding weapon special (right now to all from picked range (melee or ranged) in future i will try make it to pick randomly one of unit weapons and to only this one add weapon special)
- increasing unit movement points
- increasing unit resistances (max 60% or 70%)
- adding unit new abilities (if its not have it already).
- healing poison.
Because my code adds bonuses at turn end some things (as increasing unit mp without increasing max mp) werent added here (also if unit ends own turn with more mp than max is it gonna have it at next turn start or decreased to mp max?))
Still here can be added decreasing unit max xp (by object & effect tags).
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: dabber's questions: modify object?

Post by tekelili »

ChaosRider wrote:You may not like my way of coding tekelili
All coding languages developing history was targeted to increase abstraction level. You can comunicate with engine using just "1" and "0" but that is just unredeable for humans. Advises were not giving only by me, if you dont want take them is ok, just dont bring issue again and again in other people posts, imho.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: dabber's questions: modify object?

Post by ChaosRider »

Sorry that I wanted to help you conceited man, next time dont make that mistake imho.
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Post Reply