OnEquip issues

Post » Sat Jan 29, 2011 10:07 pm

I'm working on a script that add an ingestible when an item is equipped, then removes it when the item is unequipped. But Ive run into several issues, sometimes I get several ingestibles added to the inventory, and various other problems when I use the ingestible and try to unequip the trigger item, ranging from CTD's to having the item removed from inventory with out firing the ingestible items script. The trigger item can be equipped or force equipped (Player.GetEquipped) so that might be causing some issues as well. So I'm hoping some smart person here has a bit more experience with these commands than I do or can suggest alternate approaches. I've re-re-written the scripts several times and I'm starting to run out of ideas.
User avatar
Alexandra walker
 
Posts: 3441
Joined: Wed Sep 13, 2006 2:50 am

Post » Sun Jan 30, 2011 5:24 am

I'm working on a script that add an ingestible when an item is equipped, then removes it when the item is unequipped. But Ive run into several issues, sometimes I get several ingestibles added to the inventory, and various other problems when I use the ingestible and try to unequip the trigger item, ranging from CTD's to having the item removed from inventory with out firing the ingestible items script. The trigger item can be equipped or force equipped (Player.GetEquipped) so that might be causing some issues as well. So I'm hoping some smart person here has a bit more experience with these commands than I do or can suggest alternate approaches. I've re-re-written the scripts several times and I'm starting to run out of ideas.


Sounds like you might be using an effect script and not really working it right.

If you want code to run exactly one time in an effect script, you need to put it into a "scripteffectstart" block in your code, and also, the effect will be configured with the 'no duration" setup. If you think this might be the case, fix it, and see what symptoms remain.
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm

Post » Sat Jan 29, 2011 7:28 pm

I have completley removed all the onequip scripts and have determined that the problem must lie in the effect script on my ingestable. The really wierd part is thet the effect script is basicly just a "copy and paste" of another effect script that is working, in fact the same copy and paste works on all the other ingestables but this one. That's why I thought it had to do with the onequip script.

So my new question is what would cause an effect script to simply not run. I've already re-double-checked the obvious items as Tarrant suggested.
User avatar
Lil'.KiiDD
 
Posts: 3566
Joined: Mon Nov 26, 2007 11:41 am

Post » Sun Jan 30, 2011 1:08 am

Nothing comes to mind, but if you could post the script perhaps we could find what's causing your issue.

Cipscis
User avatar
lilmissparty
 
Posts: 3469
Joined: Sun Jul 23, 2006 7:51 pm

Post » Sat Jan 29, 2011 8:51 pm

Sorry I meant to post the snippet of code but got interupted.

Anyway, the code is a followup to ZealotLees ACR mod that lets you swap out weapon mod kits on the fly. This script is ment to take the weapon apart and give the player all the kits that were a part of the whole.

short EquipACRfloat ACRconditionref PlayerEquippedACRbegin ScriptEffectStart	; Check to see if player has ACR equipped in Object slot #5	set EquipACR to 0	if player.IsWeaponInList ACROrderedList		set PlayerEquippedACR to Player.GetEquippedObject 5		set EquipACR to 1	endif	if EquipACR == 1		; Gets condition of equipped ACR		set ACRcondition to player.GetEquippedCurrentHealth 5		set ACRcondition to ACRcondition / GetHealth PlayerEquippedACR		if PlayerEquippedACR == ZLACRBar105			player.removeitem ZLACRBar105 1 1			player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 1			player.additem ZLACRBar105BarrelKit 1 1			player.additem ZLACRIronSightKit 1 1			player.additem ZLACRSuppressorKit 1 1			player.additem ZLACRCamoBlackKit 1 1		elseif PlayerEquippedACR == ZLACRBar105ACOG			player.removeitem ZLACRBar105ACOG 1 1			player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 1			player.additem ZLACRBar105BarrelKit 1 1			player.additem ZLACRACOGKit 1 1			player.additem ZLACRSuppressorKit 1 1			player.additem ZLACRCamoBlackKit 1 1		                                          [ the script continues with all permutations of the weapon]				endif	endifendbegin ScriptEffectFinish	if EquipACR == 0		ShowMessage ZLACREquipError		player.additem ZLACRBreakdown 1	endifend


In game nothing happens except that the ingestable gets removed from inventory. I don't even get the error message if I run it without a weapon equipped.
User avatar
Eileen Müller
 
