Jump to content

[LE] Random hunt script issues


gerg357

Recommended Posts

Scriptname HuntEvent2 extends ObjectReference

 

Import Utility

GlobalVariable property GameHour auto

Message Property huntmenu Auto

Message Property toolate2hunt Auto

Message Property foodhunt Auto

Message Property hawkhunt Auto

Message Property noarrows Auto

Message Property goldfound Auto

Message Property goodhunt Auto

MiscObject Property Gold001 auto

Message Property potionfound Auto

ImageSpaceModifier Property FadeToBlackImod Auto

ImageSpaceModifier Property FadeToBlackHoldImod Auto

ImageSpaceModifier Property FadeToBlackBackImod Auto

Potion Property FoodPheasant auto

Ammo Property IronArrow auto

Ingredient Property HawkBeak auto

Ingredient Property HawkFeathers auto

Potion Property RestoreHealth02 auto

 

Event OnActivate(ObjectReference akActionRef)

if akActionRef != Game.GetPlayer() ; do not let other NPCs trigger this

return

endif

 

 

 

 

Float starthunt = 8.0

Float endhunt = 16.0

Float HT = GameHour.GetValue()

if (Game.GetPlayer().GetItemCount(IronArrow) >= 20)

if(HT >= starthunt)

Int ihuntOption = huntmenu.Show()

If (ihuntOption == 0)

Game.FadeOutGame(true, true, 0.5, 8)

FadeToBlackImod.Apply()

utility.wait(2)

GameHour.Mod(4.0)

FadeToBlackImod.PopTo(FadeToBlackHoldImod)

utility.wait(2)

int huntchance = Utility.RandomInt(1, 11) ;

int countfood;

int countarrow;

if(huntchance == 1)

Game.GetPlayer().AddItem(FoodPheasant, 1)

Game.GetPlayer().RemoveItem(IronArrow, 3)

countfood = 1

countarrow = 3

foodhunt.Show(countfood,countarrow)

 

elseif(huntchance == 2)

Game.GetPlayer().AddItem(FoodPheasant, 2)

Game.GetPlayer().RemoveItem(IronArrow, 3)

countfood = 2

countarrow = 3

foodhunt.Show(countfood,countarrow)

 

elseif(huntchance == 3)

Game.GetPlayer().AddItem(FoodPheasant, 3)

Game.GetPlayer().RemoveItem(IronArrow, 6)

countfood = 2

countarrow = 6

foodhunt.Show(countfood,countarrow)

elseif(huntchance == 4)

Game.GetPlayer().AddItem(FoodPheasant, 2)

Game.GetPlayer().RemoveItem(IronArrow, 6)

countfood = 2

countarrow = 6

foodhunt.Show(countfood,countarrow)

elseif(huntchance == 5)

Game.GetPlayer().AddItem(FoodPheasant, 4)

Game.GetPlayer().RemoveItem(IronArrow, 8)

countfood = 4

countarrow = 8

foodhunt.Show(countfood,countarrow)

elseif(huntchance == 6)

Game.GetPlayer().AddItem(FoodPheasant, 2)

Game.GetPlayer().RemoveItem(IronArrow, 2)

countfood = 2

countarrow = 2

foodhunt.Show(countfood,countarrow)

 

elseif(huntchance == 7)

Game.GetPlayer().AddItem(HawkBeak, 2)

Game.GetPlayer().AddItem(HawkFeathers, 2)

Game.GetPlayer().RemoveItem(IronArrow, 8)

countfood = 2

countarrow = 8

hawkhunt.Show(countfood,countarrow)

 

elseif(huntchance == 8)

Game.GetPlayer().AddItem(HawkBeak, 1)

Game.GetPlayer().AddItem(HawkFeathers, 1)

Game.GetPlayer().RemoveItem(IronArrow, 4)

countfood = 1

countarrow = 4

hawkhunt.Show(countfood,countarrow)

 

elseif(huntchance == 9)

int goldchance = Utility.RandomInt(5, 75)

Game.GetPlayer().removeItem(Gold001, goldchance)

goldfound.Show(goldchance)

 

elseif(huntchance == 10)

int goldchance = Utility.RandomInt(75, 150)

