mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
321 lines
8.1 KiB
Plaintext
321 lines
8.1 KiB
Plaintext
include library.space_crafting;
|
|
include library.player_structure;
|
|
include library.utils;
|
|
include library.create;
|
|
include library.space_transition;
|
|
include library.space_utils;
|
|
//The deed script takes an object and attempts to create a ship PCD in the player's datapad container.
|
|
|
|
const string_id MNU_CREATE_VEHICLE = new string_id("sui", "create_vehicle");
|
|
const string STF = "chassis_npc";
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnGetAttributes( obj_id player, string[] names, string[] attribs )
|
|
{
|
|
//if there are no attribs bail out
|
|
int idx = utils.getValidAttributeIndex(names);
|
|
if (idx == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//if there is no HP on the deed the deed is invalid
|
|
float hp = getFloatObjVar(self, "ship_chassis.hp");
|
|
if(hp < 0)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//if there is no MASS on the deed the deed is invalid
|
|
float mass = getFloatObjVar(self, "ship_chassis.mass");
|
|
if(hp < 0)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
float currentHp = hp;
|
|
if (hasObjVar(self, "ship_chassis.currentHp"))
|
|
{
|
|
float newHp = getFloatObjVar(self, "ship_chassis.currentHp");
|
|
if(newHp > 0)//all damage on the chassis is kept and the chassis
|
|
currentHp = newHp;
|
|
}
|
|
|
|
//if no ship chassis type exists none of the rest will work
|
|
string type = getStringObjVar(self, "ship_chassis.type");
|
|
if(type == null || type.equals(""))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
//special multi-factional ship attribs go here
|
|
if(hasObjVar(self, "ship_chassis.multifactional") && getBooleanObjVar(self, "ship_chassis.multifactional") == true)
|
|
{
|
|
if(type.equals("vwing"))
|
|
{
|
|
//shows all the required certs for each pilot faction
|
|
names[idx] = "reb_pilot_cert_required";
|
|
attribs[idx] = utils.packStringId(new string_id("skl_n", "pilot_rebel_navy_starships_02"));
|
|
idx++;
|
|
names[idx] = "imp_pilot_cert_required";
|
|
attribs[idx] = utils.packStringId(new string_id("skl_n", "pilot_imperial_navy_starships_02"));
|
|
idx++;
|
|
names[idx] = "neu_pilot_cert_required";
|
|
attribs[idx] = utils.packStringId(new string_id("skl_n", "pilot_neutral_starships_02"));
|
|
idx++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
names[idx] = "pilotSkillRequired";
|
|
attribs[idx] = getSkillRequiredForShip(self, type);
|
|
idx++;
|
|
}
|
|
|
|
names[idx] = "chassisHitpoints";
|
|
attribs[idx] = Float.toString(currentHp) + "/" + Float.toString(hp);
|
|
idx++;
|
|
|
|
names[idx] = "chassisMass";
|
|
attribs[idx] = Float.toString(mass);
|
|
idx++;
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if ( !utils.isNestedWithin(self, player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int mnuColor = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_CREATE_VEHICLE);
|
|
if ( mnuColor > -1 && (( getContainedBy(self) != getOwner(self) ) || isGod(player)) )
|
|
{
|
|
string template = utils.getTemplateFilenameNoPath(self);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if ( !utils.isNestedWithin(self, player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
string template = utils.getTemplateFilenameNoPath(self);
|
|
|
|
if ( item == menu_info_types.SERVER_MENU1 )
|
|
{
|
|
obj_id datapad = utils.getDatapad(player);
|
|
if (utils.getIntScriptVar(self, "chassis_deed.inUse") == 1)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
|
|
if (isIdValid(datapad))
|
|
{
|
|
utils.setScriptVar(self, "chassis_deed.inUse", 1);
|
|
string type = getStringObjVar(self, "ship_chassis.type");
|
|
float hp = getFloatObjVar(self, "ship_chassis.hp");
|
|
float currentHp = hp;
|
|
if (hasObjVar(self, "ship_chassis.currentHp"))
|
|
{
|
|
currentHp = getFloatObjVar(self, "ship_chassis.currentHp");
|
|
}
|
|
float mass = getFloatObjVar(self, "ship_chassis.mass");
|
|
|
|
obj_id newShip = space_crafting.createChassisFromDeed(player, self, hp, currentHp, mass, type);
|
|
if(!isIdValid(newShip))
|
|
{
|
|
CustomerServiceLog("ship_deed", "PLAYER: "+ player + "(" + getPlayerName(player) + ") attempted and FAILED to create a ship from DEED:" + self + " which provided the Ship Type: " + type + " MASS: " + mass + " MAX CHASSIS HP: "+hp+ " and CURRENT CHASSIS HP: "+currentHp);
|
|
utils.removeScriptVar(self, "chassis_deed.inUse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
CustomerServiceLog("ship_deed", "PLAYER: "+ player + "(" + getPlayerName(player) + ") created SHIP: "+newShip+" from DEED:" + self + " which provided the Ship Type: " + type + " MASS: " + mass + " MAX CHASSIS HP: "+hp+ " and CURRENT CHASSIS HP: "+currentHp);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(self, "chassis_deed.inUse");
|
|
}
|
|
|
|
|
|
space_transition.handlePotentialSceneChange(player) ;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string getSkillRequiredForShip(obj_id deed, string type)
|
|
{
|
|
if(!isValidId(deed) || !exists(deed))
|
|
return "";
|
|
|
|
if (type == null || type.equals(""))
|
|
{
|
|
return "";
|
|
}
|
|
|
|
if (type.equals("z95"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_novice";
|
|
}
|
|
if (type.equals("xwing"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_starships_03";
|
|
}
|
|
if (type.equals("hutt_light_s01"))
|
|
{
|
|
return "@skl_n:pilot_neutral_novice";
|
|
}
|
|
if (type.equals("hutt_light_s02"))
|
|
{
|
|
return "@skl_n:pilot_neutral_novice";
|
|
}
|
|
if (type.equals("tiefighter"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_starships_01";
|
|
}
|
|
if (type.equals("tieinterceptor"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_starships_03";
|
|
}
|
|
if (type.equals("tieadvanced"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_starships_04";
|
|
}
|
|
if (type.equals("tieaggressor"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_starships_04";
|
|
}
|
|
if (type.equals("tiebomber"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_starships_03";
|
|
}
|
|
if (type.equals("tieoppressor"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_master";
|
|
}
|
|
if (type.equals("awing"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_starships_04";
|
|
}
|
|
if (type.equals("bwing"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_master";
|
|
}
|
|
if (type.equals("ywing"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_starships_01";
|
|
}
|
|
if (type.equals("firespray"))
|
|
{
|
|
return "@space_crafting_n:all_master";
|
|
}
|
|
if (type.equals("yt1300"))
|
|
{
|
|
return "@skl_n:pilot_neutral_master";
|
|
}
|
|
if (type.equals("decimator"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_master";
|
|
}
|
|
if (type.equals("ykl37r"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_master";
|
|
}
|
|
if (type.equals("hutt_heavy_s01"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_02";
|
|
}
|
|
if (type.equals("hutt_heavy_s02"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_02";
|
|
}
|
|
if (type.equals("hutt_medium_s01"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_01";
|
|
}
|
|
if (type.equals("hutt_medium_s02"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_01";
|
|
}
|
|
if (type.equals("tie_in"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_starships_02";
|
|
}
|
|
if (type.equals("tie_light_duty"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_novice";
|
|
}
|
|
if (type.equals("ywing_longprobe"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_starships_02";
|
|
}
|
|
if (type.equals("blacksun_light_s01"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_02";
|
|
}
|
|
if (type.equals("blacksun_light_s02"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_02";
|
|
}
|
|
if (type.equals("blacksun_light_s03"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_02";
|
|
}
|
|
if (type.equals("blacksun_light_s04"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_02";
|
|
}
|
|
if (type.equals("blacksun_heavy_s01"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_04";
|
|
}
|
|
if (type.equals("blacksun_heavy_s02"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_04";
|
|
}
|
|
if (type.equals("blacksun_heavy_s03"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_04";
|
|
}
|
|
if (type.equals("blacksun_heavy_s04"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_04";
|
|
}
|
|
else if (type.equals("blacksun_medium_s01"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_03";
|
|
}
|
|
else if (type.equals("blacksun_medium_s02"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_03";
|
|
}
|
|
else if (type.equals("blacksun_medium_s03"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_03";
|
|
}
|
|
else if (type.equals("blacksun_medium_s04"))
|
|
{
|
|
return "@skl_n:pilot_neutral_starships_03";
|
|
}
|
|
else if (type.equals("hutt_turret_ship"))
|
|
{
|
|
return "@skl_n:pilot_neutral_master";
|
|
}
|
|
else if (type.equals("gunship_neutral"))
|
|
{
|
|
return "@skl_n:pilot_neutral_master";
|
|
}
|
|
else if (type.equals("gunship_imperial"))
|
|
{
|
|
return "@skl_n:pilot_imperial_navy_master";
|
|
}
|
|
else if (type.equals("gunship_rebel"))
|
|
{
|
|
return "@skl_n:pilot_rebel_navy_master";
|
|
}
|
|
return "";
|
|
}
|
|
|