Posts: 3366
Joined: Fri Apr 13, 2007 9:06 am

Post » Sat Jan 29, 2011 10:48 pm

Did you save the script as a magic effect script?
User avatar
Britney Lopez
 
Posts: 3469
Joined: Fri Feb 09, 2007 5:22 pm

Post » Sat Jan 29, 2011 10:08 pm

Hmm, there are a couple of things that could be done to speed it up, but I can't see anything that could break it unless you haven't included every weapon in the "ACROrderedList" form list. Try adding in some http://fose.silverlock.org/fose_command_doc.html#PrintToConsole or http://fose.silverlock.org/fose_command_doc.html#DebugPrint calls to check if it stops running at any point.

Cipscis
User avatar
Cheville Thompson
 
Posts: 3404
Joined: Sun Mar 25, 2007 2:33 pm

Post » Sat Jan 29, 2011 6:17 pm

Yes it is an effect script, with the base effect set to self with a duration of zero. As far as I can tell it's setup identical to the effects I setup for the other mod kits, except those I banged out in a few hours and this one has been kicking my butt for weeks.

where do I put PrintToConsole or DebugPrint? I've seen these commands but never could get them figured out.
User avatar
Ownie Zuliana
 
Posts: 3375
Joined: Thu Jun 15, 2006 4:31 am

Post » Sat Jan 29, 2011 7:05 pm

Just insert them in a section of the script where you'd like to check if the code is being executed. The calling convention is fairly simple, especially if you just want to print a static string:
PrintToConsole "Line X is running"; OrDebugPrint "Line X is running"
If you use http://fose.silverlock.org/fose_command_doc.html#DebugPrint, you'll also need to use http://fose.silverlock.org/fose_command_doc.html#SetDebugMode in order for the messages to be printed to the console.

The advantage of http://fose.silverlock.org/fose_command_doc.html#DebugPrint is that you can leave these lines in your script for later debugging without having to worry about a performance hit or console spam - they will be disabled by default but can be enabled via http://fose.silverlock.org/fose_command_doc.html#SetDebugMode, whereas you'd have to comment out or remove http://fose.silverlock.org/fose_command_doc.html#PrintToConsole lines if you want to avoid console spam when you release.

You can also print information from variables, like this:
DebugPrint "The condition of the player's weapon, %n, is %f" PlayerEquippedACR ACRcondition

See http://fose.silverlock.org/fose_command_doc.html#FormatSpecifiers for more info on this

Cipscis
User avatar
biiibi
 
Posts: 3384
Joined: Sun Apr 08, 2007 4:39 am

Post » Sun Jan 30, 2011 12:03 am

I've redone the script like this:

begin ScriptEffectStart	; Check to see if player has ACR equipped in Object slot #5	set EquipACR to 0	PrintToConsole "EquipACR to 0 is running"	if player.IsWeaponInList ACROrderedList		set PlayerEquippedACR to Player.GetEquippedObject 5		set EquipACR to 1	endif	PrintToConsole "EquipACR to 1 is running"	if EquipACR == 1		; Gets condition of equipped ACR		set ACRcondition to player.GetEquippedCurrentHealth 5		set ACRcondition to ACRcondition / GetHealth PlayerEquippedACR		PrintToConsole "set ACRcondition is running"		if PlayerEquippedACR == ZLACRBar105			player.removeitem ZLACRBar105 1 1			player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 1			player.additem ZLACRBar105BarrelKit 1 1			player.additem ZLACRIronSightKit 1 1			player.additem ZLACRSuppressorKit 1 1			player.additem ZLACRCamoBlackKit 1 1.....


Is this correct?
User avatar
tegan fiamengo
 
Posts: 3455
Joined: Mon Jan 29, 2007 9:53 am

Post » Sun Jan 30, 2011 12:14 am

Yeah, that should compile. I'd recommend adding one at the end of the script too, so you can tell if it's halting somewhere in the middle. Do all of the http://fose.silverlock.org/fose_command_doc.html#PrintToConsole calls get executed?

Cipscis
User avatar
Jessica Nash
 
Posts: 3424
Joined: Tue Dec 19, 2006 10:18 pm

Post » Sat Jan 29, 2011 7:14 pm

