Will this code work in 1.9.4

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
hart02
Posts: 52
Joined: July 15th, 2009, 12:06 am

Will this code work in 1.9.4

Post by hart02 »

I can't seem get this code to work in a scenario i am working on. It is for 1.9.4 and up. I am working to prepare it for 2.0. It is supposed to make monsters come out at night.But nothing happens instead. I am working on the code for my sky scenario.If the sky scenario code does not work, What chance do the other macros have of working?
creatures.cfg contents

Code: Select all

#define ROAMING_SKY_MONSTERS SIDE AREA_FILTER COUNT THROTTLING
    [event]
        name=prestart
        # number of monsters respawned on first or second dusk
        {VARIABLE roaming_sky_monsters_count ({COUNT})}
        {VARIABLE roaming_sky_monsters_throttle 0}
        # number of monsters to kill before reducing respawn count by one
        {VARIABLE roaming_sky_monsters_throttle_max ({THROTTLING})}
    [/event]

    [event]
        name=activate roaming sky monsters
        first_time_only=no

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN roaming_sky_monsters_count 0}
            [then]
                {SCATTER_UNITS ($roaming_sky_monsters_count) "Errant Spirit,Phantom Unease,Frozen Soul,ESpirit,EGhost,Phantom Cloak,Phantom Widow,Phantom Spearman,Phantom Rider,Gargoyle,Batling,Vampiric Bat,Falcon Lord,Crow,Batling,Young Gryphon,Falcon,Vampiric Bat,Magic Servant,Wind Servant,Ethereal Orb,Razorbird,Wind Herder" 5 (
                    {AREA_FILTER}
                    [not]
                        [filter][/filter]
                    [/not]
                    [not]
                        [filter_adjacent_location]
                            [filter][/filter]
                        [/filter_adjacent_location]
                    [/not]
                    [not]
                        terrain=C*, K*, *^V*
                    [/not]
                ) (
                    side={SIDE}
                    [modifications]
                        {TRAIT_LOYAL}
                    [/modifications]
                )}
            [/then]
        [/if]
    [/event]

    [event]
        name=deactivate roaming sky monsters
        first_time_only=no
        [kill]
            fire_event,animate=no,no
            side={SIDE}
        [/kill]
    [/event]

    [event]
        name=die
        first_time_only=no
        [filter]
            side={SIDE}
        [/filter]

        {VARIABLE_INC roaming_sky_monsters_throttle}

        [if]
            {VARIABLE_NUMERICAL_EQUALS roaming_sky_monsters_throttle $roaming_sky_monsters_throttle_max}
            [then]
                {VARIABLE_DEC roaming_sky_monsters_count}
                {VARIABLE roaming_sky_monsters_throttle 0}
            [/then]
        [/if]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [store_time_of_day]
            variable=temp_current_tod
        [/store_time_of_day]

        [if]
            [variable]
                name=temp_current_tod.id
                contains="dusk"
            [/variable]
            [then]
                [fire_event]
                    name=activate roaming monsters
                [/fire_event]
            [/then]
            [else]
                [if]
                    [variable]
                        name=temp_current_tod.id
                        contains="dawn"
                    [/variable]
                    [then]
                        [fire_event]
                            name=deactivate roaming monsters
                        [/fire_event]
                    [/then]
                [/if]
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_current_tod}
    [/event]

    [event]
        name=victory
        {CLEAR_VARIABLE roaming_sky_monsters_count,roaming_sky_monsters_throttle,roaming_sky_monsters_throttle_max}
    [/event]
#enddef

