public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = user.Object; int ability = item.GetLocalInt("ABILITY_TYPE"); int amount = item.GetLocalInt("AMOUNT") + item.MedicineBonus; int rank = player.IsPlayer ? _skill.GetPCSkillRank(player, SkillType.Medicine) : 0; int recommendedLevel = item.RecommendedLevel; float duration = 30.0f; int perkLevel = player.IsPlayer ? _perk.GetPCPerkLevel(player, PerkType.StimFiend) : 0; float percentIncrease = perkLevel * 0.25f; duration = duration + (duration * percentIncrease); Effect effect = _.EffectAbilityIncrease(ability, amount); effect = _.TagEffect(effect, "STIM_PACK_EFFECT"); _.ApplyEffectToObject(NWScript.DURATION_TYPE_TEMPORARY, effect, target, duration); user.SendMessage("You inject " + target.Name + " with a stim pack. The stim pack will expire in " + duration + " seconds."); _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The stim pack that you applied to " + target.Name + " has expired."); }); if (!Equals(user, target)) { NWCreature targetCreature = target.Object; targetCreature.SendMessage(user.Name + " injects you with a stim pack."); } int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); _skill.GiveSkillXP(player, SkillType.Medicine, xp); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { int amount = item.GetLocalInt("HUNGER_RESTORE"); bool isTainted = item.GetLocalInt("HUNGER_TAINTED") == 1; _food.IncreaseHungerLevel((NWPlayer)user, amount, isTainted); }
private SkillType GetSkillType(NWItem item) { CustomItemType repairItemType = (CustomItemType)item.GetLocalInt("REPAIR_CUSTOM_ITEM_TYPE_ID"); switch (repairItemType) { case CustomItemType.LightArmor: case CustomItemType.HeavyArmor: case CustomItemType.ForceArmor: case CustomItemType.Shield: return(SkillType.Armorsmith); case CustomItemType.Vibroblade: case CustomItemType.FinesseVibroblade: case CustomItemType.Baton: case CustomItemType.HeavyVibroblade: case CustomItemType.Polearm: case CustomItemType.TwinBlade: case CustomItemType.MartialArtWeapon: return(SkillType.Weaponsmith); case CustomItemType.Lightsaber: case CustomItemType.BlasterPistol: case CustomItemType.BlasterRifle: case CustomItemType.Saberstaff: return(SkillType.Engineering); } if (item.GetLocalInt("LIGHTSABER") == TRUE) { return(SkillType.Engineering); } return(SkillType.Unknown); }
public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { NWItem targetItem = target.Object; float maxDurability = _durability.GetMaxDurability(targetItem); float durability = _durability.GetDurability(targetItem); if (target.ObjectType != NWScript.OBJECT_TYPE_ITEM) { return("Only items may be targeted by repair kits."); } if (targetItem.CustomItemType != (CustomItemType)item.GetLocalInt("REPAIR_CUSTOM_ITEM_TYPE_ID")) { return("You cannot repair that item with this repair kit."); } if (maxDurability <= 0.0f || durability >= maxDurability) { return("That item does not need to be repaired."); } if (durability <= 0.0f) { return("That item is broken and cannot be repaired."); } if (maxDurability <= 0.1f) { return("You cannot repair that item any more."); } SkillType skillType = GetSkillType(item); int techLevel = item.GetLocalInt("TECH_LEVEL"); if (skillType == SkillType.Armorsmith) { if (_perk.GetPCPerkLevel(user.Object, PerkType.ArmorRepair) < techLevel) { return("Your level in the 'Armor Repair' perk is too low to use this repair kit."); } } else if (skillType == SkillType.Weaponsmith) { if (_perk.GetPCPerkLevel(user.Object, PerkType.WeaponRepair) < techLevel) { return("Your level in the 'Weapon Repair' perk is too low to use this repair kit."); } } else if (skillType == SkillType.Engineering) { if (_perk.GetPCPerkLevel(user.Object, PerkType.ElectronicRepair) < techLevel) { return("Your level in the 'Electronic Repair' perk is too low to use this repair kit."); } } return(null); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { string type = item.GetLocalString("BONUS_TYPE"); int length = item.GetLocalInt("BONUS_LENGTH") * 60; int amount = item.GetLocalInt("BONUS_AMOUNT"); string data = $"{type},{amount}"; _customEffect.ApplyCustomEffect(user, target.Object, CustomEffectType.FoodEffect, length, item.RecommendedLevel, data); }
public float GetMaxDurability(NWItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (!IsValidDurabilityType(item)) { return(-1.0f); } return(item.GetLocalInt("DURABILITY_MAX") <= 0 ? DefaultDurability : item.GetLocalInt("DURABILITY_MAX")); }
public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { if (!target.IsCreature || target.IsDM) { return("Only creatures may be targeted with this item."); } if (target.CurrentHP > -11) { return("Your target is not dead."); } if (user.IsInCombat) { return("You are in combat."); } int perkLevel = _perk.GetPCPerkLevel(user.Object, PerkType.ResuscitationDevices); int requiredLevel = item.GetLocalInt("RANK"); if (perkLevel < requiredLevel) { return("You must have the Resuscitation Devices perk at level " + requiredLevel + " to use this item."); } return(null); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = user.Object; var effectiveStats = _playerStat.GetPlayerItemEffectiveStats(player); int skillRank = _skill.GetPCSkillRank(player, SkillType.Medicine); int perkLevel = _perk.GetPCPerkLevel(player, PerkType.ResuscitationDevices); int rank = item.GetLocalInt("RANK"); int baseHeal; switch (rank) { case 1: baseHeal = 1; break; case 2: baseHeal = 11; break; case 3: baseHeal = 31; break; case 4: baseHeal = 51; break; default: return; } baseHeal += perkLevel * 2; baseHeal += effectiveStats.Medicine / 2; baseHeal += item.MedicineBonus / 2; int delta = item.RecommendedLevel - skillRank; float effectivenessPercent = 1.0f; if (delta > 0) { effectivenessPercent = effectivenessPercent - (delta * 0.1f); } baseHeal = (int)(baseHeal * effectivenessPercent); Player dbPlayer = _data.Single <Player>(x => x.ID == user.GlobalID); int hpRecover = (int)(target.MaxHP * (0.01f * baseHeal)); int fpRecover = (int)(dbPlayer.MaxFP * (0.01f * baseHeal)); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectResurrection(), target); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(hpRecover), target); dbPlayer.CurrentFP = fpRecover; _data.SubmitDataChange(dbPlayer, DatabaseActionType.Update); player.SendMessage("You successfully resuscitate " + target.Name + "!"); if (target.IsPlayer) { int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(600, item.RecommendedLevel, skillRank); _skill.GiveSkillXP(player, SkillType.Medicine, xp); } }
private void HandleWeaponStatBonuses() { DamageData data = _nwnxDamage.GetDamageEventData(); if (data.Total <= 0) { return; } NWPlayer player = data.Damager.Object; NWItem weapon = _.GetLastWeaponUsed(player); if (weapon.CustomItemType == CustomItemType.BlasterPistol || weapon.CustomItemType == CustomItemType.BlasterRifle) { int statBonus = (int)(player.DexterityModifier * 0.5f); data.Base += statBonus; } else if (weapon.CustomItemType == CustomItemType.Lightsaber || weapon.CustomItemType == CustomItemType.Saberstaff || weapon.GetLocalInt("LIGHTSABER") == TRUE) { int statBonus = (int)(player.CharismaModifier * 0.25f); data.Base += statBonus; } _nwnxDamage.SetDamageEventData(data); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); int starcharts = item.GetLocalInt("Starcharts"); if (starcharts == 0) { player.SendMessage("This disk is empty."); return; } // Get the base. string starshipID = _.GetLocalString(_.GetArea(target), "PC_BASE_STRUCTURE_ID"); Guid starshipGuid = new Guid(starshipID); PCBaseStructure starship = DataService.PCBaseStructure.GetByID(starshipGuid); PCBase starkillerBase = DataService.PCBase.GetByID(starship.PCBaseID); starkillerBase.Starcharts |= starcharts; DataService.SubmitDataChange(starkillerBase, DatabaseActionType.Update); _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_IMP_CONFUSION_S), target); _.FloatingTextStringOnCreature("Starcharts loaded!", player); item.Destroy(); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = NWPlayer.Wrap(user.Object); target.RemoveEffect(EFFECT_TYPE_REGENERATE); PCSkill skill = _skill.GetPCSkill(player, SkillType.FirstAid); int luck = _perk.GetPCPerkLevel(player, PerkType.Lucky); int perkDurationBonus = _perk.GetPCPerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2); float duration = 30.0f + (skill.Rank * 0.4f) + perkDurationBonus; int restoreAmount = 1 + item.GetLocalInt("HEALING_BONUS") + player.EffectiveFirstAidBonus; int perkBlastBonus = _perk.GetPCPerkLevel(player, PerkType.ImmediateImprovement); if (perkBlastBonus > 0) { int blastHeal = restoreAmount * perkBlastBonus; if (_random.Random(100) + 1 <= luck / 2) { blastHeal *= 2; } _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(blastHeal), target.Object); } Effect regeneration = _.EffectRegenerate(restoreAmount, 6.0f); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, regeneration, target.Object, duration); player.SendMessage("You successfully treat " + target.Name + "'s wounds."); int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(100, item.RecommendedLevel, skill.Rank); _skill.GiveSkillXP(player, SkillType.FirstAid, xp); }
public bool Run(params object[] args) { NWPlaceable container = NWPlaceable.Wrap(Object.OBJECT_SELF); NWPlayer oPC = NWPlayer.Wrap(_.GetLastDisturbed()); NWItem oItem = NWItem.Wrap(_.GetInventoryDisturbItem()); int type = _.GetInventoryDisturbType(); if (type == INVENTORY_DISTURB_TYPE_ADDED) { container.AssignCommand(() => _.ActionGiveItem(oItem.Object, oPC.Object)); return(true); } int overflowItemID = oItem.GetLocalInt("TEMP_OVERFLOW_ITEM_ID"); PCOverflowItem overflowItem = _db.PCOverflowItems.Single(x => x.PCOverflowItemID == overflowItemID); _db.PCOverflowItems.Remove(overflowItem); _db.SaveChanges(); oItem.DeleteLocalInt("TEMP_OVERFLOW_ITEM_ID"); if (container.InventoryItems.Count <= 0) { container.Destroy(); } return(true); }
public SkillType GetSkillTypeForItem(NWItem item) { using (new Profiler("ItemService::GetSkillTypeForItem")) { int type = item.BaseItemType; // Armor has to specifically be set on the item in order to count. // Look for an item type property first. if (item.CustomItemType == CustomItemType.LightArmor) { return(SkillType.LightArmor); } else if (item.CustomItemType == CustomItemType.HeavyArmor) { return(SkillType.HeavyArmor); } else if (item.CustomItemType == CustomItemType.ForceArmor) { return(SkillType.ForceArmor); } // Training lightsabers are katana weapons with special local variables. if (item.GetLocalInt("LIGHTSABER") == TRUE) { return(SkillType.Lightsaber); } if (!_skillTypeMappings.TryGetValue(type, out var result)) { return(SkillType.Unknown); } return(result); } }
private static void InitializeDurability(NWItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } SetLocalBool(item, "DURABILITY_OVERRIDE", true); if (item.GetLocalInt("DURABILITY_INITIALIZE") <= 0 && item.GetLocalFloat("DURABILITY_CURRENT") <= 0.0f) { float durability = GetMaxDurability(item) <= 0 ? DefaultDurability : GetMaxDurability(item); item.SetLocalFloat("DURABILITY_CURRENT", durability); if (item.GetLocalFloat("DURABILITY_MAX") <= 0.0f) { float maxDurability = DefaultDurability; foreach (var ip in item.ItemProperties) { if (GetItemPropertyType(ip) == ItemPropertyType.MaxDurability) { maxDurability = GetItemPropertyCostTableValue(ip); break; } } item.SetLocalFloat("DURABILITY_MAX", maxDurability); } } item.SetLocalInt("DURABILITY_INITIALIZED", 1); }
public bool Run(params object[] args) { NWPlaceable container = (Object.OBJECT_SELF); NWPlayer oPC = (_.GetLastDisturbed()); NWItem oItem = (_.GetInventoryDisturbItem()); int type = _.GetInventoryDisturbType(); if (type == NWScript.INVENTORY_DISTURB_TYPE_ADDED) { container.AssignCommand(() => _.ActionGiveItem(oItem.Object, oPC.Object)); return(true); } int overflowItemID = oItem.GetLocalInt("TEMP_OVERFLOW_ITEM_ID"); PCOverflowItem overflowItem = _data.Get <PCOverflowItem>(overflowItemID); _data.SubmitDataChange(overflowItem, DatabaseActionType.Delete); oItem.DeleteLocalInt("TEMP_OVERFLOW_ITEM_ID"); if (!container.InventoryItems.Any()) { container.Destroy(); } return(true); }
public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { int structureID = item.GetLocalInt("BASE_STRUCTURE_ID"); return(target.IsValid ? "You must select an empty location to use that item." : _base.CanPlaceStructure(user, item, targetLocation, structureID)); }
public void OnItemUnequipped(NWCreature creature, NWItem oItem) { if (oItem.CustomItemType != CustomItemType.Lightsaber && oItem.GetLocalInt("LIGHTSABER") == FALSE) { return; } ApplyFeatChanges(creature, oItem); }
public void OnItemEquipped(NWPlayer oPC, NWItem oItem) { if (oItem.CustomItemType != CustomItemType.Lightsaber && oItem.GetLocalInt("LIGHTSABER") == FALSE) { return; } ApplyFeatChanges(oPC, null); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); var effectiveStats = PlayerStatService.GetPlayerItemEffectiveStats(player); target.RemoveEffect(EFFECT_TYPE_REGENERATE); int rank = SkillService.GetPCSkillRank(player, SkillType.Medicine); int luck = PerkService.GetPCPerkLevel(player, PerkType.Lucky); int perkDurationBonus = PerkService.GetPCPerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2); float duration = 30.0f + (rank * 0.4f) + perkDurationBonus; int restoreAmount = 1 + item.GetLocalInt("HEALING_BONUS") + effectiveStats.Medicine + item.MedicineBonus; int delta = item.RecommendedLevel - rank; float effectivenessPercent = 1.0f; if (delta > 0) { effectivenessPercent = effectivenessPercent - (delta * 0.1f); } restoreAmount = (int)(restoreAmount * effectivenessPercent); int perkBlastBonus = PerkService.GetPCPerkLevel(player, PerkType.ImmediateImprovement); if (perkBlastBonus > 0) { int blastHeal = restoreAmount * perkBlastBonus; if (RandomService.Random(100) + 1 <= luck / 2) { blastHeal *= 2; } _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectHeal(blastHeal), target.Object); } float interval = 6.0f; BackgroundType background = (BackgroundType)player.Class1; if (background == BackgroundType.Medic) { interval *= 0.5f; } _.PlaySound("use_bacta"); Effect regeneration = _.EffectRegenerate(restoreAmount, interval); _.ApplyEffectToObject(DURATION_TYPE_TEMPORARY, regeneration, target.Object, duration); player.SendMessage("You successfully treat " + target.Name + "'s wounds. The healing kit will expire in " + duration + " seconds."); _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The healing kit that you applied to " + target.Name + " has expired."); }); if (target.IsPlayer) { int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); SkillService.GiveSkillXP(player, SkillType.Medicine, xp); } }
public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { string type = item.GetLocalString("BONUS_TYPE"); int length = item.GetLocalInt("BONUS_LENGTH"); int amount = item.GetLocalInt("BONUS_AMOUNT"); if (string.IsNullOrWhiteSpace(type) || length <= 0 || amount <= 0) { return("ERROR: This food isn't set up properly. Please inform an admin. Resref: " + item.Resref); } bool hasFoodEffect = _customEffect.DoesPCHaveCustomEffectByCategory(user.Object, CustomEffectCategoryType.FoodEffect); if (hasFoodEffect) { return("You are not hungry right now."); } return(null); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); var effectiveStats = _playerStat.GetPlayerItemEffectiveStats(player); int rank = _skill.GetPCSkillRank(player, SkillType.Medicine); int luck = _perk.GetPCPerkLevel(player, PerkType.Lucky); int perkDurationBonus = _perk.GetPCPerkLevel(player, PerkType.HealingKitExpert) * 6 + (luck * 2); float duration = 30.0f + (rank * 0.4f) + perkDurationBonus; int restoreAmount = 1 + item.GetLocalInt("HEALING_BONUS") + effectiveStats.Medicine + item.MedicineBonus; int delta = item.RecommendedLevel - rank; float effectivenessPercent = 1.0f; if (delta > 0) { effectivenessPercent = effectivenessPercent - (delta * 0.1f); } restoreAmount = (int)(restoreAmount * effectivenessPercent); int perkBlastBonus = _perk.GetPCPerkLevel(player, PerkType.ImmediateForcePack); if (perkBlastBonus > 0) { int blastHeal = restoreAmount * perkBlastBonus; if (_random.Random(100) + 1 <= luck / 2) { blastHeal *= 2; } _ability.RestoreFP(target.Object, blastHeal); } float interval = 6.0f; BackgroundType background = (BackgroundType)player.Class1; if (background == BackgroundType.Medic) { interval *= 0.5f; } string data = (int)interval + ", " + restoreAmount; _customEffect.ApplyCustomEffect(user, target.Object, CustomEffectType.ForcePack, (int)duration, restoreAmount, data); player.SendMessage("You successfully apply a force pack to " + target.Name + ". The force pack will expire in " + duration + " seconds."); _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The force pack that you applied to " + target.Name + " has expired."); }); int xp = (int)_skill.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); _skill.GiveSkillXP(player, SkillType.Medicine, xp); }
public static void RemoveCardFromCollection(int index, NWItem collection) { // removes the card at index card, creating a card object with the right variable in the player's inventory. // First check that the card is not in the deck. for (int ii = 1; ii <= 10; ii++) { int cardInDeck = collection.GetLocalInt("DECK_" + ii); if (cardInDeck == index) { _.SendMessageToPC(_.GetItemPossessor(collection), "You cannot remove a card that's in your play deck."); return; } } // All good - extract it. NWItem card = _.CreateItemOnObject("pazaakcard", _.GetItemPossessor(collection)); card.SetLocalInt("PAZAAK_CARD_TYPE", collection.GetLocalInt("CARD_" + index)); card.Name = "Pazaak Card (" + Display(collection.GetLocalInt("CARD_" + index)) + ")"; collection.DeleteLocalInt("CARD_" + index); return; }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { if (target.ObjectType != ObjectType.Creature) { user.SendMessage("You may only use stim packs on creatures!"); return; } NWPlayer player = user.Object; var ability = (AbilityType)item.GetLocalInt("ABILITY_TYPE"); int amount = item.GetLocalInt("AMOUNT") + (item.MedicineBonus * 2); int rank = player.IsPlayer ? SkillService.GetPCSkillRank(player, SkillType.Medicine) : 0; int recommendedLevel = item.RecommendedLevel; float duration = 30.0f * (rank / 10); int perkLevel = player.IsPlayer ? PerkService.GetCreaturePerkLevel(player, PerkType.StimFiend) : 0; float percentIncrease = perkLevel * 0.25f; duration = duration + (duration * percentIncrease); Effect effect = _.EffectAbilityIncrease(ability, amount); effect = _.TagEffect(effect, "STIM_PACK_EFFECT"); _.ApplyEffectToObject(DurationType.Temporary, effect, target, duration); user.SendMessage("You inject " + target.Name + " with a stim pack. The stim pack will expire in " + duration + " seconds."); _.DelayCommand(duration + 0.5f, () => { player.SendMessage("The stim pack that you applied to " + target.Name + " has expired."); }); if (!Equals(user, target)) { NWCreature targetCreature = target.Object; targetCreature.SendMessage(user.Name + " injects you with a stim pack."); } int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); SkillService.GiveSkillXP(player, SkillType.Medicine, xp); }
public void DurabilityService_GetMaxDurability_ShouldReturn4() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); DurabilityService service = new DurabilityService(script, color); NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => BASE_ITEM_LONGSWORD); item.GetLocalInt(Arg.Any <string>()).Returns(4); float result = service.GetMaxDurability(item); Assert.AreEqual(4, result); }
public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { NWItem targetItem = target.Object; float maxDurability = DurabilityService.GetMaxDurability(targetItem); float durability = DurabilityService.GetDurability(targetItem); if (target.ObjectType != OBJECT_TYPE_ITEM) { return("Only items may be targeted by repair kits."); } if (targetItem.CustomItemType != (CustomItemType)item.GetLocalInt("REPAIR_CUSTOM_ITEM_TYPE_ID")) { return("You cannot repair that item with this repair kit."); } if (maxDurability <= 0.0f || durability >= maxDurability) { return("That item does not need to be repaired."); } if (durability <= 0.0f) { return("That item is broken and cannot be repaired."); } if (maxDurability <= 0.1f) { return("You cannot repair that item any more."); } SkillType skillType = GetSkillType(item); int techLevel = item.GetLocalInt("TECH_LEVEL"); return(null); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); NWArea area = (_.GetAreaFromLocation(targetLocation)); string parentStructureID = area.GetLocalString("PC_BASE_STRUCTURE_ID"); string pcBaseID = area.GetLocalString("PC_BASE_ID"); var data = BaseService.GetPlayerTempData(player); data.TargetLocation = targetLocation; data.TargetArea = area; data.BaseStructureID = item.GetLocalInt("BASE_STRUCTURE_ID"); data.StructureItem = item; // Structure is being placed inside an apartment. if (!string.IsNullOrWhiteSpace(pcBaseID)) { data.PCBaseID = new Guid(pcBaseID); data.ParentStructureID = null; data.BuildingType = BuildingType.Apartment; } // Structure is being placed inside a building or starship. else if (!string.IsNullOrWhiteSpace(parentStructureID)) { var parentStructureGuid = new Guid(parentStructureID); var parentStructure = DataService.Get <PCBaseStructure>(parentStructureGuid); data.PCBaseID = parentStructure.PCBaseID; data.ParentStructureID = parentStructureGuid; if (area.GetLocalInt("BUILDING_TYPE") == (int)BuildingType.Starship) { data.BuildingType = BuildingType.Starship; } else { data.BuildingType = BuildingType.Interior; } } // Structure is being placed outside of a building. else { string sector = BaseService.GetSectorOfLocation(targetLocation); PCBase pcBase = DataService.Single <PCBase>(x => x.AreaResref == area.Resref && x.Sector == sector); data.PCBaseID = pcBase.ID; data.ParentStructureID = null; data.BuildingType = BuildingType.Exterior; } DialogService.StartConversation(user, user, "PlaceStructure"); }
public static void AddCardToDeck(int collectionIndex, NWItem collection, int deckIndex) { // Adds the card at position card in collection to slot in the collection's active deck. // First check that the card is not in the deck. for (int ii = 1; ii <= 10; ii++) { int cardInDeck = collection.GetLocalInt("DECK_" + ii); if (cardInDeck == collectionIndex) { _.SendMessageToPC(_.GetItemPossessor(collection), "You cannot add a card that's already in your play deck."); return; } } collection.SetLocalInt("DECK_" + deckIndex, collectionIndex); }
private bool IsMainValid() { NWPlayer player = GetPC(); NWItem main = player.RightHand; bool canModifyMain = main.IsValid && !main.IsPlot && !main.IsCursed && // https://github.com/zunath/SWLOR_NWN/issues/942#issue-467176236 main.CustomItemType != CustomItemType.Lightsaber && main.GetLocalInt("LIGHTSABER") == FALSE; if (canModifyMain) { int mainModelTypeID = Convert.ToInt32(_.Get2DAString("baseitems", "ModelType", main.BaseItemType)); canModifyMain = mainModelTypeID == ITEM_APPR_TYPE_WEAPON_MODEL; } return(canModifyMain); }
private static void OnModuleItemAcquired() { NWPlayer oPC = (_.GetModuleItemAcquiredBy()); NWItem oItem = (_.GetModuleItemAcquired()); if (!oPC.IsPlayer) { return; } int questID = oItem.GetLocalInt("QUEST_ID"); if (questID <= 0) { return; } oItem.IsCursed = true; }
public static int AddCardToCollection(NWItem card, NWObject collection) { // Adds the card represented by card to collection, destroying the card item and returning its new index in the collection. int CardType = card.GetLocalInt("PAZAAK_CARD_TYPE"); // Find the first available slot in the collection. int index = 1; while (collection.GetLocalInt("CARD_" + index) != 0) { index++; } collection.SetLocalInt("CARD_" + index, CardType); card.Destroy(); return(index); }