When I use my item in game nothing happens, I then open the console and all I see is the cursor. I'd expect this to be the part where all of my PrintToConsole Messages scroll up the screen. Does this mean that the script just isn't firing at all?
User avatar
Eibe Novy
 
Posts: 3510
Joined: Fri Apr 27, 2007 1:32 am

Post » Sat Jan 29, 2011 4:48 pm

Yeah. Considering that there is nothing above the first http://fose.silverlock.org/fose_command_doc.html#PrintToConsole call that could cause the script to halt, it looks like there's something wrong with the base effect and/or ingestible.

If you can't find anything wrong with the setup, then I recommend recreating the ingestible and base effect from scratch.

Cipscis
User avatar
Dale Johnson
 
Posts: 3352
Joined: Fri Aug 10, 2007 5:24 am

Post » Sun Jan 30, 2011 9:04 am

This might be completely unrelated. If so, I apologize. But I have found that when force-equiping items (on NPCs), OnEquip blocks in scripts running on those items do not fire. Could this be part of your problem?
User avatar
Sophh
 
Posts: 3381
Joined: Tue Aug 08, 2006 11:58 pm

Post » Sun Jan 30, 2011 1:53 am

No, the OnEquip was for the player only. So I guess I give up on trying to fix it and start over again. Funny, I thought about that a week ago but my stubborn streak told me keep on truckin'!

Thanks for the feedback!
User avatar
Tikarma Vodicka-McPherson
 
Posts: 3426
Joined: Fri Feb 02, 2007 9:15 am

Post » Sun Jan 30, 2011 4:02 am

I've started over and am just trying to get the script I posted earlier to run. As my script was not firing at all I have determined that it in no way caused my problems, I have attatched basicaly the same script to a base effect: Effect Archetype-Script, Assoc Item - My FieldStrip Script, Flags - Self, all else is default. I have the effect attatched to the ingestible with Magnitude, Area, Duration and Cost at zero and Range set to self. The results are the same, the ingestible is removed from inventory but the script does not fire. I've done a whole string of these effect scripts that all work, so I thought I knew what I was doing. If anyone has any insight at all I'm open to just about anything.
User avatar
Jerry Jr. Ortiz
 
Posts: 3457
Joined: Fri Nov 23, 2007 12:39 pm

Post » Sun Jan 30, 2011 6:41 am

Okay rather than starting a new thread for the same scipt I'll just continue here. I got problem of the script not firing fixed (apperently you can't refrence items in another esp) but now I'm having a new problem. notice the line that reads:

player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 1

Everytime the weapon gets added it has a health of zero. At first I thought that maybe the script did'nt have enough time between Menumode and Gamemode to run the script properly, but I don't think thats the case.
User avatar
Marta Wolko
 
Posts: 3383
Joined: Mon Aug 28, 2006 6:51 am

Post » Sun Jan 30, 2011 9:21 am

Okay rather than starting a new thread for the same scipt I'll just continue here. I got problem of the script not firing fixed (apperently you can't refrence items in another esp) but now I'm having a new problem. notice the line that reads:

player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 1

Everytime the weapon gets added it has a health of zero. At first I thought that maybe the script did'nt have enough time between Menumode and Gamemode to run the script properly, but I don't think thats the case.

The math looks right. I would try changing this line: set ACRcondition to ACRcondition / GetHealth PlayerEquippedACR. Define another float, like fBaseHealth. Then set fBaseHealth to GetHealth PlayerEquippedACR, then do the division with two floats instead of having the FOSE command in the denominator: set ACRcondition to ACRcondition / fBaseHealth
User avatar
Annika Marziniak
 
Posts: 3416
Joined: Wed Apr 18, 2007 6:22 am

Post » Sun Jan 30, 2011 3:04 am

Okay rather than starting a new thread for the same scipt I'll just continue here. I got problem of the script not firing fixed (apperently you can't refrence items in another esp) but now I'm having a new problem. notice the line that reads:

player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 1

Everytime the weapon gets added it has a health of zero. At first I thought that maybe the script did'nt have enough time between Menumode and Gamemode to run the script properly, but I don't think thats the case.

hi well i don't know alot of scripting but i remember that line only there was a 100 added behind it for the health percentage for the item.
so it might be that this line is working for you:player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 1 100 or
player.AddItemHealthPercent ZLACRStripped 1 ACRcondition 100
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am


Return to Fallout 3