#define ROAMING_SEA_MONSTERS SIDE AREA_FILTER COUNT THROTTLING
    [event]
        name=prestart
        # number of monsters respawned on first or second dusk
        {VARIABLE roaming_sea_monsters_count ({COUNT})}
        {VARIABLE roaming_sea_monsters_throttle 0}
        # number of monsters to kill before reducing respawn count by one
        {VARIABLE roaming_sea_monsters_throttle_max ({THROTTLING})}
    [/event]

    [event]
        name=activate roaming sea monsters
        first_time_only=no

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN roaming_sea_monsters_count 0}
            [then]
                {SCATTER_UNITS ($roaming_sea_monsters_count) "Sea Serpent,Water Serpent,Tentacle of the Deep_C,Cuttle Fish" 5 (
                    {AREA_FILTER}
                    [not]
                        [filter][/filter]
                    [/not]
                    [not]
                        [filter_adjacent_location]
                            [filter][/filter]
                        [/filter_adjacent_location]
                    [/not]
                    [not]
                        terrain=C*, K*, *^V*
                    [/not]
                ) (
                    side={SIDE}
                    [modifications]
                        {TRAIT_LOYAL}
                    [/modifications]
                )}
            [/then]
        [/if]
    [/event]

    [event]
        name=deactivate roaming sea monsters
        first_time_only=no
        [kill]
            fire_event,animate=no,no
            side={SIDE}
        [/kill]
    [/event]

    [event]
        name=die
        first_time_only=no
        [filter]
            side={SIDE}
        [/filter]

        {VARIABLE_INC roaming_sea_monsters_throttle}

        [if]
            {VARIABLE_NUMERICAL_EQUALS roaming_sea_monsters_throttle $roaming_sea_monsters_throttle_max}
            [then]
                {VARIABLE_DEC roaming_sea_monsters_count}
                {VARIABLE roaming_sea_monsters_throttle 0}
            [/then]
        [/if]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [store_time_of_day]
            variable=temp_current_tod
        [/store_time_of_day]

        [if]
            [variable]
                name=temp_current_tod.id
                contains="dusk"
            [/variable]
            [then]
                [fire_event]
                    name=activate roaming sea monsters
                [/fire_event]
            [/then]
            [else]
                [if]
                    [variable]
                        name=temp_current_tod.id
                        contains="dawn"
                    [/variable]
                    [then]
                        [fire_event]
                            name=deactivate roaming sea monsters
                        [/fire_event]
                    [/then]
                [/if]
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_current_tod}
    [/event]

    [event]
        name=victory
        {CLEAR_VARIABLE roaming_sea_monsters_count,roaming_sea_monsters_throttle,roaming_sea_monsters_throttle_max}
    [/event]
#enddef

#define ROAMING_LAND_MONSTERS SIDE AREA_FILTER COUNT THROTTLING
    [event]
        name=prestart
        # number of monsters respawned on first or second dusk
        {VARIABLE roaming_land_monsters_count ({COUNT})}
        {VARIABLE roaming_land_monsters_throttle 0}
        # number of monsters to kill before reducing respawn count by one
        {VARIABLE roaming_land_monsters_throttle_max ({THROTTLING})}
    [/event]

    [event]
        name=activate roaming land monsters
        first_time_only=no

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN roaming_land_monsters_count 0}
            [then]
                {SCATTER_UNITS ($roaming_land_monsters_count) "Batling,Bat,Alt Walking Corpse,Alt Soulless,Errant Spirit,ESpirit,Frozen Soul,Ice Heart,Phantom Unease,Phantom Fright,EGhost,Ghoul_C,Crow,Swampcrawler,Rabbit,Tusklet,Mudcrawler_C,Giant Rat,Bobcat,Yak,Young Bear,Terrapin,Giant Swampcrawler,Giant Mudcrawler_C,Giant Crow,Arctic Wolf,Wolf_C,Horse,Tusker,White Rabbit,Timber Wolf,Ram,Falcon Lord,Silver Hydra,Giant Scorpion_C,Calf,Heifer,Sporeling,Batling,Young Gryphon,Falcon" 5 (
                    {AREA_FILTER}
                    [not]
                        [filter][/filter]
                    [/not]
                    [not]
                        [filter_adjacent_location]
                            [filter][/filter]
                        [/filter_adjacent_location]
                    [/not]
                    [not]
                        terrain=C*, K*, *^V*
                    [/not]
                ) (
                    side={SIDE}
                    [modifications]
                        {TRAIT_LOYAL}
                    [/modifications]
                )}
            [/then]
        [/if]
    [/event]

    [event]
        name=deactivate roaming land monsters
        first_time_only=no
        [kill]
            fire_event,animate=no,no
            side={SIDE}
        [/kill]
    [/event]

    [event]
        name=die
        first_time_only=no
        [filter]
            side={SIDE}
        [/filter]

        {VARIABLE_INC roaming_land_monsters_throttle}

        [if]
            {VARIABLE_NUMERICAL_EQUALS roaming_land_monsters_throttle $roaming_land_monsters_throttle_max}
            [then]
                {VARIABLE_DEC roaming_land_monsters_count}
                {VARIABLE roaming_land_monsters_throttle 0}
            [/then]
        [/if]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [store_time_of_day]
            variable=temp_current_tod
        [/store_time_of_day]

        [if]
            [variable]
                name=temp_current_tod.id
                contains="dusk"
            [/variable]
            [then]
                [fire_event]
                    name=activate roaming land monsters
                [/fire_event]
            [/then]
            [else]
                [if]
                    [variable]
                        name=temp_current_tod.id
                        contains="dawn"
                    [/variable]
                    [then]
                        [fire_event]
                            name=deactivate roaming land monsters
                        [/fire_event]
                    [/then]
                [/if]
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_current_tod}
    [/event]

    [event]
        name=victory
        {CLEAR_VARIABLE roaming_land_monsters_count,roaming_land_monsters_throttle,roaming_land_monsters_throttle_max}
    [/event]
