ModCurrentHealth doesn't work in script

Post » Fri Oct 16, 2009 9:00 pm

Hi guys,

Yes. I'm a script noob. But I really wanted something in the game that no one else made. Unfortunately, one obscure error is preventing me from enjoying the game the way I want to.

"Specs"

Morrowind with Bloodmoon 1.0.6.1820
MGE 3.8
MCP 1.6
MWSE 0.9.4.0

Mods:
Better Heads
More Classes
Passive Healthy Wildlife
Carry Your Bed Roll
Atmospheric Sound Effects
Magicka Regen v20
Dodge v21
Better Bodies
Aragorn Monk
Slof's Better Beasts
Quick Char
Wolvens 3.0
New Khajit Diversity
No Non-diseased annoyances
No Non-blighted annoyances
Westly Presents Half Races of Tamirel
AAG Status Bars no-home
Wolf Companion

Now onto the script:

Begin 1a_healringshort OnPCEquipif ( MenuMode == 1 )	returnendifif ( OnPCEquip == 0 )    returnendifif ( OnPCEquip == 1)    Set OnPCEquip to 0    StartScript 1a_healring2endifEndBegin 1a_healring2    if ( player->GetFatigue < 50 )    MessageBox "You don't have enough fatigue to heal Moro!!"    StopScript 1a_healring2     endif		if ( player->GetFatigue >= 50 )		1A_comp_wolfSpot->ModCurrentHealth 50    		player->ModCurrentFatigue -50                StopScript 1a_healring2    		endifEnd


Ok, this is two scripts in one box. But, whatever. The error is that ModCurrentHealth just does not work. I've done a lot of troubleshooting, and here are the results, so you do not have to waste time asking questions:

Does the script even run? Uh huh. It takes my fatigue. And just once when I equip the ring.

Did you get the creature's ID right? Yep! I literally copied and pasted it from the creature edit window.

Commas? It makes no difference.

Why the stop scripts? Otherwise it will loop.

Do the commands work in the console? They absolutely do.

What are you using to monitor the health? At-A-Glance Companion Status Bar. It's not wrong, for I use GetHealth as well, and the image is reasonably close to the output.

Did you try using the creature's eight digit number? Yup. But it gave me a compile error.

Are there more than one of this creature? Not anymore.

You tried debugging the script? Oh please tell me if there are any debuggers out there.

Did you try using a new copy of that ring? Sure did, using the command console.

You did restart the game, didn't you? Yes probably about 50 times on this night alone.


O wise ones, please help me solve this dilemma. *orz*
User avatar
michael danso
 
Posts: 3492
Joined: Wed Jun 13, 2007 9:21 am

Post » Sat Oct 17, 2009 4:54 am

Are there more than one of this creature? Not anymore.
Not anymore where? In your .esp or in your .ess (saved game)? If in doubt, test your mod from a fresh new game so you are sure there are no other instances of the creature coming from the previous save.

MWEdit has a handy syntax checker, but no debugger, sorry.
You could try verifying single statements are working as expected using messageboxes, for instance
Begin a1a_healring2if ( player->GetFatigue < 50 )	MessageBox "You don't have enough fatigue to heal Moro!!"else	float temp	set temp to 1A_comp_wolfSpot->GetHealth	if ( temp >= 1 )		messagebox "A) Health = %f" temp	endif	set temp to "1A_comp_wolfSpot"->GetHealth	if ( temp >= 1 )		messagebox "B) Health = %f" temp	endif	set temp to "1A_comp_wolfSpot"->GetHealth	"1A_comp_wolfSpot"->ModCurrentHealth 50	float temp2	set temp2 to "1A_comp_wolfSpot"->GetHealth	messagebox "C) prev health=%f, curr health=%f" temp temp2	player->ModCurrentFatigue -50endifStopScript 1a_healring2End
If your problem are not due to multiple creature instances from a previous save, it may be identifiers starting with a number instead that with a letter, try enclosing them in "", I.E.
replace
1A_comp_wolfSpot->ModCurrentHealth 50

with
"1A_comp_wolfSpot"->ModCurrentHealth 50


if previous hints do not work, you could try changing the script/creature ids to be http://sourceforge.net/projects/mwedit/ strict syntax check compatible.
User avatar
Rob
 
