Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Fuel Collector

Content

Warnings

  1. Found XML equipment list

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Fuel Collector scoops fuel from killed ships and collects fuel while cruising, even in witch space. Fuel Collector scoops fuel from killed ships and collects fuel while cruising, even in witch space.
Identifier oolite.oxp.Frame.FuelCollector oolite.oxp.Frame.FuelCollector
Title Fuel Collector Fuel Collector
Category Equipment Equipment
Author Frame Frame
Version 0.07 0.07
Tags Equipment Equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Fuel_Collector_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/c/c9/Oolite.oxp.Frame.FuelCollector.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1610873469

Documentation

Also read http://wiki.alioth.net/index.php/Fuel%20Collector

Equipment

Name Visible Cost [deci-credits] Tech-Level
Fuel Collector yes 20000 11+

Ships

Name
Cob3 Fuel ship tester
Wreckage

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/frame_fuel_collector.js
this.name        = "Fuel Collector"; 
this.author      = "Dennis Thony Pedersen (frame)"; 
this.copyright   = "CC BY-NC-SA 3.0"; 
this.description = "Device that collects fuel from wrecks & derelict ships"; 
this.version     = "0.07"; 

this.startUp = function()
{
	//modify this array if certain roles falls outside your preferences
	//These roles are ships that are "hackeble" by the Fuel Collector
	//you can ofcourse remove the con_role to, its there for fast editing...
this.legitDerelictRoles = new Array (
	"pirate",
	"trader",
	"hunter",
	"escort",
	"sunskim-trader",
	"shuttle",
	"miner",
	"scavenger",
	"dredgerDerelict", // on request of lestradae 
	"Fuel_collector_estest" // allways carries an escape pod...
	)

this.fuel_below01 = 0
this.fuel_level_1 = 5
this.fuel_level_2 = 10
this.fuel_level_3 = 20
this.fuel_level_4 = 30
this.checkawardhowoften = 3
this.myswitch = true	//reactivated for 1.72 and 1.72.1
this.myswitch1 = false	//reactivated for 1.72 and 1.72.1
this.myswitch3 = false; //switch indicates that we are inside the vicinity of a planet...
this.tonearsun = 290000
this.tonearplanet = 50000
this.nearsun = 350000
this.averagesun = 450000
this.farfromsun = 520000
this.ispaceswitch = true
this.hacktime = 3
this.derelictcount = this.hacktime+1
this.derelictID = false
this.firstrun = true
this.mcounter = 0;
this.mmactive = false;
this.sustain = 3;
this.delay = 3;
this.leech = 0;
this.trapship = false;
this.trapcounter = 0;
this.planetlist = 0;
this.MainPlanetName = false;
this.nottoclose = false;
this.planetlistdone = false;
this.toclosetoplanet = false;
//Sound.load("FCscoop.ogg")		//lets not use this for now, it would stop any playing music
//Sound.load("FCtrumblesqueal.ogg")	// Testing if two sounds could play at the same time, thats a negative

}

this.$itsatrap = function() 
{
	if(this.trapship)
	{
		this.trapcounter ++
		//player.ship.consoleMessage("its going 2:"+this.trapship.shipDisplayName+":"+this.trapcounter,3)
		if(this.trapcounter > 3)
		{
			this.itsatrapTimer.stop()
			//player.ship.consoleMessage("its going 3:"+this.trapship.shipDisplayName+":DEAD",3)
			this.trapcounter = 0
			this.trapship.explode()
			this.trapship.spawn("FCFrameSelfDestruct",1)
			
			//this.trapship = false
			return
		}
		return // we only get here in case of this.trapcounter<3
	}	
	else //ship died
	{
		this.itsatrapTimer.stop()
		this.trapcounter = 0
		this.trapship = false
		return
	}
	//we should never get here..
	log("Fuel Collector","Error its a trap, we should never get here")
}

