Proposed radical WML changes

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.
tsr
Posts: 790
Joined: May 24th, 2006, 1:05 pm

Post by tsr »

toms wrote:IMO WML should _not_ become a programming language. It was originally made to be able to write scenarios in a simple way.
Sometimes WML is not enough though, that's why I suggested this.
Just my 2¢.
Theese two ideas are very compatible, let's start!

/tsr
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

By 'functions', do you mean that values are written in between parentheses, for example

Code: Select all

[event type="onTurn(1,1)"]
would be an open tag for the start event? This would work well for some types of events, but for others, you want a syntax more like this:

Code: Select all

[event type=attack]
  [if attacker.side=1 and defender.side=3]
    [then]
    {CODE}
    [remove_this_event /]
    [/then]
  [/if]
  [do_event /]
[/event]
where the [remove_this_event /] command means that the event is no longer executed, i.e. first_time_only=yes.
Of course, this could also work for the initial event:

Code: Select all

[event type=turn]
  [if turn=1 and side=1]
    [then]
    {CODE}
    [remove_this_event /]
    [/then]
  [/if]
  [do_event /]
[/event]
Although in this case the event could not possibly trigger before the conditions were met, so all that is necessary is

Code: Select all

[event type=turn]
  {CODE}
  [remove_this_event /]
  [do_event /]
[/event]

Do you set these attributes at the beginning of the scenario file? For example:

Code: Select all

name= _"The Elvish Woods"
time_of_day_cycle = {DAWN},{MORNING},{AFTERNOON},{DUSK},{FIRST_WATCH},{SECOND_WATCH}
max_turns=30
Maybe tags could be used to represent array elements or elements with subelements:

Code: Select all

  [side]
    [leader]
    type=Elvish Hero
    canrecruit=yes
    [/leader]
  recruitable=Elvish Fighter,Elvish Archer
    [unit]
    type=Elvish Fighter
    hex=$side.keep
    hex.x += 1
    [/unit]
    [unit]
    type=Elvish Fighter
      [hex]
      x,y=13,14
      [/hex]
    [/unit]
  [/side]
hmm... this looks something like existing syntax :)

For units you should actually have a new object, unit_type, produced by unit.type and which has elements

Code: Select all

unit_type.name
unit_type.level
unit_type.alignment
unit_type.ability[array]
unit_type.movetype
unit_type.moves
unit_type.experience## experience needed to advance
unit_type.hitpoints## max hitpoints
unit_type.attack[array]
...I can't figure out what 'decesead' means though, it must be a typo.
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

hmm... if you can change units' attributes directly, it seems there is no need for the [store_unit] tag. The other use of [store_unit] is to have units disappear for a scenario, like this:

Code: Select all

[message]
unit=Leader Merman## this is like 'description=Leader Merman'
message= _"We must leave now"
[/message]
[for unit=side[1].unit]
  [if unit.type.name="Merman"]
    [then]
    unit.hex=NULL
    [/then]
  [/if]
[/for]

Code: Select all

[for unit=side[1].unit]
  [if unit.hex=NULL and unit.type.name="Merman"]
    [then]
      [unit.hex]
      terrain=c,s
      x,y=3-8,7-11## make them start out in water near the player
        [find_vacant_hex /]## finds a hex with the specified properties
      [/hex]
    [/then]
  [/if]
[/for]
[message]
unit=Leader Merman
message= _"We are back to help you"
[/message]
theCAS
Posts: 50
Joined: August 24th, 2004, 4:26 pm

Post by theCAS »

Dacyn wrote:By 'functions', do you mean that values are written in between parentheses, for example

Code: Select all

[event type="onTurn(1,1)"]
Mmmh, actually the values in the paranthesis are passed by the game engine.

For example, on turn five of side 3 do something

Code: Select all

[event type="onTurn"]
  [IF side==1 AND turn==5]
    [THEN]
      {CODE}
    [/THEN]
  [/IF]
  [DOEVENT /]//well here is not very useful
[/event]
The event is called upon *every* turn.

More actions in one event, Konrad gets double exp attacking and another unit changed side if attacked.

Code: Select all

[event type="onAttack"]
  [IF attacker.name=='Konrad' and defender.type=='skeleton']
     [THEN]
        attacker.experience+=2
     [/THEN]
   [/IF]
   [IF defender.name=='coward']// or [ELSEIF] ?
     [THEN]
        defender.side=attacker.side
     [/THEN]
   [/IF]
   [DOEVENT /]
[/event]
This event is called upon *every* attack.

For units you should actually have a new object, unit_type, produced by unit.type and which has elements

Code: Select all

unit_type.name
unit_type.level
unit_type.alignment
unit_type.ability[array]
unit_type.movetype
unit_type.moves
unit_type.experience## experience needed to advance
unit_type.hitpoints## max hitpoints
unit_type.attack[array]
Yes, you're right.
...I can't figure out what 'decesead' means though, it must be a typo.
It's a list of units of each side that has been killed, it can be usefull in many situations and wouldn't cost much in developer and cpu time.
theCAS
Posts: 50
Joined: August 24th, 2004, 4:26 pm

Post by theCAS »

Dacyn wrote:[message]
unit=Leader Merman## this is like 'description=Leader Merman'
message= _"We must leave now"
[/message]
[for unit=side[1].unit]
[if unit.type.name="Merman"]
[then]
unit.hex=NULL
[/then]
[/if]
[/for]
Or maybe to keep an object approach:

Code: Select all

[event type="onScenarioEnd"]
  [IF isVictory==1]
    [THEN]
      [FOR unit=side[1].units]
        [IF unit.name=='Leader Merman']
           globals.merman=unit
           unit.side=NULL//a unit without side can't exist
        [/IF]
      [/FOR]
    [/THEN]
   [/IF]
[/event]
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

That would only store the merman leader; it is supposed to store an entire array of mermen...
theCAS
Posts: 50
Joined: August 24th, 2004, 4:26 pm

Post by theCAS »

Code: Select all

[event type="onScenarioEnd"]
  [IF isVictory==1]
    [THEN]
      [FOR unit=side[1].units]
        [IF unit.type.name=='Merman']
           [ADD side[1].storedunits]unit[/ADD]//add item to an array
           [REMOVE side[1].units]unit[/REMOVE]//remove item from an array
        [/IF]
      [/FOR]
    [/THEN]
   [/IF]
[/event]
Better? We can formalize a new property for the side object and we could use some more array functions[tags].
Post Reply