#enddef

#define ROAMING_CAVE_MONSTERS SIDE AREA_FILTER COUNT THROTTLING
    [event]
        name=prestart
        # number of monsters respawned on first or second dusk
        {VARIABLE roaming_cave_monsters_count ({COUNT})}
        {VARIABLE roaming_cave_monsters_throttle 0}
        # number of monsters to kill before reducing respawn count by one
        {VARIABLE roaming_cave_monsters_throttle_max ({THROTTLING})}
    [/event]

    [event]
        name=activate roaming cave monsters
        first_time_only=no

        [if]
            {VARIABLE_NUMERICAL_GREATER_THAN roaming_cave_monsters_count 0}
            [then]
                {SCATTER_UNITS ($roaming_cave_monsters_count) "Giant Ant,Swampcrawler,Rabbit,Tusklet,Mudcrawler_C,Giant Rat,Bobcat,Yak,Young Bear,Terrapin,Giant Swampcrawler,Giant Mudcrawler_C,Arctic Wolf,Wolf_C,Horse,Tusker,Timber Wolf,Ram,Silver Hydra,Giant Scorpion_C,Calf,Heifer,Sporeling,Batling" 5 (
                    {AREA_FILTER}
                    [not]
                        [filter][/filter]
                    [/not]
                    [not]
                        [filter_adjacent_location]
                            [filter][/filter]
                        [/filter_adjacent_location]
                    [/not]
                    [not]
                        terrain=C*, K*, *^V*
                    [/not]
                ) (
                    side={SIDE}
                    [modifications]
                        {TRAIT_LOYAL}
                    [/modifications]
                )}
            [/then]
        [/if]
    [/event]

    [event]
        name=deactivate roaming cave monsters
        first_time_only=no
        [kill]
            fire_event,animate=no,no
            side={SIDE}
        [/kill]
    [/event]

    [event]
        name=die
        first_time_only=no
        [filter]
            side={SIDE}
        [/filter]

        {VARIABLE_INC roaming_cave_monsters_throttle}

        [if]
            {VARIABLE_NUMERICAL_EQUALS roaming_cave_monsters_throttle $roaming_cave_monsters_throttle_max}
            [then]
                {VARIABLE_DEC roaming_cave_monsters_count}
                {VARIABLE roaming_cave_monsters_throttle 0}
            [/then]
        [/if]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        [store_time_of_day]
            variable=temp_current_tod
       [/store_time_of_day]

        [if]
            [variable]
                name=temp_current_tod.id
                contains="underground_illum2"
            [/variable]
            [then]
                [fire_event]
                    name=activate roaming cave monsters
                [/fire_event]
            [/then]
            [else]
                [if]
                    [variable]
                        name=temp_current_tod.id
                        contains="underground_illum"
                    [/variable]
                    [then]
                        [fire_event]
                            name=deactivate roaming cave monsters
                        [/fire_event]
                    [/then]
                [/if]
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_current_tod}
    [/event]

    [event]
        name=victory
        {CLEAR_VARIABLE roaming_cave_monsters_count,roaming_cave_monsters_throttle,roaming_cave_monsters_throttle_max}
    [/event]
