I am in the process of adding a mining skill to skyrim, so that the result of mining will depend on a skill check.
See below, modifications start and end with FRON_START and FRON_END
scriptName MineOreScript extends objectReference;;This script handles the Ore Veins and handshakes with the mining furniture;===================================================================sound property DrScOreOpen auto{sound played when Ore is acquired}formlist property mineOreToolsList auto{Optional: Player must have at least one item from this formlist to interact}Message Property FailureMessage Auto{Message to say why you can't use this without RequiredWeapon}Message Property DepletedMessage Auto{Message to say that this vein is depleted}MiscObject Property Ore Auto{what you get from this Ore Vein}LeveledItem property lItemGems10 auto{Optional: Gems that may be mined along with ore}int Property ResourceCount = 1 Auto{how many resources you get per drop}int property ResourceCountTotal = 3 auto{how many resources this has before it is depleted}int property ResourceCountCurrent = -1 auto Hidden{Used to track the current remaining resources}int property StrikesBeforeCollection = 1 Auto{how many times this is struck before giving a resource}int property StrikesCurrent = -1 Auto hidden{Current number of strikes}int property AttackStrikesBeforeCollection = 3 Auto{how many times this is struck by attacks before giving a resource}int property AttackStrikesCurrent = -1 Auto hidden{Current number of attack strikes}mineOreFurnitureScript property myFurniture auto hidden{the furniture for this piece of ore, set in script}objectReference property objSelf auto hidden{objectReference to self}AchievementsScript property AchievementsQuest autoLocation Property CidhnaMineLocation AutoQuest Property MS02 AutoQuest Property DialogueCidhnaMine AutoObjectReference Property CidhnaMinePlayerBedREF Auto;FRON_startglobalvariable Property fron_mining_experience autoimport fron_utility_functionsimport GlobalVariable;FRON_stop;===================================================================;;EVENT BLOCK;===================================================================event onCellAttach(); debug.Trace(self + ": is running onCellAttach")blockActivation()SetNoFavorAllowed()objSelf = self as objectReferenceif !getLinkedRef(); debug.Trace(self + ": does not have a linked ref, going to depleted state") depleteOreDueToFailure()endifendEventevent onActivate(objectReference akActivator); debug.Trace(self + " has been activated by " + akActivator);Actor is attempting to mineif akActivator as actor ;if the actor is the player if akActivator == game.getPlayer() ;if this is not depleted and the player has the right item If ResourceCountCurrent == 0 DepletedMessage.Show() elseif playerHasTools() == false FailureMessage.Show() ;enter the furniture else If Game.GetPlayer().GetCurrentLocation() == CidhnaMineLocation && MS02.ISRunning() == False; debug.Trace(self + "Player is in Cidhna Mine, activate the bed to serve time") CidhnaMinePlayerBedREF.Activate(Game.GetPlayer()) DialogueCidhnaMine.SetStage(45) Return EndIf; debug.Trace(self + " should cause " + akActivator + " to activate " + getLinkedRef()) if getLinkedRef() myFurniture = getLinkedRef() as mineOreFurnitureScript myFurniture.lastActivateRef = objSelf getLinkedRef().activate(akActivator) AchievementsQuest.incHardworker(2) Else; debug.Trace(self + ": error this ore does not have a linkedRef") endif endif Else if getLinkedRef() getLinkedRef().activate(akActivator) Else; debug.Trace(self + ": error this ore does not have a linkedRef") endif EndIf ;Furniture is telling ore it has been struckElseIf akActivator == GetLinkedRef(); debug.Trace(self + ": has been activated by" + akActivator) ;ResourceCountTotal = utility.RandomInt(1,5) ; FRON RANDOM MOD ProccessStrikes() ;Something unexpected has activated the oreElse; debug.Trace(self + "has been activated by: " + akActivator + " why?")endifendEvent;;;May add on hit with pickaxe here laterEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked); debug.Trace(self + ": onHit - akAgressor = " + akAggressor + "; akSource = " + akSource)if akAggressor == game.getPlayer() if mineOreToolsList.hasForm(akSource) proccessAttackStrikes() endifendifendEventevent onReset(); debug.Trace(self + ": is running onReset");THIS WASN'T WORKING RIGHTself.Reset()self.clearDestruction()self.setDestroyed(False); if getLinkedRef() resourceCountCurrent = -1; else ; depleteOreDueToFailure(); endifendEvent;===================================================================;;FUNCTION BLOCK;===================================================================bool function playerHasTools()if Game.GetPlayer().GetItemCount(mineOreToolsList) > 0; debug.Trace(self + ": playerHasTools is returning true") return trueElse; debug.Trace(self + ": playerHasTools is returning false") return falseendIfendFunctionfunction proccessAttackStrikes()if AttackStrikesCurrent <= -1 AttackStrikesCurrent = AttackStrikesBeforeCollectionEndIfAttackStrikesCurrent -= 1if AttackStrikesCurrent == 0 AttackstrikesCurrent = AttackStrikesBeforeCollection giveOre()endIfendFunctionfunction proccessStrikes()if StrikesCurrent <= -1 StrikesCurrent = StrikesBeforeCollectionEndIfStrikesCurrent -= 1if StrikesCurrent == 0 strikesCurrent = StrikesBeforeCollection giveOre()endIfendFunction;FRON_startfunction FRON_checkMiningResult()int critical_failure = 5int failure = 12int success = 20int xp_gained int random = utility.RandomInt(1,8) int tempMiningLevel = fron_mining_experience.getValueInt() int skill_bonus = Fron_GetSkillBonus(tempMiningLevel) random *= 2 int total_number_to_check = random + skill_bonus ;+ object_bonus + fron_ore_mining_difficulty ;debug.messageBox("Your mining skill bonus is " + skill_bonus + "the random 2d8 is " + random + " the total number to check is " + total_number_to_check) ; + " the object bonus is " + object_bonus + " the animal skinning difficulty is " + fron_animal_skinning_difficulty) if total_number_to_check <= critical_failure ;echec critique xp_gained = utility.RandomInt(1,6)*2 debug.messageBox("Critical Failure. You gain " + xp_gained + " Xps.") game.getplayer().DamageAV("Health", 10) elseif total_number_to_check > critical_failure && total_number_to_check <= failure ;echec xp_gained = utility.RandomInt(1,4)*2 debug.messageBox("Failure. You gain " + xp_gained + " Xps.") elseif total_number_to_check > failure && total_number_to_check <= success ;réussite simple xp_gained = utility.RandomInt(1,6) debug.messageBox("Success. You gain " + xp_gained + " Xps.") if ore (game.getPlayer()).addItem(Ore, ResourceCount) endif if lItemGems10 (game.getPlayer()).addItem(lItemGems10) endif else ;réussite critique xp_gained = utility.RandomInt(1,3) debug.messageBox("Critical Success. You Gain " + xp_gained + " Xps." ) if ore (game.getPlayer()).addItem(Ore, ResourceCount) (game.getPlayer()).addItem(Ore, ResourceCount) endif if lItemGems10 (game.getPlayer()).addItem(lItemGems10) (game.getPlayer()).addItem(lItemGems10) endif endif tempMiningLevel = xp_gained + tempMiningLevel string MiningSkillName = Fron_GetSkillLevelName(tempMiningLevel) int Remaining_XP = Fron_GetRemainingNeededXPUntilNextLevel (tempMiningLevel) fron_mining_experience.setValueInt(tempMiningLevel) debug.messageBox("Your new Mining level is " + tempMiningLevel + " XPs. You are a "+MiningSkillName+" Miner. You need "+Remaining_XP+" XPs until next level.") endfunction;FRON_Stopfunction giveOre()if ResourceCountCurrent == -1 ResourceCountCurrent = ResourceCountTotalEndIfif ResourceCountCurrent > 0 ResourceCountCurrent -= 1; debug.Trace(self + ": ResourceCountCurrent = " + ResourceCountCurrent) if ResourceCountCurrent == 0 ; debug.Trace(self + ": ResourceCountCurrent == 0 - depleted" ) self.damageObject(50) getLinkedRef().activate(objSelf) DrScOreOpen.play(self) self.setDestroyed(true) ; if this vein has ore and/or gems defined, give them. ;FRON_START FRON_checkMiningResult() ; if ore ; (game.getPlayer()).addItem(Ore, ResourceCount) ; endif ; if lItemGems10 ; (game.getPlayer()).addItem(lItemGems10) ; endif ;FRON_STOP DepletedMessage.Show() else DrScOreOpen.play(self) ; if this vein has ore and/or gems defined, give them. ;FRON_START FRON_checkMiningResult() ; if ore ; (game.getPlayer()).addItem(Ore, ResourceCount) ; endif ; if lItemGems10 ; (game.getPlayer()).addItem(lItemGems10) ; endif ;FRON_STOP endifelseif ResourceCountCurrent == 0 getLinkedRef().activate(objSelf) (getLinkedRef() as MineOreFurnitureScript).goToDepletedState() DepletedMessage.Show()endifEndFunctionfunction depleteOreDueToFailure()self.damageObject(50);THIS WASN'T WORKING RIGHTself.setDestroyed(true)ResourceCountCurrent = 0endFunctionSo I created a global variable to store the mining experience of the character, and I added it to the native "mineOreScript"
So the Native Mine Ore script has a new property (the global variable) that needs to be defined for every use of this script.
This script works very well ingame except the fact that the global variable isn't modified (so the character never improves...)
I tried really hard to modify all the many base objects that use the "mineOreScript", but the world various Ore deposit dosen't seem to take the new global variable into account, although the various modifications work really well.
So my questions are:
Is there a fast way to modify all the references in the world ?
Do you think I could store this global variable in an other way ?
I am pretty mad now, because I can't finish and release both my skinning and mining skills in a proper way (that is, not only random results, that is the easy part, but also so that the character can improve himself over use...)
