Jump to content

Adjusted Dead Money ToxicDamage script not triggering


Recommended Posts

I'm trying to adjust the Dead Money toxic damage script to damage the player's gear and have ini configurable health/rad penalties, but the script isn't working even though it compiles with no issues. Neither part is working, the health damage or the equipment damage.

 

It's my first time really working with floats and such, so I wouldn't be surprised if there were a rookie mistake in here:

scn NVDLC01GlobalToxicDamageSCRIPT
 
float sDmg
float sDmg1
float sDmg2
float sDmg3
float sDmg4
float sDmg5
float sDmg6
float sDmg7
float sDmg8
float sDmg9
float sDmg0
float sHealths
float sHealth1
float sHealth2
float sHealth3
float sHealth4
float sHealth5
float sHealth6
float sHealth7
float sHealth8
float sHealth9
float sHealth0
;(Should one of the preceding float sets be int instead?)
ref sArmorRef
ref sArmorRef1
ref sArmorRef2
ref sArmorRef3
ref sArmorRef4
ref sArmorRef5
ref sArmorRef6
ref sArmorRef7
ref sArmorRef8
ref sArmorRef9
ref sArmorRef0
 
 
BEGIN GameMode
 
set sArmorRef to player.getequippeditemref 0
set sArmorRef1 to player.getequippeditemref 2
set sArmorRef2 to player.getequippeditemref 3
set sArmorRef3 to player.getequippeditemref 4
set sArmorRef4 to player.getequippeditemref 5
set sArmorRef5 to player.getequippeditemref 7
set sArmorRef6 to player.getequippeditemref 8
set sArmorRef7 to player.getequippeditemref 9
set sArmorRef8 to player.getequippeditemref 10
set sArmorRef9 to player.getequippeditemref 11
set sArmorRef0 to player.getequippeditemref 14
 
set sDmg to player.getequippeditemref 0
set sDmg1 to player.getequippeditemref 2
set sDmg2 to player.getequippeditemref 3
set sDmg3 to player.getequippeditemref 4
set sDmg4 to player.getequippeditemref 5
set sDmg5 to player.getequippeditemref 7
set sDmg6 to player.getequippeditemref 8
set sDmg7 to player.getequippeditemref 9
set sDmg8 to player.getequippeditemref 10
set sDmg9 to player.getequippeditemref 11
set sDmg0 to player.getequippeditemref 14
 
;(Will these update when the player changes their equipment?)
 
;If the player is in any interior, or has low health dont do anything.
;Or is Hardcore Off?
if (Player.IsInInterior) || (Player.GetAV Health < 35) || (Player.IsHardcore == 0)
 
return
 
elseif (Player.GetInWorldspace NVDLC01Villa) || (Player.GetInWorldspace NVDLC01VillaChristine) || (Player.GetInWorldspace NVDLC01VillaDean) || (Player.GetInWorldspace NVDLC01WestTownN) || (Player.GetInWorldspace NVDLC01WestTownS) || (Player.GetInWorldspace NVDLC01EastTownN) || (Player.GetInWorldspace NVDLC01EastTownS)
;If the player is in specific DLC01 locations, then apply damage.
 
set sHealths to sArmorRef.GetItemRefCurrentHealth
set sHealths to sHealths * .97
sArmorRef.SetItemRefCurrentHealth sHealths
 
set sHealth1 to sArmorRef1.GetItemRefCurrentHealth
set sHealth1 to sHealth1 * .97
sArmorRef1.SetItemRefCurrentHealth sHealth1
 
set sHealth2 to sArmorRef.GetItemRefCurrentHealth
set sHealth2 to sHealth2 * .97
sArmorRef2.SetItemRefCurrentHealth sHealth2
 
set sHealth3 to sArmorRef.GetItemRefCurrentHealth
set sHealth3 to sHealth3 * .97
sArmorRef3.SetItemRefCurrentHealth sHealth3
 
set sHealth4 to sArmorRef4.GetItemRefCurrentHealth
set sHealth4 to sHealth4 * .97
sArmorRef4.SetItemRefCurrentHealth sHealth4
 
set sHealth5 to sArmorRef.GetItemRefCurrentHealth
set sHealth5 to sHealth5 * .97
sArmorRef5.SetItemRefCurrentHealth sHealth5
 
set sHealth6 to sArmorRef6.GetItemRefCurrentHealth
set sHealth6 to sHealth6 * .97
sArmorRef6.SetItemRefCurrentHealth sHealth6
 
