Jump to content

A little script bug... I think!


Vortaka

Recommended Posts

Hi all! I've just started playing FO3 again and I need some help for a mod I've written... (Never posted it since it never worked properly). But I'm tired of searching for something that I can't find!

 

The mod is simple, it gives 1/3 XP when my followers (Jessi and Kelsey) kill a monster. After a lot of tests, I can almost be sure that it's because of one script (if I remove it, everything works fine). The script itself is simple and that's why I don't understand why my game crashes...

 

First, the problem. When I enter specific areas, the two that comes to mind are Rivet City Science Lab and the Jefferson Memorial Rotunda, the game simply crashes (and if I remove the mod, pass the door, reload the mod, it works good). (P.S. The sample script is from Enclave Commander (taken from Robco mod)). Here's the script!

 

scn KillerTokenScript

 

ref rContainer

short level

short xpgain

 

Begin OnAdd

set rContainer to GetContainer

if (rContainer.IsKiller JessiREF || rContainer.IsKiller LoxKelseyREF)

set level to rContainer.getlevel

if(rContainer.GetIsCreature)

if(level >= getGS iXPLevelKillCreatureVeryHard )

set xpgain to getGS iXPRewardKillOpponentVeryHard

elseif(level >= getGS iXPLevelKillCreatureHard )

set xpgain to getGS iXPRewardKillOpponentHard

elseif(level >= getGS iXPLevelKillCreatureAverage )

set xpgain to getGS iXPRewardKillOpponentAverage

elseif(level >= getGS iXPLevelKillCreatureEasy )

set xpgain to getGS iXPRewardKillOpponentEasy

else

set xpgain to getGS iXPRewardKillOpponentVeryEasy

endif

else

if(level >= getGS iXPLevelKillNPCVeryHard )

set xpgain to getGS iXPRewardKillOpponentVeryHard

elseif(level >= getGS iXPLevelKillNPCHard )

set xpgain to getGS iXPRewardKillOpponentHard

elseif(level >= getGS iXPLevelKillNPCAverage )

set xpgain to getGS iXPRewardKillOpponentAverage

elseif(level >= getGS iXPLevelKillNPCEasy )

set xpgain to getGS iXPRewardKillOpponentEasy

else

set xpgain to getGS iXPRewardKillOpponentVeryEasy

endif

endif

set xpgain to xpgain /3

if (xpgain <= 1)

set xpgain to 1

RewardXP xpgain

else

RewardXP xpgain

endif

endif

End

 

Easy? It just checks if rContainer (linked to the token (that I give to people that are dead)) was killed by Jessi or Kelsey and gives that appropriate reward... Did I do something wrong?

 

Thanks for any tip!

 

Vortaka

Link to comment
Share on other sites

Hi all! I've just started playing FO3 again and I need some help for a mod I've written... (Never posted it since it never worked properly). But I'm tired of searching for something that I can't find!

 

The mod is simple, it gives 1/3 XP when my followers (Jessi and Kelsey) kill a monster. After a lot of tests, I can almost be sure that it's because of one script (if I remove it, everything works fine). The script itself is simple and that's why I don't understand why my game crashes...

 

First, the problem. When I enter specific areas, the two that comes to mind are Rivet City Science Lab and the Jefferson Memorial Rotunda, the game simply crashes (and if I remove the mod, pass the door, reload the mod, it works good). (P.S. The sample script is from Enclave Commander (taken from Robco mod)). Here's the script!

 

scn KillerTokenScript

 

ref rContainer

short level

short xpgain

 

Begin OnAdd

set rContainer to GetContainer

if (rContainer.IsKiller JessiREF || rContainer.IsKiller LoxKelseyREF)

set level to rContainer.getlevel

if(rContainer.GetIsCreature)

if(level >= getGS iXPLevelKillCreatureVeryHard )

set xpgain to getGS iXPRewardKillOpponentVeryHard

elseif(level >= getGS iXPLevelKillCreatureHard )

set xpgain to getGS iXPRewardKillOpponentHard

elseif(level >= getGS iXPLevelKillCreatureAverage )

set xpgain to getGS iXPRewardKillOpponentAverage

elseif(level >= getGS iXPLevelKillCreatureEasy )

set xpgain to getGS iXPRewardKillOpponentEasy

else

