mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-08-01 02:16:04 -04:00
363 lines
9.8 KiB
Plaintext
363 lines
9.8 KiB
Plaintext
include library.ai_lib;
|
|
include library.beast_lib;
|
|
include library.callable;
|
|
include library.pet_lib;
|
|
include library.prose;
|
|
include library.target_dummy;
|
|
include library.tcg;
|
|
include library.utils;
|
|
|
|
trigger OnAttach()
|
|
{
|
|
ai_lib.setDefaultCalmBehavior(self, ai_lib.BEHAVIOR_LOITER);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
obj_id barn = utils.getObjIdScriptVar(self, "barnId");
|
|
if ( isIdValid(barn) )
|
|
{
|
|
obj_id owner = getOwner(barn);
|
|
if ( isIdValid(owner) && owner == player )
|
|
{
|
|
int menuPlacement = mi.addRootMenu (menu_info_types.SERVER_MENU1, new string_id(pet_lib.MENU_FILE, "menu_store"));
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if ( item == menu_info_types.SERVER_MENU1 )
|
|
{
|
|
obj_id barn = utils.getObjIdScriptVar(self, "barnId");
|
|
if ( isIdValid(barn) )
|
|
{
|
|
obj_id owner = getOwner(barn);
|
|
if ( isIdValid(owner) && owner == player )
|
|
{
|
|
string storageSlot = utils.getStringScriptVar(self, "barnSlot");
|
|
utils.removeScriptVar(barn, storageSlot);
|
|
|
|
string beastName = beast_lib.getBeastLocalizedName(self);
|
|
if ( beastName == null || beastName.length() < 1 )
|
|
{
|
|
beastName = "Unknown";
|
|
}
|
|
if ( hasObjVar(barn, "barnStorage."+storageSlot+".beast.beastName") )
|
|
{
|
|
beastName = getStringObjVar(barn, "barnStorage."+storageSlot+".beast.beastName");
|
|
}
|
|
else if ( hasObjVar(barn, "barnStorage."+storageSlot+".tempName") )
|
|
{
|
|
beastName = getStringObjVar(barn, "barnStorage."+storageSlot+".tempName");
|
|
}
|
|
|
|
string_id message = new string_id ("tcg","barn_beast_display_stored");
|
|
if ( tcg.isBarnLiteDevice(barn) )
|
|
{
|
|
message = new string_id ("tcg","barn_lite_beast_display_stored");
|
|
}
|
|
prose_package pp = prose.getPackage(message, player, player);
|
|
prose.setTO(pp, beastName);
|
|
sendSystemMessageProse(player, pp);
|
|
|
|
removeObjVar(barn, "barnStorage."+storageSlot+"."+tcg.BEAST_ROAMING);
|
|
destroyObject(self);
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler OnPack()
|
|
{
|
|
if(!isIdValid(self))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id barn = utils.getObjIdScriptVar(self, "barnId");
|
|
if ( isIdValid(barn) )
|
|
{
|
|
string storageSlot = utils.getStringScriptVar(self, "barnSlot");
|
|
if ( utils.hasScriptVar(barn, storageSlot) )
|
|
{
|
|
utils.removeScriptVar(barn, storageSlot);
|
|
}
|
|
|
|
removeObjVar(barn, "barnStorage."+storageSlot+"."+tcg.BEAST_ROAMING);
|
|
}
|
|
|
|
destroyObject(self);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnDestroy()
|
|
{
|
|
target_dummy.removeTargetDummyFromPermissions(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnGetAttributes(obj_id player, string[] names, string[] attribs)
|
|
{
|
|
if(!isMob(self))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
int idx = utils.getValidAttributeIndex(names);
|
|
|
|
obj_id barn = utils.getObjIdScriptVar(self, "barnId");
|
|
if ( !isIdValid(barn) )
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string storageSlot = utils.getStringScriptVar(self, "barnSlot");
|
|
|
|
if( hasObjVar(barn, "barnStorage."+storageSlot+"."+beast_lib.OBJVAR_BEAST_ENGINEER) )
|
|
{
|
|
string creatorName = getStringObjVar(barn, "barnStorage."+storageSlot+"."+beast_lib.OBJVAR_BEAST_ENGINEER);
|
|
names[idx] = "bm_creator";
|
|
attribs[idx] = creatorName;
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
names[idx] = "health";
|
|
attribs[idx] = " " + (int)getMaxAttrib(self, HEALTH);
|
|
idx++;
|
|
|
|
int level = getLevel(self);
|
|
|
|
if(level < 90)
|
|
{
|
|
dictionary beastStatsNextLevel = utils.dataTableGetRow(beast_lib.BEASTS_STATS, level - 1);
|
|
|
|
int experienceLastLevel = 0;
|
|
int experienceNextLevel = 0;
|
|
|
|
// You cannot get a previous level of a beast, if it is level 1 (no such thing as 0 level)
|
|
if(level > 1)
|
|
{
|
|
dictionary beastStatsLastLevel = utils.dataTableGetRow(beast_lib.BEASTS_STATS, level - 2);
|
|
|
|
if(beastStatsLastLevel == null || beastStatsLastLevel.size() <= 0)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
experienceLastLevel = beastStatsLastLevel.getInt("XP");
|
|
}
|
|
|
|
if(beastStatsNextLevel == null || beastStatsNextLevel.size() <= 0)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
experienceNextLevel = beastStatsNextLevel.getInt("XP");
|
|
int beastExperience = beast_lib.getBeastExperience(self);
|
|
|
|
// A beast has progressed towards its next level by an amount, which is equal to its current experience minus the
|
|
// experience that was required for the previous level.
|
|
int experienceProgress = beastExperience - experienceLastLevel;
|
|
|
|
// This level requires an amount of experience equal to the next level's experience requirement minus the last level's
|
|
// experience requirement.
|
|
int experienceNeeded = experienceNextLevel - experienceLastLevel;
|
|
|
|
int experiencePercentage = 0;
|
|
|
|
// No division by zero.
|
|
if(experienceProgress > 0)
|
|
{
|
|
// The percentage needed to level is equal to the total amount of experience needed for the level divided by the progress
|
|
// the beast has made.
|
|
experiencePercentage = (int)(((float)experienceProgress / (float)experienceNeeded) * 100);
|
|
}
|
|
|
|
names[idx] = "level_progress";
|
|
attribs[idx] = "" + experiencePercentage + "%";
|
|
idx++;
|
|
}
|
|
|
|
if(beast_lib.getBeastCanLevel(self))
|
|
{
|
|
names[idx] = "exp_on";
|
|
attribs[idx] = "true";
|
|
idx++;
|
|
}
|
|
else
|
|
{
|
|
names[idx] = "exp_off";
|
|
attribs[idx] = "true";
|
|
idx++;
|
|
}
|
|
|
|
names[idx] = beast_lib.BEAST_MOOD_TITLE;
|
|
int currentHappiness = 0;
|
|
if ( hasObjVar(barn, "barnStorage."+storageSlot+"."+beast_lib.OBJVAR_BEAST_HAPPINESS) )
|
|
{
|
|
currentHappiness = getIntObjVar(barn, "barnStorage."+storageSlot+"."+beast_lib.OBJVAR_BEAST_HAPPINESS);
|
|
}
|
|
string currentHappinessString = utils.packStringId (beast_lib.convertHappinessString(currentHappiness));
|
|
if(currentHappinessString != null)
|
|
{
|
|
attribs[idx] = "" + currentHappinessString;
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
names[idx] = beast_lib.BEAST_LOYALTY_TITLE;
|
|
int currentLoyalty = 0;
|
|
if ( hasObjVar(barn, "barnStorage."+storageSlot+"."+beast_lib.PET_LOYALTY_LEVEL_OBJVAR) )
|
|
{
|
|
currentLoyalty = getIntObjVar(barn, "barnStorage."+storageSlot+"."+beast_lib.PET_LOYALTY_LEVEL_OBJVAR);
|
|
}
|
|
string currentLoyaltyString = utils.packStringId (beast_lib.convertLoyaltyString(currentLoyalty));
|
|
if(currentLoyaltyString != null)
|
|
{
|
|
attribs[idx] = "" + currentLoyaltyString;
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
names[idx] = "armorhpmax";
|
|
attribs[idx] = "" + (utils.getIntScriptVar(self, "beast.display.armor") + getEnhancedSkillStatisticModifier(self, "private_armor_bonus"));
|
|
idx++;
|
|
|
|
obj_id beastWeapon = getCurrentWeapon(self);
|
|
|
|
if(isIdValid(beastWeapon))
|
|
{
|
|
int minDamage = getWeaponMinDamage(beastWeapon);
|
|
int maxDamage = getWeaponMaxDamage(beastWeapon);
|
|
|
|
int expertiseDamageBonus = getEnhancedSkillStatisticModifierUncapped(self, "expertise_damage_all");
|
|
|
|
minDamage = (int)(minDamage * (1.0f + ((float)expertiseDamageBonus / 100.0f)));
|
|
maxDamage = (int)(maxDamage * (1.0f + ((float)expertiseDamageBonus / 100.0f)));
|
|
|
|
float weaponSpeed = getWeaponAttackSpeed(beastWeapon);
|
|
|
|
names[idx] = "damage";
|
|
attribs[idx] = "" + minDamage + " - " + maxDamage;
|
|
idx++;
|
|
|
|
names[idx] = "attackspeed";
|
|
attribs[idx] = "" + weaponSpeed;
|
|
idx++;
|
|
|
|
float beastDPS = utils.roundFloatByDecimal((minDamage + maxDamage) / weaponSpeed / 2);
|
|
names[idx] = "basedps";
|
|
attribs[idx] = ""+beastDPS;
|
|
idx++;
|
|
}
|
|
else
|
|
{
|
|
obj_id defaultWeapon = getDefaultWeapon(self);
|
|
|
|
if(isIdValid(defaultWeapon))
|
|
{
|
|
int minDamage = getWeaponMinDamage(defaultWeapon);
|
|
int maxDamage = getWeaponMaxDamage(defaultWeapon);
|
|
float weaponSpeed = getWeaponAttackSpeed(defaultWeapon);
|
|
|
|
int expertiseDamageBonus = getEnhancedSkillStatisticModifierUncapped(self, "expertise_damage_all");
|
|
|
|
minDamage = (int)(minDamage * (1.0f + ((float)expertiseDamageBonus / 100.0f)));
|
|
maxDamage = (int)(maxDamage * (1.0f + ((float)expertiseDamageBonus / 100.0f)));
|
|
|
|
names[idx] = "damage";
|
|
attribs[idx] = "" + minDamage + " - " + maxDamage;
|
|
idx++;
|
|
|
|
names[idx] = "attackspeed";
|
|
attribs[idx] = "" + weaponSpeed;
|
|
idx++;
|
|
|
|
float beastDPS = utils.roundFloatByDecimal((minDamage + maxDamage) / weaponSpeed / 2);
|
|
names[idx] = "basedps";
|
|
attribs[idx] = ""+beastDPS;
|
|
idx++;
|
|
}
|
|
}
|
|
|
|
if(beast_lib.DISPLAY_NAMES.length == beast_lib.ARRAY_BEAST_INCUBATION_STATS.length &&
|
|
beast_lib.DISPLAY_NAMES.length == beast_lib.DISPLAY_CONVERSION_RATES.length)
|
|
{
|
|
for(int i = 0; i < beast_lib.DISPLAY_NAMES.length; ++i)
|
|
{
|
|
string name = beast_lib.DISPLAY_NAMES[i];
|
|
if(name.indexOf("_skill") < 0)
|
|
{
|
|
if(!name.equals("block_value_bonus"))
|
|
{
|
|
names[idx] = beast_lib.DISPLAY_NAMES[i];
|
|
attribs[idx] = "" + utils.roundFloatByDecimal((utils.getFloatScriptVar(self, beast_lib.ARRAY_BEAST_INCUBATION_STATS[i]) * beast_lib.DISPLAY_CONVERSION_RATES[i])) + "%";
|
|
idx++;
|
|
}
|
|
else
|
|
{
|
|
names[idx] = beast_lib.DISPLAY_NAMES[i];
|
|
attribs[idx] = "" + utils.roundFloatByDecimal(utils.getFloatScriptVar(self, beast_lib.ARRAY_BEAST_INCUBATION_STATS[i]));
|
|
idx++;
|
|
}
|
|
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
names[idx] = beast_lib.DISPLAY_NAMES[i];
|
|
attribs[idx] = "" + utils.roundFloatByDecimal(utils.getFloatScriptVar(self, beast_lib.ARRAY_BEAST_INCUBATION_STATS[i]));
|
|
idx++;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
|
|
float glanceReduct = beast_lib.getBeastModGlancingReduction(self);
|
|
|
|
if(glanceReduct > 0)
|
|
{
|
|
names[idx] = "bm_glance_reduct";
|
|
attribs[idx] = "" + glanceReduct + "%";
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
float damageReduct = beast_lib.getBeastModDamageReduction(self);
|
|
|
|
if(damageReduct > 0)
|
|
{
|
|
names[idx] = "bm_damage_reduct";
|
|
attribs[idx] = "" + damageReduct + "%";
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
float punishReduct = beast_lib.getBeastModPunishingReduction(self);
|
|
|
|
if(punishReduct > 0)
|
|
{
|
|
names[idx] = "bm_punish_reduct";
|
|
attribs[idx] = "" + punishReduct + "%";
|
|
idx++;
|
|
if (idx >= names.length)
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|