Cast() & RemoteCast() not working?

Post » Thu Jun 21, 2012 2:26 am

Hi all,

I am trying to script an NPC to Cast a spell at the player or on themselves but it won't work.

I can setup a package on a custom NPC with "useMagic" that tells them to cast a summon spell at the player as soon as combat starts no worries (as long as the NPC has the spell already or I script add it in game). That works fine tested it multiple times, but it won't help in my mod.

I can make an NPC cast a fireball at the player with a script applied in game, I can even make an NPC instant cast a fireball spell at a chicken in the middle of town blaming the player for the crime! with just a simple script I can apply in game with a spell.

What I CANT do is make any NPC cast any spell that requires a Target Location with said scripted spell i.e. Runes and Summons.

This is driving me crazy and I have tried everything I can think of...
- Calling my own custom NPC with god like powers and all spells then casting my "ForceCastSummon" spell at them.
- Creating a reference marker to force-cast the summon spell at me or another reference marker at the players feet.
- Summoning a Giant chicken just above the players head facing the floor then trying to make it force-cast a summon spell.
- Multiple combinations of custom spells and markers/actors to cast the summon spell.

If I use a script to make the player Cast() a spell all the self targeting spells are fine but anything with 'Target' or 'TargetLocation' only goes toward the player cross hair not the target I dictate in the script. I have read on the wiki this may be because by default an actor can only cast were they are facing so I tried calling an actor to near the player, make them face or fight the player then cast the spell. NOPE!

	 If SpellToCast != None		  SpellToCast.RemoteCast(PlayerRef, PlayerRef, PlayerRef)	 ;Cast from akCaster, too akTarget, blaming the akBlame.	 Endif

I've used: PlaceAtMe(), PlaceActorAtMe(), StartCombat(), SetLookAt(), Cast(), RemoteCast(), AddSpell(), actor bases, created multiple object references, actor references, custom spells, custom functions, debug messages, tried looking on wiki and message boards, placing hands over eyes and shouting "AAAAAAAAAAAAAAAAAAGGGGGGGGGG". But nothing seems to work.

As far as I can tell I have once again found something that CAN NOT be done via Papyrus. I can make it work with an AI package added in the CK but that will not help for my mod at all.

If anyone has found a way to make an NPC (or just an object/reference) use a script that can be applied via a spell, cast a summon or rune type spell at the player or any location please for the love of all that is good and holy tell me.
User avatar
Charlotte Buckley
 
Posts: 3532
Joined: Fri Oct 27, 2006 11:29 am

Post » Wed Jun 20, 2012 9:56 pm

Did you try something like this?

Scriptname ExampleMEScript extends ActiveMagicEffectSpell Property AimedSpell AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)    akTarget.SetAngle(0, 0, akTarget.GetAngleZ() + akTarget.GetHeadingAngle(akCaster))    Utility.Wait(0.1)    AimedSpell.RemoteCast(akTarget, Game.GetPlayer(), akCaster)    ;akTarget casts a spell in front of him/herself, player gets the blame, akCaster is the target (not that it does anything)EndEvent
User avatar
aisha jamil
 
Posts: 3436
Joined: Sun Jul 02, 2006 11:54 am

Post » Wed Jun 20, 2012 4:17 pm

@ RandomNoob
I had tried multiple ways of making the NPC face me including StartCombat() and SetLookAt()

I loaded up a blank esp and ran your script anyway on a new spell (thanks for taking the time to write that for me btw) and gave it a test.

It worked, I was stunned to say the least but after a bit of testing I realised what I had been doing wrong all this time.

What I was originally using was a created actor I made with a reference then disabled when my spell effect ran out, well when a caster is Disabled() any summon they created disappears too plus I was disabling them so fast after trying to cast the spell didn't have time to manifest properly.
Thank the light for RandomNoob! for showing me the error of my ways :biggrin:

Unfortunatly this still doesnt solve my problem with them casting a Rune spell. Even with the script you gave me the NPC will turn to look directly at me but not cast anything.

Thanks anyway for your help.

Leon
User avatar
Miguel
 
Posts: 3364
Joined: Sat Jul 14, 2007 9:32 am


Return to V - Skyrim