HasSpellFunction

Post » Mon Jun 18, 2012 4:51 am

Does anyone know what the HasSpell function is?

I saw (somewhere) it written as:
[size=4]Game.GetPlayer().HasSpell(abhorse)[/size][size=4]
[/size]

But that turns up a 'missing RPAREN at '\\r\\n'...

All I basically want to do is run an (If Player.HasSpell X == 1 ) script.... :S

The creationkit wiki page is just empty...
http://www.creationkit.com/HasSpell

Thanks again for any input :)
User avatar
Zach Hunter
 
Posts: 3444
Joined: Wed Aug 08, 2007 3:26 pm

Post » Sun Jun 17, 2012 6:31 pm

I haven't looked at the scripting syntax of any of the Elder Scrolls games, but in regular programming languages calling a function of an object has a space for parameters ().

In other words, wouldn't calling the HasSpell function on player look like:
Player.HasSpell(spell goes here)
with the paranthesis?
User avatar
Neil
 
Posts: 3357
Joined: Sat Jul 14, 2007 5:08 am

Post » Sun Jun 17, 2012 8:18 pm

It's here: http://www.creationkit.com/HasSpell_-_Actor.
User avatar
Stefanny Cardona
 
Posts: 3352
Joined: Tue Dec 19, 2006 8:08 pm

Post » Mon Jun 18, 2012 2:28 am

Posting your entire script here as well as the compile errors you are getting would help in figuring out what exactly is wrong, but I’ll give it a shot with the information you provided.

The error you mention – “missing RPAREN at ‘\r\n’” basically means that the compiler expected a RPAREN – the “)” character – but instead found the end of a line. The example you posted above seems to be the correct syntax, so my guess is that when you typed it into your script, you forgot the right parenthesis at the end of the line. The compiler error should have a line number on it that will point you at the offending line :)
User avatar
Vickey Martinez
 
Posts: 3455
Joined: Thu Apr 19, 2007 5:58 am

Post » Mon Jun 18, 2012 4:54 am

OK, that cleared up one issue, at least, thanks :smile:

Scriptname ZCDMSotVControl00Script extends questInt DoOnceInt PCIsAVampireInt PCCurrentBloodInt PCMaxBloodInt VampHourGlobalVariable Property GameHour AutoEvent onInit()If DoOnce == 0  DoOnce = ( DoOnce + 1 )  PCIsAVampire = 1  PCCurrentBlood = 1000  PCMaxBlood = 1000  debug.MessageBox("CDM - Symphony of the Vampire Installed...")  RegisterForSingleUpdate(1)EndIfendEventEvent OnUpdate()If ( PCIsAVampire == 1 )  If ( Game.GetPlayer().HasSpell(DiseaseBoneBreakFever) )  EndIf  PCCurrentBlood = ( PCCurrentBlood - 1 )  If ( PCCurrentBlood < 0 )   PCCurrentBlood = 0  ElseIf ( PCCurrentBlood > PCMaxBlood )   PCCurrentBlood = PCMaxBlood  EndIf    If ( GameHour.GetValue() >= 6 ) && ( GameHour.GetValue() < 20 )   Debug.MessageBox("TakingDamage")  EndIf  EndIfRegisterForSingleUpdate(1)EndEvent
Errors:

(32,33)variable DiseaseBoneBreakFever is undefined

This script is really rough, I am just trying to get my head around how things work now-- so please ignore that it does not seem to really 'do' anything properly; thanks for the help :smile:
User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am

Post » Sun Jun 17, 2012 8:16 pm

That compiler error means that it doesn’t know what “DiseaseBoneBreakFever” is. Note that Papyrus has no knowledge of what is in the master file, so you’ll have to get the disease you want via a different method known as a http://www.creationkit.com/Differences_from_Previous_Scripting#Properties.

In short, you’ll want to add “Spell Property DiseaseBoneBreakFever Auto” to your script, probably near your existing GameHour property, just to keep things organized. That will tell the compiler what DiseaseBoneBreakFever is (a property with a type of Spell), and will let the compile error go away.

Then you’ll want to point the property at the appropriate disease in the editor via the property window on the script. (I am assuming the Disease is a Spell, you may have to change the type a little if the dropdown in the editor doesn’t display it. The type that the form you’re interested in appears under in the object window may give you a hint as to what Papyrus type is appropriate)
User avatar
I’m my own
 
Posts: 3344
Joined: Tue Oct 10, 2006 2:55 am

Post » Mon Jun 18, 2012 12:26 am

