[solved]modified Plague questions
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.
[solved]modified Plague questions
Hi, I'm working on making a special kind of plague. I'm having a hard time trouble shooting vairous aspects of it because it works sometimes but not others and I can't find any predictable pattern of when it works and when it doesn't.
I'm having a couple problems with it:
1) It is a basic unit with 1 hit point, it is supposed to get its hit points increased by the unit who created its hit points divided by 6. The first event in the spoiler is what controls this. This works MOST of the time, but every once in a while I get a unit that has 0/1 hit point.
2) The leveled up versions of it(plagued 2 and 3) are supposed to have various effects, controlled by the second two events in the spoiler. Plagued2 is supposed to explode when it dies, damaging adjacent enemies. Plagued3 is supposed to do the same as well as heal adjacent allies.These work every once in a while and sometimes the plagued unit respawns.
Any help or hints for fixing this would be greatly appreciated
I am using the built in plague here: {WEAPON_SPECIAL_PLAGUE_TYPE plagued1}
I'm having a couple problems with it:
1) It is a basic unit with 1 hit point, it is supposed to get its hit points increased by the unit who created its hit points divided by 6. The first event in the spoiler is what controls this. This works MOST of the time, but every once in a while I get a unit that has 0/1 hit point.
2) The leveled up versions of it(plagued 2 and 3) are supposed to have various effects, controlled by the second two events in the spoiler. Plagued2 is supposed to explode when it dies, damaging adjacent enemies. Plagued3 is supposed to do the same as well as heal adjacent allies.These work every once in a while and sometimes the plagued unit respawns.
Any help or hints for fixing this would be greatly appreciated
I am using the built in plague here: {WEAPON_SPECIAL_PLAGUE_TYPE plagued1}
Spoiler:
Last edited by Rodil on September 10th, 2019, 5:29 am, edited 2 times in total.
Re: modified Plague questions
First store_unit may match multiple units. It is possible that if plaguer is array, then plaguer.attribute is empty. During developing it is better to not clear variable and inspect it instead.
Unit placed is allowed to fire multiple times for many different reasons. If event has issue with that, it should keep track of for which units it has already fired.
General hint - add message inside event showing event name/id and possibly some other values.
Unit placed is allowed to fire multiple times for many different reasons. If event has issue with that, it should keep track of for which units it has already fired.
General hint - add message inside event showing event name/id and possibly some other values.
Re: modified Plague questions
1) I did not test your code, I'm just looking at it, but I think your filters are not precise enough. In the unit placed event, if the
Here's how it becomes an array: what if multiple units with this special plague are standing adjacent to the killed unit? The code won't know which killed it. Then it is an array. I'd modify the code to store the attacker unit during the attack:
See if this works.
2) Again, I think your filters in
The same filter is needed inside [heal_unit]. Hope this helps.
store_unit
finds multiple units, and it will do that, I'll explain soon, than indeed array.attribute is (I think) array[0].attribute, which is the dead unit which has 0 HP. That would explain your error. Here's how it becomes an array: what if multiple units with this special plague are standing adjacent to the killed unit? The code won't know which killed it. Then it is an array. I'd modify the code to store the attacker unit during the attack:
Code: Select all
# Note, I did not test the code.
[event]
name=attack end
[filter_attack]
special=plague # you should also give the special plague another id, to avoid collisions with the stock plague attack.
[/filter_attack]
# you should also do this for filter_second_attack for defence, it's very similar
# if the attacked unit died
[if]
[variable]
name=second_unit.hitpoints
less_than=1
[/variable]
[then]
{VARIABLE plaguer $unit} # save the unit
[/then]
[/if]
[/event]
[event]
name=unit_placed
first_time_only=no
[filter]
type=plagued1, plagued2, plagued3
[/filter]
# ideally you should check here if $plaguer is not a non-existent variable.
# If this special plague is the only way these units spawn though, then it's not necessary.
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
max_hitpoints="$($plaguer.max_hitpoints/6)"
hitpoints="$($plaguer.max_hitpoints/6)"
[/modify_unit]
{CLEAR_VARIABLE plaguer}
[/event]
2) Again, I think your filters in
harm_unit
are not precise, and you store units you don't want to. [filter_adjacent] doesn't work like this, you need [filter_location] with radius.
Code: Select all
[harm_unit]
[filter]
######## changes in here:
[filter_side] # must be an enemy
[enemy_of]
side=$unit.side
[/enemy_of]
[/filter_side]
[not] # don't store the unit itself
x,y=$x1,$y1
[/not]
[filter_location] # store adjacent units
x,y=$x1,$y1
radius=1
[/filter_location]
#########
[/filter]
amount=$temp
animate=no
[/harm_unit]
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: modified Plague questions
Thank you both! I got the first part working correctly, White wolf was correct in that my filters were messed up and with Ravana's advice of adding messages in the events I was able to stumble my way through it! Now on to working on the second part of the problem. The second problem seems to have been fixed with a direct copy of Whitewolfs code, thanks again.
I really need to work on figuring out how to correctly manipulate those filters.
For those that are interested here is my final result:
I wanted to keep the array after thinking about it and let multiple 'necromancers' increase the hit point total of the created unit.
I really need to work on figuring out how to correctly manipulate those filters.
For those that are interested here is my final result:
Code: Select all
[event]
name=unit_placed
first_time_only=no
[filter]
type=plagued1, plagued2, plagued3
[/filter]
[store_unit]
[filter]
[filter_location]
x,y=$x1,$y1
radius=1
[/filter_location]
side=$unit.side
[has_attack]
special=plague
[/has_attack]
[/filter]
variable=plaguer
kill=no
[/store_unit]
{VARIABLE temp 0}
{FOREACH plaguer i}
{VARIABLE_OP temp add $plaguer[$i].max_hitpoints}
{NEXT i}
{VARIABLE_OP temp divide 6}
[modify_unit]
[filter]
x,y=$x1,$y1
[/filter]
max_hitpoints=$temp
hitpoints=$temp
[/modify_unit]
{CLEAR_VARIABLE plaguer}
[/event]
[event]
name=die
first_time_only=no
[filter]
type=plagued2,plagued3
[/filter]
{VARIABLE temp $unit.max_hitpoints}
{VARIABLE_OP temp divide 2}
[harm_unit]
[filter]
[filter_side]
[enemy_of]
side=$unit.side
[/enemy_of]
[/filter_side]
[not]
x,y=$x1,$y1
[/not]
[filter_location]
x,y=$x1,$y1
radius=1
[/filter_location]
[/filter]
amount=$temp
animate=no
[/harm_unit]
[/event]
[event]
name=die
first_time_only=no
[filter]
type=plagued3
[/filter]
{VARIABLE temp $unit.max_hitpoints}
{VARIABLE_OP temp divide 2}
[heal_unit]
[filter]
[filter_location]
x,y=$x1,$y1
radius=1
[/filter_location]
side=$unit.side
[not]
x,y=$x1,$y1
[/not]
[/filter]
amount=$temp
animate=no
restore_statuses=no
[/heal_unit]
[/event]
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [solved]modified Plague questions
Just to be clear,
[filter_adjacent
means "some adjacent units must match this filter", while [filter_location]
means "unit matches if it's on one of these locations that match the filter".