Game.GetPlayer().AddItem(RestoreHealth02, 1)

Game.GetPlayer().removeItem(Gold001, goldchance)

Game.GetPlayer().AddItem(HawkBeak, 1)

Game.GetPlayer().AddItem(HawkFeathers, 1)

Game.GetPlayer().AddItem(FoodPheasant, 1)

 

countfood = 1

goodhunt.Show(goldchance,countfood)

 

elseif(huntchance == 11)

int potionchance = Utility.RandomInt(1, 3)

Game.GetPlayer().AddItem(RestoreHealth02, potionchance)

potionfound.Show(potionchance)

 

endif

FadeToBlackHoldImod.PopTo(FadeToBlackBackImod)

FadeToBlackHoldImod.Remove()

;Game.FadeOutGame(False, true, 1, 2)

endIf

If (ihuntOption == 1)

EndIf

elseif(HT <= endhunt)

toolate2hunt.Show()

endif

else

noarrows.Show()

endIf

EndEvent

 

 

My message box sometimes comes up twice or gets stuck.. and time issue I'm trying to make activator be active from 8 to 4 in game hour.

Link to comment
Share on other sites

if((HT >= starthunt) && (HT<endhunt))

might you want this?

 

also think about how time works. Lets say you can hunt between 8-6. This is in military format so 6 is really 18.00. You get to 24 at midnight, but then 1 am is actually later than 24...

 

Here. Let me show you what I mean. This is from dawnfang/duskfang. At 6 pm the blade turns into night fang. At 6 am it turns into dawnfang. 3 conditionals are necessary:

 

 

	float TimeofDay=GameHour.GetValue() ;thanks to tonycubed2 for this
	;daytime flag & time until update 	
	if (TimeofDay>=6.0 && TimeofDay<18.0)
		DayTime=1
		TimeUntilUpdate=18.0-TimeofDay
	elseif (TimeofDay>=18.0 && TimeofDay<=24.0)
		DayTime=0
		TimeUntilUpdate=30.0-TimeofDay ;shoutout to SarthesArai for spotting a bug with my maths
	elseif (TimeofDay<6.0)
		DayTime=0
		TimeUntilUpdate=6.0-TimeofDay
	endif

just something to keep in mind. Not sure what you are trying to do.

 

Link to comment
Share on other sites

Activator that you click it asks to hunt it will fade out screen advance time 4 hours then pop up the results my time I think isn't working but looks right with numbers 8am is 8 and 4pm is 16 if it's clicked any time before 8 am or after 4 pm it should say you cant to that..seems like the first message box is glitching maybe I need to adjust the wait time ibdunno but it will let me click it twice on yea to hunt and it's doubling my results
Link to comment
Share on other sites

Try this ... ( untested, will compile )

 

 

 

 

Scriptname HuntEvent2 extends ObjectReference

Import Utility
GlobalVariable property GameHour auto
Message Property huntmenu Auto
Message Property toolate2hunt Auto
Message Property foodhunt Auto
Message Property hawkhunt Auto
Message Property noarrows Auto
Message Property goldfound Auto
Message Property goodhunt Auto
MiscObject Property Gold001 auto
Message Property potionfound Auto
ImageSpaceModifier Property FadeToBlackImod Auto
ImageSpaceModifier Property FadeToBlackHoldImod Auto
ImageSpaceModifier Property FadeToBlackBackImod Auto
Potion Property FoodPheasant auto
Ammo Property IronArrow auto
Ingredient Property HawkBeak auto
Ingredient Property HawkFeathers auto
Potion Property RestoreHealth02 auto
Float starthunt = 8.0
Float endhunt = 16.0
Int hunting = 0

 

Event OnInit()
GoToState("Done")
EndEvent

