Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: 1 ... 94 95 [96] 97 98 ... 281

Author Topic: Project Ironclads TC (28 of April, 2017) Source files for the mod  (Read 1638542 times)

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1425 on: August 15, 2013, 11:44:42 PM »

Ok. It works now!

Getting 50 supplies per day as intended. Though mining in Barnard`s Star is a bit tricky due to pirate activity - its so damn fun!

Thanks to everyone involved! You guys are true gurus :)


Now all i need is to add miners to all factions (and i think that Scavenger is going to be a less effective pirate`s miner). And i`ll try to create a random resource generation script. Oh, and i might eventually need some help with industrial skills that will:

a. increase mining efficiency
b. increase chances to get rare materials
c. some other cool stuff regarding mining

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1426 on: August 16, 2013, 12:29:15 AM »

Ok. It works now!

Getting 50 supplies per day as intended. Though mining in Barnard`s Star is a bit tricky due to pirate activity - its so damn fun!

Thanks to everyone involved! You guys are true gurus :)


Now all i need is to add miners to all factions (and i think that Scavenger is going to be a less effective pirate`s miner). And i`ll try to create a random resource generation script. Oh, and i might eventually need some help with industrial skills that will:

a. increase mining efficiency
b. increase chances to get rare materials
c. some other cool stuff regarding mining

Excellent, nice work :)

Yeah I will be adding some industrial skills (and other mining/manufacturing stuff) to Exerelin (at some point when i get time :P), so I will have some working examples soon I hope :)
Logged

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1427 on: August 16, 2013, 12:35:01 AM »

Very well done chaps/chapets! Fantastic to see such a strong community flourishing together and working as a team. Very lovely :)
Logged
A person who's never made a mistake, never tried anything new
- Albert Einstein

As long as we don't quit, we haven't failed
- Jamie Fristrom (Programmer for Spiderman2 & Lead Developer for Energy Hook)

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1428 on: August 16, 2013, 02:34:26 AM »

Ok. I managed to significantly expand the mining script.

It now generates 3 types of materials based on random factor and mining efficiency. The more miners in the fleet - the better are the odds to get high value materials.

Each mining operation consumes 50 supplies per efficiency rating (efficiency is now a float value and differs slightly from miner to miner). If a player has not enough supplies - he gets a nasty red message. If his mining efficiency is 0 - he is also being informed. Both messages pop up after the day has passes :)

So, as you can see, mining is a lottery where you can either loose all your supplies and get some cheap stuff or invest into miners and start to get really expensive stuff from time to time.

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1429 on: August 16, 2013, 02:38:32 AM »

