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
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Dixie's Thread

Post by Dixie »

* This post was edited to show all the resolved ability codes achieved in this thread. Hoe it helps someone! *

You can find all these codes in Internet Meme Era for reference, if need be! :)

Grape Shot

This code is intended to give an attack splash damage. All adjacent units of the target will receive X damage (in this particular code, it's set to 10)
Grape Shot:

Buster

This weapon special is intended to give 90% CTH against a target sitting on a village, but 10% CTH everywhere else.
Buster:

Bulldoze

This ability lets a unit modify terrain. When it sits on forests or hills, it will turn them to dirt. Same goes with a variety of others.
Bulldoze:

Relentless

This weapon special is intended for drill-type weapons. Once a strike hits, all remaining strikes are ensured 100% CTH.
Relentless:

Fueling

This ability kinda works like feeding: when the main unit kills a target, its melee attack's damage increases by 1.
Fueling:
PS: Silly me, I just found out it was already existing in WML Abilities as "Soul Taker"!


Smog Spill

This ability triggers upon the death of the unit. When it dies, it will poison all surrounding units.
Correct code for Smog Spill:

Extract

These are actually three abilities, which let you generate gold per turn. Lv1 generates 1, Lv2 genereates 2, and Lv3 generates 3.
Extract, Lv1 through Lv3:

Dazzle

This is a new status effect, which limits the target's CTH to 50% and vanishes after a turn (or at level up) much like slow does.
Complete, working code for Dazzle:
Last edited by Dixie on August 31st, 2010, 3:23 pm, edited 14 times in total.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: Grenade ability

Post by zengetsu88 »

If I understand the code... you are wanting to damage any units that surround the unit your are attacking... or any unit surrounding the unit you are using TO attack with...

this code is extremely overcomplicated to me... I have been working on a similar ability that attacks any unit within a given radius around my units.... It uses the same principal...

if you want to negate defense on any of the characters and you want it to attack the units surrounding your unit try this....

weapon special

Code: Select all

#define WEAPON_SPECIAL_GRENADE
   [damage]
      id=grenade
      name= _ "grenade"
      name_inactive= _ "grenade"
       description= _ "Grenade: When this attack is used, all units adjacent to a target get damage. Does not work on defense."
      description_inactive= _ "Grenade: When this attack is used, all units adjacent to a target get damage. Does not work on defense."
    [/damage]
#enddef

now put this event on your unit that you want to have this ability....

Code: Select all

[event]
    name=attacker_hits
    first_time_only=no
   
    [filter_attack]
        special=grenade
    [/filter_attack]
   
    [store_unit]
        [filter]
            [filter_adjacent]
                x,y=$x2,$y2
                is_enemy=yes
                [not]
                    x,y=$x1,$y1
                [/not]
            [/filter_adjacent]
        [/filter]
       
        variable=units
    [/store_unit]
   
    [store_unit]
        [filter]
            x,y=$x1,$y1
        [/filter]
       
        variable=self
    [/store_unit]

    {FOREACH units i}
        {VARIABLE_OP units[$i].hitpoints add -10}
# you can change the damage to whatever you want it to be
            [if]
                [variable]
                    name=units[$i].hitpoints
                    less_than=1
                [/variable]
                [then]
                    [kill]
                        x,y=$units[$i].x,$units[$i].y
                    [/kill]     
                    {VARIABLE_OP self.experience add 4}
                [/then]
                [else]
                    {VARIABLE_OP units[$i].experience add 1}
                    [unstore_unit]
                        variable=units[$i]
                        find_vacant=no
                        text= _ "10"
                        {COLOR_HARM}
                    [/unstore_unit]
                [/else]
            [/if]
    {NEXT i}
   
        [unstore_unit]
            variable=self
            find_vacant=no
        [/unstore_unit]

    {CLEAR_VARIABLE units}
    {CLEAR_VARIABLE self}
[/event]
try playing with that... I don't know if that is what your were trying to do...
I am currently looking at how to expand this by making the damage done a range of damages... and I am trying to get it to include the defense of every unit attacked...
If you are interested in that then take a look at my forum topic Attack surrounding units...
I've hit a speed bump right now but once it is finished the entire code should be posted...

If this is what you were looking for good luck... if not sry... that's the best I can do to help you... I'm a newb as well :(
my logic is sound
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Grenade ability

Post by Dixie »

It's not EXACTLY what I was looking for (I wanted a splash damage around the unit I am attacking, regardless of being allied or not), but I think I might be able to toy with your code and make something out of it.

Well thanks anyway, I'll give you some news once I take the time to work something out! :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: Grenade ability

Post by zengetsu88 »

if you want it to be ally or not just take out the is_enemy clause
my logic is sound
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Grenade ability

Post by Dixie »

Well I had less manipulation to do to make it work. Thanks a lot!

There's still an issue. The damage splashes around the target alright, but even if it doesn't affect the attacking unit (the one who has the special), it still displays the red "10" above its head, as if it had been damaged. Even though it hadn't. I must admit I'm not sure I understand why the display occurs even if the damage is not applied. I would have expected the display to go along with the damage...

Here the actual code:
Spoiler:
I'll tell you if I find anything. Thanks! :)
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: Grenade ability

Post by fog_of_gold »

Put your [not] tag in the first [store_unit] in [filter], not in [filter_adjacent] since it'll just give a ever-true condition: It just ask, if the target isn't the unit which attacked. Also, don't forget to put 'defense_weight=0' between [/specials] and [/attack] so this attack won't be used in defense. This part (see below) won't work correctly, too since the [then] tag don't know the variables 'text' and 'color'. remove these two keys and put instead the [unstore_unit] tag of [else] directly after the {VARIABLE_OP} macro:
Spoiler:
You don't need the [store_unit] with 'self'. Instead, use 'unit' and 'second_unit' because they are stored automatical.
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: Grenade ability

Post by Gambit »

I suppose this calls the macro. If I understand correctly, the first numbers (2,5,6,4,1,0) refer to the hexes, and the second number is the damage. Is there a reason why the hexes number are in that order? Why isn't there a 3?
Dunno if this was mentioned yet, but in the way wesnoth stores things, 3 is the middle hex (when storing radius 1).

It goes top to bottom, then left to right.
storage.jpg
storage.jpg (7.07 KiB) Viewed 5094 times
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Grenade ability

Post by Dixie »

Hey thanks a lot, fog_of_gold! Everything works perfectly! Thanks to zengetsu88 again for the main part of the code. And to Gambits, even though I didn't need to info anymore, it's still good to know, if I ever use that command in the future :)

Here's the final code:
Spoiler:
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: Grenade ability [fixed]

Post by zengetsu88 »

not a problem...
my logic is sound
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

I edited my old "grenade" topic to change its title and use it again for some other ability-related questions. No use in spamming new threads for every ability difficulty I encounter, right?

Well I come here today with three main questions.

1) Works ability