That compiler error means that it doesn’t know what “DiseaseBoneBreakFever” is. Note that Papyrus has no knowledge of what is in the master file, so you’ll have to get the disease you want via a different method known as a http://www.creationkit.com/Differences_from_Previous_Scripting#Properties.

In short, you’ll want to add “Spell Property DiseaseBoneBreakFever Auto” to your script, probably near your existing GameHour property, just to keep things organized. That will tell the compiler what DiseaseBoneBreakFever is (a property with a type of Spell), and will let the compile error go away.

Then you’ll want to point the property at the appropriate disease in the editor via the property window on the script. (I am assuming the Disease is a Spell, you may have to change the type a little if the dropdown in the editor doesn’t display it. The type that the form you’re interested in appears under in the object window may give you a hint as to what Papyrus type is appropriate)

Thank-you very much. I will try that in a moment, but it seems to make sense to me :biggrin:

If the Script does not recognise what is in the Master, does that mean you could reference other Mods? So if I had A and B, I could reference Spells in A, just by defining them in B?

Edit:

That seems to work :D It saves :)

However, in game nothing happens... I do not think that second half of my script (from Event OnUpdate) is working at all... The first part does, and the message displays... so it is something there.. If anyone could point out that issue, I would be much obliged :)
User avatar
Jesus Lopez
 
Posts: 3508
Joined: Thu Aug 16, 2007 10:16 pm

Post » Sun Jun 17, 2012 9:30 pm

Not entirely sure what you’re asking for, but in general, the compiler cannot see anything in the master file or any mods. The only thing it can see is what is in the script files, so you’ll need to make a property (which the compiler understands) and give that property a value in the editor (which is what ‘glues’ the game and script together).

What’s going wrong isn’t obvious from your script, but there are a few steps you could try to help narrow it down. First, turn on script logging (you want http://www.creationkit.com/INI_Settings_(Papyrus)#bEnableLogging, http://www.creationkit.com/INI_Settings_(Papyrus)#bEnableTrace, and http://www.creationkit.com/INI_Settings_(Papyrus)#bLoadDebugInformation, all set to 1), then sprinkle a few http://www.creationkit.com/Trace_-_Debug calls in various parts of your script, like at the beginning of the update event, inside your if statements, etc, that would help you keep track of what your script is doing. Then monitor the Papyrus.0.log file inside "My Documents/My Games/Skyrim/Logs" (may have to launch the game twice to get it to make the log the first time) for your trace statements to see what’s happening.

You can also try typing in “DumpPapyrusUpdates” (or “DPU”) into the console to spit out a list of everything registered for update events, and “DumpPapyrusStacks” (or “DPS”) into the console to dump a list of everything actually running to see if your script is stuck somewhere. The output for both of those functions goes to the script log. The log will also detail any errors your script may be causing, so keep an eye out :)

Example:
Event OnUpdate()Debug.Trace("Got an update! PCIsAVampire = " + PCIsAVampire)If ( PCIsAVampire == 1 )  If ( Game.GetPlayer().HasSpell(DiseaseBoneBreakFever) )  EndIf  PCCurrentBlood = ( PCCurrentBlood - 1 )  If ( PCCurrentBlood < 0 )   PCCurrentBlood = 0  ElseIf ( PCCurrentBlood > PCMaxBlood )   PCCurrentBlood = PCMaxBlood  EndIf    If ( GameHour.GetValue() >= 6 ) && ( GameHour.GetValue() < 20 )   Debug.Trace("Taking damage!")   Debug.MessageBox("TakingDamage")  else    Debug.Trace("Not taking damage!")  EndIf  EndIfRegisterForSingleUpdate(1)EndEvent
User avatar
michael danso
 
Posts: 3492
Joined: Wed Jun 13, 2007 9:21 am

Post » Mon Jun 18, 2012 1:12 am

This is the error I am gettig now...

[02/09/2012 - 05:41:20PM] error: No Spell or Shout passed to HasSpellstack: [ (00000014)].Actor.HasSpell() - "" Line ?

But I DO pass a Spell, I think:

