Nexus Modding > Mod Development / Released Mods

Limiting weapon ranges

<< < (3/3)

Arparso:
I'm trying out ideas for limiting weapon ranges through the use of a script. The general idea is to disable fighter-carried anti-fighter weaponry for as long as the distance between the fighter and its target are above a certain maximum range. I already made a first prototype seemingly working as intended:


--- Code: ---MACHINE "foo"

    STATE bar

        RULE event Tick
        :action
            // select all fighter-carried anti-fighter weapons
            SelectEx(s.weapon & Purpose(s.this, 5) & InSet(s.this, 37) & s.owner:boat,

                // the current attack mode of the squadron (attack, guard, etc.)
                E.weaponMode := s.owner:launcherWeapon:mode;
                // the squad the fighter belongs to
                E.squad := s.owner:launcherWeapon;
                // the targetted squad of this fighter's squad
                E.squadTarget := E.squad:target;

                // handle all relevant cases for the attack mode of the squadron
                ChooseFirst(
                    // squad attacks another squad (targets a "weapon")
                    E.weaponMode = 5 & E.squad:target:weapon,

                        // disable device, if target is out of range
                        If(IsValid(s.target) & Distance(s.owner, s.target) > 1800,
                            s.this:active := 0;
                        );

                        // device isn't active (has been disabled before?)
                        If(s.this:active = 0,
                            E.aaWeapon := s.this;

                            // loop through all fighters of the targetted squadron
                            SelectEx(s.boat & s.launcherWeapon = E.squadTarget,
                                // if an enemy fighter has entered firing range,
                                // activate the device again and assign a target
                                If(Distance(E.aaWeapon:owner, s.this)

Navigation

[0] Message Index

[*] Previous page

Go to full version