Scripts/.InSystemTrader_worldscript.js.swp |
b0VIM 7.4 �4Q�7h� vlad SFC ~vlad/Dropbox/Development/Game Development/OOLite/dev/In_System_Trader_1.4.oxp/Scripts/InSystemTrader_worldscript.js
3210 #"! U tp Q ��������K R � ad f Q � � � � d 4 � � � k ' �
j
� � � T � � � t 6 �
�
�
�
h
a
� � n 5 � � � � g K D � � � � P � � � � � � Z � � � � � v t O � � � � � � k G " � � � f e var workingStation = system.mainStation; //Will need to watch for Errors here! //Illeagal/Controlled items are not refreshed! //We choose a single commodity to alter/refresh! var ChoiceCom = CommList[Choice]; ChoiceName = CommNames[Choice];1 if(Choice != 3 && Choice != 6 && Choice != 10){ var Choice = Math.floor(Math.random() * CommNames.length); var CommList = ["food","textiles","radioactives","slaves","liquor_wines","luxuries","narcotics","computers","machinery","alloys","firearms","furs","minerals","gold","platinum","gem_stones","alien_items"]; var CommNames = ["Food","Textiles","Radioactives","Slaves","Liquor/Wines","Luxuries","Narcotics","Computers","Machinery","Alloys","Firearms","Furs","Minerals","Gold","Platinum","Gem-Stones","Alien Items"]; //we will only allow the market to change when there IS a market and we are not docked! { if((!system.isInterstellarSpace) && (!player.ship.docked)) // I'm a moron, me. This needed to be an AND var ChoiceName = "nothing"; { this.cycleMarket = function() } //We will check docked status in the cycleMarket and do nothing if docked or if there is no MainStation! //initially this is a 300 second timer delay, to prevent changes While docked. this.timer = new Timer(this, this.cycleMarket, 300, 300); } this.IN_SYSTEM_TRADER_REP = missionVariables.IN_SYSTEM_TRADER_REP; { else } //otherwise we use a this.property //we only want to touch the missionVariables on save/load //missionVariables.IN_SYSTEM_TRADER_LAST_DEBARK = 0; missionVariables.IN_SYSTEM_TRADER_REP = 0; if (!missionVariables.IN_SYSTEM_TRADER_REP){ */ Handle first use of oxp, if we have no rep we set it to 0 for the first time! /* this.startUp = function (){ // Ambushes now happen where the player is // Although in Modified format // By popular demand, returned ambush and taunt //1.4 // Fixed a bug that was causing Market updates while docked! // Friendly com traffic reduced (multiplier removed) // Pirate taunts, while fun, have also been removed, as they make less sense now. // -Much rarer as well (multiplier removed) // rather than attack player directly // Refactored pirate attack, now I use them to impeade traders //1.35 // Added A.M.W. Unit Equipment and notification //1.30 // Fixed something I broke when fixing things... //1.22 // Fixed a code redundancy //1.21 // cycleMarket now explicitly mainStation // Debark timer remover, in favor of 1.77 timer function! // Code cleanup and timer use (as suggested by spara) // Ambush and greetings (when they make no sense) fixed //1.20 // Bugfix, refactored plist values //1.11 // Pirates make crude, and embarrasing, threats! // Stock now only cycled if it has been more than one hour (game time) since your last debark with a fresh market! // Moved Chatter to external plist //1.10 // Well meaning but medlesome friends now will try to set you up with good parcel deals to get you out more! // Repeatdly redocking now increases the chance you will get the attention of a pirate wing! //1.05 Added IN_SYSTEM_TRADER_REP property, will be used for tracking w/ mission variables. //1.01 added remaining items, no illegals, capped item stock at 63. //1.0 Basic changes, re-calculate prices/quantities when player leaves main station. //this.IN_SYSTEM_TRADER_LAST_DEBARK = 0; <=No longer used this.IN_SYSTEM_TRADER_REP = 0; this.version = "1.4"; this.description = "In system trader support"; this.licence = "CC BY 3.0"; this.copyright = "2013 Rob Hess"; this.author = "Dr.Tripsa"; this.name = "In_System_Trader"; "use strict"; ad � � � � � � � } } player.commsMessage(system.name + " traffic control: " + expandDescription("[in_system_trader_greet] [in_system_trader_invite] [in_system_trader_relation] [nom]. [in_system_trader_offer]")); //This too has had it's multiplier removed to make it less predictable[ |
Scripts/InSystemTrader_worldscript.js |
"use strict";
this.name = "In_System_Trader";
this.author = "Dr.Tripsa";
this.copyright = "2013 Rob Hess";
this.licence = "CC BY 3.0";
this.description = "In system trader support";
this.version = "1.4";
this.IN_SYSTEM_TRADER_REP = 0;
//this.IN_SYSTEM_TRADER_LAST_DEBARK = 0; <=No longer used
//1.0 Basic changes, re-calculate prices/quantities when player leaves main station.
//1.01 added remaining items, no illegals, capped item stock at 63.
//1.05 Added IN_SYSTEM_TRADER_REP property, will be used for tracking w/ mission variables.
// Repeatdly redocking now increases the chance you will get the attention of a pirate wing!
// Well meaning but medlesome friends now will try to set you up with good parcel deals to get you out more!
//1.10
// Moved Chatter to external plist
// Stock now only cycled if it has been more than one hour (game time) since your last debark with a fresh market!
// Pirates make crude, and embarrasing, threats!
//1.11
// Bugfix, refactored plist values
//1.20
// Ambush and greetings (when they make no sense) fixed
// Code cleanup and timer use (as suggested by spara)
// Debark timer remover, in favor of 1.77 timer function!
// cycleMarket now explicitly mainStation
//1.21
// Fixed a code redundancy
//1.22
// Fixed something I broke when fixing things...
//1.30
// Added A.M.W. Unit Equipment and notification
//1.35
// Refactored pirate attack, now I use them to impeade traders
// rather than attack player directly
// -Much rarer as well (multiplier removed)
// Pirate taunts, while fun, have also been removed, as they make less sense now.
// Friendly com traffic reduced (multiplier removed)
// Fixed a bug that was causing Market updates while docked!
//1.4
// By popular demand, returned ambush and taunt
// Although in Modified format
// Ambushes now happen where the player is
this.startUp = function (){
/*
Handle first use of oxp, if we have no rep we set it to 0 for the first time!
*/
if (!missionVariables.IN_SYSTEM_TRADER_REP){
missionVariables.IN_SYSTEM_TRADER_REP = 0;
//missionVariables.IN_SYSTEM_TRADER_LAST_DEBARK = 0;
//we only want to touch the missionVariables on save/load
//otherwise we use a this.property
}
else
{
this.IN_SYSTEM_TRADER_REP = missionVariables.IN_SYSTEM_TRADER_REP;
}
this.timer = new Timer(this, this.cycleMarket, 300, 300);
//initially this is a 300 second timer delay, to prevent changes While docked.
//We will check docked status in the cycleMarket and do nothing if docked or if there is no MainStation!
}
this.cycleMarket = function()
{
var ChoiceName = "nothing";
// I'm a moron, me. This needed to be an AND
if((!system.isInterstellarSpace) && (!player.ship.docked))
{
//we will only allow the market to change when there IS a market and we are not docked!
var CommNames = ["Food","Textiles","Radioactives","Slaves","Liquor/Wines","Luxuries","Narcotics","Computers","Machinery","Alloys","Firearms","Furs","Minerals","Gold","Platinum","Gem-Stones","Alien Items"];
var CommList = ["food","textiles","radioactives","slaves","liquor_wines","luxuries","narcotics","computers","machinery","alloys","firearms","furs","minerals","gold","platinum","gem_stones","alien_items"];
var Choice = Math.floor(Math.random() * CommNames.length);
if(Choice != 3 && Choice != 6 && Choice != 10){
ChoiceName = CommNames[Choice];1
var ChoiceCom = CommList[Choice];
//We choose a single commodity to alter/refresh!
//Illeagal/Controlled items are not refreshed!
//Will need to watch for Errors here!
var workingStation = system.mainStation;
var RAND_MULT = (system.scrambledPseudoRandomNumber(clock.minutes) * 255);
workingStation.setMarketPrice(ChoiceName,((Number(workingStation.market[ChoiceCom].marketBasePrice)) + (RAND_MULT & Number(workingStation.market[ChoiceCom].marketMaskPrice)) + ( Number(system.economy) * Number(workingStation.market[ChoiceCom].marketEcoAdjustPrice)))*4);
workingStation.setMarketQuantity(ChoiceName,(Number(workingStation.market[ChoiceCom].marketBaseQuantity) + (RAND_MULT & Number(workingStation.market[ChoiceCom].marketMaskQuantity)) - ( Number(system.economy) * Number(workingStation.market[ChoiceCom].marketEcoAdjustQuantity))) & 63);
//If the player has the EQ_SYSTEM_MARKET_WATCH, let us inform them of a change!
if(player.ship.equipmentStatus("EQ_SYSTEM_MARKET_WATCH") == "EQUIPMENT_OK")
{
var mySound = new SoundSource;
mySound.sound = "beep.ogg";
mySound.play();
player.consoleMessage("A.M.W.: Stock rotation detected on commodity: " + ChoiceName + ". See market datascreen (F8) for details.",8);
}
}
else
{
//Move pirate ambush code here as well, to be triggered when an invalid commodity is chosen
var RAND_MULTB = (Math.random() * 255);
//yes, we have a new RAND_MULT for this, separate of the clock
if((this.IN_SYSTEM_TRADER_REP >= RAND_MULTB) && (this.IN_SYSTEM_TRADER_REP >= 2))
{
//Ambush redux, the bitwise and caps the number of pirates at 16
//and comparing RAND_MULTB in the if keeps the players IN_SYSTEM_TRADER_REP relevant
//as the number of pirates will never be more than the players IN_SYSTEM_TRADER_REP
//I also removed the multiplier but kept the 'Rep must be at least 2' factor
var ambush = system.addShips("pirate",((RAND_MULTB & 15) +1), player.ship.position);
//Returning taunts
ambush[0].commsMessage(expandDescription("[in_system_trader_pgreet] [in_system_trader_ptaunt]"));
}
}
//Change the timer.interval, based on system activity, TY Spara!
var traders = system.countShipsWithPrimaryRole("trader");
if (traders > 0)
{
// 1/traders * (30 + [0 - 30]) mins till next price and restock check
this.timer.interval = Math.round((1 / traders) * (1800 + (Math.random() * 1800)));
}
}
}
this.shipLaunchedFromStation = function(station)
{
// Here we will give the IN_SYSTEM_TRADER_REP a boost
// We used to limit this to main station, now any station in system
// will boost IN_SYSTEM_TRADER_REP!
this.IN_SYSTEM_TRADER_REP += 1;
// If our IN_SYSTEM_TRADER_REP has crossed a threshhold of 16, we give a parcel Reputation bonus for knowing "the right" people!
// Note this probably will not have any effect until the player witches out and a new set of parcels is generated!
var test = this.IN_SYSTEM_TRADER_REP % 16;
if(test === 0)
{
player.increaseParcelReputation();
}
}
this.shipExitedWitchspace = function()
{
//Divide IN_SYSTEM_TRADER_REP by 2
//This will cause decrease as the once system bound player explores the Ooniverse
this.IN_SYSTEM_TRADER_REP /= 2;
}
this.playerWillSaveGame = function(message)
{
//Here we move the property back to mission variable for save.
missionVariables.IN_SYSTEM_TRADER_REP = this.IN_SYSTEM_TRADER_REP;
}
this.shipEnteredStationAegis = function(station)
{
//Give player a hint that the friends they have made might have deals for them
var RAND_MULT = (Math.random() * 255);
// this is indepandant of the clock
if((this.IN_SYSTEM_TRADER_REP >= RAND_MULT) && (this.IN_SYSTEM_TRADER_REP >=2))
{
//periodically we give the player a hint... friend of a friend etc
//This too has had it's multiplier removed to make it less predictable[
player.commsMessage(system.name + " traffic control: " + expandDescription("[in_system_trader_greet] [in_system_trader_invite] [in_system_trader_relation] [nom]. [in_system_trader_offer]"));
}
} |