(scripting) trying to run a spell off a button

Post » Mon Mar 14, 2011 3:17 pm

I've made six scripts that use a menu system with buttons. You click a button and it does something, except it's not using the CastImmediateOnSelf command.


example:
...if ( Button == 0 )     if player.GetItemCount ItemA == 0 || player.GetActorValue Health < 150          ShowMessage FailureMsg     elseif player.GetItemCount ItemA >= 1 && player.GetActorValue Health >= 151          player.RemoveItem ItemA 1 1          player.CastImmediateOnSelf WDIngestibleEffect          player.AddItem ItemB 1          set Button to -1    endifendif...


If the player has none of ItemA in their inventory or less than 150hp of health a failure message should display. Else, If I have 1 or more of ItemA and more than 151hp of health, the new item should be added to their inventory and an effect triggered. The effect is not triggering and I'm not sure why, it's a modified ingestible I used successfully in a non-button script so I'm wondering if I've missed something. Also am I using GetActorValue correctly to test against the player's health? I'd prefer to get an exact health amount than something like "GetHealthPercentage".

Final Edit (Grammar and typos)
User avatar
Peter lopez
 
Posts: 3383
Joined: Mon Sep 10, 2007 5:55 pm

Post » Tue Mar 15, 2011 12:45 am

I'd double-check to make sure that the WDIngestibleEffect you're using is the right type of effect to be called on the player. I've seen where the GECK does not protest if you script in a CIOS to the wrong type of effect.. it only seems to check if the effect actually exists, not if it's the right type and will work that way.

Yes, you're using GetActorValue correctly. GetBaseActorValue returns the amount started with, GetPermanentActorValue returns the base amount plus any ingame, non-removable modifications (like bobbleheads and some perks), and GetActorValue returns the current, working amount, which is all that plus any temporary mod amounts (like armor effects and spells)... it's the final number you see ingame.

Edit: Be wary of using "set Button to -1" in a GetButtonPressed statement.. that's the amount automatically returned when it's waiting for the player to click a button..
Better to set it to -2 and include a
if ( Button == -1 )
Return
endif
User avatar
Christina Trayler
 
Posts: 3434
Joined: Tue Nov 07, 2006 3:27 am

Post » Tue Mar 15, 2011 5:53 am

Thanks for having a look at it, yeah I was also messing with Actor Effects, I couldn't make them work either for some reason. I'll change the buttons to -2.
User avatar
Aaron Clark
 
Posts: 3439
Joined: Fri Oct 26, 2007 2:23 pm


Return to Fallout 3