Ok so... I'd like to give a weapon when fired at an enemy (namely overcharge), a certain % chance of giving over control of the targeted unit instead of damaging it. A sort of mind control, if you will.
I am currently stuck on the piece of code needed to actually do the unit ownership transfer itself.
Basically, I edit OnImpact of the weapon so that I
1. exclude any overpowered categories from any ownership transfer chance whatsoever,
2. Create a 20% initial chance of the event triggering
3. further create a 50:50 chance if the target is an experimental unit
4 ...yeah...now would come the actual transferring of the unit that was hit by the projectile to a new owner.
How would one go about that? Can it even be done directly within the OnImpact (or OnWeaponFired)?
Clearly unit ownership can be transferred. I just need a way to apply that to the current target of a weapon.
Here's my seriously lacking script so far
- Code: Select all
OverCharge = Class(TDFOverchargeWeapon) {
--give us a % chance of mind control of the target instead of damaging it
OnImpact = function(self, TargetType, TargetEntity)
--first let's exclude OP units
if not EntityCategoryContains(categories.COMMAND + categories.BOSS + categories.OMEGA, TargetEntity) then
local mcChance = 1
local mcChance2 = 1
mcChance = math.random(1, 5) --20% chance of success
mcChance2 = math.random(1, 2) --50% chance of success to further reduce getting experimentals
if mcChance == 2 then --we got a winner!!!!!
if EntityCategoryContains(categories.EXPERIMENTAL) then --the target is an experimental, go for the second filter
if mcChance2 == 2 then --we got a winner again!!!
--(target gets mind controlled)
else
TDFOverchargeWeapon.OnImpact(self, TargetType, TargetEntity)
end
else
--(target gets mind controlled)
end
else
TDFOverchargeWeapon.OnImpact(self, TargetType, TargetEntity)
end
else --apply damage as usual
TDFOverchargeWeapon.OnImpact(self, TargetType, TargetEntity)
end
end,
},
If anyone has any clue how to do this OR EVEN BETTER, KNOWS OF A MOD WHERE IT IS ALREADY DONE so I figure it for myself, that would be just epic.