Jump to content

Scripting Event Help


senterpat

Recommended Posts

So I'm trying to make overdoses for chem, but none of the scripting commands I used for the features exist as they did in NV, I've gone over the list of events am not really sure what to use in order to get it to run how I would like. Basically the way I'm trying to do it:

Add a MGEF that gives an Armor token to the player when a potion is consumed.(Which I don't need help with)

Use a quest to track how many armor tokens have been added, and remove them as time passes(1 token per game hour). (I can figure the majority of the script, I'm just not sure what events to use that are the equivalent of GameMode for FNV)

 

I'm not totally sure this is the most efficient way to accomplish this, it's just how I got it running in FNV.

 

Thanks in advance for your help :D

 

Link to comment
Share on other sites

So I found a GameMode event on this website: http://mod.gib.me/fallout4/functions.html#events but there is no documentation for how to use it. And I cannot find it on the CK website.

 

I've also switched from armor token items to a custom actor value, I think it will be easier to handle in the scripts this way.

 

I made this quick script to try and figure out if the event is triggering in game:

Scriptname patOverdoseQuestScript extends Quest 

;---------------------------------------------------------------------------------------------------------------------------------------------------
;Properties
;---------------------------------------------------------------------------------------------------------------------------------------------------
ActorValue Property patOverdoseAV Auto
;---------------------------------------------------------------------------------------------------------------------------------------------------
;Variables
;---------------------------------------------------------------------------------------------------------------------------------------------------

Actor PlayerREF

;----------------------------------------------------------------------------------------------------------------------------------------------------
;Events
;----------------------------------------------------------------------------------------------------------------------------------------------------

Event GameMode()
	PlayerREF = Game.GetPlayer()
	int ODCount = PlayerREF.GetValue(patOverdoseAV) as int
	If (ODCount >= 0)
		Debug.Trace("Test.")
	EndIf
EndEvent

	


 

which prints out this error: new event gamemode cannot be defined because the script is not flagged as native

I tried placing Native after extends quest, but that printed out even more errors.

Edited by senterpat
Link to comment
Share on other sites

It means the event is not coded into the game engine, - not a valid event. Perhaps it once was during development. Or a possible carry over from Oblivion, since the CK is basically family of the past 3 games meshed together. Some functions/forms still present but are no longer used.

Link to comment
Share on other sites

Ah, thank you for the response. I gave up on it awhile ago and started testing with some other functions. I have everything working pretty much, except I cannot get it to kill the player. I've attached it to a player alias, and ended up adding back in the armor tokens in order to trigger the OnItemAdded event.

Scriptname patODTrackerScript extends ReferenceAlias 

;-----------------------------------------------------------
;Properties
;-----------------------------------------------------------

Armor Property patTokenChemOverdose Auto  
Message Property patModActive Auto 
FormList Property patOverdoseList Auto 
ActorValue Property patOverDoseChemAV Auto
ActorValue Property HealthAV Auto
;------------------------------------------------------------
;Variables
;------------------------------------------------------------

int ODTimer = 10
;------------------------------------------------------------
;Events
;------------------------------------------------------------

Event OnInit()
    addInventoryEventFilter(patOverdoseList)
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	If akBaseItem == patTokenChemOverdose
		int ODCount = Game.GetPlayer().GetValue(patOverdoseChemAV) as int
		If (ODCount < 1)	
			Game.GetPlayer().DamageValue(HealthAV, 10000)
		else
			StartTimerGameTime(0.2,10)
			Game.GetPlayer().RemoveItem(patTokenChemOverdose, 1, True)
		endif
	Endif
Endevent

Event OnTimerGameTime(int aiTimerID)
	If aiTimerID == ODTimer
		Game.GetPlayer().ModValue(patOverDoseChemAV, 1)
			StartTimerGameTime(0.2,10)		
	endif
EndEvent

Everything else is working as expected, except the player wont die.

 

edit: I also tried Game.GetPlayer().Kill, but that returned errors

Edited by senterpat
Link to comment
Share on other sites

You forgot to add the parenthesis I think. Should be Game.GetPlayer().Kill()

 

Another way to kill the player is:

ActorValue property HealthAV auto
 
Actor player = Game.GetPlayer()
player.DamageValue(HealthAV, player.GetValue(HealthAV))

Untested, but in theory, this will kill the player by damaging the player's health via the current health value.

Edited by Rasikko
Link to comment
Share on other sites

Ill test that when I get home. I think youâre right and I forgot to add the ().

 

On the second on tho I think youâd have to assign an INT, I donât think the system will let you pass the player.getvalue(healthav) directly there.

Edited by senterpat
Link to comment
Share on other sites

Yep, the kill() command compiled that time, thank you.
The command still isnât registering when the AV hits 0 tho, gonna play with it a bit and see if I can work it out.

 

Edit: Got it working, just had to assign the AV variables as floats instead of integers. Since they were assigned to do 1 AV damage over 1 second, when I used them too fast they would return a value like .15.

 

Thanks for your help again Rassiko

Edited by senterpat
Link to comment
Share on other sites

  On 10/30/2018 at 7:45 PM, senterpat said:

Ill test that when I get home. I think youâre right and I forgot to add the ().

 

On the second on tho I think youâd have to assign an INT, I donât think the system will let you pass the player.getvalue(healthav) directly there.

The parameters for DamageValue expects a float, and getvalue returns a float value.

 

Glad it worked out for you. Good luck.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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