Author Topic: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]  (Read 4493 times)

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
[1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« on: December 29, 2010, 07:13:47 PM »
==============================================================================
 MultiTargeting MOD                      Version 0.90
==============================================================================

Description:
   Re-works how weapons target and fire to allow for firing on multiple
   targets at the same time.
   The following weapons are effected:
      TorpedoBay
      Railgun
      PlasmaThrower
      Laser
      ShortLaser
      OverchargeLaser
      PhasedLaser
      PlasmaBeam

   The Targeting Array is no longer a link, and instead improves
   Max Target Potential for the ship.


Files:
==============================================================================

 Mod Additions:
  -new_effectors.txt
  -new_effects.txt
  -new_Combat.as
  -Stnd_Weapons.txt
   
 Mod Changes:
  -weapons.txt
   cleared. All entries moved to Stnd_Weapons.txt (Im funny like that)


==============================================================================
 MODIFIED: 12-29-2010                          Version 0.91

 Mod Changes:
  -Fixed an error in new_combat.as that gave too much default target Que.






Let me know how it works, if there is any lag, how much you like/dislike it, or any ideas you have.
Basicly, feedback is encouraged. ;D

Enjoy!
« Last Edit: December 29, 2010, 08:06:19 PM by erdrik »
Erdrik's Mods:
Refuel Auto-Pilot

Steiner

  • Star Ruler Tester (Group 2)
  • Delusional
  • *
  • Posts: 709
  • Karma: +81/-0
  • Magnetize, Magnetize!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.9 release: 12.29.10]
« Reply #1 on: December 29, 2010, 07:27:29 PM »
Great! I'll definitely look at this and give it a couple of stress tests.  ;D


