• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Spell] How to create units for a specific player when a unit with specific buff dies

Status
Not open for further replies.
Level 1
Joined
Mar 7, 2019
Messages
2
Hello, I'm asking a question here because I'm struggling with one of my triggers...

Here's the deal: I want to create a zombie unit which, when it attack another unit, transmit a plague which will cause the target unit to raise as a zombie once killed.

I've created a passive spell on the zombie (based on slow poison) which transmit a buff, but now I can't figure how to create a zombie for the owner of the "attacking zombie" when the unit dies.

The real deal is that several players could own zombies and I can't figure how to create a zombie for the owner of the unit who applied the buff...
 
Level 39
Joined
Feb 27, 2007
Messages
5,024
There is no way to get the buff-applier. Instead you will have to save that information when the units gain the buff/take damage/die. Also when units die they don’t have buffs any more so you actually need to intercept the damage with a DDS and check for the buff right before the damage that kills the unit happens. There are multiple ways this could be approached, so the method will depend on:

Is the debuff permanent once applied or does it only last for X seconds? If player 1’s zombie places the debuff on unit A but then player 2’s zombie kills unit A, who gets the new zombie... player 1 or 2?

The simplest thing I can think of is this: make a different version of the slow poison ability for each player that could/does have a zombie. Base it on the non-stacking version. The abilities should be identical except for each has a unique buff (they can look the same just have different raw codes). Then you use a periodic trigger to search the map for units that have any of these buffs and put them in different unit groups depending on which buff they have. Group[1] is for units with the debuff from player 1 zombies, Group[2] is for units with the debuff from player 2 zombies, etc. When you put a unit in a group make sure to remove it from all other groups. Then when a unit dies check if it's in one of those groups and if it is then you know which player should 'get' the new zombie.
 
Level 1
Joined
Mar 7, 2019
Messages
2
Thanks for your answer! It's a good idea indeed, I'm gona try it.
Only one problem remain: The debuff is upgradable and could be temporary or permanent. Your answer works for the permanent kind but how could I remove a specific unit from an unit group after a short time? I could use a variable on the unit, wait, then remove it from the group but this won't work if the pyer attacks several units on a row...

EDIT: I figured it out, rather than creating units group, I create a trigger which set custom value to units attacked by units with specific buff (the passive plague on my zombies) with one specific custom value per player. So I can create trigger with permanent debuff or temporary (by setting "wait" then "set custom value to *basevalue*")

Thank you for your help!
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,024
This will mean you can't use custom value for anything else in your map, and CV is often used for a unit indexer, which is often a requirement for systems you might want to import. Food for thought.

If you do something like <set cv>, <wait>, <set CV to 0> then it will not work correctly. By way of example: if you attack unit a, then wait until just before the buff is about to expire and then attack again... the unit's buff will get removed when the first wait is up even though the second attack should re-apply the buff. A better solution is to actually use a unit group array like I suggested and then loop through the units in the groups to remove any units that don't have any of the debuffs.
 
you could also use parasit beeing casted by an orb ability. Parasit has this on death summon unit feature.

If you want to keep with the poison. The last unit dealing damage beeing able to produce the dot is also the buff placer for duration of buff seconds, although you might also now have to consider dispells and other stuff.


Simpler is the parasit as orb.
 
Status
Not open for further replies.
Top