set xpgain to getGS iXPRewardKillOpponentVeryEasy

endif

else

if(level >= getGS iXPLevelKillNPCVeryHard )

set xpgain to getGS iXPRewardKillOpponentVeryHard

elseif(level >= getGS iXPLevelKillNPCHard )

set xpgain to getGS iXPRewardKillOpponentHard

elseif(level >= getGS iXPLevelKillNPCAverage )

set xpgain to getGS iXPRewardKillOpponentAverage

elseif(level >= getGS iXPLevelKillNPCEasy )

set xpgain to getGS iXPRewardKillOpponentEasy

else

set xpgain to getGS iXPRewardKillOpponentVeryEasy

endif

endif

set xpgain to xpgain /3

if (xpgain <= 1)

set xpgain to 1

RewardXP xpgain

else

RewardXP xpgain

endif

endif

End

 

Easy? It just checks if rContainer (linked to the token (that I give to people that are dead)) was killed by Jessi or Kelsey and gives that appropriate reward... Did I do something wrong?

 

Thanks for any tip!

 

Vortaka

 

I would add some NULL checking to make sure rContainer has a value before running functions against it. I would also remove the token after you are done with it to get rid of the script running. I think you have an extra 'endif' at the end also.

 

scn KillerTokenScript

ref rContainer
short level
short xpgain

Begin OnAdd

set rContainer to GetContainer

if(rContainer)
if (rContainer.IsKiller JessiREF || rContainer.IsKiller LoxKelseyREF)

set level to rContainer.getlevel

if(rContainer.GetIsCreature)

	if(level >= getGS iXPLevelKillCreatureVeryHard )
		set xpgain to getGS iXPRewardKillOpponentVeryHard
	elseif(level >= getGS iXPLevelKillCreatureHard )
		set xpgain to getGS iXPRewardKillOpponentHard
	elseif(level >= getGS iXPLevelKillCreatureAverage )
		set xpgain to getGS iXPRewardKillOpponentAverage
	elseif(level >= getGS iXPLevelKillCreatureEasy )
		set xpgain to getGS iXPRewardKillOpponentEasy
	else
		set xpgain to getGS iXPRewardKillOpponentVeryEasy
	endif
else
	if(level >= getGS iXPLevelKillNPCVeryHard )
		set xpgain to getGS iXPRewardKillOpponentVeryHard
	elseif(level >= getGS iXPLevelKillNPCHard )
		set xpgain to getGS iXPRewardKillOpponentHard
	elseif(level >= getGS iXPLevelKillNPCAverage )
		set xpgain to getGS iXPRewardKillOpponentAverage
	elseif(level >= getGS iXPLevelKillNPCEasy )
		set xpgain to getGS iXPRewardKillOpponentEasy
	else
		set xpgain to getGS iXPRewardKillOpponentVeryEasy
	endif
endif

set xpgain to xpgain /3

if (xpgain <= 1)
set xpgain to 1
RewardXP xpgain
else
RewardXP xpgain
endif

rContainer.removeItem Whateveryourtokennameis 1
return

endif

End

Link to comment
Share on other sites

Thanks for the code (scripting is not my best subject!). I'll still need sometime to test it but it seems to work ok...

 

That, except the "remove" part... See, my script works with an invisible explosion that looks if the "target" has the token... If I remove it, without removing the target, it doesn't stop counting! (Very nice for XP; but too much leveling up! :)

 

The only thing I don't really get is the return at the end... I do not understand why it's there! I mean, is it that important? (I fell dumb, but I don't understand it never the less!)

 

Thanks for the tip, really cool!

 

Vortaka

Link to comment
Share on other sites

Thanks for the code (scripting is not my best subject!). I'll still need sometime to test it but it seems to work ok...

 

That, except the "remove" part... See, my script works with an invisible explosion that looks if the "target" has the token... If I remove it, without removing the target, it doesn't stop counting! (Very nice for XP; but too much leveling up! :)

 

The only thing I don't really get is the return at the end... I do not understand why it's there! I mean, is it that important? (I fell dumb, but I don't understand it never the less!)

 

Thanks for the tip, really cool!

 

Vortaka

 

I always put a return when removing a token - it makes sure the script stops. I've had it crash before when I didn't. But if you aren't removing the token, you don't need a return

Link to comment
Share on other sites

  • Recently Browsing   0 members

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