this.$buildplanetlist = function()
{ //function very much in developing stages.. 	

	//if(this.planetlistdone) //make sure....
	//return 

	if(!system.sun)
	return;	//sanity check.. no distance measurements to sun, or else we get errors..
		//number planets by posistion in the array.. execpt main planet ofcourse
	
	if(system.planets.length == 1) //sanity check...
	{
		this.MainPlanetName = system.name //+" 1" //used +1 one for testing..
		return //return from here, there is no more planets in the system
	}
	
	//this.temp = new Array();
	this.planetlist = new Array();
	this.moonlist = new Array();	
	
	for(var i = 0;i<system.planets.length;i++)
	{
		if(!system.planets[i].hasAtmosphere) //presume moon if no atmosphere
		{
			this.moonlist.push(system.planets[i])			
		}
		else
		{
			this.planetlist.push(system.planets[i])
		}
	}
	
	this.noofplanets = this.planetlist.length
	this.noofmoons = this.moonlist.length
	
	//log("Fuel Collector","planets n is "+this.noofplanets)
	//log("Fuel Collector","moons n is "+this.noofmoons)
	
	//we dont need a check for planets,its greater than 0
	
	//build a distancelist
	if(this.noofplanets>1) //sanity check
	{
		for(var i = 0;i<this.noofplanets;i++)
		{
			this.planetlist[i].name = system.name +" "+this.$romanize(i+1)
			this.planetlist[i].moons = 0;
		}
	}
	else
	{
		this.planetlist[0].name = system.name
		this.planetlist[0].moons = 0;
	}
		
	/* for(i = 0;i<this.noofplanets;i++)
	{
		log("Fuel Collector","name:"+this.planetlist[i].name)		
	}
	*/
	
	if(this.moonlist)
	{			
		for(i=0;i<this.noofmoons;i++)
		{
			let motherplanet = 0
			let cr = this.moonlist[i].position.distanceTo(planetlist[0])
			
			for(var al=0;al<this.noofplanets;al++)
			{				
				if(cr>this.moonlist[i].position.distanceTo(planetlist[al]))
				{
					cr = this.moonlist[i].position.distanceTo(planetlist[al])
					this.planetlist[al].moons = 0;
					motherplanet = al
				}				
			}
			this.planetlist[motherplanet].moons ++;
			this.moonlist[i].name = this.planetlist[motherplanet].name +"¥s moon "+this.$romanize(this.planetlist[motherplanet].moons)
			this.moonlist[i].motherplanet = motherplanet
		}
		// next is a sanity check of wheter or not a planet has more than 1 moon.... if not, the name gets changed to not include the roman letter
		for(i=0;i<this.noofmoons;i++)
		{
			if(this.planetlist[moonlist[i].motherplanet].moons == 1)
			{			
                this.moonlist[i].name = this.planetlist[this.moonlist[i].motherplanet].name +"¥s moon"				
			}
		}
	}	
}

this.$self_destruct_countdown = function()
{
	//self destruct is allready initiated, all we need to check is if the
	//the ship is still alive..
	if(this.trapship)
	{
		this.trapship.setAI("dumbAI.plist")
		//player.ship.consoleMessage("its going 1"+this.trapship.shipDisplayName,3)
		this.itsatrapTimer = new Timer(this, this.$itsatrap,0,3)
	}
	//do nothing ship is dead..
}

this.$consolemessage = function()
{
	if(player.ship.docked)
	{ 
		this.consolemessageTimer.stop()
		return
	}
	
	this.mcounter ++
	if(this.mcounter < this.delay)
	return
	this.consolemessageTimer.stop()
	this.mmactive = false
	this.mcounter = 0
	delete this.consolemessageTimer //remove so that we can set a new one with a new interval
}	

this.$delayedmessage = function(message,delay,sustain)
{	
	//this is a delayed message, it pops up on screen after n seconds = delay, and will stay there for n=sustain time
	if(this.mmactive)
	{
		//log("Fuel Collector", "WARNING!!! this.$delayedmessage: Timer start before other is expired")
		this.additionalfuel =+ this.leech
		return
	}
	
	this.additional_fuel = 0;
	this.mmessage = message	
	this.sustain = sustain
	this.delay = delay
	this.mmactive = true
	
	//start our timer..
	
	this.consolemessageTimer = new Timer(this, this.$consolemessage,0,delay)
}