set sHealth7 to sArmorRef.GetItemRefCurrentHealth
set sHealth7 to sHealth7 * .97
sArmorRef7.SetItemRefCurrentHealth sHealth7
 
set sHealth8 to sArmorRef.GetItemRefCurrentHealth
set sHealth8 to sHealth8 * .97
sArmorRef8.SetItemRefCurrentHealth sHealth8
 
set sHealth9 to sArmorRef9.GetItemRefCurrentHealth
set sHealth9 to sHealth9 * .97
sArmorRef9.SetItemRefCurrentHealth sHealth9
 
set sHealth0 to sArmorRef0.GetItemRefCurrentHealth
set sHealth0 to sHealth0 * .94
sArmorRef0.SetItemRefCurrentHealth sHealth0
 
 
if GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini" == 1
if (player.getequipped NVDLC04HelmetBreathingMask == 0)
playerREF.DamageActorValue Health 2
playerREF.DamageActorValue RadiationRads 1
ApplyImageSpaceModifier GetHit
endif
endif
if GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini" == 2
if (player.getequipped NVDLC04HelmetBreathingMask == 0)
playerREF.DamageActorValue Health 1
playerREF.DamageActorValue RadiationRads 1
ApplyImageSpaceModifier GetHit
endif
endif
if GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini" == 3
if (player.getequipped NVDLC04HelmetBreathingMask == 0)
playerREF.DamageActorValue Health 1
ApplyImageSpaceModifier GetHit
endif
endif
if GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini" == 4
if (player.getequipped NVDLC04HelmetBreathingMask == 0)
playerREF.DamageActorValue RadiationRads 1
ApplyImageSpaceModifier GetHit
endif
endif
endif
 
END ;GameMode
Link to comment
Share on other sites

"Floats" deal with the precision of your numbers, as decimal values. "Ints/shorts" (same thing) are whole numbers that don't have fractional values. Behind the scenes everything is stored as floats and then converted to the designated display type of "float" or "int/short", etc..

 

If your script compiles, you need to read the "debugging" entries (TIP Debugging data to file in particular) in the "Scripting" section of the wiki "Getting started creating mods using GECK" article in order to trace where things break down.

 

But first you need to read "TIP Block Types Multiple vs Single Frame processing". You are resetting your variables to their initial values every time the GameBlock processes, which is every frame. Thus you are losing all "progress" every frame. See "TIP Best Practice Sharing Variables between Scripts". (At the least you want to move the initialization lines above the block line.)

 

You also want to look into "TIP Do not overlook EventHandlers".

 

Finally, please indent your code and use the "code tags" inside of "spoiler tags" in the forum when posting, for readability.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

Thanks for the help! Once I lined everything up inside of a single if block and started using the correct functions to actually reference the player's equipped gear, it's all working perfectly! Can't believe I never realized that I was trying to grab armor references with a function that just gets health values.

 

I'll put up the fixed script as an example for anyone looking, but I can't find anywhere describing how to use code tags. Could you point me in the right direction so that I can format it correctly for the forums?

EDIT: Nvm, I just have to replace the /spoiler with /code

Link to comment
Share on other sites



scn NVDLC01GlobalToxicDamageSCRIPT

float sHealths
float sHealth1
float sHealth2
float sHealth3
float sHealth4
float sHealth5
float sHealth6
float sHealth7
float sHealth8
float sHealth9
float sHealth0



BEGIN GameMode


;If the player is in any interior, or has low health dont do anything.
;Or is Hardcore Off?
if (Player.IsInInterior) || (Player.GetAV Health < 35) || (Player.IsHardcore == 0)

return

elseif (Player.GetInWorldspace NVDLC01Villa) || (Player.GetInWorldspace NVDLC01VillaChristine) || (Player.GetInWorldspace NVDLC01VillaDean) || (Player.GetInWorldspace NVDLC01WestTownN) || (Player.GetInWorldspace NVDLC01WestTownS) || (Player.GetInWorldspace NVDLC01EastTownN) || (Player.GetInWorldspace NVDLC01EastTownS)
;If the player is in specific DLC01 locations, then apply damage.
printc "Toxic Script started"

set sHealths to PlayerRef.GetEquippedCurrentHealth 0
set sHealths to sHealths * .98
PlayerRef.SetEqCurHealth sHealths 0

