mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
338 lines
8.9 KiB
Plaintext
338 lines
8.9 KiB
Plaintext
/* Title: systems.beast.beast_egg
|
|
*/
|
|
|
|
include library.utils;
|
|
include library.beast_lib;
|
|
include library.hue;
|
|
include library.incubator;
|
|
include library.sui;
|
|
include library.utils;
|
|
|
|
|
|
//constants
|
|
const string_id SID_WHILE_DEAD = new string_id("beast","no_hatch_while_dead");
|
|
const string_id SID_EGG_HATCH = new string_id("beast","hatch_egg");
|
|
const string_id SID_GOD_EGG_HATCH = new string_id("beast","god_hatch_egg");
|
|
const string_id SID_MAKE_MOUNT = new string_id("beast","egg_make_mount");
|
|
const string_id SID_HATCH_MOUNT = new string_id("beast","egg_hatch_mount");
|
|
const string_id SID_MOUNT_CONVERT_PROMPT = new string_id("beast","egg_make_mount_prompt");
|
|
const string_id SID_MOUNT_CONVERT_TITLE = new string_id("beast","egg_make_mount_title");
|
|
const string_id SID_MAKE_HOLOPET = new string_id("beast","egg_make_holopet");
|
|
|
|
const string_id SID_HOLOBEAST_CONVERT_PROMPT = new string_id("beast","egg_make_holobeast_prompt");
|
|
const string_id SID_HOLOBEAST_CONVERT_TITLE = new string_id("beast","egg_make_holobeast_title");
|
|
|
|
|
|
trigger OnAttach()
|
|
{
|
|
messageTo(self, "handleInitializeValues", null, 1, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
incubator.setEggHue(self);
|
|
|
|
messageTo(self, "rename_egg", null, 1.0f, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler rename_egg()
|
|
{
|
|
string beastType = beast_lib.getBCDBeastType(self);
|
|
beastType = "egg_" + beast_lib.stripBmFromType(beastType);
|
|
|
|
setName(self, new string_id("beast", beastType));
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
obj_id egg = self;
|
|
|
|
//not while dead or incapped
|
|
if(isDead(player) || isIncapacitated(player) )
|
|
{
|
|
sendSystemMessage( player, SID_WHILE_DEAD );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(utils.isNestedWithinAPlayer(egg, false))
|
|
{
|
|
if(beast_lib.isBeastMaster(player) && hasObjVar(egg, beast_lib.OBJVAR_BEAST_TYPE) && !incubator.isEggMountFlagged(egg))
|
|
{
|
|
mi.addRootMenu (menu_info_types.ITEM_USE, SID_EGG_HATCH);
|
|
}
|
|
|
|
if(incubator.isEggMountType(egg) && hasSkill(player, "expertise_bm_train_mount_1") && !incubator.isEggMountFlagged(egg))
|
|
{
|
|
mi.addRootMenu (menu_info_types.SERVER_MENU1, SID_MAKE_MOUNT);
|
|
|
|
}
|
|
else if(incubator.isEggMountType(egg) && incubator.isEggMountFlagged(egg))
|
|
{
|
|
mi.addRootMenu (menu_info_types.SERVER_MENU1, SID_HATCH_MOUNT);
|
|
}
|
|
|
|
if(beast_lib.isBeastMaster(player) && hasObjVar(egg, beast_lib.OBJVAR_BEAST_TYPE))
|
|
{
|
|
mi.addRootMenu (menu_info_types.SERVER_MENU2, SID_MAKE_HOLOPET);
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
sendDirtyObjectMenuNotification(self);
|
|
//not while dead or incapped
|
|
if(isDead(player) || isIncapacitated(player) )
|
|
{
|
|
sendSystemMessage( player, SID_WHILE_DEAD );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id egg = self;
|
|
if(utils.isNestedWithinAPlayer(egg))
|
|
{
|
|
if (item == menu_info_types.ITEM_USE && !incubator.isEggMountFlagged(egg))
|
|
{
|
|
if(!beast_lib.isBeastMaster(player))
|
|
{
|
|
//Only Beast masters can hatch eggs
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
obj_id bcd = beast_lib.createBCDFromEgg(player, egg);
|
|
|
|
if(beast_lib.isValidBCD(bcd))
|
|
{
|
|
playClientEffectObj(player, "appearance/pt_egg_crack.prt", player, "");
|
|
destroyObject(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
if (item == menu_info_types.SERVER_MENU1 && hasSkill(player, "expertise_bm_train_mount_1") && !incubator.isEggMountFlagged(egg))
|
|
{
|
|
if(!incubator.isEggMountType(egg))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
int pid = sui.msgbox(self, player, "@" + SID_MOUNT_CONVERT_PROMPT, sui.YES_NO, "@" + SID_MOUNT_CONVERT_TITLE, "handleStampEggAsMount");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if(item == menu_info_types.SERVER_MENU1 && incubator.isEggMountType(egg) && incubator.isEggMountFlagged(egg))
|
|
{
|
|
if(!incubator.isEggMountType(egg))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//lets create the mount
|
|
obj_id pcd = incubator.convertEggToMount(egg, player);
|
|
if(isValidId(pcd) && exists(pcd))
|
|
{
|
|
CustomerServiceLog("BeastEggToMountConversion: ", "Player ("+player+") has converted Egg (" + egg + ")"+" to PCD (" + pcd + ") we are now going to destroy the egg" );
|
|
//check to see if there is an active pet out for this pcd. If so, we need to store it.
|
|
destroyObject(egg);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
CustomerServiceLog("BeastEggToMountConversion: ", "Player ("+player+") tried to convert incubated egg (" + egg + "). Conversion was not a success. New PCD was NOT created and egg was NOT destroyed." );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
if ( item == menu_info_types.SERVER_MENU2 && hasObjVar(egg, beast_lib.OBJVAR_BEAST_TYPE) )
|
|
{
|
|
if( !beast_lib.isBeastMaster(player) )
|
|
{
|
|
//Only Beast masters can hatch eggs
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
int pid = sui.msgbox(self, player, "@" + SID_HOLOBEAST_CONVERT_PROMPT, sui.YES_NO, "@" + SID_HOLOBEAST_CONVERT_TITLE, "handleConvertEggToHolobeast");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
|
|
{
|
|
int idx = utils.getValidAttributeIndex(names);
|
|
|
|
if(idx == -1)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if(exists(self))
|
|
{
|
|
for(int i = 0; i < beast_lib.ARRAY_BEAST_INCUBATION_STATS.length; ++i)
|
|
{
|
|
if(hasObjVar(self, beast_lib.ARRAY_BEAST_INCUBATION_STATS[i]) && !incubator.isEggMountFlagged(self))
|
|
{
|
|
string name = beast_lib.DISPLAY_NAMES[i];
|
|
int stat = getIntObjVar(self, beast_lib.ARRAY_BEAST_INCUBATION_STATS[i]);
|
|
|
|
if(name.indexOf("_skill") < 0)
|
|
{
|
|
if(!name.equals("block_value_bonus"))
|
|
{
|
|
|
|
names[idx] = beast_lib.DISPLAY_NAMES[i];
|
|
attribs[idx] = "" + utils.roundFloatByDecimal((float)stat * beast_lib.DISPLAY_OBJVAR_CONVERSION_RATES[i]) + "%";
|
|
idx++;
|
|
}
|
|
else
|
|
{
|
|
names[idx] = beast_lib.DISPLAY_NAMES[i];
|
|
attribs[idx] = "" + stat;
|
|
idx++;
|
|
}
|
|
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
names[idx] = beast_lib.DISPLAY_NAMES[i];
|
|
attribs[idx] = "" + stat;
|
|
idx++;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(hasObjVar(self, beast_lib.OBJVAR_BEAST_PARENT))
|
|
{
|
|
names[idx] = "bm_template";
|
|
|
|
int hashType = getIntObjVar(self, beast_lib.OBJVAR_BEAST_TYPE);
|
|
|
|
string template = getStringObjVar(self, beast_lib.OBJVAR_BEAST_PARENT);
|
|
|
|
string_id templateId = new string_id("mob/creature_names", template);
|
|
|
|
if(localize(templateId) == null)
|
|
{
|
|
template = incubator.convertHashTypeToString(hashType);
|
|
template = beast_lib.stripBmFromType(template);
|
|
|
|
templateId = new string_id("monster_name", template);
|
|
if(localize(templateId) == null)
|
|
{
|
|
templateId = new string_id("mob/creature_names", template);
|
|
}
|
|
}
|
|
|
|
attribs[idx] = "" + localize(templateId);
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(hasObjVar(self, beast_lib.OBJVAR_BEAST_TYPE))
|
|
{
|
|
names[idx] = "beast_type";
|
|
|
|
int hashType = getIntObjVar(self, beast_lib.OBJVAR_BEAST_TYPE);
|
|
|
|
string template = incubator.convertHashTypeToString(hashType);
|
|
template = beast_lib.stripBmFromType(template);
|
|
string_id templateId = new string_id("monster_name", template);
|
|
|
|
if(localize(templateId) == null)
|
|
templateId = new string_id("mob/creature_names", template);
|
|
|
|
attribs[idx] = "" + localize(templateId);
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(incubator.isEggMountFlagged(self))
|
|
{
|
|
names[idx] = "is_mount";
|
|
attribs[idx] = "true";
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if(hasObjVar(self, beast_lib.OBJVAR_BEAST_ENGINEER))
|
|
{
|
|
string creatorName = getStringObjVar(self, beast_lib.OBJVAR_BEAST_ENGINEER);
|
|
names[idx] = "bm_creator";
|
|
attribs[idx] = creatorName;
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
if(hasObjVar(self, beast_lib.OBJVAR_BEAST_HUE))
|
|
{
|
|
color eggColor = getPalcolorCustomVarSelectedColor(self, hue.INDEX_1);
|
|
string attrib = "";
|
|
|
|
attrib += "" + eggColor.getR() + ", " + eggColor.getG() + ", " + eggColor.getB();
|
|
|
|
names[idx] = "bm_rgb_values";
|
|
attribs[idx] = attrib;
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
|
|
}
|
|
|
|
messageHandler handleInitializeValues ()
|
|
{
|
|
LOG("beast", "beast_egg: handleInitializeValues()");
|
|
incubator.initializeEgg(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
messageHandler handleStampEggAsMount ()
|
|
{
|
|
int bp = sui.getIntButtonPressed(params);
|
|
if ( bp == sui.BP_CANCEL )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id player = sui.getPlayerId(params);
|
|
obj_id egg = self;
|
|
|
|
incubator.stampEggAsMount(egg, player);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleConvertEggToHolobeast()
|
|
{
|
|
int bp = sui.getIntButtonPressed(params);
|
|
if ( bp == sui.BP_CANCEL )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( isIdValid(player) )
|
|
{
|
|
obj_id holopetCube = beast_lib.createHolopetCubeFromEgg(player, self);
|
|
if( isIdValid(holopetCube) )
|
|
{
|
|
destroyObject(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|