this.$checkifover01 = function(fuel_award)
{	
	this.fuel_below01 += fuel_award	
	if(this.fuel_below01 > 1000)
	{
		
		player.ship.fuel += 0.1
		//Sound.playMusic("FCscoop.ogg")
		//Sound.playMusic("FCtrumblesqueal.ogg")			
		player.consoleMessage("Fuel Collector", 10)
		player.consoleMessage("Gathered fuel: 0.1 ly", 10)
			
		this.fuel_below01 -= 1000
	}
}

this.$extractfuel = function()
{
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") != "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK") //checkup of both dependacies
	{		
		this.extractfuelTimer.stop()
		
		player.consoleMessage("Fuel Collector",3)
		player.consoleMessage("Malfunction!!!",3)
				
		this.derelictID = false //set if we somehow mysteriously got it fixed
		return
	}
	
	if(player.ship.docked)
	{ 
		this.extractfuelTimer.stop() //should not happen, but for safety reasons, there could in theory be a dereclict ship right outside the docking bay
		return
	}
	if(!this.derelictID || this.derelictID != player.ship.target) //does ship exist, and is linked ship still the players target
	{
		player.consoleMessage("Fuel Collector",3)
		player.consoleMessage("Lost link",3)		
		this.extractfuelTimer.stop()
		//either way make sure that we dont enter a reoccuring loop
		this.derelictID = false
		return
	}
	else if(this.derelictID)
	{
		if(player.ship.position.distanceTo(this.derelictID) > 300) //within range ?
		{
			this.extractfuelTimer.stop()
			
            player.consoleMessage("Fuel Collector",3)
            player.consoleMessage("Lost link to "+this.derelictID.displayName,3)
			
			if(this.derelictID.fuel > 0.09) //check if there is any fuel left in ships tanks
			this.derelictID = false	//if so set Id to false so we can connect to it again, next time we come in range
			return
		}
	}			
	
	if(this.derelictID.fuel > 0.09)	//extract fuel of any in the tank
	{
		this.derelictID.fuel -= 0.1
		//Sound.playSound("FCscoop.ogg")		
		player.ship.fuel += 0.1
		if(player.ship.fuel == 7.0)	//are our tank full ?
		{
            player.consoleMessage("Fuel Collector",3)
            player.consoleMessage("Tank full",3)
			
			this.extractfuelTimer.stop()
			this.derelictID = false	//if so set Id to false so we can connect to it again, next time we come in range
			return
		}
		return // we check for empty tank next time
	}
	
	//if we made it here it means the victims fuel tank is empty
    player.consoleMessage("Fuel Collector",3)
    player.consoleMessage(this.derelictID.displayName+"¥s Fuel tank is empty",3)		
	this.extractfuelTimer.stop()	
}

	
	

