Dixie's Thread

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
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: Ability related questions

Post by fog_of_gold »

Why? -It's already random since hitting is random.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

Well I am not on my computer since I'm not home, and thus cannot copy you the code, but it could be done pretty easily by replacing 1 by some throw_a_dice variable which can be easily randomnly generated. I know there was a thread about a month old or two that suggested that code. Or if you want it, you can go look at my Kamikaze weapon special, in Internet Meme Era, which uses it to generate random splash damage.

But Fog_of_gold's point is actually pretty good as fine as my interests go.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

Well, well, I feel a bit weird fetching this thread at the bottom of page four, but it's my dear ability questionning thread, so I just had to fetch it :)

Anyway, I've worked on some of the new abilities for IME's robot faction. I think I managed to deal with most of the stuff, and although I haven't tested it yet, I'd like you to take a peek at a few of them if you don't overly mind and give me your opinion.


Bulldoze

That ability is a terrain-altering one for a bulldozer unit. When it ends/starts its turn on a snow/forest/hill hex, it should change it to dirt (flat). All kind of desert terrains should be changed to desert roads, and rocky caves/mushroom grves should be changed to caves. (illuminated rocky caves are changed to illuminated caves. The wiki didn't mention illuminated mushroom groves, and I don't remember them: should I include them?)

So anyway, here's the code. Tell me if there's something wrong, or if there are stuff I could have done better (it gets confusing pretty easily with the layers!...)
Bulldoze ability's code:

Relentless

So this attack is meant for drills. I've changed lindsay40k's original idea a bit. Drill attacks are gonne be pierce, with many weak strikes. It should have normal CTH at first, but as soon as it scores a hit, CTH is changed to 90%. If a ulterior attack misses, it goes back to normal. And it could theorially go back and forth from either 90% or normal% CTH as much as luck would allow it until the attack ends.

Now, I've tried something with the [effect] tag, which is the best option I could think of. It basically adds a 90% CTH special ("surehit") to the attack, and removes it afterwards. My concern, however, is wether you can change CTH in the middle of an attack like that, and wether it'll go back and forth between either mode smoothly.
Relentless ability's code; Surehit's at the bottom:

Dazzle

Now that's the tough one! Honestly, I've looked all over the wiki, but I could find no way to achieve what I want this special to do, and I know of no other era that uses a similar effect. Here is what it should do: when a unit with a dazzling attack scores a hit, the target's CTH are maxed at 50% for the next turn. It disappears by itself one turn later much like slow does. I thought of using the same (possibly dubious) method as relentless, but I could find no way to set a maximum CTH, and I couldn't figure out a way to make it vanish after a turn. Also, I haven't overlooked that last issue since it is not the most essential, but it'd be nice to be able to add "dazzled" to the target's stat, or something like that, much like poison and slow show under a unit's name in the right-handed pannel.

So, any idea how we could go about this ability?

Thanks again in advance for everything, fellas! :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
markm
Posts: 158
Joined: August 13th, 2008, 3:53 pm
Location: Halifax Nova Scotia Canada

Re: Ability related questions

Post by markm »

I like the idea of combining buster with steal. "Lets just nip into town to pick that chap's pocket..." ;)

-MarkM-
Developing Between the Worlds campaign portmanteau.
Have you eaten today?
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

@ markm:
Hmm... It wasn't my intent in the least, but the idea has merit. I'll think about it, I might use that somewhere.

----

Ok, apart from that, I coded my units and tested my new abilities. Turns out a lot of them don't work (surprised?), and I don,t really know how to fix that (although I tried, mind you). So! Here goes, if anyone cares to give me a few pointers:


Bulldoze
Problem Fixed!:
Last edited by Dixie on June 11th, 2010, 9:10 pm, edited 3 times in total.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

So, just a "few" words about my recent developments. I actually managed to fix a lot of problems by myself! I now feel a little silly and ashamed for having asked your help previously :oops:

Anyway, I stroke the corrected codes in the previous post, and I'll also add the new, correct ones in case any body came over here and needed them. Who knows? Better have it archived somewhere, I guess.

So, I'm still struggling with Bulldoze, but I stopping for tonight. I've tried something else, I thought it would work, but it didn't. Still, I'm fairly confident it can be done, somehow. I'll just post it here if anybody passes by and has any idea or insight to offer on that, but I'll continue working on it some this tomorrow, so I might eventually fix it.

Bulldoze, still not working...:
I'm also at a total loss with Dazzle. Is there a way to create new statuses? Is there even way to set a maximum cth? I've looked a lot in the wiki and the game's various util files, but found nothing that could really help so far. Well maybe that bit of code I used for relentless but... I'm not too sure it'd really work. Sure, I could set cth to 50%, I could probably even find a way to make the sprite whitish or something and a way to make it vanish after one turn, but I don,t absolutely want cth to be precisely 50%, I want it to be at a maximum of 50%... So, no solution as of yet.

