mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-01 01:15:59 -04:00
126 lines
3.2 KiB
Plaintext
126 lines
3.2 KiB
Plaintext
include library.space_transition;
|
|
include library.space_utils;
|
|
|
|
// ======================================================================
|
|
//
|
|
// turret_ladder.script
|
|
//
|
|
//
|
|
//
|
|
// ======================================================================
|
|
|
|
const string_id SID_PILOT = new string_id("space/space_interaction", "pilot_ship");
|
|
const string_id SID_TURRET_ENTER = new string_id("space/space_interaction", "turret_enter");
|
|
|
|
// ======================================================================
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
obj_id objShip = space_transition.getContainingShip(player);
|
|
|
|
// Define your turret slot in your ship_interior row for the object this script is on (a turret ladder)
|
|
if(!hasObjVar(self, "turret_slot"))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(space_utils.playerCanControlShipSlot(objShip, player, true))
|
|
{
|
|
mi.addRootMenu(menu_info_types.ITEM_USE, SID_TURRET_ENTER);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
// check if the weapon si equipped
|
|
|
|
// gunner0 is weapon _
|
|
|
|
if(item == menu_info_types.ITEM_USE)
|
|
{
|
|
int slot = getIntObjVar(self, "turret_slot");
|
|
|
|
// There are only 8 slots maximum allowed on a ship for turrets as defined by the file:
|
|
// //depot/swg/current/dsrc/sku.0/sys.shared/compiled/game/abstract/slot/slot_definition/slot_definitions.mif
|
|
if(slot < 0 || slot > 7)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string slotName = "ship_gunner" + slot + "_pob";
|
|
|
|
int intSlot = ship_chassis_slot_type.SCST_weapon_0;
|
|
|
|
switch(slot)
|
|
{
|
|
case 0:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_0;
|
|
break;
|
|
case 1:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_1;
|
|
break;
|
|
case 2:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_2;
|
|
break;
|
|
case 3:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_3;
|
|
break;
|
|
case 4:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_4;
|
|
break;
|
|
case 5:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_5;
|
|
break;
|
|
case 6:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_6;
|
|
break;
|
|
case 7:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_7;
|
|
break;
|
|
default:
|
|
intSlot = ship_chassis_slot_type.SCST_weapon_0;
|
|
break;
|
|
}
|
|
|
|
obj_id objShip = space_transition.getContainingShip(player);
|
|
|
|
if(space_utils.playerCanControlShipSlot(objShip, player, false))
|
|
{
|
|
if(hasTurretWeapon(objShip, intSlot, player))
|
|
{
|
|
if(!equip(player, self, slotName))
|
|
{
|
|
string_id strSpam = new string_id("space/space_interaction", "turret_occupied");
|
|
sendSystemMessage(player, strSpam);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// ======================================================================
|
|
|
|
boolean hasTurretWeapon(obj_id objShip, int intSlot, obj_id objPlayer)
|
|
{
|
|
if(!isShipSlotInstalled(objShip, intSlot))
|
|
{
|
|
string_id strSpam = new string_id("space/space_interaction", "no_turret");
|
|
sendSystemMessage(objPlayer, strSpam);
|
|
return false;
|
|
}
|
|
if(isShipComponentDisabled(objShip, intSlot))
|
|
{
|
|
|
|
string_id strSpam = new string_id("space/space_interaction", "turret_disabled");
|
|
sendSystemMessage(objPlayer, strSpam);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|