this.$DerelictCheck = function()
{
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") != "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK") //checkup of both dependacies
	{		
		this.DerelictCheckTimer.stop()
		if(!(this.derelictcount == this.hacktime+1))
		{
				player.consoleMessage("Fuel Collector",3)
				player.consoleMessage("Malfunction!!!",3)			
		}
		this.derelictcount == this.hacktime+1
			
		return
	}
	
	if(player.ship.docked)
	{
		this.DerelictCheckTimer.stop() //should not happen, but for safety reasons, there could theory be a dereclict ship right outside the docking bay
		this.derelictcount = this.hacktime+1
		return
	}
	
	let a_derelict_ship = player.ship.target
	
	if(!a_derelict_ship) //first check that there is a ship locked in players target computer
	{
		this.DerelictCheckTimer.stop()
		if(!(this.derelictcount == this.hacktime+1))
		{
			player.consoleMessage("Fuel Collector",3)
			player.consoleMessage("Malfunction!!!",3)
		}
		this.derelictcount == this.hacktime+1
		
		return	//no active target return and stop timer.. 
	}
	if(a_derelict_ship.AI != "nullAI.plist") //is this ship unpiloted, if so it could be derelict
	{
		this.DerelictCheckTimer.stop()
		this.derelictcount = this.hacktime+1
		player.consoleMessage("Fuel Collector",3)
		player.consoleMessage("Lost link",3)	
		return // not unpiloted(something must have happend).. stop timer
	}
	if(player.ship.position.distanceTo(a_derelict_ship) > 300) //are we still within the 300 meters limit
	{
		this.DerelictCheckTimer.stop()
		this.derelictcount = this.hacktime+1
		player.consoleMessage("Fuel collector: Weak Signal",3)
		player.consoleMessage("Lost link to "+a_derelict_ship.displayName, 3)
		
		return //we left the minimum distance.. stop timer
	}
	//if(a_derelict_ship.isPirate || a_derelict_ship.isTrader || a_derelict_ship.hasRole("hunter") || a_derelict_ship.hasRole("shuttle") || a_derelict_ship.hasRole("miner") || a_derelict_ship.hasRole("escort"))	//legit derelict ship Traders & Pirates & Hunters
	if(this.$CheckLegitDerelictRole(a_derelict_ship))
	{
		//do stuff here
		this.derelictcount --
		player.consoleMessage("Hacking: "+a_derelict_ship.displayName+" "+this.derelictcount, 1)
		if(this.derelictcount < 1)
		{
			let rab = Math.random()
			
			if(a_derelict_ship.fuel < 0.1)
			{				
				player.consoleMessage("Fuel Collector: Ship has no fuel in tank",3)				
				this.derelictID = a_derelict_ship //mark as last ship connected to is empty
				
				if(a_derelict_ship.isPirate)//high odds for ship will self destruct..
				{
					if(rab<0.5)
					{
						//player.ship.consoleMessage("gonna go boom boom boom:pirate",3)
						this.trapship = a_derelict_ship
						this.$self_destruct_countdown()
					}
					
					//run random boobytrap
					//we use a new timer that slowly but surely drains the ships energy bank //would be nice to alter recharge rate, but i guees that is not a possibility
				}
				else	//low odds for ship will have a bobbytrap
				{
					if(rab<0.05)
					{
						//player.ship.consoleMessage("gonna go boom boom boom:trader",3)
						this.trapship = a_derelict_ship
						this.$self_destruct_countdown()
					}
				}								
				
				this.derelictcount = this.hacktime+1
				this.DerelictCheckTimer.stop()
				return
			}
			else
			{
				if(a_derelict_ship.isPirate && rab <0.5) //high odds
				{
					//player.ship.consoleMessage("gonna go boom boom boom:pirate",3)
					this.trapship = a_derelict_ship
					this.$self_destruct_countdown()
				}
				else if(rab<0.05)
				{
					//player.ship.consoleMessage("gonna go boom boom boom:trader",3)
					this.trapship = a_derelict_ship
					this.$self_destruct_countdown()
				}	
								
				this.derelictcount = this.hacktime+1
				player.consoleMessage("Extracting fuel",3)
				this.derelictID = a_derelict_ship				
				this.extractfuelTimer = new Timer(this,this.$extractfuel,0,1) //tip dont use an arguement when you start a timer like this,this.mytimer(arguement) it will make a CTD			
				this.DerelictCheckTimer.stop()
				return // return because we dont need more checking from here..
			}			
		}
	}
	else	//no legit roles return and stop timer
	{	
		this.DerelictCheckTimer.stop()
		this.derelictcount = this.hacktime+1
		player.consoleMessage("Fuel Collector",3) //we might have changed targets..
		player.consoleMessage("Lost link ", 3)
		return //no legit roles
	}	
}

