Jump to content

short script with a really confusing bug


angelwraith

Recommended Posts

I was refering to this:

 

set rCombatTarget to GetCombatTarget
If (GetDistance rCombatTarget > 100 )

 

Most of the time rCombatTarget will be null as the script is run every frame. You will be running GetDistance on a null reference at those times. You should guard against doing that. With NVSE functions, you can cause a CTD that way. Other times, a script will just silently halt. It's just a good idea to avoid it.

Link to comment
Share on other sites

I was refering to this:

 

set rCombatTarget to GetCombatTarget
If (GetDistance rCombatTarget > 100 )

 

Most of the time rCombatTarget will be null as the script is run every frame. You will be running GetDistance on a null reference at those times. You should guard against doing that. With NVSE functions, you can cause a CTD that way. Other times, a script will just silently halt. It's just a good idea to avoid it.

 

i did...:

 if GetCombatTarget
 set rCombatTarget to GetCombatTarget
endif

 

i realized this before i posted the script, however, even with rCombatTarget conditionalized enabling the commented out section still made it not work.

 

 

although i guess i needed to conditionalize the getdistance function as well as this only prevents the ref from being set to 0.. not from being called at 0

 

 

 

 

but hey i got it to work anyway!!!

how:

i made a seperate script that simply kills the creature and then have it being applied as its unarmed attack effect.. then im using a forced melee AI package..

so instead of detonating based on distance, it detonates as its melee attack, and always gets in for that melee attack so its now working exactly as planned.

Edited by angelwraith
Link to comment
Share on other sites

  • Recently Browsing   0 members

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