I think that i`ll experiment further into supply consumption and probably expand the miningShip class to get that new value per ship.

This will allow me to create diverse miners with various characteristics. And probably even get deeper into new hull mods that increase mining efficiency or supply consumption and later get to industrial skills to govern these things...

Oh man, so many new possibilities are now open with your help, guys! :)

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1430 on: August 16, 2013, 05:34:46 AM »

This could be more accurate in finding mining ships tho (needs 0.6a)
Code
package data.scripts.world.init;

import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import java.util.HashMap;
import java.util.ListIterator;

/* A mining ship in reality its every ship that possesses a mining tool/weapon
 * So grab the ship, search these weapons, if it finds them its a mining ship
 */

public class MiningShip
{
    public String variant_id = null;
    public int effectiveness = 1;
    public ShipAPI ship = null;
    public FleetMemberAPI fleetMember = null;
    public boolean miningWeapon = false;
   
    public static HashMap weaponIDS = new HashMap();
    static
    {
        weaponIDS.put("mining_id", 1); //add more ids if needed
    }

    public MiningShip(String variant_id,
            int effectiveness)
    {
            this.variant_id = variant_id;
            this.effectiveness = effectiveness;
    }

    public MiningShip(ShipAPI ship)
    {
            this.variant_id = ship.getVariant().toString();
            shipEffectiveness(ship);
    }
   
    public MiningShip(FleetMemberAPI fleetMember,
            int effectiveness)
    {
            this.variant_id = fleetMember.getSpecId();
            this.effectiveness = effectiveness;
    }
   
    public String getVariantID() {
            return variant_id;
    }

    public boolean hasMiningWeapons(ShipAPI ship)
    {
        ListIterator allweapons = ship.getAllWeapons().listIterator();
        while(allweapons.hasNext())
        {
            if(weaponIDS.containsKey(((WeaponAPI)allweapons.next()).getId()))
            {
                return true;
            }
            else
            {
                continue;
            }
        }
        return false;
    }
   
    public void shipEffectiveness(ShipAPI ship)
    {
        ListIterator allweapons = ship.getAllWeapons().listIterator();
        while(allweapons.hasNext())
        {
            if(weaponIDS.containsKey(((WeaponAPI)allweapons.next()).getId()))
            {
                this.effectiveness += ((Integer)weaponIDS.get(((WeaponAPI)allweapons.next()).getId()));
            }
            else
            {
                continue;
            }
        }
    }
   
    public int getEffectiveValue() {
            return effectiveness;
    }
}

EDIT: heres the "almost final" code
« Last Edit: August 16, 2013, 06:01:08 AM by silentstormpt »
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1431 on: August 16, 2013, 05:47:22 AM »

This could be more accurate in finding mining ships tho
Code
public static List<String> weaponIDS = new ArrayList();
    static
    {
        weaponIDS.add("mining_id"); //add more ids if needed
    }

Code
public boolean hasMiningWeapons(ShipAPI ship)
    {
        ListIterator allweapons = ship.getAllWeapons().listIterator();
        while(allweapons.hasNext())
        {
            ListIterator allminingweapons = weaponIDS.listIterator();
            while(allminingweapons.hasNext())
            {
                if(((WeaponAPI)allweapons.next()).getId().equals(allminingweapons.next()))
                {
                    return true;
                }
                else
                {
                    continue;
                }
            }
        }
        return false;
    }

It would be another option yes, but currently there is no way to retrieve the ShipAPI object in campaign mode (you only have FleetMemberAPI) :)

However, StarSector 0.6 has the solution :)
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1432 on: August 16, 2013, 05:57:00 AM »

Well, i got another miner in my fleet and my mining power didn`t grow with it. It just seems to be picking the first miner in the fleet.

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1433 on: August 16, 2013, 06:06:10 AM »

