Need help creating custom trait
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.
-
- Posts: 10
- Joined: June 5th, 2009, 3:38 pm
Need help creating custom trait
I want to create a unit specific trait that is dependent on both time of day and the terrain the unit is on. At the beginning of every turn where the unit is not stationed in a village or on Keep/Castle terrain, it loses a set amount of hit points, except for if time of day is Dusk or Night. I also want to set a a way for this trait to cut attack power by 50% and defense by 30%. How would I go about setting this up?
Re: Need help creating custom trait
i'm not sure exactly how to go about what you want to do, but if i recall correctly, either under the burning suns or Invasion from the unknown has something like this happen, problem is i can't remember which it is. sorry i couldn't be of more help.
Re: Need help creating custom trait
You could probably do a regeneration ability that has a negative value but only works in certain areas and times.
You can use this to filter the effect to only work during the day:
Look at the code for the Concealment power for an example of how to make a filter for locations - of course that one is only villages and not castles, so you'll have to add some stuff.
Peet
You can use this to filter the effect to only work during the day:
Code: Select all
[filter_self]
[filter_location]
time_of_day=lawful
[/filter_location]
[/filter_self]
Peet
-
- Posts: 10
- Joined: June 5th, 2009, 3:38 pm
Re: Need help creating custom trait
Thanks, I'm actually working on it now. I tried using a modified version of the "feeds" ability, and the good news is that the game doesn't crash. The bad news is that the ability shows up and has a working description, but doesn't do anything.
Here's what I've brainstormed so far:
Edit: tried it with [regenerate], still didn't work. Maybe I'm doing something wrong with my conditionals. On the plus side, at least it didn't cause any fatal errors.
Here's what I've brainstormed so far:
Code: Select all
# wmllint: unbalanced-on
#define ABILITY_PHOTOSENSITIVE
# Unit will burn in direct sunlight
[dummy]
id=photosensitive
name= _ "photosensitive"
female_name= _ "female^photosensitive"
description=_ "This unit has an aversion to extremely bright light, natural or otherwise, and will burn unless in darkness or under the cover of night"
[/dummy]
[/abilities]
[event]
name=dawn [or]morning[/or] [or]afternoon[/or]
first_time_only=no
[filter_self]
[filter_location]
terrain=[not]Ce,Ch,Cv,Cud,Chr,Chw,Chs,Ke,Kh,Kud,Khr,Khw,Khs,Uu,Dd^Vda,Dd^Vdt,Aa^Vea,Gg^Ve,Aa^Vha,Gg^Vh,Hh^Vhh,Ha^Vhha,Mm^Vhh,Gs^Vht,Uu^Vu,Uu^Vud,Ww^Vm,Ss^Vhs,Ss^Vm[/not]
[/filter_location]
[/filter_self]
[filter_second]
ability=photosensitive
[/filter_second]
[object]
silent=yes
duration=forever
[filter]
x,y=$x2,$y2
[/filter]
[effect]
apply_to=hitpoints
increase=-8
[/effect]
[/object]
[/event]
[+abilities]
#enddef
# wmllint: unbalanced-off
Code: Select all
#define ABILITY_PHOTOSENSITIVE
# Unit will burn in direct sunlight
[regenerate]
id=photosensitive
name= _ "photosensitive"
female_name= _ "female^photosensitive"
description=_ "This unit has an aversion to extremely bright light, natural or otherwise, and will burn unless in darkness or under the cover of night"
[filter_self]
[filter_location]
time_of_day=lawful
terrain=[not]*C*,*K*,Uu,*^V*[/not]
[/filter_location]
[/filter_self]
value=-8
[/regenerate]
#enddef
Re: Need help creating custom trait
i'm pretty dure you are not allowed to have conditionals where you have them. by that i mean you can't put them in the name= tag
just copy and past the code so that yyou have a separate {event} tag for each time of day. speaking of time of day it is not a predefined event name according to the reference wiki.
as for your terrain= tag remove the [not] conditionals there and filter for all terrains other than what you want to protect the units. because (to the best of my knowledge you can't use conditionals there)
this may seem aggrivating but it just might solve you problem. of course there is the chance i'm completely wrong about the filtering for the terrainb part but if you want to have an event trigger that you name after a ToD then i'm pretty sure you'll have to define it as a name for events.
check the reference wiki to be sure though.
best of luck,
Huston
if anyone sees somthing wrong with what i've said please correct me
just copy and past the code so that yyou have a separate {event} tag for each time of day. speaking of time of day it is not a predefined event name according to the reference wiki.
as for your terrain= tag remove the [not] conditionals there and filter for all terrains other than what you want to protect the units. because (to the best of my knowledge you can't use conditionals there)
this may seem aggrivating but it just might solve you problem. of course there is the chance i'm completely wrong about the filtering for the terrainb part but if you want to have an event trigger that you name after a ToD then i'm pretty sure you'll have to define it as a name for events.
check the reference wiki to be sure though.
best of luck,
Huston
if anyone sees somthing wrong with what i've said please correct me
Re: Need help creating custom trait
I'm not an expert, but I think you need to do:
rather than:
Peet
Code: Select all
[not]
terrain=*C*,*K*,Uu,*^V*
[/not]
Code: Select all
terrain=[not]*C*,*K*,Uu,*^V*[/not]
-
- Posts: 10
- Joined: June 5th, 2009, 3:38 pm
Re: Need help creating custom trait
Still doesn't work but at least I'm getting closer: I finally figured out to make the ability trigger. Only problem is, it ignores terrain and time of day and triggers twice, once at the beginning and end of a turn.
Code: Select all
# wmllint: unbalanced-on
#define ABILITY_PHOTOSENSITIVE
# Unit will burn in direct sunlight
[dummy]
id=photosensitive
name= _ "photosensitive"
female_name= _ "female^photosensitive"
description=_ "This unit has an aversion to extremely bright light, natural or otherwise, and will burn unless in darkness or under the cover of night"
[/dummy]
[/abilities]
[event]
name=side turn
first_time_only=no
[filter_self]
[filter_location]
[not]
terrain=C*,K*,Uu,*^V*
[/not]
[and]
time_of_day=lawful
[/and]
[and]
ability=photosensitive
[/and]
[/filter_location]
[/filter_self]
{FLOATING_TEXT x,y=$x1,$y1 255,0,0 "8"}
sound=torch-miss.ogg
[object]
silent=yes
duration=forever
[filter]
x,y=$x1,$y1
[/filter]
[effect]
apply_to=hitpoints
increase=-8
[/effect]
[/object]
[/event]
[+abilities]
#enddef
# wmllint: unbalanced-off
-
- Posts: 462
- Joined: June 8th, 2006, 3:25 am
Re: Need help creating custom trait
Try this for your event, it should store all the units that meet the requirements, and adjust their hp individually:
Code: Select all
[event]
name=side_turn
first_time_only=no
[if]
[have_unit]
ability=photosensitve
side=$side_number
[filter_location]
time_of_day=lawful
[not]
terrain=C*,K*,Uu,*^V*
[/not]
[/filter_location]
[/have_unit]
[then]
[store_unit]
variable=light_burns
[filter]
ability=photosensitve
side=$side_number
[filter_location]
time_of_day=lawful
[not]
terrain=C*,K*,Uu,*^V*
[/not]
[/filter_location]
[/filter]
[/store_unit]
{FOREACH light_burns i}
[if]
[variable]
name=light_burns[$i].hitpoints
less_than=10
[/variable]
#this gives behavior like poison, can't reduce below 1 hp
#you can change this part if you want them to die from the light
[then]
{VARIABLE light_burns[$i].hitpoints 1}
[/then]
[else]
{VARIABLE_OP light_burns[$i].hitpoints add -8}
[/else]
[/if]
[unstore_unit]
variable=light_burns[$i]
text="8"
{COLOR_HARM}
[/unstore_unit]
sound=torch-miss.ogg
{NEXT i}
{CLEAR_VARIABLE light_burns}
[/then]
[/if]
[/event]
-
- Posts: 10
- Joined: June 5th, 2009, 3:38 pm
Re: Need help creating custom trait
I don't know why, but it still doesn't work. For some reason, it seems like I can only get the ability to do nothing, or it works but ignores terrain and time of day. Does it matter that I'm testing this with 2p MP against the AI? I've also noticed that even though it's in the recruit list, the computer won't recruit the custom unit, unless both are factions are the same and it recruits them to counter me. Other than creating a new faction with its own recruit list, is there any way to increase the frequency of the AI recruiting certain units (I've also noticed the AI almost NEVER recruits Ghouls).
Re: Need help creating custom trait
for increasing that you can just modify the recruitment pattern
if there isn't one then add one
if there isn't one then add one
-
- Posts: 462
- Joined: June 8th, 2006, 3:25 am
Re: Need help creating custom trait
It's possible that the documentation is wrong in places due to changes since those parts were written - try replacing 'lawful' with 'morning' or 'morning,afternoon' and seeing what happens.
-
- Posts: 10
- Joined: June 5th, 2009, 3:38 pm
Re: Need help creating custom trait
For some reason I can't figure out, it still doesn't do anything. The ability doesn't launch with the filters, and without them it only "works" for the leader unit, which starts on the map. For some reason recruited units with the ability aren't affected by it.
Re: Need help creating custom trait
In that case you've done something else wrong. Exasperation's piece of code looks like it should work just fine (except for the sound= bit). Also it has "photosensitve" when it should be "photosensitive", maybe you didn't fix that when you tried it.JKilligans wrote:For some reason I can't figure out, it still doesn't do anything. The ability doesn't launch with the filters, and without them it only "works" for the leader unit, which starts on the map. For some reason recruited units with the ability aren't affected by it.
Re: Need help creating custom trait
Other problems:
1. the event should be side turn, not side_turn
2. photosensitive is a trait, not an ability. ((Edit: Er... actually, you were using an ability. I got confused because of the name of the thread. Still, I think that having it as a trait is more appropriate. If you want to keep in an ability, replace my filter_wml with ability=photosensitive - then it should work.))
I'm trying to get it to work; I'll post the result when I have it. Would it be okay if I use this in my campaign once it's working?
EDIT:: Try this:
1. the event should be side turn, not side_turn
2. photosensitive is a trait, not an ability. ((Edit: Er... actually, you were using an ability. I got confused because of the name of the thread. Still, I think that having it as a trait is more appropriate. If you want to keep in an ability, replace my filter_wml with ability=photosensitive - then it should work.))
I'm trying to get it to work; I'll post the result when I have it. Would it be okay if I use this in my campaign once it's working?
EDIT:: Try this:
Code: Select all
[event]
name=side turn
first_time_only=no
[store_unit]
variable=light_burns
[filter]
[filter_wml]
# Uncomment the modifications lines if you use a modification when creating the unit instead of defining the trait in the unit cfg file.
# [modifications]
[trait]
id=photosensitive
[/trait]
# [/modifications]
[/filter_wml]
side=$side_number
[filter_location]
time_of_day=lawful
[not]
terrain=C*,K*,Uu,*^V*
[/not]
[/filter_location]
[/filter]
kill=no
[/store_unit]
{FOREACH light_burns i}
{VARIABLE light_burns[$i].resting no}
[if]
[variable]
name=light_burns[$i].hitpoints
greater_than=8
[/variable]
#this gives behavior like poison, can't reduce below 1 hp
#you can change this part if you want them to die from the light
[then]
{VARIABLE_OP light_burns[$i].hitpoints add -8}
[/then]
[else]
{VARIABLE light_burns[$i].hitpoints 1}
[/else]
[/if]
[unstore_unit]
variable=light_burns[$i]
find_vacant=no
text="8"
{COLOR_HARM}
[/unstore_unit]
[sound]
name=torch-miss.ogg
[/sound]
{NEXT i}
{CLEAR_VARIABLE light_burns}
[/event]
-
- Posts: 10
- Joined: June 5th, 2009, 3:38 pm
Re: Need help creating custom trait
Sure, I don't mind at all. I'm just trying to figure out how to make this work mostly for practice with WML, and since it's GPL anyway, I don't see the point of being possessive of it. If you can figure out how to make it work, I don't have any problem with you using the ability in a campaign. The reason I decided to make it an ability instead of a trait was because I couldn't figure out how to set up and edit a trait so that it was conditional, and trying to figure out how "Feeding" was set up to work seemed easier at the time.melinath wrote:Other problems:
1. the event should be side turn, not side_turn
2. photosensitive is a trait, not an ability. ((Edit: Er... actually, you were using an ability. I got confused because of the name of the thread. Still, I think that having it as a trait is more appropriate. If you want to keep in an ability, replace my filter_wml with ability=photosensitive - then it should work.))
I'm trying to get it to work; I'll post the result when I have it. Would it be okay if I use this in my campaign once it's working?
Spoiler:
Edit: Hey, it actually works! It was just the typo -- I'm glad you caught that because I would have kept overthinking what was wrong and probably never notice that in a million years. The only problem it has now is it still takes out double the value it's supposed to; the lazy solution is to just change the value to be half of what you actually want it to be. Thanks for all the help!