Event OnActivate(ObjectReference akActionRef)
if akActionRef != Game.GetPlayer() ; do not let other NPCs trigger this
return
endif
Float HT = GameHour.GetValue()
if (Game.GetPlayer().GetItemCount(IronArrow) >= 20)
if (HT >= starthunt)
if (hunting == 0)
hunting = 1
Int ihuntOption = huntmenu.Show()
If (ihuntOption == 0)
Game.FadeOutGame(true, true, 0.5, :cool:
FadeToBlackImod.Apply()
utility.wait(2)
GameHour.Mod(4.0)
FadeToBlackImod.PopTo(FadeToBlackHoldImod)
utility.wait(2)
int huntchance = Utility.RandomInt(1, 11) ;
int countfood
int countarrow
if(huntchance == 1)
Game.GetPlayer().AddItem(FoodPheasant, 1)
Game.GetPlayer().RemoveItem(IronArrow, 3)
countfood = 1
countarrow = 3
foodhunt.Show(countfood,countarrow)
elseif(huntchance == 2)
Game.GetPlayer().AddItem(FoodPheasant, 2)
Game.GetPlayer().RemoveItem(IronArrow, 3)
countfood = 2
countarrow = 3
foodhunt.Show(countfood,countarrow)
elseif(huntchance == 3)
Game.GetPlayer().AddItem(FoodPheasant, 3)
Game.GetPlayer().RemoveItem(IronArrow, 6)
countfood = 2
countarrow = 6
foodhunt.Show(countfood,countarrow)
elseif(huntchance == 4)
Game.GetPlayer().AddItem(FoodPheasant, 2)
Game.GetPlayer().RemoveItem(IronArrow, 6)
countfood = 2
countarrow = 6
foodhunt.Show(countfood,countarrow)
elseif(huntchance == 5)
Game.GetPlayer().AddItem(FoodPheasant, 4)
Game.GetPlayer().RemoveItem(IronArrow, :cool:
countfood = 4
countarrow = 8
foodhunt.Show(countfood,countarrow)
elseif(huntchance == 6)
Game.GetPlayer().AddItem(FoodPheasant, 2)
Game.GetPlayer().RemoveItem(IronArrow, 2)
countfood = 2
countarrow = 2
foodhunt.Show(countfood,countarrow)
elseif(huntchance == 7)
Game.GetPlayer().AddItem(HawkBeak, 2)
Game.GetPlayer().AddItem(HawkFeathers, 2)
Game.GetPlayer().RemoveItem(IronArrow, :cool:
countfood = 2
countarrow = 8
hawkhunt.Show(countfood,countarrow)
elseif(huntchance == :cool:
Game.GetPlayer().AddItem(HawkBeak, 1)
Game.GetPlayer().AddItem(HawkFeathers, 1)
Game.GetPlayer().RemoveItem(IronArrow, 4)
countfood = 1
countarrow = 4
hawkhunt.Show(countfood,countarrow)
elseif(huntchance == 9)
int goldchance = Utility.RandomInt(5, 75)
Game.GetPlayer().removeItem(Gold001, goldchance)
goldfound.Show(goldchance)
elseif(huntchance == 10)
int goldchance = Utility.RandomInt(75, 150)
Game.GetPlayer().AddItem(RestoreHealth02, 1)
Game.GetPlayer().removeItem(Gold001, goldchance)
Game.GetPlayer().AddItem(HawkBeak, 1)
Game.GetPlayer().AddItem(HawkFeathers, 1)
Game.GetPlayer().AddItem(FoodPheasant, 1)
countfood = 1
goodhunt.Show(goldchance,countfood)
elseif(huntchance == 11)
int potionchance = Utility.RandomInt(1, 3)
Game.GetPlayer().AddItem(RestoreHealth02, potionchance)
potionfound.Show(potionchance)
endif
FadeToBlackHoldImod.PopTo(FadeToBlackBackImod)
FadeToBlackHoldImod.Remove()
;Game.FadeOutGame(False, true, 1, 2)
hunting = 0
endIf
endif
elseif(HT <= endhunt)
toolate2hunt.Show()
endif
else
noarrows.Show()
endIf
EndEvent

State Done
;do nothing
EndState

 

 

 

 

Also: you called Import Utility

Then still used the long form.

 

Removed:

 

If (ihuntOption == 1)

EndIf

 

Towards the end of the script.

Not sure why that was there.

Edited by NexusComa
Link to comment
Share on other sites

Sorry I hadn't tried yet I took mine removed the fades and waits and added a and statement that says if time is greater than 8 and less than 4pm then changed the bottom elseif to a else statement it works I just like the fade so it would fade out the screen change time do what it had to do then fade back in

 

I'll check out the script too

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...