Scriptname ZCDMSotVMainControlScript001 extends Quest Int FirstStartUp;Globals (Default)GlobalVariable Property GameHour AutoGlobalVariable Property GameDay Auto;Globals (SotV)GlobalVariable Property ZCDMSotVPCIsAVampire AutoGlobalVariable Property ZCDMSotVPCVampireStage Auto;VariablesInt InfectDayInt NewInfectDayInt IsInfectedInt DaysInfectedInt BeginTransformation;DiseasesSpell Property DiseaseSanguinareVampiris AutoSpell Property ZCDMSotVVampireDisease Auto ;<--Spell DefinedEvent OnInit() If ( FirstStartUp == 0 ) Debug.Trace("Started")   FirstStartUp = 1  debug.MessageBox("Loaded")  Game.GetPlayer().AddSpell(ZCDMSotVVampireDisease) ;<-- Spell Passed  RegisterForSingleUpdate(1) EndIfEndEventEvent OnUpdate() Debug.Trace("Started Update") If ( Game.GetPlayer().HasSpell(ZCDMSotVVampireDisease) == 1 ) ;<-- Spell Passed  IsInfected = 1 elseIf ( Game.GetPlayer().HasSpell(ZCDMSotVVampireDisease) == 0 ) ;<-- Spell Passed  IsInfected = 0  InfectDay = 0  DaysInfected = 0  NewInfectDay = 0 EndIf Debug.Trace("Checked for Disease") If ( IsInfected == 1 )  NewInfectDay = GameDay.GetValueInt()  If ( InfectDay == 0 )   InfectDay = NewInfectDay  ElseIf ( InfectDay != NewInfectDay )   DaysInfected = ( DaysInfected + 1 )   InfectDay = NewInfectDay     EndIf  If ( DaysInfected >= 3 )   Game.GetPlayer().RemoveSpell(ZCDMSotVVampireDisease)  ;<-- Spell Passed   BeginTransformation = 1   IsInfected = 0   InfectDay = 0   DaysInfected = 0   NewInfectDay = 0  EndIf EndIf If ( BeginTransformation == 1 ) EndIf  Debug.Trace("About to Register New Update") RegisterForSingleUpdate(1) Debug.Trace("Ended  Update")EndEvent

Any idea what is up?
User avatar
Sarah Edmunds
 
Posts: 3461
Joined: Sat Jul 08, 2006 8:03 pm

Post » Mon Jun 18, 2012 6:18 am

While you are correctly defining your property and passing the value of that property to the HasSpell function, the game is complaining because your property doesn’t actually have any value. You’ll want to make sure that you’ve given the property a value inside the editor wherever you’ve attached your script. (Pro tip: The property window can be resized and will show all your values you’ve given to properties in the list)
User avatar
Elisha KIng
 
Posts: 3285
Joined: Sat Aug 18, 2007 12:18 am

Post » Mon Jun 18, 2012 1:57 am

While you are correctly defining your property and passing the value of that property to the HasSpell function, the game is complaining because your property doesn’t actually have any value. You’ll want to make sure that you’ve given the property a value inside the editor wherever you’ve attached your script. (Pro tip: The property window can be resized and will show all your values you’ve given to properties in the list)

Thanks. That resolved it :)

I seem to have hit one last issue now, though... When I start the Mod, it correctly comes up that the disease has been added-- but it is not added. I commented out the 'Remove' line, in case that was breaking it somehow, but even with that gone, the Disease does not take effect on the player... Chaning it to an ability had the same effect.
If I try via the console, it comes up with a random percent, DOES NOT add, and then eventually will.

I have 'Disallow Absorb/Reflect' and 'Ignore Immunities' checked.
User avatar
Robyn Lena
 
Posts: 3338
Joined: Mon Jan 01, 2007 6:17 am

Post » Sun Jun 17, 2012 11:22 pm

Ah – I bet I know what’s going on. “AddSpell” added the spell you gave it to the player’s spell book. It didn’t apply the disease as if you had been hit by it. RemoveSpell will then remove it from the spell book, but not dispel it. And HasSpell is checking the spell book, not what is applied to the player. I think what you actually want here is http://www.creationkit.com/Cast_-_Spell, http://www.creationkit.com/DispelSpell_-_Actor, and http://www.creationkit.com/HasMagicEffect_-_Actor used like this:

Actor player = Game.GetPlayer(); To apply the diseaseZCDMSotVVampireDisease.Cast(player, player); To remove the diseasePlayer.DispellSpell(ZXDMSotVVampireDisease); To see if the player has the diseaseif Player.HasMagicEffect()  ; Do cool stuff!endIf
User avatar
Steven Nicholson
 
Posts: 3468
Joined: Mon Jun 18, 2007 1:24 pm

Post » Mon Jun 18, 2012 5:35 am

SmKViper,

Thanks for the help, but I am still having a nightmare with this...
1. I tried that change, and nothing happened; but turning it back, suddenly it DID start happening, so I have no idea what happened there.

2. I finally managed to add the Spell, but hit on another issue-- it was not showing up. Remaking it fixed this-- somehow it had become locked as 'constant/contact' -- any way to change this after the spell has been initially made? It always seems to gray out, and removing the effects does not open it up for me... :S
User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am


Return to V - Skyrim