public static void MountHorse(CLRScriptBase script, uint Character, uint Horse) { if (!isWarhorse.ContainsKey(Character)) isWarhorse.Add(Character, true); string cloakResRef; switch(script.GetTag(Horse)) { case "abr_cr_an_horse01": cloakResRef = "acr_ooc_horse01"; isWarhorse[Character] = true; break; case "abr_cr_an_horse02": cloakResRef = "acr_ooc_horse02"; isWarhorse[Character] = true; break; case "abr_cr_an_horse03": cloakResRef = "acr_ooc_horse03"; isWarhorse[Character] = true; break; default: cloakResRef = "acr_ooc_horse03"; isWarhorse[Character] = true; break; } uint horseCloak = script.CreateItemOnObject(cloakResRef, Character, 1, "", CLRScriptBase.FALSE); if (script.GetLocalInt(Horse, ACR_IS_WARHORSE) == 1) { script.RemoveHenchman(Character, Horse); script.SetLocalInt(horseCloak, ACR_IS_WARHORSE, 1); } script.SetLocalInt(horseCloak, ACR_HORSE_ID, script.GetLocalInt(Horse, ACR_HORSE_ID)); script.SetLocalInt(horseCloak, ACR_HORSE_HP, script.GetCurrentHitPoints(Horse)); uint equippedCloak = script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CLOAK, Character); if (script.GetIsObjectValid(equippedCloak) == CLRScriptBase.TRUE) { foreach (NWItemProperty prop in script.GetItemPropertiesOnItem(equippedCloak)) { // copying property duration type prevents us from turning temporary properties into // permanent ones. But because we don't know how long the non-permanent ones have left, // we pretty much have to assign them with the expectation that they immediately expire. script.AddItemProperty(script.GetItemPropertyDurationType(prop), prop, horseCloak, 0.0f); } script.SetFirstName(horseCloak, script.GetName(equippedCloak) + "(( Horse Appearance ))"); script.AddItemProperty(CLRScriptBase.DURATION_TYPE_PERMANENT, script.ItemPropertyWeightReduction(CLRScriptBase.IP_CONST_REDUCEDWEIGHT_80_PERCENT), horseCloak, 0.0f); } script.SetPlotFlag(horseCloak, CLRScriptBase.TRUE); script.SetPlotFlag(Horse, CLRScriptBase.FALSE); script.AssignCommand(Horse, delegate { script.SetIsDestroyable(CLRScriptBase.TRUE, CLRScriptBase.FALSE, CLRScriptBase.FALSE); }); script.AssignCommand(Horse, delegate { script.DestroyObject(Horse, 0.0f, CLRScriptBase.FALSE); }); script.AssignCommand(Character, delegate { script.ActionEquipItem(horseCloak, CLRScriptBase.INVENTORY_SLOT_CLOAK); }); if (!isWarhorse[Character]) script.DelayCommand(6.0f, delegate { RidingHeartbeat(script, Character); }); }
public static void CalculatePrice(CLRScriptBase script, uint target) { #region Reject to Price Objects Which Can't or Shouldn't be Priced if (script.GetObjectType(target) != OBJECT_TYPE_ITEM) { return; } int itemType = script.GetBaseItemType(target); if (GetIsOOCItem(itemType)) { return; } #endregion #region Find out What the Item Should be Worth int targetValue = 0; if (GetIsWeapon(itemType) || GetIsAmmunition(itemType)) { targetValue = GetWeaponPrice(script, target); } else if (GetIsArmor(itemType)) { targetValue = GetArmorPrice(script, target); } else { targetValue = GetWonderousPrice(script, target); } #endregion #region Early Return for Illegal and Custom-Scripted Items if (targetValue == -1) { // We can't price this item, because it's illegal. script.SetFirstName(target, "(Illegal) " + script.GetName(target)); return; } else if (targetValue == -2) { return; } #endregion #region Determine if the Item Requires Adjustment, and Adjust if Necessary bool isPlot = false; bool isUnidentified = false; if (script.GetLocalInt(target, localVarName) == pricingVersion) { // We've already used this logic to price this item. We have nothing to add. return; } if (script.GetPlotFlag(target) == TRUE) { script.SetPlotFlag(target, FALSE); isPlot = true; } if (script.GetIdentified(target) == FALSE) { script.SetIdentified(target, TRUE); isUnidentified = true; } int currentValue = script.GetGoldPieceValue(target); if (script.GetItemStackSize(target) > 1) { currentValue /= script.GetItemStackSize(target); } if (currentValue != targetValue) { script.StoreCampaignObject(ItemChangeDBName, PriceChangeVarName, target, script.OBJECT_SELF); if (ALFA.Shared.Modules.InfoStore.ModifiedGff.Keys.Contains(PriceChangeVarName)) { if (ALFA.Shared.Modules.InfoStore.ModifiedGff[PriceChangeVarName].TopLevelStruct["ModifyCost"].ValueInt == 0 || targetValue > currentValue || script.GetLocalInt(target, localVarName) != 0) { // We only want to adjust the price if either a) no effort to control the item's price has been made or // b) the item is actually less valuable than the current price reads. Artificial inflations of price are // legal in ALFA. // Also, if this item was priced automatically, we want to be able to correct it. script.SetLocalInt(target, localVarName, pricingVersion); AdjustPrice(script, target, targetValue - currentValue); } } } if (isPlot) { script.SetPlotFlag(target, TRUE); } if (isUnidentified) { script.SetIdentified(target, FALSE); } #endregion }
public static void Dismount(CLRScriptBase script, uint Character, uint Cloak, NWLocation Location) { string resRef = ""; if (script.GetLocalInt(Cloak, ACR_IS_WARHORSE) == 1) { resRef = "abr_cr_an_horse_pal_"; int nPalLevel = script.GetLevelByClass(CLRScriptBase.CLASS_TYPE_PALADIN, Character); if (nPalLevel >= 15) resRef += "15"; else if (nPalLevel >= 11) resRef += "11"; else if (nPalLevel >= 8) resRef += "8"; else if (nPalLevel >= 5) resRef += "5"; else resRef = "abr_cr_an_horse03"; } else { switch (script.GetTag(Cloak)) { case "acr_ooc_horse01": resRef = "abr_cr_an_horse01"; break; case "acr_ooc_horse02": resRef = "abr_cr_an_horse02"; break; case "acr_ooc_horse03": resRef = "abr_cr_an_horse03"; break; default: // Looks like we're not actually dismounting a horse. return; } } uint Horse = script.CreateObject(CLRScriptBase.OBJECT_TYPE_CREATURE, resRef, Location, CLRScriptBase.FALSE, ""); script.SetLocalInt(Horse, ACR_HORSE_OWNER, script.GetLocalInt(Character, ACR_CID)); script.SetLocalInt(Horse, ACR_HORSE_ID, script.GetLocalInt(Cloak, ACR_HORSE_ID)); int damage = script.GetCurrentHitPoints(Horse) - script.GetLocalInt(Cloak, ACR_HORSE_HP); if(damage > 0) { script.ApplyEffectToObject(CLRScriptBase.DURATION_TYPE_INSTANT, script.EffectDamage(damage, CLRScriptBase.DAMAGE_TYPE_MAGICAL, CLRScriptBase.DAMAGE_POWER_PLUS_TWENTY, CLRScriptBase.TRUE), Horse, 0.0f); } if (script.GetLocalInt(Cloak, ACR_IS_WARHORSE) == 1) { script.AddHenchman(Character, Horse); script.SetLocalInt(Horse, ACR_IS_WARHORSE, 1); script.SetLocalObject(Character, ACR_PAL_WARHORSE, Horse); } uint Item = GetOwnershipItemById(script, Character, script.GetLocalInt(Cloak, ACR_HORSE_ID)); script.SetLocalObject(Item , ACR_HORSE_OBJECT, Horse); script.SetLocalObject(Horse, ACR_HORSE_OBJECT, Character); script.SetLocalString(Item, ACR_HORSE_PERS_LOC_AREA, script.GetTag(script.GetArea(Horse))); script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_X, script.GetPosition(Horse).x); script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_Y, script.GetPosition(Horse).y); script.SetLocalFloat(Item, ACR_HORSE_PERS_LOC_Z, script.GetPosition(Horse).z); script.SetPlotFlag(Cloak, CLRScriptBase.FALSE); script.DestroyObject(Cloak, 0.0f, CLRScriptBase.FALSE); isWarhorse.Remove(Character); }