this.$CruiseCheck = function()
{
	if(player.ship.docked)
	{
		this.CruiseCheckTimer.stop()
		return // return because we really dont need more checking from here
			//return also saves a few cycles, instead of having the CPU do 3 extra Compares it just jumps to an address in memory
	}
	
	//if(this.tonearplanet) //if it is zero, then return
	//return
	
	// we never got here if the fuel collector was not started in the first place which is why
        // we can use explicit OR	
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") != "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK") //is EQ damaged ?
	{
		this.CruiseCheckTimer.stop() // should we stop or keep it running, in order for it to be repaired..
		//i'd say performance is of the essense here, therefore we kill it until next witchspace / station launch
		return // return because we really dont need more checking from here
	}
    	
	//player.ship.consoleMessage("entering cruisecheck", 3) // for testing
	
		
	//if(system.isInterstellarSpace) //some person in the future might add a sun in interstellar space
	if(!system.sun)
			//so if there is a sun present, it will activate the crusing mode collector	
	{
		if(this.ispaceswitch && this.firstrun)
		{
			this.ispaceswitch = false
			this.firstrun = false
			player.consoleMessage("Fuel Collector",3)
			player.consoleMessage("Interstellar space: Fly at max speed to extract fuel",3)
		}
		
		//if there is not a sun there it will extract whatever it can from its surroundings..
		//however only as long as the player is at max speed.
		if(player.ship.speed == player.ship.maxSpeed)		
		this.$checkifover01(this.fuel_level_1*Math.random())
		return  
	}
	else 
	{		
		//what distance are we at to the star
		// to close and it will shutdown, to far away it will collect very little
		
		/* a notice on why it shuts down, when to close
		
		due to the fine filter of the fuel collector, it will shut down when it
		gets to close to the star so that the filter is having a chance of getting
		cleaned by the subsequent cleaning, which in effect harvest the fuel from
		the filter
		
		The fuel scoop will then take over shortly after..
		*/
		
		
		let sun_distance = player.ship.position.distanceTo(system.sun)+system.sun.radius	
		/* This is the old shut off if to close to sun..
		// this however didnt take into consideration, the proximity to the planet
		*/
		
		if((player.ship.speed > player.ship.maxSpeed) || ( 7 == player.ship.fuel)) //|| means explicit or // injector or warp speed
		{
            return // return because we really dont need more checking from here
		}
		
		let distancemodifier =10
				
		if(sun_distance< this.averagesun)
		distancemodifier = 30
		if(sun_distance< this.nearsun)
		distancemodifier = 50 //this is near the filters saturation limit,..
				
		let speedp = 100/player.ship.maxSpeed*player.ship.speed
		
		if(speedp>89)
		{
			this.$checkifover01(this.fuel_level_4+distancemodifier)			
			//player.consoleMessage("speed over 89 %", 3) // for testing
			return			
		}
		
		if(speedp>49)
		{
			this.$checkifover01(this.fuel_level_3+distancemodifier)
			//player.consoleMessage("speed over 49 %",3) // for testing
			return			
		}
		
		if(speedp>19)
		{
			this.$checkifover01(this.fuel_level_2+distancemodifier)
			//player.consoleMessage("speed over 19 %",3) // for testing
			return			
		}		
	}
}

this.$killCheck = function()
{
	//while this is no more the function that awards fuel after a kill, it still does valueble checkups
	if(player.ship.docked)
	{
		this.KillCheckTimer.stop()
		return
	}
	else
	{
		if(player.ship.fuel < 7 && player.ship.speed <= player.ship.maxSpeed) //if players tank is full, no need to check, dont work at injector or warp speed
		{
			let pl_target = player.ship.target
			//derelict ship section.   			
			if(pl_target && (this.derelictcount == this.hacktime+1)) //11 means our timer has not yet started, lets save some cpu cycles
			{
				let target_ship_AI = pl_target.AI
				if(target_ship_AI == "nullAI.plist" && this.derelictID != pl_target)	//derelict ships have nullAI.plist, ID means this is the last ship that has been linked too we either emptied its tanks, or it was empty
				{
					//player.ship.consoleMessage("got NULLAI:"+pl_target.primaryRole, 3)
					this.derelictID = false
					if(player.ship.position.distanceTo(pl_target) < 301)
					{
						//log("Fuel Collector", "distance below 301")
						//log("this.DerelictCheckTimer is"+this.DerelictCheckTimer)
						let isRunning = false
						if(this.DerelictCheckTimer)
						{
							if(this.DerelictCheckTimer.isRunning)
							isRunning = true
						}
						//if(pl_target.isPirate || pl_target.isTrader || pl_target.hasRole("hunter") && !this.DerelictCheckTimer)
						if(this.$CheckLegitDerelictRole(pl_target) && !isRunning)	//legit derelict ship Traders & Pirates & Hunters
						{
							//log("Fuel Collector", "got role")
							if(this.DerelictCheckTimer)
								this.DerelictCheckTimer.start()
							else
								this.DerelictCheckTimer = new Timer(this,this.$DerelictCheck,0,1) //tip dont use an arguement when you start a timer like this,this.mytimer(arguement) it will make a CTD
							player.consoleMessage("Fuel Collector", 3)
								player.consoleMessage("Established link to "+pl_target.displayName, 3)
						}
					}
				}
			}
		}
	}
	//check if Equipment has been damaged during battle..
	// we never got here if the fuel collector was not started in the first place which is why
	// we can use explicit OR
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") != "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK") //checkup of both dependacies
		this.KillCheckTimer.stop()
}