Thanks in advance for anything, guys! :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: Ability related questions

Post by fog_of_gold »

About dazzle, you'll need filter_base_value:

Code: Select all

    [chance_to_hit]
        value=50
        [filter_base_value]
            greater_than=50
        [/filter_base_value]
    [/chance_to_hit]
And then just include it the same way your did with your other abilities.

BTW, next time it would be nice to mention into your IME topic you asked here since I usually don't look here.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

@ fog_of_gold:

Hmm, good idea, I'll have to try that. And sorry about not mentionning :?

---

Well, I've been struggling with Bulldoze some more. I tried lots of ways to write this diffrently: I used [store_location] instead of [store_unit], I tried [have_unit] instead of [have_location], tons of different filters and ways to include them, which in the end I figured should all amount to making the ability work, but to no avail. I looked at a lot of sections from the wiki, I looked in terrains-util.cfg (and a lot of other util files, actually), and I found nothing that could help me. I can't believe this seriously can't be scripted.

So anyway, I've narrowed the code for you, it's about 20-30 lines long, so if someone could take a peek at it and tell if there's something that seems wrong... it would be really appreciated. Now of course, you will say stuff like "Hey, there's no [/event] closing tag!" etc., but they're present in my code, I just gave you the critical bit. The rest is copy-paste.
Critical bit of code from Bulldoze:
Thanks in advance :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: Ability related questions

Post by fog_of_gold »

You mustn't use [filter] within side turn. I'm not sure if it makes troubles since unknown/unneeded tags are usually ignored. But this tag isn't always unneeded which make differents. The best idea is, to try it out. Could you make empty messages ([message][/message]) and tell us in which part is called and which not (should be within [event], {FOREACH} and [then] tags)
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

Seems like you were right about filters with "side turn". I thought I had done it elsewhere, but in those other events they were like "name=die" or other such thing. As far as I know the wiki didn't mention this issue, however, so I'm not sure I had a way of finding out. In any event, thanks a lot! Bulldoze now works! Yay!

I'll edit the code a few posts above, so the correct one is archived on the forum somewhere. I may be loosing my time doing this, but oh well, too bad.

---

About Dazzle. I've been looking for pieces of WML I'd need to create the whole thing. I was thinking of creating a weapon special (Dazzle) which colors the unit white-blue-ish (with the "CS(r,g,b)" code, in an [effect] tag) and gives an ability (Dazzled) which would reproduce the idea you stated earlier with the [chance_to_hit] tag. So far, all good.

Here's where I'm currently at: I want this to vanish after a turn, much like slow does. Now, I thought of storing "$side_turn" and "$turn_number" in variables to compare it afterwards, but there are two issues, mainly:

1) I can't find if there is a way to easily store a unit to a numbered variable, and having two other variables with the same number storing on what turn and on which side's turn said unit was dazzled, so we know which unit was dazzled when. Problem is, I need multiple variables (hence the number), since there could be literally dozens of dazzled units at once, and I also need a way to check wether a numbered variable is free or not. I was also wondering if I could find a way to do this more or less automatically, maybe with the {FOREACH marco? Can a {FOREACH macro with "i" create assorted variables[$i] (and scan for free ones)?

2) The next step would be creating an event that fires at every "side_turn" to compare the above variables with the current $turn_number and $side_turn. So I would ideally need a {FOREACH macro that scans and compares all the previous variables[$i], and removes the "dazzled" ability and white-blueish hue from the unit which have been dazzled for a whole turn. First, is this possible? Second, where should I put it? Will it launch if I place it in my [era] tag? Or would I need an event in, say, the dazzled ability to fire that sanning event every side_turn? And would that make the game lag horribly at the beginning of every side_turn?

Well, I'm not asking you to write it down for me. I think I'm pretty much able to do the main frame myself, but since it's quite some work, I would have wanted to know if it's possible before I put all the work in it. Or if you have any other ideas to suggest?

Either way, thanks for all you've done already, as well as for your future insight :)

-----

EDIT, a few hours later:

I will not do it tonight, but I have tought of a way I could make the code work. It would be a whole lot more work, though, but I am fairly certain I can achieve it. So here is:

1) The Dazzle special would be like I said above: change unit hue to white-blue-ish and give the Dazzled ability.

2) Now, I would have to code a whole bunch of different "Dazzled" abilities, say a hundred, to be sure we're never short even if a campaign is made. They are numbered, and each one is assorted with a XDazzled_on_turn and XDazzled_on_side_turn variable (where X is the number matching the Dazzled ability). Each Dazzled ability not only limits CTH like shown above by fog_of_gold, but it also test at each side_turn if XDazzled_on_turn is one less than $turn_number AND X XDazzled_on_side_turn is matching $side_turn. If it does, it removes the ability and the hue, and clears the variables.

