Jump to content

Photo

Issues casting concentration spells from script

papyrus script creation kit spell cast papyrus script magic

  • Please log in to reply
5 replies to this topic

#1
lDelta6l

lDelta6l

    Fan

  • Members
  • PipPipPip
  • 447 posts

I've spent days trying to figure this out but I still haven't been able to come to a reasonable solution. Hopefully all of you intelligent people can help me. :)

 

I'm trying to cast spells from a script. I'm doing it when the game believes the player is in a non-spell-casting state (like falling) so using standard casting doesn't work. I'm using SelectedSpell.Cast(PlayerRef) and it works fine for fire-and-forget spells but has some weird issues with concentration spells. The biggest problem is that concentration spells will only fire for about five seconds before stopping. My current basic script is like this:

Event OnKeyDown(Int KeyCode)		
	
        If(!IsInMenuMode())
		If KeyCode == attackright
		        _AttackRightPressed = true	
			;Get current spell information first.
			sright = Player.GetEquippedSpell(1)				
			sRight.Cast(Player)
		EndIf
	EndIf

EndEvent



Event OnKeyUp(Int KeyCode, Float HoldTime)	
	
	If KeyCode == attackright
		_AttackRightPressed = false
		Player.InterruptCast()	
	EndIf

EndEvent

This script works perfectly... for under 5 seconds. If the cast goes over five seconds, the spell casting stops on its own and does not restart. I've tested the spell cast function under multiple conditions and it consistently behaves like this. I've also tried putting it in a loop (essentially While(_AttackRightPressed) { sRight.Cast(Player) } EndWhile) and the spell "casts" indefinitely but becomes extremely choppy, like it keeps turning itself on and off (I tested it with Flames and it kept making noise but I didn't even see any flames being shot out). I've also tried implementing a reset timer that calls the cast again after 4 seconds but that doesn't work well either. There seems to be some sort of cast cooldown working in the background. If I interrupt the cast then quickly call cast again (either via script or via the attack button) it behaves as if it's still using the timer from the original cast. For example, if I call cast, wait 3 seconds, interrupt the cast, then call cast again, it will only work for another 2 seconds before stopping. This "timer" only seems to reset if the player goes without casting for a few seconds.

I figured there must be an .ini setting somewhere that controls this behavior so I went to https://wiki.step-pr...uide:Skyrim_INI but I can't find anything that looks like it would relate to this. Alternatively, I also tried messing with the animation events to make the game believe that the player is in a state where they can cast spells normally (like MTState) so it would just use the vanilla casting mechanics but I haven't had any success with that, either.

So, does anyone know of a way to get this working? I'm also open to completely different approaches so long as it works.



#2
dylbill

dylbill

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,346 posts

Hmmm, you tried all of the things I would have thought of already. There are some Concentration Spell game settings that you could change maybe. In the Creation Kit, under Gameplay / Settings, type in Concentration and you'll see a bunch of em.



#3
maxarturo

maxarturo

    Faithful poster

  • Members
  • PipPipPipPip
  • 1,736 posts
Try this:
A) Put an 'xMarkerActivator' somewhere in a cell, any cell, it doesn't need to be in the same cell that the Player is, and make the xMarker cast the spell (constant spell) to the Player.
Example:
Spoiler
 
B) Make the spell an 'Ability' (constant spell) and then add / remove the spell OnKeyDown() > OnKeyUp().

Edited by maxarturo, 23 May 2020 - 02:40 AM.


#4
ReDragon2013

ReDragon2013

    Old hand

  • Members
  • PipPipPip
  • 526 posts

(1) You wrote: "I'm using SelectedSpell.Cast(PlayerRef) and it works fine for fire-and-forget spells but has some weird issues with concentration spells."
spells

    [SPEL:00012FCD] Flames          "Flames"
    [SPEL:0007D996] FlamesLeftHand  "Flames"
    [SPEL:000C969A] FlamesRightHand "Flames" 

    charge time  = 0.0,    cast duration = 0.0,     range = 0.0,     type = aimed
magic effect

    [MGEF:00013CA9] FireDamageConcAimed "Flames"

    base cost = 1.5,     skill usage multiplier = 1.4

(2) You wrote: "So, does anyone know of a way to get this working?"

  By using (vanilla) spells casted by the player, the player loses constantly magicka. Depends on "actorvalue of magicka" and "magic skills" the player is able to maintain the fire spell a specific time only.
  After that he/she runs out of magicka.

(3) The suggestion from maxarturo is that:

  Instead of the player as caster use an xmarker, which will be activated by SKSE based OnKeyXXX() events. The Xmarker casts the concentration spell to the player without loosing magicka or

  interrupts casting depends on state. I am not sure is that what you want.

 

(4) wiki: https://www.creation...le=Cast_-_Spell, https://www.creation...orValue_-_Actor


Edited by ReDragon2013, 23 May 2020 - 09:52 AM.


#5
lDelta6l

lDelta6l

    Fan

  • Members
  • PipPipPip
  • 447 posts

dylbill: Thanks for the suggestion. I didn't think to look in the game settings for some reason. I found a bunch of settings that look like they should adjust the concentration spell cast duration, but none of them seem to do anything relevant when I change them. Here are all the ones I tried:
    Game.SetGameSettingFloat("fCombatCastConcentrationOffensiveMagicCastTimeMax", 30.0)
    Game.SetGameSettingFloat("fCombatCastConcentrationOffensiveMagicCastTimeMin", 25.0)    
    Game.SetGameSettingFloat("fCombatMagicConcentrationMinCastTime", 20.0)
    Game.SetGameSettingFloat("fCombatMagicConcentrationScoreDuration", 15.0)
    Game.SetGameSettingFloat("fCombatMagicOffensiveMinCastTime", 30.0)    
    Game.SetGameSettingFloat("fCombatCastConcentrationOffensiveMagicWaitTimeMax", 0.0)
    Game.SetGameSettingFloat("fCombatCastConcentrationOffensiveMagicWaitTimeMin", 0.0)        
    Game.SetGameSettingFloat("fMagicCloudDurationMin", 30.0)
    Game.SetGameSettingFloat("fCombatMagicTargetEffectMinCastTime", 30.0)

I agree that there should be a setting for this somewhere, but I still haven't found it.


Edited by lDelta6l, 25 May 2020 - 07:16 PM.


#6
lDelta6l

lDelta6l

    Fan

  • Members
  • PipPipPip
  • 447 posts

As for using an xMarker, wouldn't casting the spell at the player be a bad thing? For example, if the player had "Flames" equipped and I had the marker cast it at the player, wouldn't the player be cooking themselves instead of their target?

ReDragon2013, running out of magicka isn't the issue. It stops even when I have plenty left.





Also tagged with one or more of these keywords: papyrus, script, creation kit, spell, cast, papyrus script, magic

Page loaded in: 1.074 seconds