Custom attack special doesn't do anything

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
Anagkai
Posts: 58
Joined: February 12th, 2012, 10:05 am

Custom attack special doesn't do anything

Post by Anagkai »

My attack special is supposed to increase damage by one for every adjacent unit with the same attack special. It doesn't seem to work, though. Any help is appreciated. This is my code:

Code: Select all

#define WEAPON_SPECIAL_STATE_ATTACK
    [damage]
        id=agk_state_attack
        name= _ "State Attack"
        description= _ ""
    [/damage]
    [damage]
        add=1
        cumulative=yes
        affect_self=yes
        [filter_adjacent]
			[has_attack]
				special=agk_state_attack
			[/has_attack]
        [/filter_adjacent]
    [/damage]
#enddef
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
User avatar
Ravana
Forum Moderator
Posts: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Custom attack special doesn't do anything

Post by Ravana »

Last I tried there was not nice way to do it. https://github.com/ProditorMagnus/Agele ... ouping.cfg
gfgtdf
Developer
Posts: 1431
Joined: February 10th, 2013, 2:25 pm

Re: Custom attack special doesn't do anything

Post by gfgtdf »

you can count the mumber of adjacent unit with that weapon special with a formula

Code: Select all

	[damage]
		cumulative=yes
		add = "(size(filter(filter(locations_in_radius(loc, 1), 'loc', unit_at(loc) != null()), 'loc', size(filter(unit_at(loc).attacks, 'att', size(filter(att.specials, 'sp', sp = 'agk_state_attack')) > 0 )) > 0)))"
	[/damage]
note that this counts within all units that have a distance of at most one to the unit, in particular the unit itself, also it doesnt make a differnt between allied and enemy units.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Celtic_Minstrel
Developer
Posts: 2158
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom attack special doesn't do anything

Post by Celtic_Minstrel »

gfgtdf wrote: September 21st, 2018, 4:48 pm you can count the mumber of adjacent unit with that weapon special with a formula

Code: Select all

	[damage]
		cumulative=yes
		add = "(size(filter(filter(locations_in_radius(loc, 1), 'loc', unit_at(loc) != null()), 'loc', size(filter(unit_at(loc).attacks, 'att', size(filter(att.specials, 'sp', sp = 'agk_state_attack')) > 0 )) > 0)))"
	[/damage]
note that this counts within all units that have a distance of at most one to the unit, in particular the unit itself, also it doesnt make a differnt between allied and enemy units.
For some reason I just felt like reformatting your formula, because it's so long and confusing like that...

Code: Select all

	[damage]
		cumulative=yes
		add = "(
			def count_specials_by_id(unit*, id)
				size(specials)
				where specials = filter(attacks, size(
					filter(specials, 'spec', spec = id)
				) > 0);
			def adjacent_occupied_locs(loc)
				filter(
					adjacent_locs(loc),
					'loc',
					unit_at(loc) != null()
				);
			size(matching_units)
			where matching_units = filter(
				adjacent_occupied_locs(loc),
				'loc',
				count_specials_by_id(unit_at(loc), 'agk_state_attack') > 0
				# If you want allies only you can add an additional condition here, something like:
				and not is_enemy(unit_at(loc).side, side)
				#
			)
		)"
	[/damage]
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply