Hrm..learnign the ropes, help me out a bit

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:

Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

I got a few questions for you scripting wizzards.

1. Will this work:

Code: Select all

#define TRAIT_DETERMINED
    # A DETERMINED unit gets a +1 bonus to damage (melee and ranged), +10% resistance to fire, cold and arcane, but get a max XP increase of 25%.
    [trait]
        id=agile
        male_name= _ "agile"
        female_name= _ "female^agile"
        [effect]
            apply_to=attack
            range=ranged
            increase_damage=1
        [/effect]
        [effect]
            apply_to=attack
            range=melee
            increase_damage=1
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
        [effect]
             [resistance]
                 value=10
                 max_value=100
                 apply_to=fire,cold,arcane
             [/resistance]
         [/effect]
    [/trait]
#enddef


2. To explain what I'm after here - the map has fog. Once a player unit approaches within viewing distance of a specific hex, two units should be generated - one belonging to the enemy and one belonging to an ally (no leader) so they fight.
If you save the unit it joins you.
And obviously I'll need a different trigger that turn 3.. something like unit_moved if there is one.. Still haven't memorized all commands and macros and stuff

Code: Select all

[event]
name= turn3

        [store_locations]
            [filter]
                side=1
            [/filter]
            x=24
            y=50
            range=8

            variable=units_in_range
        [/store_locations]
        [if]
            [variable]
                name=units_in_range.length
                greater=0
            [/variable]
             [then]
                  #create units code goes here
            [/then]
          [/if]
    [/event]
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
CIB
Code Contributor
Posts: 625
Joined: November 24th, 2006, 11:26 pm

Re: Hrm..learnign the ropes, help me out a bit

Post by CIB »

The first one looks alright, as to the second one: Use the moveto event and filter for the locations that are in view of the particular units. If you don't want the event to trigger before turn 3, you can also use nested events.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

moveto requires a X and Y coordinate IIRC.

I can use complex conditions within a filter? Hrm..I'm a bit slow today...soo

Code: Select all

[event]
name= moveto

            [filter]
                side=1
                x=24
                y=50
                range=8
            [/filter]
[/event]
Is that it? Can I use range within a filter like that, or is there a better way to check if the hex is in the visual radius of a unit?
Last edited by TrashMan on December 22nd, 2008, 9:28 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! <<<
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Hrm..learnign the ropes, help me out a bit

Post by AI »

About the first one, take a better look at [effect], you can't just throw [resistance] in like that.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

AI wrote:About the first one, take a better look at [effect], you can't just throw [resistance] in like that.
# resistance: Sets percent damage taken from combat

* replace: If set to "true", any new values replace the old ones. Otherwise, new values are added to old values (negative values allowed).
* [resistance]: a subtag that describes the new resistance just like in UnitWML for describing a unit type
???? :? now I'm confused...
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Hrm..learnign the ropes, help me out a bit

Post by zookeeper »

The contents of your [resistance] are wrong.

Also you're still insisting on using a key called range= which doesn't exist.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

I could swear I saw it inside one of Northern Rebiths scenarios.

Radius then?
Thanks for telling me what's wrong..


Now could one of you gents show me the right way to do it?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
CIB
Code Contributor
Posts: 625
Joined: November 24th, 2006, 11:26 pm

Re: Hrm..learnign the ropes, help me out a bit

Post by CIB »

In order to use radius, you need a standard location filter, i.e. [filter_location] (i think you put it inside [filter], atleast that's what the wiki says, but I'm not sure)

The easiest approach is to use x,y ranges in the unit filter, e.g. x=20-28;y=45-55
# resistance: Sets percent damage taken from combat

* replace: If set to "true", any new values replace the old ones. Otherwise, new values are added to old values (negative values allowed).
* [resistance]: a subtag that describes the new resistance just like in UnitWML for describing a unit type
Read what UnitWML says about the [resistance] tag, it's rather something like

Code: Select all

apply_to=resistance
replace=false
[resistance]
  fire=-10
  cold=-10
[/resistance]
Note that, in order for the unit to take less damage, you need to apply negative values, since [resistance] describes the amount of damage taken, see UnitsWML.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

Thank you very much.

I wish the sighted event worked with hexes, and not only units - it would be simpler.

But I think I got it. Sight range in fog is..what? 8 hexes?

So, I'd be basicely checking if a unit moved into any hex withing 8 range of the X,Y coordiantes of my hex.

so, if the hex is 26, 42 I should basecly jsut use a simple event like this:

Code: Select all

[event]
name=moveto
   [filter]
       side=1
       x=18-34
       y=34-50
   [/filter]
#spawn units
[event 
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
CIB
Code Contributor
Posts: 625
Joined: November 24th, 2006, 11:26 pm

Re: Hrm..learnign the ropes, help me out a bit

Post by CIB »

The sight is the unit's movement, so you should usually go for around 6 hexes.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

Thank you very much...now that that's over with..MORE questions :P

Would something like this work?

Code: Select all

#define ABILITY_RETRIBUTION_AURA
[heals]
		value=2
		id=healing
		affect_allies=no
                affect_self=no
                affect_enemies=yes
		name= _ "Holy Aura"
		description=  _ "bruning aura:
enemy units nearby recive damage each turn. Double damage against undead"
		[affect_adjacent]
			adjacent=n,ne,se,s,sw,nw
		[/affect_adjacent]
[/heals]
#enddef
This doesn't do double damage to undead..yet (if at all. Can healing be used with a negative value anyway?)
I suppose for it to do that I'd have to add another heal event with a filter that screens for undead. (by looking for undead ability? or should I just list undead units?)
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Hrm..learnign the ropes, help me out a bit

Post by AI »

Negative healing works fine, you'll have to actually use a negative number though. :P

You can add another instance that filters on undead in [affect_adjacent], be sure to use a different id though, otherwise it won't stack.
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

Ahh...so in this case the id is arbitary..I started confusing it with name of events..lol

just one question AI - how would you filter for undead?

Am I right to assume this would be it:

Code: Select all

[heals]
      value=2
      id=undeadsmiting
      affect_allies=no
                affect_self=no
                affect_enemies=yes
      name= _ "Holy Aura"
      description=  _ "bruning aura:
enemy units nearby recive damage each turn. Double damage against undead"
      [affect_adjacent]
         adjacent=n,ne,se,s,sw,nw
               [filter]
                     type=Skeleton Archer,Soulless,  (and others)
                [/filter]
      [/affect_adjacent]
[/heals]
Is there a simpler way to filter for undead. And, does another [heal] effect need another description??
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

>>> MY LITTLE LAB! <<<
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Hrm..learnign the ropes, help me out a bit

Post by AI »

race=undead should work ;)
User avatar
TrashMan
Posts: 601
Joined: April 30th, 2008, 8:04 pm
Contact:

Re: Hrm..learnign the ropes, help me out a bit

Post by TrashMan »

F'course..such a simple solution...I should have guessed. Thanks again :wink:

Oh, can I remove the double name and description lines? They are optional, right?
Light travels much faster than sound, that's why some people seem bright until you hear them speak.

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