Files
dsrc/sku.0/sys.server/compiled/game/script/working/reecetest.script
T
2013-09-10 23:17:15 -07:00

1222 lines
39 KiB
Plaintext

include library.ai_lib;
include library.battlefield;
include library.bio_engineer;
include library.buff;
include library.create;
include library.dot;
include library.features;
include library.hq;
include library.locations;
include library.mustafar;
include library.pclib;
include library.pet_lib;
include library.prose;
include library.player_structure;
include library.regions;
include library.skill;
include library.utils;
include library.space_crafting;
include library.space_transition;
//inherits theme_park.newbie_tutorial.tutorial_base;
const int SPAWN_TEMPLATE_CHECK_DISTANCE = 128;
const int SPAWN_CHECK_TEMPLATE_LIMIT = 140; // 14 templates allowed in an area
const int SPAWN_THEATER_CHECK_DISTANCE = 200;
const int SPAWN_CHECK_DISTANCE = 64; // you must move X meters before you get more spawns after the limit
const int SPAWN_CHECK_LIMIT = 15; // you get X creatures!
const int SPAWN_CHECK_THEATER_LIMIT = 1;
messageHandler checkDifficulty()
{
int intRawDifficulty = getLevel(self);
sendSystemMessageTestingOnly(self, "getLevel returned "+intRawDifficulty);
if(intRawDifficulty==0)
{
sendSystemMessageTestingOnly(self, "you lost your difficulty!");
deltadictionary dctScriptVars = self.getScriptVars();
sendSystemMessageTestingOnly(self, "Scriptvars are "+dctScriptVars.toString());
}
messageTo(self, "checkDifficulty", null, 3, false);
return SCRIPT_CONTINUE;
}
void setupJediTrainer(obj_id self)
{
//const string[] TRAINER_TYPES = { "trainer_brawler", "trainer_artisan", "trainer_scout", "trainer_marksman", "trainer_entertainer", "trainer_medic"};
const string[] TRAINER_TYPES = { "trainer_brawler"};//, "trainer_artisan", "trainer_scout", "trainer_marksman", "trainer_entertainer", "trainer_medic"};
string strPrimaryCategory = "trainer";
string strSecondaryCategory = TRAINER_TYPES[rand(0, TRAINER_TYPES.length-1)];
map_location[] mapLocations = getPlanetaryMapLocations(strPrimaryCategory, strSecondaryCategory);
if((mapLocations==null)||(mapLocations.length==0))
{
location locTest = getLocation(self);
LOG("DESIGNER_FATAL", "JEDI : For planet "+locTest.area+", primary category : "+strPrimaryCategory+" and secondary category "+strSecondaryCategory+" No planetary map location was found");
return;
}
int intRoll = rand(0, mapLocations.length-1);
location locHome = getLocation(self);
location locTest = new location();
locTest.x = mapLocations[intRoll].getX();
locTest.z = mapLocations[intRoll].getY();
locTest.area = locHome.area;
setObjVar(self, "jedi.locTrainerLocation", locTest);
return;
}
trigger OnHearSpeech(obj_id objSpeaker, string strText)
{
if(objSpeaker!=self)
{
return SCRIPT_CONTINUE;
}
if(strText=="name")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
string creatureName = getCreatureName(target);
sendSystemMessageTestingOnly(self, "creatureName = "+creatureName);
}
}
if(strText=="level")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
ai_lib.creatureLevelUp(target, self);
}
}
if(strText=="stats")
{
sendSystemMessageTestingOnly(self, "Action = "+getMaxAttrib(self, ACTION)+" Mind = "+getMaxAttrib(self, MIND));
sendSystemMessageTestingOnly(self, "Stamina = "+getMaxAttrib(self, STAMINA)+" Constitution = "+getMaxAttrib(self, CONSTITUTION));
}
if(strText=="cef1")
{
playClientEffectObj(self, "clienteffect/mustafar/som_force_crystal_drain.cef", self, "");
sendSystemMessageTestingOnly(self, "CEF 1 !!!!!!!!!");
}
if(strText=="cef2")
{
playClientEffectObj(self, "clienteffect/mustafar/som_force_crystal_buff.cef", self, "");
sendSystemMessageTestingOnly(self, "CEF 2 !!!!!!!!!");
}
if(strText=="cef3")
{
playClientEffectObj(self, "clienteffect/mustafar/som_force_crystal_destruction.cef", self, "");
sendSystemMessageTestingOnly(self, "CEF 3 !!!!!!!!!");
}
if(strText=="cef4")
{
playClientEffectObj(self, "clienteffect/mustafar/som_dark_jedi_laugh.cef", self, "");
sendSystemMessageTestingOnly(self, "CEF 4 !!!!!!!!!");
}
if(strText=="test")
{
//obj_id target = getLookAtTarget(self);
//if(target!=null)
obj_id dungeon = getTopMostContainer(self);
obj_id crystal = utils.getObjIdScriptVar(dungeon, "crystal");
messageTo (crystal, "crystalTest1", null, 1, false);
sendSystemMessageTestingOnly(self, "TEST !!!!!!!!!");
}
if(strText=="test2")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
messageTo (target, "crystalTest2", null, 1, false);
sendSystemMessageTestingOnly(self, "TEST2 !!!!!!!!!");
}
if(strText=="attach")
{
attachScript(self,"theme_park.dungeon.mustafar_trials.obiwan_finale.obiwan_quest_monitor");
if(hasScript(self,"theme_park.dungeon.mustafar_trials.obiwan_finale.obiwan_quest_monitor"))
sendSystemMessageTestingOnly(self, "script attached");
}
if(strText=="detach")
{
if(detachScript(self,"theme_park.dungeon.mustafar_trials.obiwan_finale.obiwan_quest_monitor"))
sendSystemMessageTestingOnly(self, "script detatched");
}
if(strText=="fireone")
{
attachScript(self,"theme_park.dungeon.mustafar_trials.obiwan_finale.obiwan_quest_monitor");
sendSystemMessageTestingOnly(self, "fireone");
if (mustafar.canCallObiwan(self))
{
mustafar.callObiwan(self, true);
sendSystemMessageTestingOnly(self, "callingObiwan");
}
else
{
setObjVar(self, "waitingOnObiwan", 1);
messageTo(self, "recallObiwanDelay", null, 180, false);
sendSystemMessageTestingOnly(self, "recallObiwanDelay");
}
sendSystemMessageTestingOnly(self, "firetwo");
}
if(strText=="firetwo")
{
sendSystemMessageTestingOnly(self, "firetwo");
utils.setScriptVar(self,"sawObiwanAtLauncher",1);
}
if(strText=="hittem")
{
sendSystemMessageTestingOnly(self, "hittem");
obj_id target = getLookAtTarget(self);
if(target!=null)
{
obj_id weapon = getCurrentWeapon(self);
hit_result cbtHitData = new hit_result();
cbtHitData.success = true;
cbtHitData.baseRoll = 50;
cbtHitData.finalRoll = 100;
cbtHitData.hitLocation = rand(0, 5);
cbtHitData.canSee = true;
cbtHitData.damage = 5000;
cbtHitData.bleedingChance = 0;
doDamage(self, target, weapon, cbtHitData);
}
}
if(strText=="cbuff")
{
buff.applyBuff(self, "crystal_buff");
sendSystemMessageTestingOnly(self, "I C'BUFFED YA!");
}
if(strText=="dbuff")
{
buff.removeAllBuffs(self);
sendSystemMessageTestingOnly(self, "I D'BUFFED YA!");
}
if(strText=="reforce")
{
sendSystemMessageTestingOnly(self, "reforce start");
obj_id target = getLookAtTarget(self);
if(target!=null)
{
messageTo(target, "specialForcePowerAttackWindup", null, rand(10,20), false);
}
sendSystemMessageTestingOnly(self, "reforce done");
}
if(strText=="bossman")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
if (utils.hasScriptVar(target, "dungeon"))
{
sendSystemMessageTestingOnly(self, "got dungeon objid. going to spawn BOSS.");
obj_id dungeon = utils.getObjIdScriptVar(target, "dungeon");
//mustafar.spawnContents(dungeon, "boss", 1);
spawnContents(dungeon, "boss", 1);
}
}
}
if(strText=="currentScene")
{
string scene = getCurrentSceneName();
sendSystemMessageTestingOnly(self, "current scene name is: "+scene);
}
if(strText=="locations")
{
for(int i = 0; i< 4; i++)
{
location here = getLocation(self);
location spawnLoc = locations.getGoodLocationAroundLocation(here, 1f, 1f, 4f, 4f);
if ( spawnLoc == null )
{
sendSystemMessageTestingOnly(self, " spawnLoc was NULL ");
spawnLoc = here;
}
sendSystemMessageTestingOnly(self, "found location #"+i+" and it was at: "+spawnLoc);
}
}
if(strText=="expansion")
{
if(features.hasTrialsOfObiwanExpansion(self))
sendSystemMessageTestingOnly(self, " YEE HAW! GOT MUSTAFAR");
else
sendSystemMessageTestingOnly(self, "No mustafar expansion detected");
if(features.hasEpisode3PreOrderDigitalDownload(self))
sendSystemMessageTestingOnly(self, " YEE HAW! EP3 Preorder");
else
sendSystemMessageTestingOnly(self, "No EP3 pre-order expansion detected");
}
if(strText=="petcount")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
int petcount = pet_lib.getMaxStoredPets( target );
sendSystemMessageTestingOnly(self, " Got pet count. It was: "+petcount);
}
}
if(strText=="patroller")
{
location here = getLocation(self);
obj_id spawn = create.object("fbase_stormtrooper", here);
/*
const string[] BASE_CELL_NAMES = {
"mainhall",
"foyer",
"entry"
};
*/
obj_id base = player_structure.getStructure(self);
string[] base_cells = getCellNames(base);
//resizeable obj_id[] cells = new obj_id[0];
location[] locs = new location [base_cells.length];
for(int i = 0; i< base_cells.length; i++)
{
/*
obj_id cellId = getCellId(base, BASE_CELL_NAMES[i]);
if ( isIdValid(cellId))
cells = utils.addElement(cells, cellId);
location iSpot = new location(dx, dy, dz, here.area, cellId);
*/
locs[i] = getGoodLocation(base, base_cells[i]);
}
ai_lib.setPatrolPath( spawn, locs );
}
if(strText=="conditionon")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
hq.activateHackAlarms(target, true);
hq.activateDestructAlarms(target, true);
sendSystemMessageTestingOnly(self, "alarm!");
}
}
if(strText=="conditionoff")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
hq.activateHackAlarms(target, false);
hq.activateDestructAlarms(target, false);
sendSystemMessageTestingOnly(self, "alarm! off");
}
}
if(strText=="respawnalarms")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
hq.cleanupBaseAlarmUnits(target);
hq.spawnAlarmUnits(target);
sendSystemMessageTestingOnly(self, "alarm! RESPAWN!");
}
}
if(strText=="disableobj")
{
obj_id target = getLookAtTarget(self);
sendSystemMessageTestingOnly(self, "disabled objective! target is: "+target);
if(target!=null)
{
hq.disableObjective(target);
sendSystemMessageTestingOnly(self, "disabled objective!");
}
}
if(strText=="startcountdown")
{
obj_id target = getLookAtTarget(self);
sendSystemMessageTestingOnly(self, "startcountdown detected! target is: "+target);
if(target!=null)
{
float delay = 300f + 300f * 1;
int minutes = Math.round(delay/60f);
obj_id[] players = player_structure.getPlayersInBuilding(getTopMostContainer(target));
if ( players != null && players.length > 0 )
{
for ( int i = 0; i < players.length; i++ )
sendSystemMessageProse(players[i], prose.getPackage(new string_id ("faction/faction_hq/faction_hq_response", "terminal_response40"), minutes));
}
int stamp = getGameTime() + Math.round(delay);
utils.setScriptVar(target, "countdownInProgress", stamp);
dictionary d = new dictionary();
d.put("player", self);
d.put("cnt", minutes);
messageTo(target, "handleCountdown", d, 10f, false);
}
}
if(strText=="accountCheck")
{
obj_id target = getLookAtTarget(self);
if(target!=null)
{
int pBits = getSubscriptionFeatureBits(target);
sendSystemMessageTestingOnly(self, "CHECKING ACCOUNT TYPE Got account bits. They came back as: "+pBits);
if ( (utils.isFreeTrial(target) ))
sendSystemMessageTestingOnly(self, "It would appear that this IS a free trial account, per results from utils.isFreeTrial");
else
sendSystemMessageTestingOnly(self, "It would appear that this IS NOT a free trial account, per results from utils.isFreeTrial");
obj_id playerObject = getPlayerObject(target);
if(playerObject!=null)
{
pBits = getSubscriptionFeatureBits(playerObject);
sendSystemMessageTestingOnly(self, "Running same checks on PLAYER ACCOUNT OBJECT. Got account bits came back as: "+pBits);
if ( (utils.isFreeTrial(playerObject) ))
sendSystemMessageTestingOnly(self, "testing PLAYER ACCOUNT OBJ, this IS a free trial account, per results from utils.isFreeTrial");
else
sendSystemMessageTestingOnly(self, "testing PLAYER ACCOUNT OBJ, this IS NOT a free trial account, per results from utils.isFreeTrial");
}
}
}
if(strText=="reloadtest")
{
obj_id ship = space_transition.getContainingShip (self);
if(!isIdValid(ship))
return SCRIPT_CONTINUE;
int[] slots = space_crafting.getShipInstalledSlots(ship);
for(int i = 0; i< slots.length; i++)
{
if (space_crafting.isMissileSlot(ship, slots[i]))
setShipWeaponAmmoCurrent(ship, slots[i], 1);
else if (space_crafting.isCounterMeasureSlot(ship, slots[i]))
setShipWeaponAmmoCurrent(ship, slots[i], 1);
}
sendSystemMessageTestingOnly(self, "unloaded!");
}
if(strText=="zaprear")
{
obj_id ship = space_transition.getContainingShip (self);
if(!isIdValid(ship))
return SCRIPT_CONTINUE;
setShipShieldHitpointsBackCurrent(ship, 5.0f);
sendSystemMessageTestingOnly(self, "BANG! Rear Shields ZAPPED! Should be at 5.0f units");
}
if(strText=="gettime")
{
long now = System.currentTimeMillis();
long curTime = ((now / 1000) - 1072224000);
int currentTime = (int) curTime + 3600;
sendSystemMessageTestingOnly(self, "SET STAMP TIME TO: "+currentTime);
}
if(strText=="getlots")
{
sendSystemMessageTestingOnly(self, "Got getlots command");
obj_id playerObject = getPlayerObject(self);
int lots = getAccountNumLots(playerObject);
sendSystemMessageTestingOnly(self, "Current Lots Count is "+lots);
}
if(strText=="getcell")
{
string currentCell = getCellName(self);
sendSystemMessageTestingOnly(self, "DEBUG - currentCell VIA reecetest IS: "+currentCell);
location locTest = getLocation(self);
if(isIdValid(locTest.cell))
{
sendSystemMessageTestingOnly(self, "DEBUG - current cell information VIA reecetest locTest IS: "+locTest.cell);
currentCell = getCellName(locTest.cell);
sendSystemMessageTestingOnly(self, "DEBUG - currentCell VIA reecetest, second method IS: "+currentCell);
}
else
sendSystemMessageTestingOnly(self, "DEBUG - current cell information VIA reecetest locTest IS NOT VALID ");
}
if(strText=="goSlow")
{
obj_id objMount = getMountId(self);
setBaseRunSpeed(objMount, 6.0f); // RUn like the wind!
sendSystemMessageTestingOnly(self, "SLOOOW");
}
if(strText=="slowMe")
{
setBaseRunSpeed(self, 1.0f); // RUn like the wind!
}
if(strText=="fastMe")
{
setBaseRunSpeed(self, 6.0f); // RUn like the wind!
}
if(strText=="getScriptVars")
{
deltadictionary dctScriptVars = self.getScriptVars();
sendSystemMessageTestingOnly(self, "Scriptvars are "+dctScriptVars.toString());
}
if(strText=="basereset")
{
sendSystemMessageTestingOnly(self, "Received baseReset command.");
obj_id target = getLookAtTarget(self);
if(target!=null)
{
sendSystemMessageTestingOnly(self, "Sending message to target. Obj_id target is: "+target);
messageTo(target, "handleManualSpawnResetTest", null, 3, false);
}
}
else if(strText=="getStats")
{
//setMaxAttrib(self, CONSTITUTION, 300);
//setMaxAttrib(self, HEALTH, 1000);
//setMaxAttrib(self, STRENGTH, 300);
//setMaxAttrib(self, STAMINA, 300);
//setMaxAttrib(self, ACTION, 1000);
//setMaxAttrib(self, QUICKNESS, 1000);
//setMaxAttrib(self, WILLPOWER, 300);
//setMaxAttrib(self, MIND, 400);
//setMaxAttrib(self, FOCUS, 300);
obj_id objTarget = getLookAtTarget(self);
if(objTarget!=null)
{
int intConstitution = getConst(objTarget);
int intHealth = getHealth(objTarget);
sendSystemMessageTestingOnly(self, "Const="+intConstitution+" Health="+intHealth);
int intStamina = getStam(objTarget);
int intAction = getAction(objTarget);
sendSystemMessageTestingOnly(self, "Stamina="+intStamina+" Action="+intAction);
int intWillPower = getWill(objTarget);
int intMind = getMind(objTarget);
sendSystemMessageTestingOnly(self, "WillPower="+intWillPower+" Mind="+intMind);
}
}
if(strText=="damage")
{
obj_id objTarget = getLookAtTarget(self);
if(objTarget!=null)
{
obj_id objWeapon = getCurrentWeapon(self);
hit_result cbtHitData = new hit_result();
cbtHitData.success = true;
cbtHitData.baseRoll = 50;
cbtHitData.finalRoll = 100;
cbtHitData.hitLocation = rand(0, 5);
cbtHitData.canSee = true;
cbtHitData.damage = 200;
cbtHitData.bleedingChance = 1;
doDamage(self, objTarget, objWeapon, cbtHitData);
sendSystemMessageTestingOnly(self, "200 damage done to target");
debugSpeakMsg(objTarget, "ow!");
}
}
if(strText=="music")
{
//playMusic(self, "sound/music_acq_academic.snd");
//playMusic(self, "sound/music_event_celebration.snd");
playMusic(self, "sound/music_int_complete_rebel.snd");
}
if(strText=="badWeapon")
{
obj_id objWeapon = createObject("object/weapon/ranged/rifle/rifle_dlt20a.iff", getLocation(self));
setWeaponAttackSpeed(objWeapon, 1.5f);
}
if(strText=="checkFlags")
{
obj_id objTarget = getLookAtTarget(self);
if(isIdValid(objTarget))
{
sendSystemMessageTestingOnly(self, "NPC is: "+objTarget);
sendSystemMessageTestingOnly(self, "InvulnerableFlag is: "+isInvulnerable(objTarget));
sendSystemMessageTestingOnly(self, "pvpCanAttack is: "+ pvpCanAttack(self, objTarget));
}
}
if(strText=="combatr2")
{
debugServerConsoleMsg(self, "working.reecetest - entered combatr2 module");
obj_id inventoryContainer = getObjectInSlot(self, "inventory");
if ( !isIdValid(inventoryContainer) )
debugServerConsoleMsg(self, "working.reecetest - looks like the objid of the player inventory is invalid");
obj_id deed = createObject("object/tangible/deed/pet_deed/deed_r2_basic.iff", inventoryContainer, "SLOT_INVENTORY");
if ( !isIdValid(deed) )
debugServerConsoleMsg(self, "working.reecetest - failed to create the deed object");
int powerLevel = 50;
const string CREATURE_NAME = "r2_crafted";
// Load the creature data from the datatable and initialize the prototype
dictionary creatureDict = dataTableGetRow( create.CREATURE_TABLE, "r2_crafted" );
setObjVar (deed, "creature_attribs.type", "r2_crafted" );
setObjVar(deed, "creature_attribs.level", 30);
setObjVar(deed, "creature_attribs.maxHealth", 4000);
setObjVar(deed, "creature_attribs.maxConstitution", 0);
setObjVar(deed, "creature_attribs.general_protection", 2000);
setObjVar(deed, "creature_attribs.toHitChance", 81);
setObjVar(deed, "creature_attribs.defenseValue", 81);
setObjVar(deed, "creature_attribs.minDamage", 61);
setObjVar(deed, "creature_attribs.maxDamage", 284);
setObjVar(deed, "creature_attribs.aggroBonus", 0.0f);
setObjVar(deed, "creature_attribs.critChance", 0.0f);
setObjVar(deed, "creature_attribs.critSave", 0.0f);
setObjVar(deed, "creature_attribs.scale", 1.0f);
setObjVar(deed, "creature_attribs.stateResist", 0.0f);
setObjVar(deed, "crafting_components.cmbt_module", 600.0f );
setObjVar(deed, "dataModuleRating", 12);
setObjVar(deed, "ai.pet.hasContainer", 12);
setObjVar(deed, "ai.pet.isRepairDroid", true);
setObjVar(deed, "craftingStationSpace", true);
setObjVar(deed, "craftingStationWeapon", true);
setObjVar(deed, "craftingStationFood", true);
}
if(strText=="combatprobot")
{
debugServerConsoleMsg(self, "working.reecetest - entered probot module");
obj_id inventoryContainer = getObjectInSlot(self, "inventory");
if ( !isIdValid(inventoryContainer) )
debugServerConsoleMsg(self, "working.reecetest - looks like the objid of the player inventory is invalid");
obj_id object = createObject("object/tangible/deed/pet_deed/deed_probot_basic.iff", inventoryContainer, "SLOT_INVENTORY");
if ( !isIdValid(object) )
debugServerConsoleMsg(self, "working.reecetest - failed to create the deed object");
int powerLevel = 50;
const string CREATURE_NAME = "probot";
// Load the creature data from the datatable and initialize the prototype
dictionary creatureDict = dataTableGetRow( create.CREATURE_TABLE, "r2_crafted" );
setObjVar ( object, "creature_attribs.type", "probot" );
// Calculate the creatures stats based on the final attributes and set on the prototype
for ( int attribNum = HEALTH; attribNum <= WILLPOWER; attribNum++)
{
int minAttrib = creatureDict.getInt( create.MINATTRIBNAMES[ attribNum ] );
int maxAttrib = creatureDict.getInt( create.MAXATTRIBNAMES[ attribNum ] );
int attribRange = maxAttrib - minAttrib;
int newAttribValue = (int) ((attribRange * powerLevel) / 1000) + minAttrib;
setObjVar ( object, "creature_attribs." + create.MAXATTRIBNAMES[attribNum], newAttribValue );
}
// to-hit chance
int toHitChance = creatureDict.getInt( "toHitChance" );
float minToHit = toHitChance + (toHitChance * bio_engineer.CREATURE_MIN_TO_HIT_MOD);
float maxToHit = toHitChance + (toHitChance * bio_engineer.CREATURE_MAX_TO_HIT_MOD);
setObjVar ( object, "creature_attribs.toHitChance", toHitChance );
obj_id creatureWeapon = getCurrentWeapon( object );
if ( !isIdValid(creatureWeapon) )
debugServerConsoleMsg(self, "working.reecetest - failed to get the obj_id of the creature's current weapon. Uh oh!");
// attack speed
float wpnSpeed = (float)creatureDict.getInt("attackSpeed");
float minWpnSpeed = wpnSpeed + (wpnSpeed * bio_engineer.CREATURE_MIN_WEAPON_SPEED_MOD);
float maxWpnSpeed = wpnSpeed + (wpnSpeed * bio_engineer.CREATURE_MAX_WEAPON_SPEED_MOD);
setObjVar ( object, "creature_attribs.attackSpeed", wpnSpeed );
// damage
int minDamage = creatureDict.getInt("minDamage");
int maxDamage = creatureDict.getInt("maxDamage");
float minMinDamage = minDamage + (minDamage * bio_engineer.CREATURE_MIN_DAMAGE_MOD);
float maxMinDamage = minDamage + (minDamage * bio_engineer.CREATURE_MAX_DAMAGE_MOD);
float minMaxDamage = maxDamage + (maxDamage * bio_engineer.CREATURE_MIN_DAMAGE_MOD);
float maxMaxDamage = maxDamage + (maxDamage * bio_engineer.CREATURE_MAX_DAMAGE_MOD);
minDamage = (int) (minMinDamage + (((maxMinDamage - minMinDamage) * powerLevel) / 1000));
maxDamage = (int) (minMaxDamage + (((maxMaxDamage - minMaxDamage) * powerLevel) / 1000));
setObjVar ( object, "creature_attribs.minDamage", minDamage);
setObjVar ( object, "creature_attribs.maxDamage", maxDamage);
setObjVar ( object, "crafting_components.cmbt_module", 600.0f );
}
return SCRIPT_CONTINUE;
}
location getGoodMissionLocation(location locSpawnLocation, obj_id objPlayer)
{
int intSize = 72;
location locGoodLocation = locations.getGoodLocationAroundLocation(locSpawnLocation,intSize, intSize, 300, 300, false, true);
if(locGoodLocation==null)
{
locGoodLocation = locations.getGoodLocationAroundLocation(getLocation(objPlayer), intSize, intSize, 400, 400, false, true);
if(locGoodLocation==null)
{
////LOG("DESIGNER_FATAL", "location "+locSpawnLocation+" and size "+intSize+" generated a null good location so we're returning false");
return null;
}
}
if(locations.isInMissionCity(locGoodLocation))
{
locGoodLocation = locations.getGoodLocationAroundLocation(getLocation(objPlayer), intSize, intSize, 400, 400, false, true);
if(locGoodLocation==null)
{
////LOG("DESIGNER_FATAL", "location "+locSpawnLocation+" and size "+intSize+" generated a null good location so we're returning false");
return null;
}
if(locations.isInMissionCity(locGoodLocation))
{
return null;
}
}
region rgnBattlefield= battlefield.getBattlefield(locGoodLocation);
if(rgnBattlefield!=null)
{
return null;
}
if(locations.isInMissionCity(locGoodLocation))
{
return null;
}
return locGoodLocation;
}
boolean checkTemplatesInRange(obj_id objPlayer, location locHome, boolean boolCheckForTheaters, string strObjectType) // boolean for finding a REAL spawn location as oppposed to around the playre
{
boolean boolLogFailures = true;
boolean boolVerboseMode = true;
//////LOG("spawning", objPlayer+ " Canspawn checking templaktes in range (" + SPAWN_TEMPLATE_CHECK_DISTANCE + ")");
//////LOG("spawning", objPlayer+ " locHome is "+locHome);
//obj_id[] objTemplates = getAllObjectsWithScript(locHome, SPAWN_TEMPLATE_CHECK_DISTANCE, "systems.spawning.spawn_template");
float fltDistance = rand(120, 200);
obj_id[] objTemplates = getObjectsInRange(locHome, fltDistance);
// we'll use SP
if(objTemplates==null)
{
return true;
}
else
{
//////LOG("spawning", objPlayer+ " " + objTemplates.length + " objects in range");
// we need to check what kind of templates we found..
// if we get more than 1 theater objects within a 64 meter radius of the spawn, we kick out
// if we get 1 object of the theater parent type, within 100 meters, we kick out
if(boolCheckForTheaters)
{
////LOG("spawning", objPlayer+ " locHome was "+locHome);
obj_id[] objLairs = getAllObjectsWithTemplate(locHome, fltDistance, "object/tangible/lair/npc_lair.iff");
if(objLairs!=null)
{
sendSystemMessageTestingOnly(objPlayer, "Non null objLairs.. length is "+objLairs.length);
/*
for(int intI = 0; intI< objLairs.length; intI++)
{
location locLairHome = getLocation(objLairs[intI]);
float fltDistance = getDistance(locLairHome, locHome);
////LOG("spawning", objPlayer+ " fltDistance is "+fltDistance);
////LOG("spawning", objPlayer+ "for object "+objLairs[intI]+" location is "+locLairHome);
}
*/
////LOG("spawning", objPlayer+ " objLairs is "+objLairs.length);
if(objLairs.length>0)
{
string strSpam = objPlayer+ " Too many lairs in the area, kicking out, area was "+locHome+" number of lairs is "+objLairs.length;
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
return false;
}
}
if(strObjectType!=null)
{
int intIndex = strObjectType.indexOf("theater");
if(intIndex>-1)
{ // it's a theater, so do our uber check
objLairs = getAllObjectsWithTemplate(locHome, 200, "object/creature/planet/bothan_male.iff");
int intCount = utils.countSubStringObjVars(objLairs, "spawing.lairType", "theater");
if(intCount>0)
{
string strSpam = objPlayer+ " theaters in range is "+intCount+" too many at location "+locHome;
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
return false;
}
}
}
/*
objTheaters = getAllObjectsWithObjVar(locHome, 200, "theater.stamp"); // look for parents
if(objTheaters!=null)
{
//////LOG("spawning", objPlayer+ " objTheaters.length is "+objTheaters.length);
//////LOG("spawning", objPlayer+ " locHome is "+locHome);
if(objTheaters.length>0)
{
//////LOG("spawning", objPlayer+ " Parent object found in range, returning false");
//////LOG("spawning", objPlayer+ " objTheaters length of "+objTheaters.length+" is greater than 0");
return false;
}
}
*/
obj_id[] objTheaters = getAllObjectsWithObjVar(locHome, 200, "isScenario"); // scenario check
if(objTheaters!=null)
{
if(objTheaters.length>0)
{
string strSpam = objPlayer+ " too many scenarios neat "+locHome+" count was "+objTheaters.length;
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
return false;
}
}
}
if(objTemplates.length>SPAWN_CHECK_TEMPLATE_LIMIT)
{
if(boolLogFailures)
{
string strSpam = objPlayer+ " found too many normal templates in range of "+locHome+" count was "+objTemplates.length;
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
}
return false;
}
}
//////LOG("spawning", objPlayer+ " returning true from checkTemplatesInRange");
return true;
}
boolean canSpawn(obj_id objPlayer, location locSpawnLocation, boolean boolCheckForTheaters, string strObjectType)
{
boolean boolLogFailures = true;
boolean boolVerboseMode = true;
if(!isSpawningAllowed(locSpawnLocation))
{
string strSpam = objPlayer+ " spawning not allowed on "+locSpawnLocation.area;
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
return false;
}
////LOG("spawning", "canSpawn: running check for " + objPlayer);
//////LOG("spawning", "canspawn check");
int intServerSpawnLimit = getServerSpawnLimit();
string strSpam = "";
//string strSpam = objPlayer +" intserverspawnlimit is "+intServerSpawnLimit;
//sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
// we need to compare our current location distance to the last couple of spawns...
// AM I IN A STRUCTURE?!?!?!
// if so, we're kicking out
//////////LOG("spawn_spam", "objPlayer is "+objPlayer);
/// check number of everything to make sure we're good
location locCurrentLocation = getLocation(objPlayer);
if(locCurrentLocation.area=="tutorial")
{
strSpam = objPlayer+ " canSpawn failed: spawning disabled in tutorial";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
////LOG("spawning", "IN TUTORIAL, FAILING CANSPAWN");
return false; // tutorial
}
region[] rgnCities = getRegionsWithMunicipalAtPoint(locCurrentLocation, regions.MUNI_TRUE);
if(rgnCities!=null)
{
// in a city
strSpam = objPlayer+ " canSpawn failed: spawning not allowed in cities";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
////////LOG("spawning", "In A city returnig false from canspawn");
return false;
}
region rgnBattlefield= battlefield.getBattlefield(locCurrentLocation);
if(rgnBattlefield!=null)
{
strSpam = objPlayer+ " canSpawn failed: spawning disabled in battlefields";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
////////LOG("spawning", "In A battlefield returnig false from canspawn");
return false;
}
rgnCities = getRegionsWithGeographicalAtPoint(locCurrentLocation, regions.GEO_CITY);
if(rgnCities!=null)
{
strSpam = objPlayer+" canSpawn failed: spawning not allowed in cities";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
// in a city
////////LOG("spawning", "In A city returnig false from canspawn");
return false;
}
obj_id objMasterSpawner = getPlanetByName(locCurrentLocation.area);
if(hasObjVar(objMasterSpawner, "boolSpawnerIsOn"))
{
//////////LOG("spawn_spam", "Spawner has objvar");
boolean boolSpawnerIsOn;
boolSpawnerIsOn = getBooleanObjVar(objMasterSpawner, "boolSpawnerIsOn");
//////////LOG("spawn_spam", "objVar is "+boolSpawnerIsOn);
// is it set to on?
if(boolSpawnerIsOn==false)
{
strSpam = objPlayer+" canSpawn failed: spawning is disabled";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
////////LOG("spawning", "Spawn system is turned off, returnign false");
return boolSpawnerIsOn;
}
}
//////////LOG("player_spawner", "Cell is "+locCurrentLocation.cell);
if(locCurrentLocation.cell!=obj_id.NULL_ID)
{
// INSIDE OF A CELL! BAD!
strSpam = objPlayer+ " canSpawn failed: spawnig is disabled in cells";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
return false;
}
if(hasObjVar(objPlayer, "spawning.locSpawnLocation"))
{
// check quantitities
int intSpawnedTemplates = 0;
if(hasObjVar(objPlayer, "spawning.intSpawnedTemplates"))
{
intSpawnedTemplates = getIntObjVar(objPlayer, "spawning.intSpawnedTemplates"); // how many we spawned in the current area
////////LOG("player_spawner", objPlayer + "'s intSpawnedTemplates is "+intSpawnedTemplates);
}
if(intSpawnedTemplates>=SPAWN_CHECK_LIMIT)
{
// greater than.. check our location
////////LOG("player_spawner", objPlayer+ " greater than "+SPAWN_CHECK_LIMIT);
location locLastSpawnLocation = getLocationObjVar(objPlayer, "spawning.locSpawnLocation");
////////LOG("spawner", "locCurrentLocation is "+locCurrentLocation);
////////LOG("spawner", "locLastSpawnLocation is "+locLastSpawnLocation);
float fltDistance = utils.getDistance(locLastSpawnLocation, locCurrentLocation);
////////LOG("player_spawner",objPlayer+ " fltDistance is "+fltDistance);
if(fltDistance<SPAWN_CHECK_DISTANCE)
{
strSpam = objPlayer+ " You need to move before we spawn more stuff";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
strSpam = objPlayer+ " The minimum check distance is: " + SPAWN_CHECK_DISTANCE;
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
strSpam = objPlayer+ " Your distance is: " + fltDistance;
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
// don't spawn anything because they hit their max within the current range
return false;
}
}
}
if(locSpawnLocation!=null)
{
rgnCities = getRegionsWithMunicipalAtPoint(locSpawnLocation, regions.MUNI_TRUE);
if(rgnCities!=null)
{
strSpam = " spawn location is in a city, returning false from canspawn";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
// in a city
//////LOG("spawning", objPlayer+ " canSpawn failed: spawning not allowed in cities");
return false;
}
rgnCities = getRegionsWithGeographicalAtPoint(locSpawnLocation, regions.GEO_CITY);
if(rgnCities!=null)
{
strSpam = "location is in a city2, returning false from canspawn";
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
// in a city
//////LOG("spawning", objPlayer+ " canSpawn failed: spawning not allowed in cities");
return false;
}
rgnBattlefield = battlefield.getBattlefield(locSpawnLocation);
if(rgnBattlefield!=null)
{
strSpam = "location is in a battlefield, returning false from canspawn";
//////LOG("spawning", objPlayer+ " canSpawn failed: spawning not allowed in battlefields");
sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
return false;
}
// check to make sure there aren't too many creatures in the area
// also check for the number of players
if(!checkTemplatesInRange(objPlayer, locSpawnLocation, boolCheckForTheaters, strObjectType))
{
//strSpam = objPlayer+ " Too many templates in area, canspawn returns false";
//sendSpawnSpam(objPlayer, boolLogFailures, boolVerboseMode, strSpam);
//////LOG("spawning", objPlayer+ " canSpawn failed: checkTemplatesInRange returned false ");
return false; // TOO MANY TEMPLATES IN THE AREA. DON'T SPAWN.
}
}
//////////LOG("spawn_spam",objPlayer+" canSpawn returned true");
return true;
}
void sendSpawnSpam(obj_id self, boolean boolLogFailures, boolean boolVerboseMode, string strSpam)
{
sendSystemMessageTestingOnly(self, strSpam);
return;
}
boolean isSpawningAllowed(location locTest)
{
return true;
}
commandHandler gmCreateSpecificResource()
{
string strClass = params;
if((strClass==null)||(strClass==""))
{
sendSystemMessageTestingOnly(self, "Bad class passed in, syntax is /gmCreateClassResource class");
return SCRIPT_CONTINUE;
}
//obj_id rtype = getResourceTypeByName(strClass);
obj_id rtype = pickRandomNonDepeletedResource(strClass);
if(!isIdValid(rtype))
{
sendSystemMessageTestingOnly(self, "No id found");
sendSystemMessageTestingOnly(self, "Type was "+strClass);
return SCRIPT_CONTINUE;
}
string crateTemplate = getResourceContainerForType(rtype);
if ( !crateTemplate.equals("") )
{
obj_id pInv = utils.getInventoryContainer(self);
if ( pInv != null )
{
obj_id crate = createObject(crateTemplate, pInv, "");
if ( addResourceToContainer (crate, rtype, 100000, self) )
{
sendSystemMessageTestingOnly(self, "Resource of class "+params+" added");
return SCRIPT_CONTINUE;
}
}
}
return SCRIPT_CONTINUE;
}
commandHandler gmCreateClassResource()
{
string strClass = params;
if((strClass==null)||(strClass==""))
{
sendSystemMessageTestingOnly(self, "Bad class passed in, syntax is /gmCreateClassResource class");
return SCRIPT_CONTINUE;
}
obj_id rtype = pickRandomNonDepeletedResource(strClass);
if(!isIdValid(rtype))
{
sendSystemMessageTestingOnly(self, "Bad class passed in, syntax is /gmCreateClassResource class");
return SCRIPT_CONTINUE;
}
string crateTemplate = getResourceContainerForType(rtype);
if ( !crateTemplate.equals("") )
{
obj_id pInv = utils.getInventoryContainer(self);
if ( pInv != null )
{
obj_id crate = createObject(crateTemplate, pInv, "");
if ( addResourceToContainer (crate, rtype, 100000, self) )
{
sendSystemMessageTestingOnly(self, "Resource of class "+params+" added");
return SCRIPT_CONTINUE;
}
}
}
return SCRIPT_CONTINUE;
}
void spawnContents(obj_id dungeon, string spawnType, int numberOfCopies)
{
obj_id self = getSelf();
sendSystemMessageTestingOnly(self, "//***// spawnContents: ////>>>> entered. SpawnType requested was: "+spawnType);
string[] spawnTypeColumnData = dataTableGetStringColumnNoDefaults(mustafar.CONST_TBL_EVENT_DATA, "dataType");
if (spawnTypeColumnData.length == 0)
return;
for (int i=0;i < spawnTypeColumnData.length;i++)
{
if (spawnTypeColumnData[i].equals(spawnType))
{
dictionary dict = dataTableGetRow(mustafar.CONST_TBL_EVENT_DATA, i);
sendSystemMessageTestingOnly(self, "spawnContents:Retrieving info for row("+i+")");
int locx = dict.getInt("locx");
int locy = dict.getInt("locy");
int locz = dict.getInt("locz");
location myself = getLocation (dungeon);
string scene = myself.area;
//string scene = getCurrentSceneName();
obj_id cell = getCellId(dungeon, "mainroom"); // <- name of instanced dungeon's cell
float yaw = dict.getFloat("yaw");
string script = dict.getString("script");
location spawnLoc = new location (locx, locy, locz, scene, cell);
string object = dict.getString("object");
if (dict.getString("dataType").equals("setpiece")) //if the object isn't a creature, spawn it this way
{
sendSystemMessageTestingOnly(self, "//***// spawnContents: ////>>>> Going to try to spawn a 'setpiece'");
obj_id item = createObjectInCell(object, dungeon, "mainroom", spawnLoc); // <- name of instanced dungeon's cell
if (!isIdValid(item))
{
sendSystemMessageTestingOnly(self, "spawnContents: Tried to create invalid item("+object+")");
return;
}
setYaw(item, yaw);
if (!script.equals("none"))
attachScript(item, script);
utils.setScriptVar(item,"dungeon", dungeon);
sendSystemMessageTestingOnly(self, "spawnContents: Created object("+object+"/"+item+") with script("+script);
}
else if (!dict.getString("dataType").equals("location") && !dict.getString("dataType").equals("forcePowerAttack")) // if the object IS a creature, spawn it this way
{
sendSystemMessageTestingOnly(self, "//***// spawnContents: ////>>>> Going to try to spawn a creature of some kind");
sendSystemMessageTestingOnly(self, "//***// spawnContents: ////>>>> Going to try to spawn a creature. SERIOUSLY!");
if (numberOfCopies < 1)
numberOfCopies = 1;
sendSystemMessageTestingOnly(self, "//***// spawnContents: ////>>>> numberOfCopies is: "+numberOfCopies);
for (int j=0;j < numberOfCopies;j++)
{
sendSystemMessageTestingOnly(self, "//***// spawnContents: ////>>>> spawn loop 1");
obj_id creature = create.object (object, spawnLoc);
sendSystemMessageTestingOnly(self, "//***// spawnContents: ////>>>> creature spawned objId is: "+creature);
if (!isIdValid(creature))
{
sendSystemMessageTestingOnly(self, "spawnContents: Tried to create invalid creature("+object+")");
return;
}
if (!script.equals("none"))
attachScript(creature, script);
utils.setScriptVar(creature,"dungeon", dungeon);
sendSystemMessageTestingOnly(self, "spawnContents: Created object("+object+"/"+creature+") with script("+script);
}
}
}
}
}