this.$CheckLegitDerelictRole = function(the_object)
{
	for(var i=0;i<this.legitDerelictRoles.length;i++)
	{
		if(the_object.primaryRole == this.legitDerelictRoles[i])
		return true
	}
	
	return false
}

this.shipLaunchedFromStation = function() //script starts here after startup borrowed from bouy repair great work Erich ;)
{
	//this.myswitch = true	//just in case there is a station inside the tonear zone
	//this.myswitch1 = false
	if(!this.planetlistdone)
	this.$buildplanetlist()
	this.planetlistdone = true
	
	this.ispaceswitch = true
	// && is correct, we need both dependancies for the Fuel Collector to start...	
		if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") == "EQUIPMENT_OK" && player.ship.equipmentStatus("EQ_FUEL_SCOOPS") == "EQUIPMENT_OK") //checkup of both dependacies
	{
		if(this.KillCheckTimer)
		this.KillCheckTimer.start()
		else
		this.KillCheckTimer = new Timer(this, this.$killCheck,0,3)
		
		if(this.CruiseCheckTimer)
		this.CruiseCheckTimer.start()
		else
		this.CruiseCheckTimer = new Timer(this,this.$CruiseCheck,0,this.checkawardhowoften)
	}
}

this.shipExitedWitchspace = function() //script starts here once player jumps to a new system
{
	// reset our switches player can have witched out, well within the tonear zone
	this.$buildplanetlist();
	this.ispaceswitch = true
	
	// && is correct, we need both dependancies for the Fuel Collector to start...
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") == "EQUIPMENT_OK" && player.ship.equipmentStatus("EQ_FUEL_SCOOPS") == "EQUIPMENT_OK") //checkup of both dependaciesif(player.ship.hasEquipment("EQ_FRAME_FUEL_COLLECTOR"))
	{
		if(this.KillCheckTimer)
		this.KillCheckTimer.start()
		else
		this.KillCheckTimer = new Timer(this, this.$killCheck,0,3)
		  
		if(this.CruiseCheckTimer)
		this.CruiseCheckTimer.start()
		else
		this.CruiseCheckTimer = new Timer(this,this.$CruiseCheck,0,this.checkawardhowoften)
	}
}

this.shipDied = function()
{
	//player.ship.consoleMessage("player died",10)
	if(this.KillCheckTimer)
	this.KillCheckTimer.stop()
	if(this.CruiseCheckTimer)
	this.CruiseCheckTimer.stop()
	if(this.consolemessageTimer)
	this.consolemessageTimer.stop()
	if(this.extractfuelTimer)
	this.extractfuelTimer.stop()
	if(this.itsatrapTimer)
	this.itsatrapTimer.stop()
}