Well, i got another miner in my fleet and my mining power didn`t grow with it. It just seems to be picking the first miner in the fleet.

Thats really strange, what values did you use on the effectiveness for each ship

Also use this:
Code
	public boolean isValidMiningFleet(CampaignFleetAPI fleet)
{
List members = fleet.getFleetData().getMembersListCopy();
for(int i = 0; i < members.size(); i++)
{
FleetMemberAPI fmAPI = (FleetMemberAPI)members.get(i);
                       
                        for(int m = 0; m < MININGSHIP_IDS.size(); m++)
                        {
                            if(fmAPI.getSpecId().equals(((MiningShip)MININGSHIP_IDS.get(m)).getVariantID()))
                            {
                                return true;
                            }
                        }
}

return false;
}

So it only checks until it finds one ship that can mine, instead of making a pass on every ship.
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1434 on: August 16, 2013, 07:06:04 AM »

   public float getMiningPower(CampaignFleetAPI fleet)
   {
      float power = 0;

      List members = fleet.getFleetData().getMembersListCopy();
      for(int i = 0; i < members.size(); i++)
      {
         FleetMemberAPI fmAPI = (FleetMemberAPI)members.get(i);

                           for(int m = 0; m < MININGSHIP_IDS.size(); m++)
                           {                           
                               if(fmAPI.getSpecId().equals(((MiningShip)MININGSHIP_IDS.get(m)).getVariantID())) {
                                  power += ((MiningShip)MININGSHIP_IDS.get(m)).getEffectiveValue();
                               }
                             }
      }

      return power;
   }




This is what i`m using for mining power (its the very same funstion you`ve provided me with).

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1435 on: August 16, 2013, 07:08:55 AM »

This could be more accurate in finding mining ships tho (needs 0.6a)
Spoiler
Code
package data.scripts.world.init;

import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import java.util.HashMap;
import java.util.ListIterator;

/* A mining ship in reality its every ship that possesses a mining tool/weapon
 * So grab the ship, search these weapons, if it finds them its a mining ship
 */

public class MiningShip
{
    public String variant_id = null;
    public int effectiveness = 1;
    public ShipAPI ship = null;
    public FleetMemberAPI fleetMember = null;
    public boolean miningWeapon = false;
   
    public static HashMap weaponIDS = new HashMap();
    static
    {
        weaponIDS.put("mining_id", 1); //add more ids if needed
    }

    public MiningShip(String variant_id,
            int effectiveness)
    {
            this.variant_id = variant_id;
            this.effectiveness = effectiveness;
    }

    public MiningShip(ShipAPI ship)
    {
            this.variant_id = ship.getVariant().toString();
            shipEffectiveness(ship);
    }
   
    public MiningShip(FleetMemberAPI fleetMember,
            int effectiveness)
    {
            this.variant_id = fleetMember.getSpecId();
            this.effectiveness = effectiveness;
    }
   
    public String getVariantID() {
            return variant_id;
    }

    public boolean hasMiningWeapons(ShipAPI ship)
    {
        ListIterator allweapons = ship.getAllWeapons().listIterator();
        while(allweapons.hasNext())
        {
            if(weaponIDS.containsKey(((WeaponAPI)allweapons.next()).getId()))
            {
                return true;
            }
            else
            {
                continue;
            }
        }
        return false;
    }
   
    public void shipEffectiveness(ShipAPI ship)
    {
        ListIterator allweapons = ship.getAllWeapons().listIterator();
        while(allweapons.hasNext())
        {
            if(weaponIDS.containsKey(((WeaponAPI)allweapons.next()).getId()))
            {
                this.effectiveness += ((Integer)weaponIDS.get(((WeaponAPI)allweapons.next()).getId()));
            }
            else
            {
                continue;
            }
        }
    }
   
    public int getEffectiveValue() {
            return effectiveness;
    }
}
[close]

EDIT: heres the "almost final" code


Well, i`m not going to use mining weapons - just specialised mining ships.

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1436 on: August 16, 2013, 07:31:56 AM »

Guys. I just realised that i can use my own restructure to help the game find proper hulls.

All my miner-capable ships have "-min-" in their IDs. Now i just need a script to help my mod to find needed hulls.

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1437 on: August 16, 2013, 07:35:31 AM »

Guys. I just realised that i can use my own restructure to help the game find proper hulls.

All my miner-capable ships have "-min-" in their IDs. Now i just need a script to help my mod to find needed hulls.



If you find a way to get that array in the timerManager script you can fill the array with those ids if each string .contains("-min-")
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1438 on: August 16, 2013, 07:40:14 AM »

Hey, i found the problem with multiple miners. A pretty trivial one!

All bought ships use _Hull variant :) That`s why i only got my original miner.

Now i wonder if there is any way in java to use something like this: "rsf7-min-scrapper1_*', because i feel that there might be a problem with user created miner variants...

silentstormpt

  • Admiral
  • *****
  • Posts: 1060
    • View Profile
Re: Project Ironclads, version 5.2 (0.54.1)
« Reply #1439 on: August 16, 2013, 07:46:50 AM »

Hey, i found the problem with multiple miners. A pretty trivial one!

All bought ships use _Hull variant :) That`s why i only got my original miner.

Now i wonder if there is any way in java to use something like this: "rsf7-min-scrapper1_*', because i feel that there might be a problem with user created miner variants...

Thats another problem that would be fixed if the actual miners were ships that have mining weapons, regardless of what ship it checked, as long its for a mining weapon, its a mining ship.

to make this chance i would need to redo a big part of the TimerManager so might as well wait for the 0.6a and use the variant_ids.
Logged
Pages: 1 ... 94 95 [96] 97 98 ... 281