Kyndra72 Posted December 27, 2018 Share Posted December 27, 2018 Hello, I'm trying to make a mod using the "defaultFakeHarvestableScript" to turn Shellbugs into harvestables without them dying or being disabled. The goal is to be able to walk up to the Shellbug (the activator), activate it to recieve 3 Shellbug Chitin without mining or killing it, it will literally just act like a harvestable ingredient without disappearing after it's been harvested. The problem is I only want to be able to do this once every 10 days so that it's not OP. Everything works so far EXCEPT it doesn't reset after 10 days, it just keeps giving me the failure message I set. Can anyone please help? I'm a total noob to scripting and I've been working on this for hours and I'm probably doing wrong that's ridiculously obvious without realizing it. I've looked up tutorials and did numerous Google searches and read a probably unnecessary amount of CK Wiki pages and I'm just at my wit's end lol it's embarassing because this seems like it's going to be really simple. :pinch: Shellbug Chitin is a MiscObject, not an Ingredient by the way. Here's the script I have so far: Scriptname AAA_STSBGetItemScript extends ObjectReference miscobject property IngredientHarvested auto {miscobject added when harvested} bool property deleteSelfOnHarvest = false auto {if true, delete this object when harvested} message property HarvestMessage auto {Message that appears when you have successfully harvested something} message property FailureMessage auto {Message that appears when you fail to harvest something} globalVariable property DaysToResetFakeHarvest auto {The amount of game days that it takes to become reharvestable} float property lastHarvestedDay auto Hidden {the game day this was last successfuly harvested, used to know when to respawn} sound property HarvestSound auto {Sounds played on harvest} ;=================================================================== ;;STATE BLOCK ;=================================================================== auto state readyForHarvest event onActivate(objectReference akActivator) goToState("waitingToRespawn") fakeHarvest(akActivator) if deleteSelfOnHarvest disable() delete() endif endEvent endState state waitingToRespawn event onBeginState() lastHarvestedDay = utility.getCurrentGameTime() endEvent event onActivate(objectReference akActivator) FailureMessage.show() endEvent event onCellLoad() if (lastHarvestedDay + DaysToResetFakeHarvest.getValue()) <= utility.getCurrentGameTime() goToState("readyForHarvest") endif endEvent endState ;=================================================================== ;;FUNCTION BLOCK ;=================================================================== function fakeHarvest(objectReference akActivator) if (akActivator as actor) HarvestMessage.show() HarvestSound.play(self) if IngredientHarvested (akActivator as actor).addItem(IngredientHarvested, 3, true) endif endif endFunction Please be gentle lol Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 28, 2018 Share Posted December 28, 2018 (edited) Maybe this is working better, but who knows. Vanilla script "defaultFakeHarvestableScript" has some mistakes that are not easy to find.Whenever a script reset and an auto state is given, the script changed the state to this by reseting. AAA_STSBGetItemScript Scriptname AAA_STSBGetItemScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/7264231-scripting-help-activator-wont-reset/ ; EAB961996 wrote: "The goal is to be able to walk up to the Shellbug (the activator), ; activate it to recieve 3 Shellbug Chitin without mining or killing it.." GlobalVariable PROPERTY DaysToResetFakeHarvest auto ; The amount of game days that it takes to become reharvestable Float PROPERTY lastHarvestedDay auto Hidden ; game day this was last successfuly harvested, used to know when to respawn Message PROPERTY HarvestMessage auto ; appears when you have successfully harvested something Message PROPERTY FailureMessage auto ; appears when you fail to harvest something Sound PROPERTY HarvestSound auto ; played on harvest MiscObject PROPERTY MiscObjectHarvested auto ; miscobject added when harvested Bool PROPERTY deleteSelfOnHarvest auto ; [default=False], if TRUE delete this object when harvested ; -- EVENTs -- 2 + "readyForHarvest" + "waitingToRespawn" EVENT OnReset() float f = lastHarvestedDay + DaysToResetFakeHarvest.GetValue() ;* Debug.Trace(" OnReset(" + (f as Int) + ") - has been reached.. " +self) ;* info only ENDEVENT EVENT OnCellLoad() float f = lastHarvestedDay + DaysToResetFakeHarvest.GetValue() Debug.Trace(" OnCellLoad(" + (f as Int) + ") - has been reached.. " +self) ; info only IF (f <= Utility.GetCurrentGameTime()) gotoState("readyForHarvest") ; ### STATE ### ENDIF ENDEVENT ;======================================== auto state readyForHarvest ;========================= EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - no player, no action ENDIF ;--------------------- gotoState("waitingToRespawn") ; ### STATE ### fakeHarvest(akActionRef) IF ( deleteSelfOnHarvest ) self.Disable() self.Delete() ENDIF ; The question is, if this script object has been deleted, what script is placing a new scripted object as replacement? ENDEVENT ;======= endState ;======================================== state waitingToRespawn ;===================== EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) myF_Show(FailureMessage, 0) ; player activated, but waiting for respawn ENDIF ENDEVENT ;======= endState ; -- FUNCTIONs -- 2 ;------------------------------------ FUNCTION myF_Show(Message msg, Int i) ;------------------------------------ IF ( msg ) msg.Show() ELSE Debug.Notification("Missing property message " +i) ENDIF ENDFUNCTION ;------------------------------------------------ FUNCTION fakeHarvest(ObjectReference akActionRef) ;------------------------------------------------ IF ( !MiscObjectHarvested ) Debug.Notification("Missing property MiscObjectHarvested!") RETURN ; - STOP - ENDIF ;--------------------- lastHarvestedDay = Utility.GetCurrentGameTime() ; moved from OnBeginState() to this place, store time of harvesting IF ( HarvestSound ) HarvestSound.Play(self) ; returns an interger variable ENDIF myF_Show(HarvestMessage, 1) akActionRef.AddItem(MiscObjectHarvested as Form, 3, TRUE) ; gives the player 3x harvested object ENDFUNCTION Edited December 28, 2018 by ReDragon2013 Link to comment Share on other sites More sharing options...
Kyndra72 Posted December 28, 2018 Author Share Posted December 28, 2018 BLESS YOU. It's working now! Thank you so much! I'll credit you once I upload the mod :) Link to comment Share on other sites More sharing options...
Recommended Posts