Files
dsrc/sku.0/sys.server/compiled/game/script/space/ship/turret_falcon.script
T

92 lines
2.6 KiB
Plaintext

include library.space_transition;
include library.space_utils;
// ======================================================================
//
// turret_falcon.script
//
//
// ======================================================================
const string_id SID_PILOT = new string_id("space/space_interaction", "pilot_ship");
const string_id SID_TURRET_UPPER = new string_id("space/space_interaction", "turret_upper");
const string_id SID_TURRET_LOWER = new string_id("space/space_interaction", "turret_lower");
// ======================================================================
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
{
obj_id objShip = space_transition.getContainingShip(player);
if (space_utils.playerCanControlShipSlot(objShip, player, true))
{
mi.addRootMenu(menu_info_types.SERVER_MENU1, SID_TURRET_UPPER);
mi.addRootMenu(menu_info_types.SERVER_MENU2, SID_TURRET_LOWER);
}
return SCRIPT_CONTINUE;
}
// ----------------------------------------------------------------------
trigger OnObjectMenuSelect(obj_id player, int item)
{
// check if the weapon si equipped
// gunner0 is weapon _
if (item == menu_info_types.SERVER_MENU1)
{
obj_id objShip = space_transition.getContainingShip(player);
if (space_utils.playerCanControlShipSlot(objShip, player, false))
{
if(hasTurretWeapon(objShip, ship_chassis_slot_type.SCST_weapon_0, player))
{
if (!equip(player, self, "ship_gunner0_pob"))
{
string_id strSpam = new string_id("space/space_interaction", "turret_occupied");
sendSystemMessage(player, strSpam);
}
}
}
}
else if (item == menu_info_types.SERVER_MENU2)
{
obj_id objShip = space_transition.getContainingShip(player);
if (space_utils.playerCanControlShipSlot(objShip, player, false))
{
if(hasTurretWeapon(objShip, ship_chassis_slot_type.SCST_weapon_1, player))
{
if (!equip(player, self, "ship_gunner1_pob"))
{
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;
}