Fractal Softworks Forum
January 23, 2018, 11:20:48 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: New blog post: Revisiting the Economy (01/03/18); Starsector 0.8.1a is out!
 
   Home   Help Search Login Register  
Pages: 1 ... 250 251 [252]
  Print  
Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 429953 times)
Nicke535
Commander
***
Posts: 177


What do you want, human?


View Profile Email
« Reply #3765 on: January 18, 2018, 12:11:06 AM »

sup, FS.
is there a way i can get all ships within sertain distance from a beam, i.e. inside a rectangular area, parallel to a beam?
also how can i prevent getnearestally(ship_sample) from picking ship_sample's modules, and instead pick next nearest ally.

My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code:
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.


As for the beam... it's possible to get the formula for that area mathematically and then check all enemies in range to see if they fit the formula. But i suspect that is far from the easiest solution, and the formula itself would grow fairly complicated.

Another solution would be to iterate a large amount of circular areas along the beam (simply moving the center coordinate from beamStart to beamEnd with sufficiently small steps), though i doubt that would be particularly performance-friendly.
Logged

passwalker
Lieutenant
**
Posts: 84



View Profile
« Reply #3766 on: January 18, 2018, 12:31:21 AM »

My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code:
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.
i meant AIUtils.getNearestAlly(beam.getSource()). it just returns nearest ally. and if source ship has modules, they will be closer  to source than any other ship.
i can't actually put anything inside, that's lazylib function.
Logged

Any and ALL sprites i ever posted on this forum are FREE to use. even if i'm using them myself. Don't ever, EVER ask for permission, or i will come to your home and EAT YOUR DOG!!!
- all my stuff in on place http://fractalsoftworks.com/forum/index.php?topic=12896.msg218548#msg218548
- Terraformer faction mod http://fractalsoftworks.com/forum/index.php?topic=12907.msg218093#msg218093 - very WIP, coder assistance needed.
my keyboard has malfunctioning buttons E and W. misspelling happens often.
Nicke535
Commander
***
Posts: 177


What do you want, human?


View Profile Email
« Reply #3767 on: January 18, 2018, 01:05:30 AM »

My reccomendation for the module issue would be to simply put an if-case inside the getnearestally(ship_sample) function, like so:

Code:
if (currentShip.getParent() == ship_sample) {
    continue;
}

Where currentShip is the ship you are currently checking the distance for.
i meant AIUtils.getNearestAlly(beam.getSource()). it just returns nearest ally. and if source ship has modules, they will be closer  to source than any other ship.
i can't actually put anything inside, that's lazylib function.

Aha. That makes things more difficult.

My recommendation is to instead run AIUtils.getNearbyAllies and then manually run a loop to see which is closest. You'll have to input a range, but if you want it global just input a really high one. This would allow you to ignore modules through the previously mentioned "if" function, though it is not quite as compact code-wise.
Logged

passwalker
Lieutenant
**
Posts: 84



View Profile
« Reply #3768 on: January 18, 2018, 01:32:40 AM »

My recommendation is to instead run AIUtils.getNearbyAllies and then manually run a loop to see which is closest. You'll have to input a range, but if you want it global just input a really high one. This would allow you to ignore modules through the previously mentioned "if" function, though it is not quite as compact code-wise.
then i face another problem, since i keep getting "assignment conversion error" whenever i am trying to make a list of targets.  probably due to not having a .jar.
thanks for the help anyway
« Last Edit: January 18, 2018, 01:39:56 AM by passwalker » Logged

Any and ALL sprites i ever posted on this forum are FREE to use. even if i'm using them myself. Don't ever, EVER ask for permission, or i will come to your home and EAT YOUR DOG!!!
- all my stuff in on place http://fractalsoftworks.com/forum/index.php?topic=12896.msg218548#msg218548
- Terraformer faction mod http://fractalsoftworks.com/forum/index.php?topic=12907.msg218093#msg218093 - very WIP, coder assistance needed.
my keyboard has malfunctioning buttons E and W. misspelling happens often.
Nicke535
Commander
***
Posts: 177


What do you want, human?


View Profile Email
« Reply #3769 on: January 18, 2018, 02:54:38 AM »

My recommendation is to instead run AIUtils.getNearbyAllies and then manually run a loop to see which is closest. You'll have to input a range, but if you want it global just input a really high one. This would allow you to ignore modules through the previously mentioned "if" function, though it is not quite as compact code-wise.
then i face another problem, since i keep getting "assignment conversion error" whenever i am trying to make a list of targets.  probably due to not having a .jar.
thanks for the help anyway

Are you attempting to make a List() or an ArrayList()? An ArrayList() should still work without the .jar (this is what I run on my AI scripts, which are not compiled).
Logged

passwalker
Lieutenant
**
Posts: 84



View Profile
« Reply #3770 on: January 18, 2018, 04:39:31 AM »

i think i set up the IDEA so thee problem is obsoleetee now.

good suggestion, but too late.

thanks anyway.
Logged

Any and ALL sprites i ever posted on this forum are FREE to use. even if i'm using them myself. Don't ever, EVER ask for permission, or i will come to your home and EAT YOUR DOG!!!
- all my stuff in on place http://fractalsoftworks.com/forum/index.php?topic=12896.msg218548#msg218548
- Terraformer faction mod http://fractalsoftworks.com/forum/index.php?topic=12907.msg218093#msg218093 - very WIP, coder assistance needed.
my keyboard has malfunctioning buttons E and W. misspelling happens often.
Pages: 1 ... 250 251 [252]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2006-2011, Simple Machines
Simple Audio Video Embedder
Valid XHTML 1.0! Valid CSS!