Night-transforming unit

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
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Night-transforming unit

Post by Sapient »

ulfgur wrote:Okay, now it's working the other way. The werewolf will turn to the nobleman @ day, but the nobleman stubbornly refuses to be turned to a werewolf at night.
Then you'll probably have to post your code. I don't see any problem with the example as provided.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
ulfgur
Posts: 88
Joined: December 16th, 2008, 1:01 am

Re: Night-transforming unit

Post by ulfgur »

Code: Select all

[unit_type]
    id=nobleman
    name= _ "nobleman"
    race=human
    image="units/noble/nobleman.png"
    ellipse="misc/ellipse"
    profile="portraits/humans/nobleman.png"
    {MAGENTA_IS_THE_TEAM_COLOR}
    hitpoints=28
    movement_type=smallfoot
    movement=5
    experience=40
    level=1
    alignment=lawful
    advances_to=daimyo
    cost=15
    usage=fighter
    description= _ "Swords are, for many, an expensive luxury, and one which peasants can ill afford. Spears are much easier to make and will do well even without a spearhead, though most can afford one. Clad in leather armor, and often armed with a shield and a few javelins, spearmen are the staple of most armies, often thrown into the front lines with only the most basic training."+{SPECIAL_NOTES}+{SPECIAL_NOTES_FIRSTSTRIKE}
    die_sound={SOUND_LIST:HUMAN_DIE}
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/humans/transparent/spearman.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/humans/transparent/spearman.png"
    [/portrait]
    {DEFENSE_ANIM "units/noble/nobleman-defend.png" "units/noble/nobleman.png" {SOUND_LIST:HUMAN_HIT} }
    [leading_anim]
        [frame]
            begin=-150
            end=150
            image="units/noble/nobleman-leading.png"
        [/frame]
    [/leading_anim]
    [attack]
        name=wakizashi
        description=_"Katana"
        type=blade
        range=melee
        damage=28
        number=1
        icon=units/noble/katana.png
        [specials]
            {WEAPON_SPECIAL_FIRSTSTRIKE}
        [/specials]
    [/attack]
  [event]
    name=new turn,recruit
    first_time_only=no
    [store_time_of_day]
    [/store_time_of_day]
    [if]
      [variable]
        name=time_of_day.lawful_bonus
        less_than=0
      [/variable]
      [then]
        {TRANSFORM_UNIT type=nobleman werewolf}
      [/then]
    [/if]
  [/event]
[/unit_type]


[unit_type]
    id=werewolf
    name= _ "Werewolf"
    race=human
    image="units/noble/werewolf.png"
    ellipse="misc/ellipse"
    profile="portraits/humans/werewolf.png"
    {MAGENTA_IS_THE_TEAM_CProxy-Connection: keep-alive
Cache-Control: max-age=0

OR}
    hitpoints=28
    movement_type=smallfoot
    movement=7
    experience=40
    level=1
    alignment=lawful
    advances_to=daimyo
    cost=15
    usage=fighter
    description= _ "Swords are, for many, an expensive luxury, and one which peasants can ill afford. Spears are much easier to make and will do well even without a spearhead, though most can afford one. Clad in leather armor, and often armed with a shield and a few javelins, spearmen are the staple of most armies, often thrown into the front lines with only the most basic training."+{SPECIAL_NOTES}+{SPECIAL_NOTES_FIRSTSTRIKE}
    die_sound={SOUND_LIST:HUMAN_DIE}
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/humans/transparent/spearman.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/humans/transparent/spearman.png"
    [/portrait]
    {DEFENSE_ANIM "units/noble/nobleman-defend.png" "units/noble/nobleman.png" {SOUND_LIST:HUMAN_HIT} }
    [leading_anim]
        [frame]
            begin=-150
            end=150
            image="units/noble/nobleman-leading.png"
        [/frame]
    [/leading_anim]
    [attack]
        name=wakizashi
        description=_"Katana"
        type=blade
        range=melee
        damage=28
        number=1
        icon=units/noble/katana.png
        [specials]
            {WEAPON_SPECIAL_FIRSTSTRIKE}
        [/specials]
    [/attack]
  [event]
    name=new turn,recruit
    first_time_only=no
    [store_time_of_day]
    [/store_time_of_day]
    [if]
      [variable]
        name=time_of_day.lawful_bonus
        greater_than_equal_to=0
      [/variable]
      [then]
        {TRANSFORM_UNIT type=werewolf nobleman}
      [/then]
    [/if]
  [/event]
[/unit_type]


You will notice I deleted the attack anims. I wanted to get rid of some of the bulk of the code until the rest was functional.
Elmor
Posts: 152
Joined: May 5th, 2010, 8:19 am

Re: Night-transforming unit

Post by Elmor »

i got such unit
but i got also a problem
"new turn" event doesnt works, so i used "move to" and "attack" events, but there are problems too: animation doesnt synch
Harion
Posts: 61
Joined: October 17th, 2009, 5:00 pm

Re: Night-transforming unit

Post by Harion »

The way I think of it try having the code for them as if they were two separate units. But do what you did to get them to transform into the other one at the time of day you want instead of having it as just one unit.
Post Reply