I renamed it "Scavenge". The original code can be found here: http://wiki.wesnoth.org/WML_Abilities#Works
It had a problem, though. It would give gold only at side X turn, but would show the yellow "1" over every unit at the start of every side's turn. Also, it worked only for one unit type, so I would need an ability macro for each unit type I intend on giving it to. Seems bothersome to me. I tried playing with the "name" line of the event, but the most useful looking "name" (something like "side X turn") was said to be development only. I tried some other stuff anyway, but now the ability just doesn't work. Here's the actual code:
Spoiler:
2) Buster weapon special

Well I guess this one must be quite simple. It should basically be a variant of Marksman, which gives the unit a 90% cth for a target on a village, or else a 10% cth. Doesn't work, though my [if] tags look fine. Do they work only in [event] tags? What do you recommend? Here's the code:
Spoiler:
3) Pickpocket weapon special

This one can also be found on the WML Abilities page. I didn't edit it much, appart from changing its name to loot and correcting a minor issue: the description said it stole 1 gold, but the code actually said 2, or something like that. Anyway, there are still some issues with it. First, it doesn't "steal" gold, it only adds to the attacker. The victim's side doesn't actually lose any gold, which seems like a bother to me. I guess I could fix that with some ease if I just added some variable command or something, but I haven't looked into it much yet. Second, this ability works only on attack, and for anyone attacking said unit. Say U1 has pickpocket. If it attacks U2, it earns gold to his side. But if U2 attacks U1 on his turn, U2 is gonna get the gold! Seems like a problem too!...

Oh, I just noticed: I did like I did for the knockback/retreat abilities discussed elsewhere: I doubled the code to make it work on defense too. Maybe the problem is coming from there?

Here's the code:
Spoiler:
Thanks everyone!
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Ability related questions

Post by zookeeper »

Dixie wrote:

Code: Select all

	name=$side_number turn
Variable substitution doesn't work there. Just use "side turn" and an [if].
Dixie wrote:

Code: Select all

#define WEAPON_SPECIAL_BUSTER
    [chance_to_hit]
        id=buster
        name= _ "buster"
        description= _ "Buster:
If this attack's target is on a village, it will always have a 90% chance to hit. If the target is not on a village, it will never have more then a 10% chance to hit."

[if]
Which part of AbilitiesWML said that you can put an [if] in a [chance_to_hit]? None, so that's why it doesn't work.
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:[...]2) Buster weapon special

Well I guess this one must be quite simple. It should basically be a variant of Marksman, which gives the unit a 90% cth for a target on a village, or else a 10% cth. Doesn't work, though my [if] tags look fine. Do they work only in [event] tags? What do you recommend? Here's the code:
Spoiler:
[...]
like zookeeper said, you mustn't use [if]. Just remove [if], [have_unit] and [then], create two abilities and do some other changes:
Spoiler:
BTW, you mustn't use [second_unit] in [have_unit].

About the pickpocket, instead of $side_number use $unit.side and $second_unit.side. If you want to make it really steal, double the [gold] tag and change $unit.side into $second_unit.side and the other way arround. Also, change '1' to '-1'.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Ability related questions

Post by Dixie »

Hey thanks guys, everything works! :)

Here are the codes, just in case it interests anyone:

Buster
Spoiler:
Scavenge
Spoiler:
Steal
Spoiler:
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 »

I don't know if it's intentional, but the floating text of the stealing special will show an '!' instead of a '1'.
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: Ability related questions

Post by zengetsu88 »

It would be nice to see if you could make the steal ability a larger or variable amount of gold, and make it a chance that it is stolen...
my logic is sound
Post Reply