set sHealth1 to PlayerRef.GetEquippedCurrentHealth 2
set sHealth1 to sHealth1 * .98
PlayerRef.SetEqCurHealth sHealth1 2

set sHealth2 to PlayerRef.GetEquippedCurrentHealth 3
set sHealth2 to sHealth2 * .98
PlayerRef.SetEqCurHealth sHealth2 3

set sHealth3 to PlayerRef.GetEquippedCurrentHealth 4
set sHealth3 to sHealth3 * .98
PlayerRef.SetEqCurHealth sHealth3 4

set sHealth4 to PlayerRef.GetEquippedCurrentHealth 5
set sHealth4 to sHealth4 * .98
PlayerRef.SetEqCurHealth sHealth4 5

set sHealth5 to PlayerRef.GetEquippedCurrentHealth 7
set sHealth5 to sHealth5 * .98
PlayerRef.SetEqCurHealth sHealth5 7

set sHealth6 to PlayerRef.GetEquippedCurrentHealth 8
set sHealth6 to sHealth6 * .98
PlayerRef.SetEqCurHealth sHealth6 8

set sHealth7 to PlayerRef.GetEquippedCurrentHealth 9
set sHealth7 to sHealth7 * .98
PlayerRef.SetEqCurHealth sHealth7 9

set sHealth8 to PlayerRef.GetEquippedCurrentHealth 10
set sHealth8 to sHealth8 * .98
PlayerRef.SetEqCurHealth sHealth8 10

set sHealth9 to PlayerRef.GetEquippedCurrentHealth 11
set sHealth9 to sHealth9 * .98
PlayerRef.SetEqCurHealth sHealth9 11

set sHealth0 to PlayerRef.GetEquippedCurrentHealth 14
set sHealth0 to sHealth0 * .96
PlayerRef.SetEqCurHealth sHealth0 14
printc "armor health set"


