What does "meant to be used as a suffix" mean for macros?

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
Saratos
Posts: 20
Joined: June 29th, 2016, 8:05 am

What does "meant to be used as a suffix" mean for macros?

Post by Saratos »

Hey there, I am rather new to this, and this is probably a n00b question, but I can't seem to find any answers out there and I want to write good WML code. Side note: Really excited to become a part of the WML dev community. It's something I've always wanted to do and finally got around to. Hope to be putting out my first co-op survival scenario very soon :D

I am trying to use the built in macros to spawn units in a multiplayer survival scenarioI am working on using the internal macro

Code: Select all

{UNIT SIDE TYPE X Y WML}
. I want to make some of the units have the "guardian" ability. I see that there is a

Code: Select all

{GUARDIAN}
macro available internally in the game, but it is described as "Meant to be used as a suffix to a unit-generating macro call." I'm not sure what this means or how to implement it.

If someone would shed some light on this for me, I'd be very grateful.
Thanks for your help!
- S
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: What does "meant to be used as a suffix" mean for macros?

Post by zookeeper »

That macro is used in hundreds of places in mainline campaigns, so if you search for some of those it should become clear how it's used.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: What does "meant to be used as a suffix" mean for macros?

Post by enclave »

Saratos wrote: June 1st, 2018, 4:07 am I am trying to use the built in macros to spawn units in a multiplayer survival scenarioI am working on using the internal macro

Code: Select all

{UNIT SIDE TYPE X Y WML}
. I want to make some of the units have the "guardian" ability. I see that there is a

Code: Select all

{GUARDIAN}
macro available internally in the game, but it is described as "Meant to be used as a suffix to a unit-generating macro call." I'm not sure what this means or how to implement it.
I could try to help you if you could tell me which units have this ability.. unit type or name or campaign they are present..
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: What does "meant to be used as a suffix" mean for macros?

Post by Tad_Carlucci »

You looked but didn't see ...

Code: Select all

#define GUARDIAN
    # Meant to be used as a suffix to a unit-generating macro call.
    [+unit]
        ai_special=guardian
        animate=no
    [/unit]
#enddef
The [+unit] means you must have JUST closed a [unit] tag and this macro is re-opening it to make a change.

The assumption that you must have done that as a results of a unit-generating macro call is simply that, had you done the unit by-hand, you'd not have needed to re-open the block.
I forked real life and now I'm getting merge conflicts.
User avatar
vultraz
Developer
Posts: 960
Joined: February 7th, 2011, 12:51 pm
Location: Dodging Daleks

Re: What does "meant to be used as a suffix" mean for macros?

Post by vultraz »

Practically it just means you stick the {GUARDIAN} inclusion right after the unit-generating macro's inclusion.
Creator of Shadows of Deception (for 1.12) and co-creator of the Era of Chaos (for 1.12/1.13).
SurvivalXtreme rocks!!!
What happens when you get scared half to death...twice?
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: What does "meant to be used as a suffix" mean for macros?

Post by enclave »

Tad_Carlucci wrote: June 1st, 2018, 1:26 pm

Code: Select all

#define GUARDIAN
    # Meant to be used as a suffix to a unit-generating macro call.
    [+unit]
        ai_special=guardian
        animate=no
    [/unit]
#enddef
vultraz wrote: June 1st, 2018, 2:43 pm Practically it just means you stick the {GUARDIAN} inclusion right after the unit-generating macro's inclusion.
So according to what they were saying, I could think/assume that you could use guardian ability in 2 ways...
1) your unit code would look like this (might not work, but I believe it should work), Spearman would appear on x=22 y=33 and belong to side 1

Code: Select all

{UNIT 1 Spearman 22 33 (
ai_special=guardian
animate=no
)}
2) your unit code would look like this (according to what they said it should 100% work, but I never tried, so I hope it does), exactly same..

Code: Select all

{UNIT 1 Spearman 22 33} ## this might show error... I never used unit macro..
{GUARDIAN}
or

Code: Select all

{UNIT 1 Spearman 22 33 " "} ## because I assume it expects WML which might be empty if you dont plan any more code.. 
{GUARDIAN}

I'm not sure as I never used {UNIT macro... so instead of WML you can either put some WML code like in example #1)
or you could leave it empty with putting quotes or brackets " " or ( ) i guess..
-------------------------
if you want things more complicated you can create your custom unit macro.. like so:
Just once and NOT inside any event in your code put something like this:

Code: Select all

#define MY_CUSTOM_UNIT_MACRO SIDE TYPE POSITION
	[unit]
ai_special=guardian
animate=no
		type={TYPE}
		x,y={POSITION}
		side={SIDE}
		generate_name=yes
		random_traits=yes		
        random_gender=yes
		role=monster
		[modifications]
			{TRAIT_LOYAL}
		[/modifications]
  	[/unit]
#enddef
And then later inside the events you can use instead of {UNIT} and {GUARDIAN} macros just call your custom macro like so:
{MY_CUSTOM_UNIT_MACRO 5 (Tentacle of the Deep) (3,2)} ## Tentacle of the Deep appears on x=3 y=2 for side 5
and it will already have guardian inside of it.
Saratos
Posts: 20
Joined: June 29th, 2016, 8:05 am

Re: What does "meant to be used as a suffix" mean for macros?

Post by Saratos »

Thanks so much for the replies! I think I understand now.

So I just need to place the "suffix" code on the following line after the macro it is being added to?

There's a bunch of code in the macros section that says that it is to be used like this, so I am just looking to understand how the reference is written.
I had thought of making my own macro, but yeah, like I said, this was more of an exercise in understanding the "built in code" and also getting out in the community a bit. Although, I did like that first suggestion to go through the mainline campaigns. I had thought of that after posting this question, and figured I would just wait to hear it from you all instead. Thanks for helping me out.

Gonna go try this now, all the best!
Post Reply