3) Now, the variables XDazzled (that's actually the id, the name and description would be the same standard "Dazzled" for every single one) with its two assorted X variables should be given by the Dazzle weapon special. A serie of [if]s would test if a unit with the "1Dazzled" ability exists, if so it test "2Dazzled" and so on, until it finds a free one, applies it and sets the X variables. Hence the importance of having a good amount of Dazzled abilities.

So there, I think that covers it. Lots of code (all the 100 [if]s in the Dazzle weapon special and the 100 Dazzled abilities), but at least I know I can do it, and I think it should work, given that I make no mistake in all those lines. It'll be a lot of copy-paste, so it shouldn,t be so bad. If anyone has a simpler solution code-wise, though, don't hesitate sharing it :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

Ok, double post again, people, mea culpa.

Here are the most recent developments regarding my Dazzle weapon special.

I've started coding it the way I described in my last edit, except for one small detail. I was planning to give the unit an ability which controlled [chance_to_hit]. I realised, however, that [chance_to_hit] is a weapon special tag, and not an ability one! So I decided creating a Dazzled weapon special to limit the chance_to_hit. But I still keep the XXDazzled ability for two reasons:

1) It'll have the code to test the variables and remove the effect.
2) I need it to match the numbered variables, and for the Dazzle weapon special to look for which number is free.

So far, so good. I have run in a few problems, some of which I could fix, some I'm still struggling with. So, the event from the Dazzle weapon special launches top notch on offense as well as on defense. I stored the target in the "todazzle" variable. I know my [if] (see code below) works, since the text in [unstore_unit] shows. Absolutely none of the other effects are applied, however: the ability "00dazzled" is not given, the weapon specials are not given, and the Color Shift is not applied.

