explosive damage
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.
- hermestrismi
- Posts: 626
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
explosive damage
Hi wesnothians,
after some months awway, it seems that I forget some basics. I want to give a special weapon the ability to attack multiply units (explosion).
I tried both LotI code and the wiki code, they didn't work with me (the LotI code contain parts coded in many .cfg and I didn't find the missing part, as for the wiki it seems outdated for 1.16, I think)
Anyway , this is my try
after some months awway, it seems that I forget some basics. I want to give a special weapon the ability to attack multiply units (explosion).
I tried both LotI code and the wiki code, they didn't work with me (the LotI code contain parts coded in many .cfg and I didn't find the missing part, as for the wiki it seems outdated for 1.16, I think)
Anyway , this is my try
Code: Select all
[event]
name=attacker_hits
first_time_only=no
[filter_weapon]
special_id=area_of_effect
[/filter_weapon]
[harm_unit]
[filter]
[filter_adjacent]
x,y=$x2,$y2
[/filter_adjacent]
[not]
x,y=$x2,$y2
[/not]
[filter_side]
[enemy_of]
side=$unit.side
[/enemy_of]
[/filter_side]
[/filter]
[filter_second]
x,y=$x1,$y1
[/filter_second]
amount=$weapon.damage
damage_type=$weapon.type
fire_event=yes
experience=no
[/harm_unit]
[if]
[variable]
name=damage
greater_than=24
[/variable]
[then]
[harm_unit]
[filter]
[filter_location]
[not]
x,y=$x2,$y2
radius=1
[/not]
[and]
x,y=$x2,$y2
radius=2
[filter_radius]
terrain=!,X*,X*^*,*^X*
[/filter_radius]
[/and]
[/filter_location]
[filter_side]
[enemy_of]
side=$unit.side
[/enemy_of]
[/filter_side]
[/filter]
[filter_second]
x,y=$x1,$y1
[/filter_second]
amount=$($weapon.damage*2)
damage_type=$weapon.type
fire_event=yes
experience=no
animate=no
[/harm_unit]
[/then]
[/if]
[/event]
#define WEAPON_SPECIAL_AREA_OF_EFFECT
[damage]
id=area_of_effect
name= _ "area of effect"
description= _ "When this attack is used, all units adjacent the attacker take the damage, and cannot be countered."
[/damage]
#enddef
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
-
- Posts: 484
- Joined: August 4th, 2019, 5:27 pm
Re: explosive damage
Have you tried LotI code with
[harm_unit_loti]
replace with [harm_unit]
? [harm_unit_loti]
is defined in lua/main.go and needed only for different XP calculation logic. LotI's event for explosive defined here https://github.com/Dugy/Legend_of_the_I ... .cfg#L3841 (and INCORPORATE_EFFECTS defined in the beginning of the same file). You'll need to have this event in every scenario where the special is supposed to workCo-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Re: explosive damage
I would've gone with
harm_unit
as well. Did it work?I don't recall ever seeing a filter like this...
I'm not saying it's wrong, but I don't understand what it does.
Code: Select all
[filter]
[filter_adjacent]
x,y=$x2,$y2
[/filter_adjacent]
[not]
x,y=$x2,$y2
[/not]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- hermestrismi
- Posts: 626
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: explosive damage
It's supposed to exclude the enemy from taking damage twice. Any suggestion to replace is welcomedHelmet wrote: ↑November 23rd, 2022, 4:48 amI would've gone withharm_unit
as well. Did it work?
I don't recall ever seeing a filter like this...
I'm not saying it's wrong, but I don't understand what it does.Code: Select all
[filter] [filter_adjacent] x,y=$x2,$y2 [/filter_adjacent] [not] x,y=$x2,$y2 [/not]
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
- hermestrismi
- Posts: 626
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: explosive damage
I tried it. The problem was that it contains many fragments (dwarftough wrote: ↑November 23rd, 2022, 3:33 am Have you tried LotI code with[harm_unit_loti]
replace with[harm_unit]
?[harm_unit_loti]
is defined in lua/main.go and needed only for different XP calculation logic. LotI's event for explosive defined here https://github.com/Dugy/Legend_of_the_I ... .cfg#L3841 (and INCORPORATE_EFFECTS defined in the beginning of the same file). You'll need to have this event in every scenario where the special is supposed to work
Code: Select all
damage
Code: Select all
resistance
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
-
- Posts: 484
- Joined: August 4th, 2019, 5:27 pm
Re: explosive damage
If you are talking about variables damage and resistance, they are defined in INCORPORATE_EFFECTS macro here https://github.com/Dugy/Legend_of_the_I ... nts.cfg#L3hermestrismi wrote: ↑November 23rd, 2022, 7:22 am I tried it. The problem was that it contains many fragments (,Code: Select all
damage
...) coded elsewhere which means that I need to copy/past a lot of things without any modifications while I want something more simpleCode: Select all
resistance
So I don't quite understand what you need to copypaste about it, just macro and event should be fine, what do I miss?
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Re: explosive damage
Oh, I see. That's a clever solution to the problem. But if the enemy was taking damage twice, another approach might be to stop the repetition of damage problem from happening in the first place. I don't completely understand your code, but I don't see any reason why damage would happen twice.hermestrismi wrote: ↑November 23rd, 2022, 7:18 am It's supposed to exclude the enemy from taking damage twice. Any suggestion to replace is welcomed
I like simpler solutions also.
Here's an idea. Maybe you could create a status called blasted, and assign it to everyone in the blast radius. And then filter for the status, and every unit with the status takes $weapon.damage. And then the blasted status is removed from everyone.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: explosive damage
The enemy takes the normal damage of the attack, and then the damage caused by this event.Helmet wrote: ↑November 23rd, 2022, 1:34 pmOh, I see. That's a clever solution to the problem. But if the enemy was taking damage twice, another approach might be to stop the repetition of damage problem from happening in the first place. I don't completely understand your code, but I don't see any reason why damage would happen twice.hermestrismi wrote: ↑November 23rd, 2022, 7:18 am It's supposed to exclude the enemy from taking damage twice. Any suggestion to replace is welcomed
Re: explosive damage
What parts of your code are working and what parts aren't?
Perhaps break it into 2 specials,
area_of_effect_small
and area_of_effect_big
, and see if the bug reveals itself.Oh, thanks for explaining. The attack is like a barrel of TNT exploding. The target gets damaged once, and then the surrounding units also get damaged.lhybrideur wrote: ↑November 23rd, 2022, 2:37 pm The enemy takes the normal damage of the attack, and then the damage caused by this event.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: explosive damage
[filter_adjacent]
x,y=$x2,$y2
[/filter_adjacent]
[not]
x,y=$x2,$y2
[/not]
I think unit is not adjacent to itself. This check is needed when you are harming additionally around attacker.
x,y=$x2,$y2
[/filter_adjacent]
[not]
x,y=$x2,$y2
[/not]
I think unit is not adjacent to itself. This check is needed when you are harming additionally around attacker.
- hermestrismi
- Posts: 626
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: explosive damage
Hi everybody , I am back
first thing's first, I want to thank alll of you
are coded elsewhere. you can't just copy past it without copying other macro that explain what is [get_unit_resistance] for example
Anyway, this is my final result. I tested it and I hope there is no bugs...
first thing's first, I want to thank alll of you
I meant that some variables likedwarftough wrote: ↑November 23rd, 2022, 11:17 am If you are talking about variables damage and resistance, they are defined in INCORPORATE_EFFECTS macro here https://github.com/Dugy/Legend_of_the_I ... nts.cfg#L3
So I don't quite understand what you need to copypaste about it, just macro and event should be fine, what do I miss?
Code: Select all
{VARIABLE damage $damage_inflicted}
{VARIABLE_OP damage multiply 100}
[get_unit_resistance]
find_in=second_unit
damage_type=$weapon.type
to_variable=resistance
[/get_unit_resistance]
the first part was answered thanks to lhybrideur . As for the second, I followed your suggestions and it worked. thank you.Helmet wrote: ↑November 23rd, 2022, 1:34 pm Oh, I see. That's a clever solution to the problem. But if the enemy was taking damage twice, another approach might be to stop the repetition of damage problem from happening in the first place. I don't completely understand your code, but I don't see any reason why damage would happen twice.
I like simpler solutions also.
Here's an idea. Maybe you could create a status called blasted, and assign it to everyone in the blast radius. And then filter for the status, and every unit with the status takes $weapon.damage. And then the blasted status is removed from everyone.
Exactly. An area of damage that make any other special attack (not only the damage quantity but also poison, slow, ...) explode.lhybrideur wrote: ↑November 23rd, 2022, 2:37 pm The enemy takes the normal damage of the attack, and then the damage caused by this event.
exactly, the attack hit the enemy then anyone around him then anyone within radius=2. without the exempt, the original enemy will be damaged twice because he is adjacent to another unit who will pass the damage.
Anyway, this is my final result. I tested it and I hope there is no bugs...
Code: Select all
#define WEAPON_SPECIAL_AREA_OF_EFFECT
[damage]
id=area_of_effect
name= _ "area of effect"
description= _ "When this attack is used, all units adjacent the attacker take the damage, and cannot be countered."
active_on=offense
apply_to=self
[/damage]
#enddef
[event]
name=attacker_hits
first_time_only=no
[filter_attacker]
special_id=area_of_effect
[/filter_attacker]
[harm_unit]
[filter]
[filter_adjacent]
x,y=$x2,$y2
[/filter_adjacent]
[not]
x,y=$x2,$y2
[/not]
[filter_side]
[enemy_of]
side=$unit.side
[/enemy_of]
[/filter_side]
[/filter]
[filter_second]
x,y=$x1,$y1
[/filter_second]
amount=$weapon.damage
damage_type=$weapon.type
fire_event=yes
experience=no
[/harm_unit]
[if]
[variable]
name=weapon.damage
greater_than=12
[/variable]
[then]
[harm_unit]
[filter]
[filter_location]
[not]
x,y=$x2,$y2
radius=1
[/not]
[and]
x,y=$x2,$y2
radius=2
[filter_radius]
terrain_type=!,X*,X*^*,*^X*
[/filter_radius]
[/and]
[/filter_location]
[filter_side]
[enemy_of]
side=$unit.side
[/enemy_of]
[/filter_side]
[/filter]
[filter_second]
x,y=$x1,$y1
[/filter_second]
amount=$($weapon.damage/2)
damage_type=$weapon.type
fire_event=yes
experience=no
animate=no
[/harm_unit]
[/then]
[/if]
[/event]
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin