Sorry to bombard the forums with requests, but I have a data (I hope) specific request that is somewhat different from my "power" system that I asked for direction on in the Melee section.
One thing I'd love to be able to do is to have units die, and then after a countdown (currently thinking 3 or 5 minutes) turn into Minerals worth 75% of the cost of the unit.
Specifically, here's the process I want to implement for any unit.
the unit dies (if an air unit, it would have to die over normal terrain - if traveling over impassable terrain it would not generate a wreck)
the unit turns into a "burning wreck" with hit points equal to 75% of the Mineral cost of the unit. I'm OK with this using the same model as the initial unit with a fire effect going off on top of it - in fact, I think I prefer that
this burning wreck persists for X (thinking 3 or 5) minutes and then turns into minerals
if the burning wreck is destroyed before its timer runs out, it will disappear per normal for units
the value of the mineral deposit created is the amount of remaining HP the burning wreck had (thus if the wreck were to take damage the resulting minerals deposit would have a lower value)
This would effectively create timed mineral fields in areas where battles happen, without worrying too much about players killing a bunch of cheap units to block players in with mineral fields (since the burning wreck can be killed)
I'm hoping all of this can be done with Data, as Triggers thus far elude me >.>
The point-to-point transfer will be the hardest part I think.
Units have their own "death response" fields which you can use, or set a Buff with a Damage Response. Tick the "Fatal" flag in the latter case.
You have to create individual wreck units for each potential mineral cost, or at least Modify Unit effects to hardcode the HP. Triggers would probably be more elegant here. Graphics design again has to be per-unit unless you use a generic wreckage model and merely scale its hp.
Buff or Persistent effect with that duration, Morph ability or Create Unit effect for the conversion.
"Not Dead" validator if necessary, buffs vanish automatically if their host unit dies.
Probably best done via trigger, but a Persistent with period duration 0, period count higher than any HP value in your map should work, make it apply a Set effect that deals 1 damage to the wreck and gives 1 resource unit to the created deposit (Modify Unit effects or so can modify resource amounts, check how the Auto-Refinery does it)
OK, so I've got this almost complete, thanks to TheUltragon. When the unit dies, a buff is applied that sets its HP to 75% of that of the original unit, has 1 charge, and increases armor by 10 while disallowing movement or abilities. When the buff duration ends, the unit turns into a mineral field.
What I'm still missing is:
I'd like the unit to provide 0 population cap while it's got this buff applied. I don't see a simple way to set the unit's population impact to 0 (though there is an option to modify the population impact of the unit), but perhaps it could change the ownership of the unit to Player 0? Unsure how do do this.
I'd like to have the resulting mineral field to have the same Current health as the unit which spawned it. The current implementation of this is a Kill Effect and a Spawn Unit effect, though I'm happy to change this.
Buffs and Modify Unit effects can change ownership, and you can select the predefined players "Neutral" or "Hostile" from the list. I know that for Modify Unit effects you have to explicitely tick the "Change Ownership" flag or it won't work. Not sure if you can maintain the original team color without case-to-case actor edits, if that is desired. Then again I could swear there was a flag to set the population impact to 0, go through all the mind control abilities from the campaigns, maybe one of them has it.
The point-to-point transfer is fairly easy if you can get both units into the same scope: run a 0 period Persistent effect that drains one point from the sender and gives one point to the receiver, with a validator to check if the sender has any points left. In this case check for the unit wreckage having 1hp, then execute a different effect (Switch or Persistent:Effect-Final field) that gives a final point to the receiver and kills the sender. You could even change the "give" effect to a Modify Unit to actually grant minerals I believe.
I have a separate system that sets the minerals value of any unit with a specific behavior to the hitpoints of that unit... Hmm... maybe I can just grant the unit the Scrap behavior at the end of the effect. Then it'd just... turn into resources. I'm going to try this. Thanks!
So, it turns out adding the resource behavior to a non-resource unit doesn't seem to do anything (unless I'm doing it wrong) and I can't seem to add a resource value to a unit (again, unless I'm doing something wrong) so we're back to creating a new unit and giving it all of the original unit's health.
Photoloss, you said something about getting both units in the same scope... would you mind explaining this, or any mechanism I'd use to select the source of the unit creating the effect and the unit created by the effect, and how to transfer health from one to the other? I tried the Leech Fraction effect but it didn't seem to do anything
A scope is defined by an effect tree, so you basically need one unit to cast an effect on the other. For non-unique units, especially when massed, this isn't really feasible, but thankfully certain unit-creating effects (Create Unit, Launch Missile, Transport/Magazine abilities etc.) have fields you can use to apply an effect to the newly-spawned unit. For your concrete setup this means you must cast whatever creates the mineral field directly from the wreckage.
You specify the target units via the various "Target+" or "Location+" fields on each effect. You can also specify an effect from which to draw these unit references from, but the scope effect must lie in the past of the current effect, hence the above restriction: You can make the Mutalisk weapon's second bounce apply a debuff to the first target, but you can't make the first strike "pre-load" a debuff onto the last target directly.
For the point transfer use a Damage or Modify Unit effect to reduce wreckage HP, and a Modify Unit effect to increase mineral HP/resource count. For point-to-point transfer the chain probably has to be Create Unit(Mineral Field)->"Create Effect": Persistent(Period 0, Period Count higher than any HP number)->Set->Damage/Modify effects. Plus a few validators to check when HP run out, and if using Modify Unit instead of Damage on the wreckage, to handle shield points properly. For your scopes you can probably use Persistent.Caster for the wreckage and Persistent.Target for the mineral field.
To check your chosen scope, make the effect create the Psi Storm persistent e.g. replace the Modify Unit with a Set, then add the Psi Storm to that. Provides a nice blue cloud on whatever is the focus of the scope.
Ok so... I've basically copied the Viper Consumption ability and applied it to the new Mineral patch upon creation. It kills the origin unit (the unit it was spawned from) but its HP remains at... 1, regardless of the life points that are supposedly being leeched by the effect.
Consumption most likely applies the "heal" portion to the Source or Caster unit, both of which would the the wreckage if you followed my directions. It also restores energy, not life, in case you forgot to change that.