if (GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini") == 1 && (player.getequipped NVDLC04HelmetBreathingMask) == 0
playerREF.DamageActorValue Health 3
playerREF.DamageActorValue RadiationRads 2
ApplyImageSpaceModifier GetHit
elseif (GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini") == 2 && (player.getequipped NVDLC04HelmetBreathingMask) == 0
playerREF.DamageActorValue Health 2
playerREF.DamageActorValue RadiationRads 2
ApplyImageSpaceModifier GetHit
elseif (GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini") == 3 && (player.getequipped NVDLC04HelmetBreathingMask) == 0
playerREF.DamageActorValue Health 2
ApplyImageSpaceModifier GetHit
elseif (GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini") == 4 && (player.getequipped NVDLC04HelmetBreathingMask) == 0
playerREF.DamageActorValue RadiationRads 2
ApplyImageSpaceModifier GetHit
endif
endif
printc "health damage done"

END ;

Link to comment
Share on other sites

Glad to hear you got it worked out.

 

Please see "How to markup images (etc) in forum posts and comments" article for how to use "Spoiler tags", etc.. You can "nest" "code tags" within "spoiler tags", e.g. '<spoiler><code> <some code> </code></spoiler>'. The code tags will preserve the indentation spacing, which the spoiler tags won't otherwise.

 

FYI: Because the GECK parses the entire line of a conditional test before it determines the results of the various tests themselves, it is preferable and more efficient to assign the returns from function calls like 'GetINIFloat "CustomSettings:sCloudHardcorePenalty"' to a variable and test against that variable. Please see the "TIP Basic conditional test syntax" and "TIP Debugging Compound Conditionals" entries.

 

-Dubious-

Link to comment
Share on other sites

Please take a look at this. Your script is really inefficient as it is: I just realized (after typing all the stuff below) that you are modifying an existing script of an existing quest that is currently running every 20 seconds. If you don't want to change the logic I am suggesting here, you don't have to.

 

Firstly: Add quest conditions to the quest that prevents it from running at all when the player is not in one of the Dead Money worldspace. It's more efficient than doing it in the script.

Condition Function - GetInWorldSpace
Function Parameters - Select the NVDLC01 world space here and set the rest to == 1.0 and check the Or checkbox
Run on - Reference
Select - Go the second dropdown list and find the PlayerRef reference

 

MEGA EDIT! Change script to show how you can insert your code into the existing script.

scn NVDLC01GlobalToxicDamageSCRIPT

;This script contains the basic functionality for Global Toxic Damage while in DLC01.
;The player periodically takes a minor amount of damage from being outside in the Villa with the cloud that covers the city.
;These are the following locations that the player takes damage:
;NVDLC01Villa
;NVDLC01VillaChristine
;NVDLC01VillaDean
;NVDLC01WestTownN
;NVDLC01WestTownS
;NVDLC01EastTownN
;NVDLC01EastTownS
;CES 9/24/10

float fItemHealth
int iItemSlot

; ini stuff
int iCloudHardcorePenalty

BEGIN GameMode

;==============================================================================================================================
; Only do thgis once at startup.  Reading stuff from files is a very expensive operation for a script that has a GameMode
if GetGameLOaded || GetGameRestarted
   set iCloudHardcorePenalty to GetINIFloat "CustomSettings:sCloudHardcorePenalty" "DMT Config.ini"
    ; Make sure the user installed the ini correctly and set its one setting to an appropriate value
    if (iCloudHardcorePenalty < 1 || iCloudHardcorePenalty > 4
      ShowMeessage MyMessageBadINIFile  ; example text "The INI file for 'my mod name' is either not installed correctly or has a bad value for sCloudHardcorePenalty"
    endif
endif
​;==============================================================================================================================

;If the player is in any interior, or has low health don't do anything.
;Or is Hardcore Off?
if (Player.IsInInterior) || (Player.GetAV Health < 10) || (Player.IsHardcore == 0)

  return

elseif (Player.GetInWorldspace NVDLC01Villa) || (Player.GetInWorldspace NVDLC01VillaChristine) || (Player.GetInWorldspace NVDLC01VillaDean) || (Player.GetInWorldspace NVDLC01WestTownN) || (Player.GetInWorldspace NVDLC01WestTownS) || (Player.GetInWorldspace NVDLC01EastTownN) || (Player.GetInWorldspace NVDLC01EastTownS)
  ;If the player is in specific DLC01 locations, then apply damage.
​;==============================================================================================================================

  ; REMOVED PlayerREF.DamageActorValue Health 3
  ; REMOVED ApplyImageSpaceModifier GetHit

  printc "Toxic Script started"
  set iItemSlot to 0
  while (iItemSlot <= 14)
    set fItemHealth to PlayerRef.GetEquippedCurrentHealth iItemSlot
    ;====================================================================
    ; What happens if no item is equipped in that slot?  Does it error out or return 0?  I am guess it returns 0
    ;====================================================================
     if (fItemHealth > 0.001)
      set fItemHealth to fItemHealth * 0.98
      PlayerRef.SetEqCurHealth sHealths iItemSlot
    endif
    set iItemSlot to iItemSlot + 1
  loop

  printc "armor health set"

  if (player.getequipped NVDLC04HelmetBreathingMask) == 1
     printc "health damage NOT done. Player wearing mask."
     return
  endif

  if iCloudHardcorePenalty < 1 || iCloudHardcorePenalty > 4  ; player hasn't fixed the problem with the INI file inspite of the message on game-load or entered a wrong number
     return
  endif

  if (iCloudHardcorePenalty == 1)
     playerREF.DamageActorValue Health 3
     playerREF.DamageActorValue RadiationRads 2
  elseif (iCloudHardcorePenalty == 2)
     playerREF.DamageActorValue Health 2
     playerREF.DamageActorValue RadiationRads 2
  elseif (iCloudHardcorePenalty == 3)
     playerREF.DamageActorValue Health 2
    elseif (iCloudHardcorePenalty == 4)
     playerREF.DamageActorValue RadiationRads 2
    endif
  ApplyImageSpaceModifier GetHit

  printc "health damage done"
;==============================================================================================================================

endif

END ;GameMode
Edited by GamerRick
Link to comment
Share on other sites

Thanks GamerRick, that's some really helpful stuff, I appreciate you sharing it. I'll probably get around to converting those changes into AGE eventually too, I'm pretty sure the ini call was what makes performance so terrible when Rez-ing out is turned off.

Link to comment
Share on other sites

Glad to help. I just learned how to do an MCM menu. If you want that instead of or in addition to the INI file, let me know. I can easily edit my script to work for your purposes.

 

Let me know and I will show you how to create a new quest for it and create a new quest script to do it. You must have NVSE and JIP installed for it. You don't actually have to install the MCM menu or make your mod dependent on it to do this. It is all handled in the script.

Edited by GamerRick
Link to comment
Share on other sites

  • Recently Browsing   0 members

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