Is there a specific order I should respect for such codes (my order may seem weird, but since I'll do this code portion a hundred times, I figured I'd put all the values I'd have to modify at the top, so I lose less time searching)? Are my filters incorrect, or is the problem something else? I know for sure it's not the 00dazzled ability that undoes all this too quick, since I tried removing the code portion that undid it and it the effects weren't applied anyway. The one thing I can think of being wrong is the attack name in the effect tag below the {FOREACH macro, but it doesn't explain why the others effect don't trigger. Even if the weapon special wasn't applied, I'd figure the hue and the ability would still show up anyway?

The code portion isn't too long, about 50 lines maybe.
troublesome code in Dazzle weapon special:
So, thanks for your help, once again :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: Ability related questions

Post by fog_of_gold »

[effect] is only usable within [advancement] and [object]. You'll need xx.variables of a unit you save the turn number in. It's much easier anyway:
Spoiler:
You don't need to ask if the unit was dazzled, just remove it and reset it. Also, you don't need to store the dazzled unit and therefore delete the variable. Just use second_unit. You mustn't/needn't repeat the filter within the effect. Just leave it in the object tag. 'find_vacant=no' is default anyway so you don't need it.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

Hmmm... seems a LOT less complicated then I had envisionned :P Still, a few questions:

- How should I test the turn number so the vanishes? An [event] somewhere, like in the [era] tag? Or should I use a [then] and [removeitem] subtag in that [object]? If so, does the [then] need to be enclosed in a [if]?
- Won't the variables (second_unit.variables.dazzled_turn) be overwritten if more units are dazzled before the effect has ended for that one? Or are they closely associated with the unit? Still, if the verification event is somewhere else, how will the game differenciate between a bunch of "second_unit"s? And if it's not somewhere else, it will only trigger whe the event is launched (ie. when a unit hits another with a Dazzle attack), no? Or is this meant to not actually be in an event?
- Maybe I could just use the "duration=" within the object? Does this support the key "turn" or something like that? It mentions "level", but there's no alternative...
- Also, I'll need some kind of filter to apply this to every attack. I guess I'll stick to my {FOREACH macro, right?

I'm really sorry for all these questions :S The [object] idea is good, but I still have trouble picturing how I'll get this done with about a hundred variables to test the turns. And now I don't know where I'd place my turn testing event anymore :hmm: . Unless I fusion your [object] idea with my previous one, but it's a load of tedious work...

Anyway, thanks for your support, really!

EDIT:

I decided that even if I was not sure how I'd make the effect vanish yet (I thought maybe of an event in the weapon special), I'd at least try to make the object and let it be applied. I'm currently trying with your [object] tag. Ok, maybe the way I wrote the part about applying the weapon special to the attack is dubious, but I figured the color shift whould at least take place! I,ve tried lots of things: with and without the quotes, with filters in each effect, different ways to write a bunch of stuff... I've not figured what doesn't work in this yet. And I know it's not a faulty [if] or an [event] not launching, since the red "dazzled" text from the [unstore_unit] is shown... This is some epic code, damn!

It's longer that way, but jsut so we are clear on how I did the whole thing, I'm supplying you with my entire code, not just with a fraction I suspect might not work.
Another failed attempt at Dazzle:
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
markm
Posts: 158
Joined: August 13th, 2008, 3:53 pm
Location: Halifax Nova Scotia Canada

Re: Ability related questions

Post by markm »

All the descriptions of slow that I have read all seem to agree that the slowed unit loses the slow effect when it ends a turn.

I have even seen suggestions for more-complex schemes, but your complex scheme maybe indicates part of why such schemes have not been accepted. :)

Can you live with a dazzle effect that only lasts as long as slow does? Or do you need it to last some arbitrary number of turns?

If you end it at end of the unit's turn no counting of how many turns it has been is needed. Just make removing it be part of turn end for all units all the time. Maybe no need to even check if is there if removing it is faster than checking first that it is present.

-MarkM-
Developing Between the Worlds campaign portmanteau.
Have you eaten today?
fog_of_gold
Posts: 637
Joined: December 20th, 2009, 5:59 pm
Location: Germany

Re: Ability related questions

Post by fog_of_gold »

Dixie wrote:[...]- How should I test the turn number so the vanishes? An [event] somewhere, like in the [era] tag? Or should I use a [then] and [removeitem] subtag in that [object]? If so, does the [then] need to be enclosed in a [if]?
I'm not sure what you are asking here. I'll answer it the way I understood your question: If you want to remove the effect, use [object], [effect] and remove_specials=dazzled together with apply_to=attack.
Dixie wrote:- Won't the variables (second_unit.variables.dazzled_turn) be overwritten if more units are dazzled before the effect has ended for that one? Or are they closely associated with the unit?
If you unstore xx and set xx.variables.yy=4, then yy is directly bound to the unit xx. You may clear now xx and with it yy. It's also possible to store the unit in aa and aa.variables.yy will instantly be 4.
Dixie wrote:Still, if the verification event is somewhere else, how will the game differenciate between a bunch of "second_unit"s?
There are non bunches of second units so the game haven't to differenciate between them.
Dixie wrote:And if it's not somewhere else, it will only trigger whe the event is launched (ie. when a unit hits another with a Dazzle attack), no? Or is this meant to not actually be in an event?
I'm sure what "it" means, in your first sentence. But hopefully this sentence will answer your question: "second_unit" and other default variables are stored just before they are needed.
Dixie wrote:- Maybe I could just use the "duration=" within the object? Does this support the key "turn" or something like that? It mentions "level", but there's no alternative...
That's possible in Future.
Dixie wrote:- Also, I'll need some kind of filter to apply this to every attack. I guess I'll stick to my {FOREACH macro, right?
Nope. Since [effect] is also the filter, you need to put the stuff of the filter here. And if the filterpart is empty, then there's an empty filter and everything (of this unit) will match the filter.
Dixie wrote:I'm really sorry for all these questions :S
Don't care.
Dixie wrote:The [object] idea is good, but I still have trouble picturing how I'll get this done with about a hundred variables to test the turns. And now I don't know where I'd place my turn testing event anymore :hmm: . Unless I fusion your [object] idea with my previous one, but it's a load of tedious work...[...]
You'll just need an object:

Code: Select all

[object]
  silent=yes
  [filter]
    [filter_wml]
      variables.turn_dazzled=$($turn_number-1)
    [/filter_wml]
  [/filter]
  [effect]
    apply_to=just_redo_everything
  [/effect]
[/object]
And I'm not sure how it makes that much work.
Dixie wrote:I decided that even if I was not sure how I'd make the effect vanish yet (I thought maybe of an event in the weapon special), I'd at least try to make the object and let it be applied. I'm currently trying with your [object] tag. Ok, maybe the way I wrote the part about applying the weapon special to the attack is dubious, but I figured the color shift whould at least take place! I,ve tried lots of things: with and without the quotes, with filters in each effect, different ways to write a bunch of stuff... I've not figured what doesn't work in this yet. And I know it's not a faulty [if] or an [event] not launching, since the red "dazzled" text from the [unstore_unit] is shown... This is some epic code, damn!

It's longer that way, but jsut so we are clear on how I did the whole thing, I'm supplying you with my entire code, not just with a fraction I suspect might not work.
Another failed attempt at Dazzle:
It's better to make a macro instead of an event. It's not just because it's shorter. Also,if you have more than one unit, let's dazzle will be fired more than one time.
Edit:
I founds some of the errors:
1. you may not use {FOREACH} within [object]. It's done automatically anyway.
2. you needn't/mustn't put a special tag within a set_special tag. Just write it in [set_specials]
Post Reply