Current Version: 1.5.1 for SR v.1.0.6.2

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.9 release: 12.29.10]
« Reply #2 on: December 29, 2010, 07:50:07 PM »
Welp, I just found an error. :( ... already. :-[
Not a big one tho.
It seems I forgot to revert some values back to their intended amounts.
Quote
   if( obj.getState("WepNetTargetQue" + evt.dest.system.type.getName()).val > obj.getState("MaxTargetQue").val + 10 )
      obj.getState("WepNetTargetQue" + evt.dest.system.type.getName()).val = obj.getState("MaxTargetQue").val + 10;
Those 10s should be 2s. ( new_Combat.as > WeaponSenserInitialize() )
Had them at 10 for testing.  :P

Not a big deal really, but the 10 makes it so you don't need Targeting Arrays.
Ill have an update up shortly.

EDIT: Also found and fixed another error in new_effectors. OP updated.
« Last Edit: December 29, 2010, 08:08:06 PM by erdrik »
Erdrik's Mods:
Refuel Auto-Pilot

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #3 on: December 29, 2010, 08:18:23 PM »
Will check the new code too. Let's see that at work :).

Edit : It's a bit difficult to test out with weapons that have such a short range; ships are on top of each others when they actually start shooting.

Edit 2: Haven't had the time to fully test it yet, will do that tomorrow.
« Last Edit: December 30, 2010, 10:50:13 PM by Foraven »
Maker of FRB mod.

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #4 on: January 03, 2011, 09:46:02 PM »
Alright, it took me a long time but did more testing today. I seen a ship take shot at two ships at once during a close range "melee". Well, that's a huge difference :). I'm too used to my mod though, lets say the ship designs and the weapons are a bit dull in vanilla...
Maker of FRB mod.

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #5 on: January 05, 2011, 02:25:54 PM »
I'm currently implementing your code in my mod, soon i will "mass test" it  ;D.
Maker of FRB mod.

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #6 on: January 05, 2011, 03:24:11 PM »
Hum... I think something is not right... Where does your scripts check for how many weapons a ship has? Also what does this part is supposed to do? :

   if (obj.getState("MaxTargetQue").val < MaxTargetQue + 2)
      obj.getState("MaxTargetQue").val = uint(MaxTargetQue + 2);

       Of course MaxTargetQue will be smaller than MaxTargetQue + 2...

Maker of FRB mod.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #7 on: January 05, 2011, 03:46:40 PM »
...   if (obj.getState("MaxTargetQue").val < MaxTargetQue + 2)
      obj.getState("MaxTargetQue").val = uint(MaxTargetQue + 2);

       Of course MaxTargetQue will be smaller than MaxTargetQue + 2...

mmm I think that was an if/then check that is now obsolete.
I just lazily rigged it to be 2 instead of removing it.

Weapon count is checked in void WeaponSenserInitialize(Event@ evt)
(It only checks weapons of the same type)
Code: [Select]
//Cycle all subsystems and set WepNetTargetQue based on matching weapon type
uint wepNetCnt = 0;
HulledObj@ hulledobj = obj.toHulledObj();
if (hulledobj is null)
return;

uint cnt = hulledobj.getSubSystemCount();

for (uint i = 0; i < cnt; ++i) {
SysRef@ ref = hulledobj.getSubSystem(i);

if( ref.system.type.getName() == evt.dest.system.type.getName() )
wepNetCnt++;
}
Erdrik's Mods:
Refuel Auto-Pilot

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #8 on: January 05, 2011, 03:56:28 PM »
Well, one issue i have with the current code is that while it check for weapons of the same type, it doesn't check if there is multiple type of weapons on the same designs. So i have a ship with 3-4 weapons, but of different types and they all attack the same target even if there is multiple enemies around. Lets say my designs often have mixed weapon types for a variety of enemy types, not good if they all target the same thing.
Maker of FRB mod.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #9 on: January 05, 2011, 04:24:25 PM »
well its easy enough to change.
just set wepNetCnt = hulledobj.getSubSystemCount();

It'll take more to optimize it, but that should get the effect your looking for.
Erdrik's Mods:
Refuel Auto-Pilot

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #10 on: January 05, 2011, 04:39:22 PM »
well its easy enough to change.
just set wepNetCnt = hulledobj.getSubSystemCount();

It'll take more to optimize it, but that should get the effect your looking for.

Doesn't that get all subsystems and not just weapons? Anyway, i made my own fix to add at least one more target if there is more weapons than what it gets of the same type. Still imperfect but picking as many target as there is weapons just make the whole counting code redundant...

Edit: Oh well, why not...
« Last Edit: January 05, 2011, 04:41:15 PM by Foraven »
Maker of FRB mod.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #11 on: January 05, 2011, 08:29:30 PM »
ah yes, well subsystem.hasTag("Weapon") should work.
But if you can get it to work go for it.

I like the "by weapon type" method myself.
Tho I am probly going to revamp the code.(yet again)
Im getting pretty bad lag in battles with as few as ~200 ships, so optimization is defenitly required.
Erdrik's Mods:
Refuel Auto-Pilot

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #12 on: January 05, 2011, 09:07:20 PM »
I noticed this :

      
Code: [Select]
if ( bhasFired > 0 && RandTarg > 25 ) //Add more robust focused targeting using target# States
Basically it means 75% of the time a ship will shoot the same target it already shot at. That defeat the purpose of the code since they do switch target a bit too rarely. At least that is what it seemed in my tests.
« Last Edit: January 05, 2011, 09:11:18 PM by Foraven »
Maker of FRB mod.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #13 on: January 05, 2011, 10:49:08 PM »
Ah.. no.
The position of that if/then statement means it will skip the current target check 25% of the time.
Remember, that function is called once for every target in the weapon sensors range.
> 25 allows it to continue to the actual weapon firing code. (which then sets a filter to prevent the weapon from firing its triggerable again)
< 25 skips the weapon firing code and moves on to the next target in the AOE que.
Erdrik's Mods:
Refuel Auto-Pilot

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #14 on: January 10, 2011, 12:57:24 PM »
Well, so far your code work well in my mod but there is one issue : force attacking planets don't seem to work for weapons with the multi-target code. Ships get there like usual but nothing is fired (and they do try again but still nothing fired). Can you add some code so force attacking works?

Edit : Another problem is your code break burst firing weapons : any weapon that has clip will fire only one shot and not the rest. I guess it's because your code was only designed to handle single fire weapons and not missile racks and the like...
« Last Edit: January 10, 2011, 04:52:53 PM by Foraven »
Maker of FRB mod.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #15 on: January 11, 2011, 02:29:49 PM »
Well, so far your code work well in my mod but there is one issue : force attacking planets don't seem to work for weapons with the multi-target code. Ships get there like usual but nothing is fired (and they do try again but still nothing fired). Can you add some code so force attacking works?

Edit : Another problem is your code break burst firing weapons : any weapon that has clip will fire only one shot and not the rest. I guess it's because your code was only designed to handle single fire weapons and not missile racks and the like...
Correct I only coded it to work with single fire weapons and only tested versus ships.
I am currently looking into a new script that may require recoding everything.

I am interested in how much if any lagg you are getting.
I got crippling lagg at around 100 - 200 ships.
NOTE: Lagg only happened once I declared war. As long as the ships are not in contact with a hostile enemy in system there is no lagg for me.
Is everything running smooth for you?
Erdrik's Mods:
Refuel Auto-Pilot

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #16 on: January 11, 2011, 02:44:28 PM »
Well, i had made a few changes to your code to adapt it to my needs so the results i had may not help you much. I currently have disabled the code from my mod because it breaks it too much (missile racks, gauss gun and multiracks were broken by it), but i did let the game run a while with several AI and some major battles occuring and did not notice slowdowns. My mod has some extensive changes from the base game, so again not a good benchmark.

Fixing the "can't attack planets" was easy enough, just needed to change the effects so it auto attack enemies and canattack: canattack (this allow force attacking). I did not understand your code enough to fix the burst firing issue though. Also i have some doubts how much your code was working, i did toy around to get it to switch targets more often but it did not seem to change anything...
Maker of FRB mod.

erdrik

  • Sentient
  • **
  • Posts: 199
  • Karma: +22/-0
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #17 on: January 12, 2011, 06:35:10 PM »
Break through!

After utterly embarassing myself in front of the developers, Ive managed to get Multitargeting without using an AOE effector or triggerable on every weapon!
Infact no changes in the weapon subsystem, or even the effects.txt are needed.
Everything is done in the Effectors.as and an accompanying server/script .as

Since this makes use of retargeting code that is already hardcoded in the game, lagg should be minimal.

However, I still need to finalize/finish things and generaly get it all tied together and working as an actual mod.
Be back soon.
Erdrik's Mods:
Refuel Auto-Pilot

Foraven

  • Delusional
  • ****
  • Posts: 1591
  • Karma: +102/-6
  • Fear the gauss weapons!
    • View Profile
Re: [1.0.4.4] MultiTargeting[v0.91 update: 12.29.10]
« Reply #18 on: January 13, 2011, 09:54:09 AM »
Yep, simple is better  ;D.
Maker of FRB mod.