// ============================== DURATION/PROBABILITY =============================== // ----------------------------------------------------------------------------------- // UCE_Harvesting_CanBoost // ----------------------------------------------------------------------------------- public bool UCE_Harvesting_CanBoost() { UCE_HarvestingProfessionRequirement requiredProfession = getRequiredHarvestingProfession(); UCE_HarvestingProfession profession = getHarvestingProfession(requiredProfession); if (profession.template.optionalTools.Length <= 0) return false; bool bValid = false; foreach (UCE_HarvestingTool tool in profession.template.optionalTools) { if ( (!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem)) ) { bValid = true; } else { bValid = false; } } return bValid; }
// ----------------------------------------------------------------------------------- // Use // ----------------------------------------------------------------------------------- public override void Use(Player player, int inventoryIndex) { ItemSlot slot = player.inventory[inventoryIndex]; // -- Only activate if enough charges left if (decreaseAmount == 0 || slot.amount >= decreaseAmount) { // always call base function too base.Use(player, inventoryIndex); if (!player.HasHarvestingProfession(learnProfession)) { UCE_HarvestingProfession tmpProf = new UCE_HarvestingProfession(learnProfession.name); tmpProf.experience = gainProfessionExp; player.UCE_Professions.Add(tmpProf); player.UCE_ShowPopup(learnProfessionText + learnProfession.name); } else { UCE_HarvestingProfession tmpProf = player.UCE_getHarvestingProfession(learnProfession); tmpProf.experience += gainProfessionExp; player.SetHarvestingProfession(tmpProf); player.UCE_TargetAddMessage(gainProfessionExp.ToString() + expProfessionTxt); } slot.DecreaseAmount(decreaseAmount); player.inventory[inventoryIndex] = slot; } }
public void CharacterLoad_UCE_Harvesting(Player player) { var table = connection.Query <professions>( "SELECT profession, experience FROM character_professions WHERE character = ?", player.name); foreach (var row in table) { UCE_HarvestingProfession profession = new UCE_HarvestingProfession(row.profession); profession.experience = row.experience; player.UCE_Professions.Add(profession); } }
// ----------------------------------------------------------------------------------- // Show // ----------------------------------------------------------------------------------- public void Show(UCE_HarvestingProfession p) { float value = 0; string lvl = " [L" + p.level.ToString() + "/" + p.maxlevel.ToString() + "]"; value = p.experiencePercent; nameText.text = p.template.name + lvl; professionIcon.sprite = p.template.image; expSlider.value = value; tooltip.enabled = true; tooltip.text = ToolTip(p.template); }
// ----------------------------------------------------------------------------------- // UCE_HarvestingProbability // ----------------------------------------------------------------------------------- public float UCE_HarvestingProbability(bool boost) { float proba = 0f; UCE_HarvestingProfessionRequirement requiredProfession = getRequiredHarvestingProfession(); UCE_HarvestingProfession profession = getHarvestingProfession(requiredProfession); // -- Modificator: Profession Skill proba = profession.template.baseHarvestChance; // -- Modificator: Node Level vs. Skill Level if (profession.level > requiredProfession.level) { proba += (profession.level - requiredProfession.level) * profession.template.probabilityPerSkillLevel; } // -- Modificator: Required Tools foreach (UCE_HarvestingTool tool in profession.template.tools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { proba += tool.modifyProbability; if (!profession.template.requiresAllTools) { break; } } } // -- Modificator: Optional Tools if (boost) { foreach (UCE_HarvestingTool tool in profession.template.optionalTools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { proba += tool.modifyProbability; break; } } } return(proba); }
// ----------------------------------------------------------------------------------- // UCE_HarvestingDuration // ----------------------------------------------------------------------------------- public float UCE_HarvestingDuration(bool boost) { float duration = 0f; int level = 0; UCE_HarvestingProfessionRequirement requiredProfession = getRequiredHarvestingProfession(); UCE_HarvestingProfession profession = getHarvestingProfession(requiredProfession); duration = UCE_selectedResourceNode.harvestDuration; // -- Modificator: Skill duration += level * profession.template.durationPerSkillLevel; // -- Modificator: Required Tools foreach (UCE_HarvestingTool tool in profession.template.tools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { duration += tool.modifyDuration; if (!profession.template.requiresAllTools) { break; } } } // -- Modificator: Optional Tools if (boost) { foreach (UCE_HarvestingTool tool in profession.template.optionalTools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { duration += tool.modifyDuration; break; } } } return(duration); }
private void CharacterLoad_UCE_Harvesting(Player player) { #if _MYSQL && _SERVER var table = ExecuteReaderMySql("SELECT profession, experience FROM character_professions WHERE `character`=@character", new MySqlParameter("@character", player.name)); foreach (var row in table) { UCE_HarvestingProfession profession = new UCE_HarvestingProfession((string)row[0]); profession.experience = (long)row[1]; player.UCE_Professions.Add(profession); } #elif _SQLITE && _SERVER var table = connection.Query <character_professions>("SELECT profession, experience FROM character_professions WHERE character=?", player.name); foreach (var row in table) { UCE_HarvestingProfession profession = new UCE_HarvestingProfession(row.profession); profession.experience = row.experience; player.UCE_Professions.Add(profession); } #endif }
public void CharacterLoad_UCE_Harvesting(Player player) { #if _MYSQL var table = ExecuteReaderMySql("SELECT profession, experience FROM character_professions WHERE `character`=@character", new MySqlParameter("@character", player.name)); foreach (var row in table) { UCE_HarvestingProfession profession = new UCE_HarvestingProfession((string)row[0]); profession.experience = (long)row[1]; player.UCE_Professions.Add(profession); } #elif _SQLITE var table = ExecuteReader("SELECT profession, experience FROM character_professions WHERE character=@character", new SqliteParameter("@character", player.name)); foreach (var row in table) { UCE_HarvestingProfession profession = new UCE_HarvestingProfession((string)row[0]); profession.experience = (long)row[1]; player.UCE_Professions.Add(profession); } #endif }
// ----------------------------------------------------------------------------------- // UCE_HarvestingExperience // ----------------------------------------------------------------------------------- public int UCE_HarvestingExperience(bool boost) { int exp = 0; UCE_HarvestingProfessionRequirement requiredProfession = getRequiredHarvestingProfession(); UCE_HarvestingProfession profession = getHarvestingProfession(requiredProfession); // -- Modificator: Resource Node exp = UnityEngine.Random.Range(UCE_selectedResourceNode.ProfessionExperienceRewardMin, UCE_selectedResourceNode.ProfessionExperienceRewardMax); // -- Modificator: Required Tools foreach (UCE_HarvestingTool tool in profession.template.tools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { exp += UnityEngine.Random.Range(tool.modifyExperienceMin, tool.modifyExperienceMax); if (!profession.template.requiresAllTools) { break; } } } // -- Modificator: Optional Tools if (boost) { foreach (UCE_HarvestingTool tool in profession.template.optionalTools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { exp += UnityEngine.Random.Range(tool.modifyExperienceMin, tool.modifyExperienceMax); break; } } } return(exp); }
public void Cmd_UCE_FinishHarvest() { if (UCE_HarvestingValidation()) { UCE_removeTask(); UCE_stopTimer(); UCE_HarvestingResult harvestingResult = UCE_HarvestingResult.None; // --------------------------------------------------------------------------- Experience UCE_HarvestingProfessionRequirement requiredProfession = getRequiredHarvestingProfession(); UCE_HarvestingProfession profession = getHarvestingProfession(requiredProfession); harvestBooster = UCE_Harvesting_CanBoost(); float harvestChance = UCE_HarvestingProbability(harvestBooster); float harvestCritChance = UCE_HarvestingCriticalProbability(harvestBooster); int nodeLevel = requiredProfession.level; int oldLevel = profession.level; int exp = UCE_HarvestingExperience(harvestBooster); profession.experience += exp; SetHarvestingProfession(profession); if (exp > 0) UCE_TargetAddMessage(exp.ToString() + " " + profession.template.name + " " + UCE_selectedResourceNode.experienceMessage); #if _iMMOTOOLS if (oldLevel < profession.level) UCE_ShowPopup(UCE_selectedResourceNode.levelUpMessage + profession.templateName + " [L" + profession.level + "]"); #endif // --------------------------------------------------------------------------- Skill Check if (UnityEngine.Random.value <= harvestChance) { harvestingResult = UCE_HarvestingResult.Success; if (UnityEngine.Random.value <= harvestCritChance) harvestingResult = UCE_HarvestingResult.CriticalSuccess; } else { harvestingResult = UCE_HarvestingResult.Failure; } // --------------------------------------------------------------------------- Deplete other Costs (mana etc.) mana -= UCE_selectedResourceNode.manaCost; // --------------------------------------------------------------------------- Check Tool breakage foreach (UCE_HarvestingTool tool in profession.template.tools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { if (UnityEngine.Random.value <= tool.toolDestroyChance) { if (tool.equippedItem) UCE_removeEquipment(tool.requiredItem); else InventoryRemove(new Item(tool.requiredItem), 1); UCE_TargetAddMessage(UCE_selectedResourceNode.breakMessage); } } } if (harvestBooster) { foreach (UCE_HarvestingTool tool in profession.template.optionalTools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) { if (UnityEngine.Random.value <= tool.toolDestroyChance) { if (tool.equippedItem) UCE_removeEquipment(tool.requiredItem); else InventoryRemove(new Item(tool.requiredItem), 1); UCE_TargetAddMessage(UCE_selectedResourceNode.boosterMessage); } } } } // --------------------------------------------------------------------------- Resources if (harvestingResult != UCE_HarvestingResult.Failure) { if (harvestingResult == UCE_HarvestingResult.CriticalSuccess) { UCE_selectedResourceNode.OnCritical(); UCE_TargetAddMessage(UCE_selectedResourceNode.criticalSuccessMessage); } else { UCE_TargetAddMessage(UCE_selectedResourceNode.successMessage); } Target_UCE_finishResourceNodeAccess(connectionToClient); UCE_selectedResourceNode.OnHarvested(); UCE_selectedResourceNode.OnDepleted(); #if _iMMOHARVESTING && _iMMOQUESTS UCE_IncreaseHarvestNodeCounterFor(profession.template); #endif } else { UCE_ShowPrompt(UCE_selectedResourceNode.failedMessage); } // --------------------------------------------------------------------------- Cleanup //UCE_cancelHarvesting(); harvestBooster = false; } }
// ----------------------------------------------------------------------------------- // SetProfession // ----------------------------------------------------------------------------------- public void SetHarvestingProfession(UCE_HarvestingProfession aProf) { int id = UCE_Professions.FindIndex(pr => pr.templateName == aProf.template.name); UCE_Professions[id] = aProf; }
// ----------------------------------------------------------------------------------- // getProfessionExp // ----------------------------------------------------------------------------------- public long getHarvestingProfessionExp(UCE_HarvestingProfession aProf) { int id = UCE_Professions.FindIndex(prof => prof.templateName == aProf.templateName); return UCE_Professions[id].experience; }
private void OnServerCharacterCreate_UCE_Traits(CharacterCreateMsg netMsg, Player player) { if (netMsg == null || netMsg.traits == null || netMsg.traits.Length == 0) return; foreach (int traitId in netMsg.traits) { if (traitId != 0) { UCE_TraitTemplate trait; if (UCE_TraitTemplate.dict.TryGetValue(traitId, out trait)) { player.UCE_Traits.Add(new UCE_Trait(trait)); #if _iMMOATTRIBUTES foreach (UCE_AttributeTemplate template in player.playerAttributes.UCE_AttributeTypes) { if (template == null) continue; UCE_Attribute attr = new UCE_Attribute(template); player.playerAttributes.UCE_Attributes.Add(attr); } #endif // ---------------------------------------------------------------------- foreach (UCE_SkillRequirement startSkill in trait.startingSkills) { for (int i = 0; i < player.skills.skills.Count; ++i) { if (player.skills.skills[i].data == startSkill.skill) { Skill skill = player.skills.skills[i]; skill.level += startSkill.level; player.skills.skills[i] = skill; } } } // ---------------------------------------------------------------------- foreach (UCE_ItemModifier startItem in trait.startingItems) { player.inventory.Add(new Item(startItem.item), startItem.amount); } #if _iMMOPRESTIGECLASSES if (trait.startingPrestigeClass != null) player.UCE_prestigeClass = trait.startingPrestigeClass; #endif #if _iMMOHONORSHOP foreach (UCE_HonorShopCurrencyCost currency in trait.startingHonorCurrency) player.UCE_AddHonorCurrency(currency.honorCurrency, currency.amount); #endif #if _iMMOFACTIONS foreach (UCE_FactionRating faction in trait.startingFactions) player.UCE_AddFactionRating(faction.faction, faction.startRating); #endif #if _iMMOCRAFTING foreach (UCE_CraftingProfessionRequirement prof in trait.startingCraftingProfession) { if (player.UCE_HasCraftingProfession(prof.template)) { var tmpProf = player.UCE_getCraftingProfession(prof.template); tmpProf.experience += prof.level; player.UCE_setCraftingProfession(tmpProf); } else { UCE_CraftingProfession tmpProf = new UCE_CraftingProfession(prof.template.name); tmpProf.experience += prof.level; player.UCE_Crafts.Add(tmpProf); } } #endif #if _iMMOHARVESTING foreach (UCE_HarvestingProfessionRequirement prof in trait.startingHarvestingProfession) { if (player.HasHarvestingProfession(prof.template)) { var tmpProf = player.getHarvestingProfession(prof.template); tmpProf.experience += prof.level; player.SetHarvestingProfession(tmpProf); } else { UCE_HarvestingProfession tmpProf = new UCE_HarvestingProfession(prof.template.name); tmpProf.experience += prof.level; player.UCE_Professions.Add(tmpProf); } } #endif #if _iMMOPVP player.UCE_setRealm(trait.changeRealm, trait.changeAlliedRealm); #endif // ------------ Recalculate all Maxes here again (in case of bonusses) player.health.current = player.health.max; player.mana.current = player.mana.max; #if _iMMOSTAMINA player.stamina = player.staminaMax; #endif // ---------------------------------------------------------------------- } } } }