Night-transforming unit
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.
Night-transforming unit
Hello.
I have been trying and failing to create a unit that turns into a werewolf at night. So far, I'm just working on getting the animation to work. Here's what i have put in the unit...
[standing_anim]
start_time=-50
[filter]
time_of_day=chaotic
[/filter]
[frame]
image="units/noble/werewolf.png"
duration=50
[/frame]
[/standing_anim]
[standing_anim]
start_time=-50
[filter]
time_of_day=lawful
[/filter]
[frame]
image="units/noble/nobleman.png"
duration=50
[/frame]
[/standing_anim]
I have been trying and failing to create a unit that turns into a werewolf at night. So far, I'm just working on getting the animation to work. Here's what i have put in the unit...
[standing_anim]
start_time=-50
[filter]
time_of_day=chaotic
[/filter]
[frame]
image="units/noble/werewolf.png"
duration=50
[/frame]
[/standing_anim]
[standing_anim]
start_time=-50
[filter]
time_of_day=lawful
[/filter]
[frame]
image="units/noble/nobleman.png"
duration=50
[/frame]
[/standing_anim]
Re: Night-transforming unit
Look at the code in HTTT. There's a scenario in there where all the bad guys become undead at night, and loyalist in the day.
Re: Night-transforming unit
And Liberty.Kapoue_II wrote:Look at the code in HTTT. There's a scenario in there where all the bad guys become undead at night, and loyalist in the day.
Anyway,
Code: Select all
[filter]
[filter_location]
time_of_day=lawful
[/filter_location]
[/filter]
"What do you mean, "a dwarvish dragonguard with marksman is overpowered"?"
Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
Re: Night-transforming unit
Brillliant! filter location tag worked. For anyone who ends up wanting to use the code, here it is:
I had to filter time of day neutral, or else the game crashed when I tried to use the unit.
Code: Select all
[standing_anim]
[filter]
[filter_location]
time_of_day=chaotic
[/filter_location]
[/filter]
start_time=-50
[frame]
image="units/noble/werewolf.png"
duration=50
[/frame]
[/standing_anim]
[standing_anim]
[filter]
[filter_location]
time_of_day=lawful
[/filter_location]
[/filter]
start_time=-50
[frame]
image="units/noble/nobleman.png"
duration=50
[/frame]
[/standing_anim]
[standing_anim]
[filter]
[filter_location]
time_of_day=neutral
[/filter_location]
[/filter]
start_time=-50
[frame]
image="units/noble/nobleman.png"
duration=50
[/frame]
[/standing_anim]
Re: Night-transforming unit
Here's the next (and final) problem. The werewolf slightly increases speed at night, and gets leadership during the day. Here is what I tried.
Code: Select all
#define ABILITY_WEREWOLF_NIGHT
# Canned definition of the werewolf ability to be included in an
# [abilities] clause.
[werewolf]
id=werewolf
name= _ "Werewolf"
female_name= _ "Werewolf"
description= _ "Werewolf:
the unit gets increased speed during the night."
name_inactive= _ "Werewolf"
female_name_inactive= _ "female^ Werewolf"
description_inactive= _ "Werewolf:
the unit gets increased speed during the night."
affect_self=yes
movement=7
[filter_self]
[filter_location]
time_of_day=chaotic
[/filter_location]
[/filter_self]
[/werewolf]
#enddef
#define ABILITY_WEREWOLF_DAY
# Canned definition of the werewolf ability to be included in an
# [abilities] clause.
[werewolf]
id=werewolfday
name= _ "Werewolf"
female_name= _ "Werewolf"
description= _ "Werewolf:
the unit gets leadership during the day."
name_inactive= _ "Werewolf"
female_name_inactive= _ "female^ Werewolf"
description_inactive= _ "Werewolf:
the unit gets leadership during the day."
{ABILITY_LEADERSHIP_LEVEL_1}
affect_self=yes
[filter_self]
[filter_location]
time_of_day=lawful
[/filter_location]
[/filter_self]
[/werewolf]
#enddef
#define ABILITY_WEREWOLF_NEUTRAL
# Canned definition of the werewolf ability to be included in an
# [abilities] clause.
[werewolf]
id=werewolfneutral
name= _ "Werewolf"
female_name= _ "Werewolf"
description= _ "Werewolf:
the unit gets leadership during the day."
name_inactive= _ "Werewolf"
female_name_inactive= _ "female^ Werewolf"
description_inactive= _ "Werewolf:
the unit gets leadership during the day."
{ABILITY_LEADERSHIP_LEVEL_1}
affect_self=yes
[filter_self]
[filter_location]
time_of_day=neutral
[/filter_location]
[/filter_self]
Proxy-Connection: keep-alive
Cache-Control: max-age=0
werewolf]
#enddef
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Night-transforming unit
I'm not sure how you're using these macros, but I can't think of a way you could use them that works. Macros are expanded just once when the scenario or unit_type is loaded, so you can't call them like functions. The best way to do what you want is to make two different unit types and then use the TRANSFORM_UNIT macro in unit-utils.cfg to switch back and forth. (It preserves XP, HP, and status.) This is what is done in Liberty's fourth scenario, "Unlawful Orders", so you could check that out.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: Night-transforming unit
Yeah, and FYI Liberty works pretty bleeping well. However, that might result in you being confused over where your unit is, so perhaps not.
Here's what I'd try.
There's some sort of max_movement you can use I believe, but I forgot exactly what it's called.
Also, there is no such tag as [werewolf] so it won't do anything, it'll just behave like a [dummy] tag, and you can't just insert movement=7 into an ability, there's no such string that the ability will recognise. That's what I understand, anyway, based on what I've read.
Here's what I'd try.
Code: Select all
#define ABILITY_WEREWOLF_NIGHT
# Canned definition of the werewolf ability to be included in an
# [abilities] clause.
[dummy]
id=werewolf
name= _ "Werewolf"
female_name= _ "Werewolf"
description= _ "Werewolf:
the unit gets increased speed during the night."
name_inactive= _ "Werewolf"
female_name_inactive= _ "female^ Werewolf"
description_inactive= _ "Werewolf:
the unit gets increased speed during the night."
[/dummy]
[/abilities]
# important bit here
[event]
name=new turn
first_time_only=no
{MODIFY_UNIT ( type=Werewolf
[filter_location]
time_of_day=chaotic
[/filter_location] ) movement 7}
[/event]
[+abilities]
#enddef
Also, there is no such tag as [werewolf] so it won't do anything, it'll just behave like a [dummy] tag, and you can't just insert movement=7 into an ability, there's no such string that the ability will recognise. That's what I understand, anyway, based on what I've read.
"What do you mean, "a dwarvish dragonguard with marksman is overpowered"?"
Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
Story of a Drake Outcast | The Nonsense Era
Played HttT-Underground Channels? Thought it was rubbish? Help us develop it here!
Re: Night-transforming unit
I would like to note at this point that, being only amateur in coding, we are really getting into code I don't know. That's why I was making it an ability, i kind of know how it works.
Okay, I tried copying/pasting Reepur's code into abilities and making a separate werewolf unit, and the game told me I had a missing closing tag for abilities in the nobleman unit. I don't. Since I am clueless about the coding, I'm having trouble fixing it.
Okay, I tried copying/pasting Reepur's code into abilities and making a separate werewolf unit, and the game told me I had a missing closing tag for abilities in the nobleman unit. I don't. Since I am clueless about the coding, I'm having trouble fixing it.
Re: Night-transforming unit
Code: Select all
[dummy]
id=werewolf
name= _ "Werewolf"
female_name= _ "Werewolf"
description= _ "Werewolf:
the unit gets increased speed during the night."
name_inactive= _ "Werewolf"
female_name_inactive= _ "female^ Werewolf"
description_inactive= _ "Werewolf:
the unit gets increased speed during the night."
[/dummy]
[/abilities]
To use this, place it in the [abilities] tag of the nobleman as so:
Code: Select all
[abilities]
{ABILITY_WEREWOLF_NIGHT}
[/abilities]
Re: Night-transforming unit
Hrmmm. Now it doesn't transform at all.
Re: Night-transforming unit
Wrong, it has to close abilities tag first to define an event. Then it re-opens it with [+abilities].bigkahuna wrote: Notice the [/abilities] stuck on the end. Take that out.
That much is correct.bigkahuna wrote: To use this, place it in the [abilities] tag of the nobleman
However, you should really be doing the entire transformation with {TRANSFORM_UNIT} and using a second unit type as multiple people have already suggested. In fact, "werewolf" or night-transforming units were the very reason that macro was written.
Code: Select all
[unit_type]
id=werewolf_day
...
[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=werewolf_day werewolf_night}
[/then]
[/if]
[/event]
[/unit_type]
[unit_type]
id=werewolf_night
...
[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_night werewolf_day}
[/then]
[/if]
[/event]
[/unit_type]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Night-transforming unit
Brilliant! Halfway there! That made the day version turn into the night version, but the night won't turn back into the day.
note: I would have used the TRANSFORM_UNIT, but the code in liberty was too complicated. In the act of digging through the code to find what i need, I would have broken something irreparably...
note: I would have used the TRANSFORM_UNIT, but the code in liberty was too complicated. In the act of digging through the code to find what i need, I would have broken something irreparably...
Re: Night-transforming unit
ulfgur wrote:Brilliant! Halfway there! That made the day version turn into the night version, but the night won't turn back into the day.
note: I would have used the TRANSFORM_UNIT, but the code in liberty was too complicated. In the act of digging through the code to find what i need, I would have broken something irreparably...
I forgot to put first_time_only=no in the event
I fixed it now and made it a little more foolproof.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Night-transforming unit
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.