gerg357 Posted September 30, 2016 Share Posted September 30, 2016 Scriptname BeeHive1 extends ObjectReference Import UtilityIngredient Property queenbee autoIngredient Property workerbee autoIngredient Property dronebee autoIngredient Property BeeHoneyComb auto Message Property Beedead AutoMessage Property Beealive AutoMessage Property BeeSuccess AutoMessage Property BeeFail AutoMessage Property beehivestarted AutoMessage Property hivenotready AutoObjectReference Property honeyhive1 auto float CheckTime ; the only status variable needed Event OnActivate(ObjectReference akActionRef) if akActionRef != Game.GetPlayer() ; do not let other NPCs trigger this return endif if (honeyhive1.GetItemCount(queenbee) == 1 && honeyhive1.GetItemCount(workerbee) == 1000 && honeyhive1.GetItemCount(dronebee) == 1 && CheckTime == 0.0) ;checktime is 0.0 on first activation by defaultCheckTime = 72.0 + Utility.GetCurrentGameTime() * 24.0 ; converts days to hours basically converts days to hours but had a issue using days so i just made 3 days 72 hoursbeehivestarted.Show() ;displays beehive is ready endif if (honeyhive1.GetItemCount(queenbee) == 1 && honeyhive1.GetItemCount(workerbee) == 1000 && honeyhive1.GetItemCount(dronebee) == 1 && Utility.GetCurrentGameTime() * 24.0 >= CheckTime) ;if 72 hours has passed when this is activated again do this section CheckTime = 0.0 ; reset for next time int killchance = Utility.RandomInt(0, 2) ; if(killchance == 0) int deadworkers = Utility.RandomInt(1, 100) honeyhive1.removeItem(workerbee, deadworkers) int deadqueen = Utility.RandomInt(0, 1) honeyhive1.removeItem(queenbee, deadqueen) honeyhive1.removeItem(dronebee, 1) Beedead.Show(deadworkers, deadqueen) elseif(killchance == 2) int deadworkers = Utility.RandomInt(1, 100) honeyhive1.removeItem(workerbee, deadworkers) int deadqueen = Utility.RandomInt(0, 1) honeyhive1.removeItem(queenbee, deadqueen) honeyhive1.removeItem(dronebee, 1) Beedead.Show(deadworkers, deadqueen) elseif(killchance == 1) Beealive.Show() endif ;the basic above section gets a count of the bees in the hive/container then it uses random numbers to decide if some of the bees die or live in in the honey making process and it gives results in a message box honeyhive1.addItem(workerbee, 1100) honeyhive1.addItem(queenbee, 8) honeyhive1.addItem(dronebee, 5) honeyhive1.addItem(BeeHoneyComb, 4) BeeSuccess.Show() ;this is the rewards added to the hive/container once 72 hours pass and death of bees are decided i give back bees probably need to make returns less so its harder to harvest them endif if (honeyhive1.GetItemCount(queenbee) == 1 && honeyhive1.GetItemCount(workerbee) == 1000 && honeyhive1.GetItemCount(dronebee) == 1 && Utility.GetCurrentGameTime() * 24.0 < CheckTime) ;if correct ammount of items are in hive/container but time hasnt been reached.. display a message saying so hivenotready.Show() endif EndEvent It works sorta it gives items but when I click it to start the process it'll do the farm start and tell me to wait longer... is that becauseI'm not using elseif I'm confused on that a little tried changing it to else ifs but has issues there too. Basically it's a container with a activator beside of it when you click activator it checks for those item counts then it'll set a time for 72 hours then if you click it before it's time it should say it's not ready but only if you leave the same ammount of items in it Idea is to keep same items in it at all times once 72 hours is up it'll give items it does but the other thing about it not being time comes up when I start the beehive up I'm guessing itchecks all if conditions and does them at the same time maybe Also need a else statement for if there item counts are anything other than what is set So if you don't have right combo of items it will not do anything it'll make you get right item ammounts Also how would I be able to check to see if only just those items are in there and nothing else like if I set to certain bees in container but nothing else to be in it but them?? This has to be something simple Link to comment Share on other sites More sharing options...
NexusComa Posted September 30, 2016 Share Posted September 30, 2016 (edited) Clearly IsharaMeradin was already working to help you.So, I'll remove my post. You couldn't "bee" in better hands ... Edited September 30, 2016 by NexusComa Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 30, 2016 Share Posted September 30, 2016 Here is your script with some modifications. The item checks since they were duplicated across all time checks were moved to their own 'if' statement. This allows you to use an 'else' to be able to do processing whenever the item amounts are not what you want. Also, the code currently requires that the player re-activate in order to restart the 72 hour process over again. You may wish to advance the CheckTime variable another 72 hours after a successful use. Scriptname BeeHive1 extends ObjectReference Import Utility Ingredient Property queenbee auto Ingredient Property workerbee auto Ingredient Property dronebee auto Ingredient Property BeeHoneyComb auto Message Property Beedead Auto Message Property Beealive Auto Message Property BeeSuccess Auto Message Property BeeFail Auto Message Property beehivestarted Auto Message Property hivenotready Auto ObjectReference Property honeyhive1 auto float CheckTime ; the only status variable needed Event OnActivate(ObjectReference akActionRef) if akActionRef != Game.GetPlayer() ; do not let other NPCs trigger this return endif if honeyhive1.GetItemCount(queenbee) == 1 && honeyhive1.GetItemCount(workerbee) == 1000 && honeyhive1.GetItemCount(dronebee) == 1 If CheckTime == 0.0 CheckTime = 72.0 + Utility.GetCurrentGameTime() * 24.0 beehivestarted.Show() Elseif ((Utility.GetCurrentGameTime() * 24.0) >= CheckTime) CheckTime = 0.0 int killchance = Utility.RandomInt(0, 2) ; if(killchance == 0) int deadworkers = Utility.RandomInt(1, 100) honeyhive1.removeItem(workerbee, deadworkers) int deadqueen = Utility.RandomInt(0, 1) honeyhive1.removeItem(queenbee, deadqueen) honeyhive1.removeItem(dronebee, 1) Beedead.Show(deadworkers, deadqueen) elseif(killchance == 2) int deadworkers = Utility.RandomInt(1, 100) honeyhive1.removeItem(workerbee, deadworkers) int deadqueen = Utility.RandomInt(0, 1) honeyhive1.removeItem(queenbee, deadqueen) honeyhive1.removeItem(dronebee, 1) Beedead.Show(deadworkers, deadqueen) elseif(killchance == 1) Beealive.Show() endif honeyhive1.addItem(workerbee, 1100) honeyhive1.addItem(queenbee, 8) honeyhive1.addItem(dronebee, 5) honeyhive1.addItem(BeeHoneyComb, 4) BeeSuccess.Show() Elseif ((Utility.GetCurrentGameTime() * 24.0) < CheckTime) hivenotready.Show() EndIf Else ;not correct amount of each item ;do whatever here endif EndEvent Link to comment Share on other sites More sharing options...
gerg357 Posted October 1, 2016 Author Share Posted October 1, 2016 Thx for the reply guys Also, the code currently requires that the player re-activate in order to restart the 72 hour process over again. You may wish to advance the CheckTime variable another 72 hours after a successful use. Don't think I understand about advancing.. or what you meant by that Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 1, 2016 Share Posted October 1, 2016 What I meant is...CheckTime is 0.0 by defaultFirst activation sets CheckTime to 72 hours laterActivation after 72 hours has passed sets CheckTime to 0.0 Under that scenario, if player needs/wants to use the device again in another 72 hours they have to activate the device in order to set CheckTime to 72 hours later. If the purpose of the device is to allow the player to do something at least every 72 hours, you may wish to cut out an extra step for the player by setting CheckTime to 72 hours later when they activate after the first 72 hours has passed. Link to comment Share on other sites More sharing options...
gerg357 Posted October 1, 2016 Author Share Posted October 1, 2016 Ohhhhh ok I get ya sorry about that... Yea that does make more sense Link to comment Share on other sites More sharing options...
gerg357 Posted October 3, 2016 Author Share Posted October 3, 2016 Thx for that code I'm getting ready to check it out I had debated using the way you had it but i couldn't get it to work for some reason..Thx again Link to comment Share on other sites More sharing options...
Recommended Posts