private void SalvagePageResponses(int responseID) { var player = GetPC(); var model = CraftService.GetPlayerCraftingData(player); switch (responseID) { case 1: // Reassemble Component(s) NWItem fuel = _.GetItemPossessedBy(player, "ass_power"); // Look for reassembly fuel in the player's inventory. if (!fuel.IsValid) { player.SendMessage(ColorTokenService.Red("You must have a 'Reassembly Fuel Cell' in your inventory in order to start this process.")); return; } if (model.IsConfirmingReassemble) { // Calculate delay, fire off delayed event, and show timing bar. float delay = CraftService.CalculateCraftingDelay(player, (int)SkillType.Harvesting); NWNXPlayer.StartGuiTimingBar(player, delay, string.Empty); var @event = new OnReassembleComplete(player, model.SerializedSalvageItem, model.SalvageComponentTypeID); player.DelayEvent(delay, @event); // Make the player play an animation. player.AssignCommand(() => { _.ClearAllActions(); _.ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0f, delay); }); // Show sparks halfway through the process. _.DelayCommand(1.0f * (delay / 2.0f), () => { _.ApplyEffectToObject(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_COM_BLOOD_SPARK_MEDIUM), NWGameObject.OBJECT_SELF); }); // Immobilize the player while crafting. Effect immobilize = _.EffectCutsceneImmobilize(); immobilize = _.TagEffect(immobilize, "CRAFTING_IMMOBILIZATION"); _.ApplyEffectToObject(DURATION_TYPE_PERMANENT, immobilize, player); // Clear the temporary crafting data and end this conversation. model.SerializedSalvageItem = string.Empty; EndConversation(); } else { model.IsConfirmingReassemble = true; SetResponseText("SalvagePage", 1, "CONFIRM REASSEMBLE COMPONENT(S)"); } break; } }
private void OnReassembleComplete(OnReassembleComplete data) { _player = data.Player; int xp = 100; // Always grant at least this much XP to player. // Remove the immobilization effect foreach (var effect in _player.Effects) { if (_.GetEffectTag(effect) == "CRAFTING_IMMOBILIZATION") { _.RemoveEffect(_player, effect); } } // Check for a fuel cell in the player's inventory again. If it doesn't exist, we exit early with an error message. NWItem fuel = _.GetItemPossessedBy(_player, "ass_power"); if (!fuel.IsValid) { _player.SendMessage(ColorTokenService.Red("A 'Reassembly Fuel Cell' was not found in your inventory. Reassembly failed.")); return; } // Otherwise the fuel cell was found. Destroy it and continue on with the process. fuel.Destroy(); _playerItemStats = PlayerStatService.GetPlayerItemEffectiveStats(_player); string serializedSalvageItem = data.SerializedSalvageItem; NWPlaceable tempStorage = _.GetObjectByTag("TEMP_ITEM_STORAGE"); NWItem item = SerializationService.DeserializeItem(serializedSalvageItem, tempStorage); int salvageComponentTypeID = data.SalvageComponentTypeID; _componentType = DataService.ComponentType.GetByID(salvageComponentTypeID); // Create an item with no bonuses every time. _.CreateItemOnObject(_componentType.ReassembledResref, _player); // Now check specific custom properties which are stored as local variables on the item. xp += ProcessProperty(item.HarvestingBonus, 3, ComponentBonusType.HarvestingUp); xp += ProcessProperty(item.PilotingBonus, 3, ComponentBonusType.PilotingUp); xp += ProcessProperty(item.ScanningBonus, 3, ComponentBonusType.ScanningUp); xp += ProcessProperty(item.ScavengingBonus, 3, ComponentBonusType.ScavengingUp); xp += ProcessProperty(item.CooldownRecovery, 3, ComponentBonusType.CooldownRecoveryUp); xp += ProcessProperty(item.CraftBonusArmorsmith, 3, ComponentBonusType.ArmorsmithUp); xp += ProcessProperty(item.CraftBonusWeaponsmith, 3, ComponentBonusType.WeaponsmithUp); xp += ProcessProperty(item.CraftBonusCooking, 3, ComponentBonusType.CookingUp); xp += ProcessProperty(item.CraftBonusEngineering, 3, ComponentBonusType.EngineeringUp); xp += ProcessProperty(item.CraftBonusFabrication, 3, ComponentBonusType.FabricationUp); xp += ProcessProperty(item.HPBonus, 5, ComponentBonusType.HPUp, 0.5f); xp += ProcessProperty(item.FPBonus, 5, ComponentBonusType.FPUp, 0.5f); xp += ProcessProperty(item.EnmityRate, 3, ComponentBonusType.EnmityUp); xp += ProcessProperty(item.LuckBonus, 3, ComponentBonusType.LuckUp); xp += ProcessProperty(item.MeditateBonus, 3, ComponentBonusType.MeditateUp); xp += ProcessProperty(item.RestBonus, 3, ComponentBonusType.RestUp); xp += ProcessProperty(item.MedicineBonus, 3, ComponentBonusType.MedicineUp); xp += ProcessProperty(item.HPRegenBonus, 3, ComponentBonusType.HPRegenUp); xp += ProcessProperty(item.FPRegenBonus, 3, ComponentBonusType.FPRegenUp); xp += ProcessProperty(item.BaseAttackBonus, 3, ComponentBonusType.BaseAttackBonusUp, 6f); xp += ProcessProperty(item.StructureBonus, 3, ComponentBonusType.StructureBonusUp); xp += ProcessProperty(item.SneakAttackBonus, 3, ComponentBonusType.SneakAttackUp); xp += ProcessProperty(item.DamageBonus, 3, ComponentBonusType.DamageUp); xp += ProcessProperty(item.StrengthBonus, 3, ComponentBonusType.StrengthUp); xp += ProcessProperty(item.DexterityBonus, 3, ComponentBonusType.DexterityUp); xp += ProcessProperty(item.ConstitutionBonus, 3, ComponentBonusType.ConstitutionUp); xp += ProcessProperty(item.WisdomBonus, 3, ComponentBonusType.WisdomUp); xp += ProcessProperty(item.IntelligenceBonus, 3, ComponentBonusType.IntelligenceUp); xp += ProcessProperty(item.CharismaBonus, 3, ComponentBonusType.CharismaUp); xp += ProcessProperty(item.DurationBonus, 3, ComponentBonusType.DurationUp); item.Destroy(); SkillService.GiveSkillXP(_player, SkillType.Harvesting, xp); }