Alternate Mining Scripts - Please Help

Post » Sat Apr 05, 2014 9:18 am

So basically I'm working on a mod that adds a new pickaxe into the game. This pickaxe is essentially going to be able to extract more ore from ore veins. So, instead of getting 1 ore per 3 hits for a total of 9 hits yielding 3 ore per vein, I would like it to get 1 ore per 2 hits for a total of 10 hits yielding 5 ore. Obviously, I could do this by simply editing the values in the mineOreScript and be done. HOWEVER, I want to add this pickaxe but still have the normal one! This means I will need 2 separate mining scripts, 1 for each pickaxe. I know how to create the pickaxe and it to a formlist but I need help with the script. I understand I could copy the mineOreScript and change the resources yielded values and change the conditons to a different formlist containing my pickaxe, but I would then have to apply the script to EVERY SINGLE ORE IN THE GAME! Therefore I have several theories on how to complete this task:

- There's some way to add a script to every single ore in the game in several clicks

- There's some way to add a script to every item that has a certain script (thus I could add my mineOreScript2 script to all items that have the default mineOreScript)

- I can somehow edit the mineOreScript (the default one on all ores) to have variables dependent on the pickaxe being used so it could determine which pickaxe the player has equipped and give the appropriate ore

If any of these ways are possible please explain how I can do it!

Thanks for reading and sorry if something didn't make sense, It's hard to explain what I'm trying to do... If you help me out I will be very grateful!

Here's the default mineOreScript for all ores in the game:

Spoiler
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 auto
Location Property CidhnaMineLocation Auto
Quest Property MS02 Auto
Quest Property DialogueCidhnaMine Auto
ObjectReference Property CidhnaMinePlayerBedREF Auto
;===================================================================
;;EVENT BLOCK
;===================================================================
event onCellAttach()
; debug.Trace(self + ": is running onCellAttach")
blockActivation()
SetNoFavorAllowed()
objSelf = self as objectReference
if !getLinkedRef()
; debug.Trace(self + ": does not have a linked ref, going to depleted state")
depleteOreDueToFailure()
endif
endEvent
event onActivate(objectReference akActivator)
; debug.Trace(self + " has been activated by " + akActivator)
;Actor is attempting to mine
if 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 struck
ElseIf akActivator == GetLinkedRef()
; debug.Trace(self + ": has been activated by" + akActivator)
ProccessStrikes()
;Something unexpected has activated the ore
Else
; debug.Trace(self + "has been activated by: " + akActivator + " why?")
endif
endEvent
;;;May add on hit with pickaxe here later
Event 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()
;PATCH 1.5 CAPTURE ON HIT EVENT AND BRING UP SERVE TIME DIALOG FOR CIDHNA MINE
if mineOreToolsList.hasForm(akSource)
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
proccessAttackStrikes()
endif
endif
endEvent
event onReset()
; debug.Trace(self + ": is running onReset")
;THIS WASN'T WORKING RIGHT
self.Reset()
self.clearDestruction()
self.setDestroyed(False)
; if getLinkedRef()
resourceCountCurrent = -1
; else
; depleteOreDueToFailure()
; endif
endEvent
;===================================================================
;;FUNCTION BLOCK
;===================================================================
bool function playerHasTools()
if Game.GetPlayer().GetItemCount(mineOreToolsList) > 0
; debug.Trace(self + ": playerHasTools is returning true")
return true
Else
; debug.Trace(self + ": playerHasTools is returning false")
return false
endIf
endFunction
function proccessAttackStrikes()
if AttackStrikesCurrent <= -1
AttackStrikesCurrent = AttackStrikesBeforeCollection
EndIf
AttackStrikesCurrent -= 1
if AttackStrikesCurrent == 0
AttackstrikesCurrent = AttackStrikesBeforeCollection
giveOre()
endIf
endFunction
function proccessStrikes()
if StrikesCurrent <= -1
StrikesCurrent = StrikesBeforeCollection
EndIf
StrikesCurrent -= 1
if StrikesCurrent == 0
strikesCurrent = StrikesBeforeCollection
giveOre()
endIf
endFunction
function giveOre()
if ResourceCountCurrent == -1
ResourceCountCurrent = ResourceCountTotal
EndIf
if 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.
if ore
(game.getPlayer()).addItem(Ore, ResourceCount)
endif
if lItemGems10
(game.getPlayer()).addItem(lItemGems10)
endif
DepletedMessage.Show()
else
DrScOreOpen.play(self)
; if this vein has ore and/or gems defined, give them.
if ore
(game.getPlayer()).addItem(Ore, ResourceCount)
endif
if lItemGems10
(game.getPlayer()).addItem(lItemGems10)
endif
endif
elseif ResourceCountCurrent == 0
getLinkedRef().activate(objSelf)
(getLinkedRef() as MineOreFurnitureScript).goToDepletedState()
DepletedMessage.Show()
endif
EndFunction
function depleteOreDueToFailure()
self.damageObject(50)
;THIS WASN'T WORKING RIGHT
self.setDestroyed(true)
ResourceCountCurrent = 0
endFunction

User avatar
Portions
 
Posts: 3499
Joined: Thu Jun 14, 2007 1:47 am

Post » Sat Apr 05, 2014 11:36 am

Wow, that is one ugly vanilla script right there :P

You don't need to make a whole new script, nor do you even have to modify the current one. What you do need to be able to do, is edit the properties in this script when the player activates the mining activator. Meaning these kinds of things:

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}

This is going to require a little bit of knowledge about how scripts communicate with one another -- i.e., how you can modify the variables on another script from your own script. Which is slightly tricky if you haven't learned anything about papyrus yet.

The way I would try to do this is by giving a perk to the player with the Entry Point "Activate" -- then condition the Activate script fragment to run only when the player is holding your special axe, and only when they are activating a mining activator (probably would need to make a formlist of those to use in your condition). Once you have that set up, it would be a simple matter of a short script fragment attached to the perk entry, something like...

mineOreScript thisScript = (akTargetRef as mineOreScript)thisScript.ResourceCount = 3 ;or whatever new number you wantthisScript.ResourceCountTotal = 9 ;ditto

You would probably also have to set those values back though when the player gets up, which would add to the complexity a bit -- you'd have to add the player to a temporary alias or somehow detect when they stopped mining so you could set the numbers back.

User avatar
Mimi BC
 
Posts: 3282
Joined: Sat Oct 07, 2006 10:30 pm


Return to V - Skyrim