Overcharge stun on projectile

Everything about mods can be found here.

Moderator: Morax

Overcharge stun on projectile

Postby DDDX » 04 Jun 2019, 21:42

Hey guys.

Quick question.

The goal is to make an enhancement that gives the Overcharge weapon stun, that it previously did not have without that enhancement.

Now, I know how to make enhancements, I know how to piggy-back an EMP weapon on another beam weapon (like the Manticore t3 Cybran turret from Blackops does)
The problem comes when I try to do the same, but on a projectile weapon, not beam weapon.
So, my projectile weapon (Overcharge) needs to start with no stun, but gain a stun with an enhancement, while still remaining an overcharge weapon.
From what i can tell, the problem lies here
Code: Select all
OnWeaponFired = function(self)    --the weapon is Overcharge, projectile
                LOG("----- Overcharge fired...");
                local wep = self.unit:GetWeaponByLabel('laser1emp')  --this is my dummy weapon, taken from the Manticore Blackops Unleashed turret, it does the stunns
                self.targetaquired = self:GetCurrentTargetPos()
                LOG("----- Overcharge target defined...");
                if self.targetaquired then      -----------THIS!!! This is where it fails.
                LOG("----- if Overcharge target defined then...");
                    if self:HasEnhancement('RailGun3') then
                        LOG("----- Overcharge we got enhancement...");
                       wep:SetTargetGround(self.targetaquired)
                        LOG("----- Overcharge settargetground done...");
                        self:SetWeaponEnabledByLabel('laser1emp', true)
                        LOG("----- Overcharge emp enabled...");
                        wep:SetTargetGround(self.targetaquired)
                        LOG("----- Overcharge emp target set...");
                        wep:OnFire()
                        LOG("----- Overcharge emp fired...");

                self:OnDisableWeapon()
                self:ForkThread(self.PauseOvercharge)
                SDFHeavyQuarnonCannon.OnWeaponFired(self)
            end,


in the "if self.targetaquired then" part, the thing stops. As if a projectile loses its target when it fires?
The same code works on beams (i have enhancements that give me beams, and further enhancements that piggyback an emp invisible projectile onto that beam to make it stun...I know how to do that).

Some of the steps I tried:

-make 2 overcharge-class weapons, the second one with a stun buff, have one enabled one disabled, switch between them with enhancements (does not work, the game only recognizes the first overcharge-class weapon)

-giving a stun order directly in the OnWeaponFired of the Overcharge weapon
local Stunns = self:GetCurrentTargetPos()
Stunns:SetStunned(7, self) --game did not know what SetStunned was

Steps to try - maybe a code that lets me have stun on overcharge right from the start, but DISABLES the buff of the weapon, till i enable it with an enhancement? What would that command be?

perhaps a function that triggers every time the OC weapon fires, borrows its current target and forces fire the emp weapon on the same target as the OC weapon fired upon, then shuts down?

Or is there an easier way to do this?
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Overcharge stun on projectile

Postby speed2 » 05 Jun 2019, 06:51

Cybran sacu has an upgrade that adds stun to the main gun. Just copy that and instead of main gun, use OC
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: Overcharge stun on projectile

Postby DDDX » 05 Jun 2019, 08:35

Cannot.
I can only have ONE OC weapon.
More than one does not get recognized.

The SACU gets a second weapon that has stun in bp, while the 1.st gets disabled.

Game code cannot distinguish between more than 1 OC weapons.
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX

Re: Overcharge stun on projectile

Postby Franck83 » 05 Jun 2019, 13:43

Hi DDDX,

If i remember well, ACU got 2 oc weapons (1 for manual and 1 for auto oc).

This code is not valid :
Code: Select all
local Stunns = self:GetCurrentTargetPos()
Stunns:SetStunned(7, self)

You cannot stun a position, only a unit.

This one is not valid too :
Code: Select all
Stunns:SetStunned(7, self)


Target:SetStunned(7) is ok.

I use a different way in my mod to make stuns, since the duration can be dynamic. But if i remember well, you can add buffs in a weapon bp. So you should be able to pass a stun as a buff.

The matter with your method in modding OnWeaponFired, is that you will stun on weapon fired not on projectile hit.
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Overcharge stun on projectile

Postby DDDX » 05 Jun 2019, 19:04

god damn. I had no idea whis existed.


self:DisableBuff('STUN')

Exellent!!!
I took Speed's advice and looked at the cybran sacu, though i was 99% certain the buff was done with 2 weapons, one with buff the other without.

Thank you both for your help. The solution was, as is often the case, simple and easy.
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.
DDDX
Avatar-of-War
 
Posts: 170
Joined: 21 Mar 2016, 16:13
Has liked: 18 times
Been liked: 16 times
FAF User Name: DDDX


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest