Forged Alliance Forever Forged Alliance Forever Forums 2019-11-09T23:08:44+02:00 /feed.php?f=41&t=18350 2019-11-09T23:08:44+02:00 2019-11-09T23:08:44+02:00 /viewtopic.php?t=18350&p=179560#p179560 <![CDATA[Re: Mind control/hacker weapon]]> Here's the deal, curtesy of Exotic_Retard

First import the function with
local TransferUnitsOwnership = import('/lua/SimUtils.lua').TransferUnitsOwnership

Then call it in an event (be it OnFire, OnGotTarget, or in a projectile script with the OnImpact). Imma make it as a small % chance for each Overcharge fire, as well as an aura around my hero unit with a small chance of success on random units inside the aura range.

Here's a simple example how a weapon's script would be the one to handle it, when the weapon hits

Code:
OnImpact = function(self, targetType, targetEntity)
        if targetType == 'Unit' then
            TransferUnitsOwnership({targetEntity}, self:GetArmy(), true)
            self:Destroy()
        else
            --OverchargeProjectile.OnImpact(self, targetType, targetEntity)
            APRoundCap.OnImpact(self, targetType, targetEntity)
        end
    end,


OFC, you can code all sorts of conditions and restrictions here, to not make it a 100% chance on everything.
A big THANK YOU to Exotic_Retard

Statistics: Posted by DDDX — 09 Nov 2019, 23:08


]]>
2019-11-09T17:57:26+02:00 2019-11-09T17:57:26+02:00 /viewtopic.php?t=18350&p=179547#p179547 <![CDATA[Re: Mind control/hacker weapon]]> https://discord.gg/eV3wmAX

Statistics: Posted by Exotic_Retard — 09 Nov 2019, 17:57


]]>
2019-11-05T21:42:57+02:00 2019-11-05T21:42:57+02:00 /viewtopic.php?t=18350&p=179439#p179439 <![CDATA[Re: Mind control/hacker weapon]]> I'd think there'd be a lot of use for such a weapon, in many mods...I can already see ACU upgrades, turrets, sniper bots, even Aeon equivalent Fire beetles with such a weaponized ability...

Statistics: Posted by DDDX — 05 Nov 2019, 21:42


]]>
2019-11-03T17:23:08+02:00 2019-11-03T17:23:08+02:00 /viewtopic.php?t=18350&p=179411#p179411 <![CDATA[Re: Mind control/hacker weapon]]> Back to the scripts we know then :p

So, I got the TransferUnitsOwnership function here
https://github.com/FAForever/fa/blob/775b4b00ec0474dc112537c9938c081e0810cb3c/lua/SimUtils.lua#L59%20BTW

Anyone willing to give me a hand on how to make it trigger for the current target of a weapon, so that the projectile converts it under my control?

Statistics: Posted by DDDX — 03 Nov 2019, 17:23


]]>
2019-11-03T00:47:29+02:00 2019-11-03T00:47:29+02:00 /viewtopic.php?t=18350&p=179401#p179401 <![CDATA[Re: Mind control/hacker weapon]]> Yeah that's what I was hoping for.
I have found the appropriate code that handles unit gifting, but am too noob in coding to transmute it into something that triggers within a weapon fire.

For example, as far as I can tel OnImpact is a dud - does nothing for the weapon itself, but is there only in a projectile script, not weapon blueprint.

So i can either hook the OnFire function of the weapon itself, or the OnImpact of the projectile to mind control.

But again, that's the least of my concerns and not hard to do - once I have the main problem solved - actual "TransferUnitsOwnership" working with a weapon...

One way comes to mind - the Loyalty gun from SupCom2. It is a long range point defence that does exactly what i need - perhaps there's something there I can use, or at least to fighure out how it's done.

Statistics: Posted by DDDX — 03 Nov 2019, 00:47


]]>
2019-11-02T06:11:37+02:00 2019-11-02T06:11:37+02:00 /viewtopic.php?t=18350&p=179384#p179384 <![CDATA[Re: Mind control/hacker weapon]]> Statistics: Posted by nine2 — 02 Nov 2019, 06:11


]]>
2019-11-02T01:23:01+02:00 2019-11-02T01:23:01+02:00 /viewtopic.php?t=18350&p=179369#p179369 <![CDATA[Mind control/hacker weapon]]>
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:

        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.

Statistics: Posted by DDDX — 02 Nov 2019, 01:23


]]>