June 26, 2024, 02:46:20

Author Topic: Limiting weapon ranges  (Read 10583 times)

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
Limiting weapon ranges
« on: August 11, 2010, 20:25:38 »
Oh-kay... I'm currently trying to balance fighter combat, but got a pretty annoying problem: I can't properly restrict the fighting range for my fighter-vs-fighter weaponry.

It's a regular anti-fighter weapon, purpose 5, projectile-based (no laser) and installed into the fighters' flak slot:

Code: [Select]
DEVICETYPE  50
    Name "weap_subach_hl7"
    Category 1
    Civilization 1
    Sets 7 30 39 ;
    Automatic
    Purpose 5 ;
    HitChanceCat 9
    AutoDistance 1800
    Substance 3
    Charge 1
    EnergyIn 4
    PenetrateShield 0
    DamageHull 27
    DamageShield 21
    DamageDevice 9
    Scanned 100
    HPmax 100000
    RepairHP 16
    Start 2 0 100 1
    Travel 2 450 101 1
    End 1 0 102 1
    CannonMaxFireAng 25
DEVICETYPE

Problem is, they attack from 5km distance... which looks totally ridiculous...
AutoDistance supposedly limits firing distance on automatic weapons (like flak lasers in vanilla Nexus) and it works somewhat - when not being given a direct attack order on an enemy squadron, the fighter only starts firing when a viable target enters his AutoDistance-range. That's what I actually want. But if the player gives a "attack this enemy squadron"-order, the fighter starts firing from as much as 5km distance (Nexus' default close-combat range).

Changing the weapon to a continious laser beam fixes that, as you can limit the laser's range in the Travel-property of the DEVICETYPE, but Freespace has no frakking laser beams for fighters - I need a projectile-based weapon and limit its range.

/edit:
Even worse... the exact same thing works perfectly fine for attacking capital ships, with a Purpose of 2. But I can't attack fighters with a Purpose-2-weapon...

Offline DreamorCZ

  • Petty Officer
  • **
  • Posts: 110
  • Karma: 1
    • View Profile
    • Czech Gaming Nexus
(No subject)
« Reply #1 on: August 11, 2010, 20:57:21 »
Well, 'Automatic' should not be there if you have set autodistance for fighter weapons. Also, 30 in sets is little unusual but it depend on your tacticbase setting. And I would rather use Substance 2 or 1 insted of 3.
Editor in Chief at http://www.cgnexus.eu/

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #2 on: August 11, 2010, 21:51:43 »
That doesn't have to do anything with range, though. Still got the same problem after these suggested changes.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #3 on: August 11, 2010, 22:53:56 »
can we see what's your BaseHitchance 9?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #4 on: August 11, 2010, 23:00:13 »
Sure, there you go:

Code: [Select]
BASEHITCHANCE  9
    1 2 35
    1 3 0
    1 4 0
    2 2 30
    2 3 0
    2 4 0
    3 2 20
    3 3 0
    3 4 0
    4 2 45
    4 3 0
    4 4 0
    5 2 85
    5 3 0
    5 4 0
    6 2 0
    6 3 0
    6 4 0
    7 2 0
    7 3 0
    7 4 0
    8 2 0
    8 3 0
    8 4 0
    9 2 0
    9 3 0
    9 4 0
    10 2 0
    10 3 0
    10 4 0
BASEHITCHANCE

It only got a hitchance against missiles, fighters, bombers and transports and only for the smallest possible range 2, which represents 5km according to my tacticsbase.ini.

Like I already said: the funny thing is I have a nearly identical weapon, just with a purpose of 2 (hull destroyer), with which my fighters attack capital ships. The AutoDistance works fine there, just not on my anti-fighter weaponry.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #5 on: August 11, 2010, 23:14:12 »
You're right.  It's probably a hardcoded thing... I think that the only way of fixing it is to reduce the combat distance.

On an other topic, did you manage to have multiple flaks on a same fighter, Arparso?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #6 on: August 11, 2010, 23:20:06 »
Yep.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #7 on: August 11, 2010, 23:24:01 »
may I ask how? I'm currently trying to do that, but the fighter always fires only one of the weapons.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(no subject)
« Reply #8 on: August 11, 2010, 23:32:27 »
Probably the same thing I encountered in this thread, which conveniently also includes a workaround for the "one turret isn't firing"-problem ;)
« Last Edit: December 08, 2010, 12:47:22 by Arparso »

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #9 on: August 11, 2010, 23:38:12 »
yeah.... well, the problem is that I DO have a secondary weapon that is accessed with the secondary weapon buttom :P

and it's in the last place of the weapon list and all, and it works too.


EDIT: Nevermind.... I've forgotten to add the 'automatic' line to the flaks....

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #10 on: August 12, 2010, 02:51:10 »
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: [Select]
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) <= 1800,
                                    E.aaWeapon:active := 1;
                                    E.aaWeapon:target := s.this;
                                );
                            );
                        );
                );
            );
        :end
        END

        TICK 1

    END

END

One or two early shots slip trough, though, and right now it only handles the case for WeaponMode=5 (squad-attacks-squad kind of situation), but it looks somewhat promising for such an ugly hack. It does limit me to use the same range for all fighter-carried anti-fighter weapons, though, unless I want to include a whole bunch of additional Ifs and ChooseFirsts... :(