#enddef
This is what the code segment looks like in my scenario file

Code: Select all

	{ROAMING_SKY_MONSTERS (3)
    (
     terrain=Fpla,Fpld,Fpll,Mybl,Mbda
        x=1-70
        y=1-30
    )
    ({DIFF 40 50 60})
    ({DIFF 15 16 17})
    }
I am at a loss.
Smart persons learn out of their mistakes, wise persons learn out of others mistakes! It seems that a select few have a talent learning out of others mistakes which many politicians lack.
Author of Era Of Two Suns
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Will this code work in 1.9.4

Post by Pentarctagon »

its actually going to be 1.10, not 2.0 :P
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
hart02
Posts: 52
Joined: July 15th, 2009, 12:06 am

Re: Will this code work in 1.9.4

Post by hart02 »

Well in any case this code still has issues having the units spawn at night or in general.I tried using the scatter units macro by itself as is and it spawns too many units.I would like to able to spawn a certain number of units at the start and it spawn new units every so often so as to not be so over whelming. Possibly on every so many turns. Maybe have it look like this:

Code: Select all

{SCATTER_UNITS NUMBER TURNS TYPES PADDING_RADIUS FILTER UNIT_WML}
or this

Code: Select all

{SCATTER_UNITS NUMBER TYPES PADDING_RADIUS FILTER TURNS THROTTLING UNIT_WML} 
or have it work the way I originally had it.
Either way I am clueless.
Smart persons learn out of their mistakes, wise persons learn out of others mistakes! It seems that a select few have a talent learning out of others mistakes which many politicians lack.
Author of Era Of Two Suns
Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Will this code work in 1.9.4

Post by Max »

you could use [inspect] to check variables at critical points:
http://wiki.wesnoth.org/InterfaceAction ... inspect.5D

and there's been a change in store_time_of_day:
http://forums.wesnoth.org/viewtopic.php ... 2&start=15

here's a list of other differences:
http://forum.wesnoth.org/viewtopic.php?f=21&t=32451
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Will this code work in 1.9.4

Post by zookeeper »

It'd be a lot easier to help if you'd tell which part of that code doesn't work and how exactly it fails to work. Hint, hint.
hart02
Posts: 52
Joined: July 15th, 2009, 12:06 am

Re: Will this code work in 1.9.4

Post by hart02 »

I found the cause of the issue. I made the changes to this

Code: Select all

[event]
        name=new turn
        first_time_only=no

        [store_time_of_day]
            variable=temp_current_tod
        [/store_time_of_day]

        [if]
            [variable]
                name=temp_current_tod.id
                contains="dusk"
            [/variable]
            [then]
                [fire_event]
                    name=activate roaming sky monsters
                [/fire_event]
            [/then]
            [else]
                [if]
                    [variable]
                        name=temp_current_tod.id
                        contains="dawn"
                    [/variable]
                    [then]
                        [fire_event]
                        name=deactivate roaming sky monsters 
                        [/fire_event]
                    [/then]
                [/if]
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_current_tod}
    [/event]
from this

Code: Select all

[event]
        name=new turn
        first_time_only=no

        [store_time_of_day]
            variable=temp_current_tod
        [/store_time_of_day]

        [if]
            [variable]
                name=temp_current_tod.id
                contains="dusk"
            [/variable]
            [then]
                [fire_event]
                    name=activate roaming monsters
                [/fire_event]
            [/then]
            [else]
                [if]
                    [variable]
                        name=temp_current_tod.id
                        contains="dawn"
                    [/variable]
                    [then]
                        [fire_event]
                        name=deactivate roaming monsters 
                        [/fire_event]
                    [/then]
                [/if]
            [/else]
        [/if]

        {CLEAR_VARIABLE temp_current_tod}
    [/event]
Turns out that it was a naming issue all along. My bad.
Smart persons learn out of their mistakes, wise persons learn out of others mistakes! It seems that a select few have a talent learning out of others mistakes which many politicians lack.
Author of Era Of Two Suns
Post Reply