Stupid Questions (see last post)

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
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Stupid Questions (see last post)

Post by TrashMan »

I used to do haling potions like this in the scenario files:
*NIPPEd*
EDIT: Problem solved. See question below
Last edited by TrashMan on February 27th, 2019, 5:12 pm, edited 1 time in total.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: REally stupid question

Post by Ravana »

You can use filter_condition to reduce nesting level.

I expect [heal_unit] is not evaluated as actionWML in [object].
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: REally stupid question

Post by TrashMan »

I figured it out..shouldn't have even bothered any of you with this. I should have used the heal_unit tag to begin with

Code: Select all

#define HEALING_POTION X Y
    {PICK_UP (items/holy-water.png) ({X}) ({Y})
    ( _ "A healing potion! What luck.")
    (
        [object]
            id=healingpot_{X}_{Y}
            image=items/potion-red.png
            duration=level

            name= _ "Healing Potion"
            description= _ "This potion heals all wounds and poisons."
            cannot_use_message= _ "This unit cannot use this item."
            [filter]
                x={X}
                y={Y}
                [not]
                    [filter_wml]
                        [status]
                            not_living=yes
                        [/status]
                    [/filter_wml]
                [/not]
                [not]
                    race=bats
                [/not]
            [/filter]
            [then]
                [remove_item]
                    x,y={X},{Y}
                [/remove_item]
            [/then]
			[effect]
                apply_to=hitpoints
				heal_full=yes
			[/effect]
		
        [/object]
    )}
#enddef
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: REally stupid question

Post by TrashMan »

A new question - I'm trying to get a menu item to show up. Basically I have a unit with the type/id of engineer and I want to be able to build an encapment next to it.

I did copy/steal/borrow the code from another campaign and level loads normally, the build menu shows up only next to the engineer and on the right terrain, but I still cannot build anything since only the leave menu option appears, and neither of the two buildings

Code: Select all

#define OPTION_HELPMENU

[event]
  name=prestart

[set_menu_item]
	id=COTSbuildingmenu
	description="Build"
	image=misc/ums.png
[show_if]
[have_location] 
	x=$x1
	y=$y1
	terrain=R*,G*,S*,H*,F*,D*,U*,A*		
[/have_location]
	[have_unit]
	   id=Engineer
	   [filter_location]
		  x,y=$x1,$y1
		  radius=1
	   [/filter_location]
	   count=1
	[/have_unit]

[/show_if]
[command]
 
[set_variable] 
	name=finished
	value=no
[/set_variable]
 
 [while]
	[variable]
		name=finished
		equals=no
	[/variable]
	[do]
	[store_gold]
		side=1
		variable=gold
	[/store_gold]
  
  [message]
	speaker=Engineer
	message= _ "<b>Buildings: Gold: $gold,</b>"


{BUILDINGOPTION Fortification 40 terrain/castle/encampment/regular-tile.png Ce}
{BUILDINGOPTION Maintent 50 terrain/castle/encampment/regular-keep-tile.png Ke}


[option]
	message= _ {MENU_IMG_TXT "icons/boots_elven.png" "Leave Buildingmenu!"}
	[command]
		[set_variable] 
			name=finished
			value=yes
		[/set_variable]
	[/command]
[/option]
        [/message]
        [/do]
	[/while]
[/command]
[/set_menu_item]

[/event]
#enddef


#define BUILDINGOPTION NAME GOLD PICTUREPATH TERRAIN

[option]
[show_if]
 [variable]
  name={NAME}
  equals=yes
 [/variable]
	[/show_if]
	message= _ {MENU_IMG_TXT "{PICTUREPATH}" "Build {NAME} for Gold: {GOLD}!"}
	[command]
  
  [if]
 [variable]
  name=gold
  greater_than_equal_to={GOLD}
 [/variable]
 [then]
   
  [sound]
  name=torch-miss.ogg
  [/sound]
 
 
  [message]
	speaker=Engineer
	message= _ "You build up one {NAME}!"
	[/message]
 
	[gold]
		side=1
		amount=-{GOLD}
	[/gold]
 
 
 [set_variable]
	name=Buildingname
	value={NAME}
 [/set_variable]
 

[terrain]
	x=$x1
	y=$y1
	terrain={TERRAIN}
[/terrain]

 [set_variable]
	name=finished
	value=yes
 [/set_variable]

 [/then]
 [else]
 
   [message]
	speaker=Engineer
	message= _ "Not enough ressources!"
	[/message]
 [/else]
 [/if]
 
[/command]
[/option]

#enddef


#define OPTION_TEXTVARIABLE VARIABLE VALUE TEXT SPEAKER
        
        [if]
        [variable]
        name={VARIABLE}
        equals={VALUE}
        [/variable]
        [then]
        [message]
            speaker={SPEAKER}
            image="items/book5.png"
            message= "{TEXT}"
        [/message]
        [/then]
        [/if]
        
#enddef
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Stupid Questions (see last post)

Post by Ravana »

That means your option filter does not allow showing that option.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Yup. I want to a walk, came back an realized that the show_if requirement wasn't necessary. Works now.
I keep asking questions and finding the solutions before I check back here.
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Another question, if I want to just alter an existing race a tad - like give it a trait or increase the number of traits to 3, what's the best way to go about it?
Would this (my add-on race.cfg) be enough?

Code: Select all

 [+units]
  [race]
        id=elf
        num_traits=3
        markov_chain_size=2
        {ELVISH_NAMES}
        {TRAIT_DEXTROUS}
	{TRAIT_EAGLEEYE}		
    [/race]
    [/units]
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

And another question - can I use modify_unit to change the units side?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Stupid Questions (see last post)

Post by Ravana »

Overriding core race is suspicious. You need to be very sure it will not corrupt data globally.

Unit side can be changed.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

I want an event that check if unit A is close enough to unit B, within 5-6 tiles. Both have specific ID's.
Normally I could use fog and the spot check, but I can't in this instance
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Stupid Questions (see last post)

Post by beetlenaut »

You can also do this with pure WML if you prefer. You can have a moveto event filtered for unit A with something like this in it:

Code: Select all

[store_unit]
    [filter]
        id=id_of_unitB
    [/filter]
    variable=unitB
[/store_unit]
[if]
    [have_unit]
        id=id_of_unitA
        [filter_location]
            x,y=unitB.x, unitB.y
            radius=5
        [/filter_location]
    [/have_unit]
    [then]
        ...
    [/then]
[/if]
I didn't test this, so no guarantees on accuracy.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Ravana wrote: March 6th, 2019, 8:18 pm Overriding core race is suspicious. You need to be very sure it will not corrupt data globally.
Well, how else should I do it?

Is there an append mode? Do I need to re-define everything, or can I just define one thing (like number of traits) and will only that thing be overriden with everything else remaining the same?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Stupid Questions (see last post)

Post by Ravana »

You can specify in your unit_type what traits and how many of them to use.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Stupid Questions (see last post)

Post by TrashMan »

Would that require setting for every unit individually?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
Post Reply