Posts: 3448
Joined: Fri Jul 13, 2007 12:26 am

Post » Fri Oct 16, 2009 5:13 pm

Not anymore where? In your .esp or in your .ess (saved game)? If in doubt, test your mod from a fresh new game so you are sure there are no other instances of the creature coming from the previous save.


Both in the .esp and the .ess. I checked the area where the creature would be, and he wasn't there. The count in the .esp is 1.

MWEdit has a handy syntax checker, but no debugger, sorry.
You could try verifying single statements are working as expected using messageboxes, for instance
Begin a1a_healring2if ( player->GetFatigue < 50 )	MessageBox "You don't have enough fatigue to heal Moro!!"else	float temp	set temp to 1A_comp_wolfSpot->GetHealth	if ( temp >= 1 )		messagebox "A) Health = %f" temp	endif	set temp to "1A_comp_wolfSpot"->GetHealth	if ( temp >= 1 )		messagebox "B) Health = %f" temp	endif	set temp to "1A_comp_wolfSpot"->GetHealth	"1A_comp_wolfSpot"->ModCurrentHealth 50	float temp2	set temp2 to "1A_comp_wolfSpot"->GetHealth	messagebox "C) prev health=%f, curr health=%f" temp temp2	player->ModCurrentFatigue -50endifStopScript 1a_healring2End



Oh, thank you! I was wondering how to get his health in a message box. I will test that out as soon as I get a chance.

If your problem are not due to multiple creature instances from a previous save, it may be identifiers starting with a number instead that with a letter, try enclosing them in "", I.E.
replace
1A_comp_wolfSpot->ModCurrentHealth 50

with
"1A_comp_wolfSpot"->ModCurrentHealth 50


if previous hints do not work, you could try changing the script/creature ids to be http://sourceforge.net/projects/mwedit/ strict syntax check compatible.


I will try that out, as well. Thank you for your help. I'll let you know the results soon.
User avatar
Trey Johnson
 
Posts: 3295
Joined: Thu Oct 11, 2007 7:00 pm

Post » Fri Oct 16, 2009 2:37 pm

(Sorry for the double post, but apparently I'm not allowed to edit my posts?? If a mod could ammend this to my previous reply that would be great.)

I guess having a count of 1 isn't good after all. I had believed that the 1 meant the creature which was following me. I was wrong. I did another search for the heck of it and found a "wild" one. This wild one was used to debug an error with my companion. I didn't save my encounter with it, though. I didn't enter the cell it was in, either, on my real save game.

The script is working now. But I have a question. Does your save game only "keep" the NPCs/creatures you actually entered the cell of? For example, when I've encountered a creature that was one of a kind, saved the game, then proceeded to delete the single instance of that creature in the mod, it was still there on my save.

If it stores everything in the world, is there a save game editor I can use to destroy the wild creature so I dont have to worry about the script failing again?
User avatar
Adrian Powers
 
Posts: 3368
Joined: Fri Oct 26, 2007 4:44 pm

Post » Sat Oct 17, 2009 12:45 am

Is there a save game editor I can use to destroy the wild creature so I dont have to worry about the script failing again?

It should be enough to enter an interior cell, wait at least three days (72 in game hours), and save.
User avatar
Chloe Mayo
 
Posts: 3404
Joined: Wed Jun 21, 2006 11:59 pm

Post » Sat Oct 17, 2009 2:16 am

If it stores everything in the world, is there a save game editor I can use to destroy the wild creature so I dont have to worry about the script failing again?
The safer way is testing from a fresh new game: this way you can be sure certain things are working as expected. Then, you can test interaction with saved games, so if problems arise, you can be sure problems are there. As always, "divide et impera" .
Having said that, there are tools you can use to get rid of object instances in saved games easily. I use http://planetelderscrolls.gamespy.com/View.php?view=other.detail&id=52#Files as general purpose or, if I need a tailored, repeated removing i make a http://tesnexus.com/downloads/file.php?id=27588 http://wryemusings.com/Wrye%20Mash.html#FileCommands file , something like
# [Filetype: Wrye Mash Remover]# replace with your object ID and Label"1A_comp_wolfSpot"	"Spot"	

User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am


Return to III - Morrowind