this.shipTargetDestroyed = function(target)
{
	//should work as it will return if neither is present...
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") != "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK")
	return
	
	if((target.fuel > 0.09) && (player.ship.position.distanceTo(target) < 2000) && !(player.ship.speed > player.ship.maxSpeed) && !target.isThargoid)
	{
		let leech = target.fuel
		let leech2 = target.fuel/0.1
		//let ra = Math.random()	//percentage
		//leech = target.fuel*ra // random percetange to start with
		let ra=Math.random()
		if(ra>0.3)
		leech=leech2*0.1*0.015 //roughtly 0.1 lyof 7 ly
		if(ra<=0.3)
		leech=leech2*0.2*0.030 //award only 5%
		if(ra<0.1)
		leech=leech2*0.5*0.060 //award 10%
    					
		//roundoff
		leech = Math.round(leech/0.1)*0.1		    					 					   					
		
		if(leech >0) //only award if victim actually had any fuel left..
		{
			let ourmessage = "Fuel: "+leech+" LY"
			player.ship.fuel += leech
			
			//Sound.playMusic("FCscoop.ogg")
			//Sound.playMusic("FCtrumblesqueal.ogg")
			this.$delayedmessage(ourmessage,3,3) //lets avoid all the message garble when getting a kill
		}
	}
}

this.shipExitedPlanetaryVicinity = function()
{
	//log("Fuel Collector 0.4","Script Message: we exited vicinity") // used to trace a bug in 1.72.1
	this.tonearplanet --
	if(this.tonearplanet < 0)
	{
		log("Fuel Collector 0.4","Script messages that this.tonearplanet went negative:"+this.tonearplanet)
	}
	
	/* this.tonearplanet counts how many times we entered a planetary/moon/sun vicinity
	and substracts from that how many times we left a planetary vicinity
	if this.tonearplanet is 0 or false, it means we are in no planetary vicinities
	
	we are not spoiled here with the information of which planets vicinity we just left.
	we just are told, that we left one.. 
	*/
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") != "EQUIPMENT_OK" || player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK")
	return		
	
	if(this.tonearplanet)	
	player.consoleMessage("Fuel Collector activated",3)
	
}

this.shipEnteredPlanetaryVicinity = function(planet)
{
	//log("Fuel Collector 0.4","Script Message: we entered planet vicinity :"+planet)
	
	if(this.tonearplanet) //if the device is allready deactivated..
	{
		this.tonearplanet ++
		return
	}
	
	this.tonearplanet ++
	if(this.tonearplanet>system.planets.length)
	{
		log("Fuel Collector 0.4","Script messages that this.tonearplanet went above the number of globes"+this.tonearplanet)
	}
	
	
	if(player.ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") != "EQUIPMENT_OK")
	{
		return
	}
	
	if(player.ship.equipmentStatus("EQ_FUEL_SCOOPS") != "EQUIPMENT_OK")
	{
		return
	}
	
	
	if(planet.isSun) //sun checking
	{
		player.consoleMessage("Fuel Collector deactivated",3)
		player.consoleMessage("Too close to "+system.name+"¥s sun",3)		
		return
	}	
	
	if(system.planets.length == 1) // single planet system checking..
	{
		player.consoleMessage("Fuel Collector deactivated",3)
		player.consoleMessage("Too close to "+system.name,3)		
		return
	}	
	
	this.toclosetoname = false;
	
	// is this a planet
	
	for(var i = 0;i<this.planetlist.length;i++)
	{
		if(planet == this.planetlist[i])
		{
			this.toclosetoname = this.planetlist[i].name
		}
	}
	
	if(!this.toclosetoname) //if there where no match for a planet it means this is a moon
	{
		for(i = 0;i<this.moonlist.length;i++)
		{
			if(planet == this.moonlist[i])
			this.toclosetoname = this.moonlist[i].name
		}	
		
	}
	
	player.consoleMessage("Fuel Collector deactivated",3)
	player.consoleMessage("Too close to "+this.toclosetoname,3)	
}

this.$romanize = function(num)
{ // credits due where credits are earned: picked this up from 
  // http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter
	if (!+num)
		return num;
	var	digits = String(+num).split(""),
		key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
		       "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC",
		       "","I","II","III","IV","V","VI","VII","VIII","IX"],
		roman = "",
		i = 3;
	while (i--)
		roman = (key[+digits.pop() + (i * 10)] || "") + roman;
	return Array(+digits.join("") + 1).join("M") + roman;
}