scn sssCreatureDevilTriggerScript
ref me
ref myUser
ref myHit
ref target
float xpos
float ypos
float zpos
float myX
float myY
float myZ
float myX2
float myY2
float myZ2
; fly vector
float dx
float dy
float dz
float dt
; private
float angz
float angx
float angz2
float angx2
float xang
float yang
float zang
float x
float x2
float sin
float cos
float mana
short index
short Voice
float timer
short framecount
begin OnActivate
set framecount to 0
end
begin OnStartCombat
end
begin OnDeath
set sssDevilTrigger.On to 0
playSound sssSoundDevilTriggerOff
SetNumericGameSetting fVanityModeWheelMin 30.0
SetNumericGameSetting fVanityModeWheelMax 600.0
disable
PositionCell 2000,2000,8200,0,sssCell
end
begin gamemode
set framecount to framecount + 1
if sssDevilTrigger.On == 1
; if player.IsAttacking == 1 || player.IsPowerAttacking == 1
; enable
; else
; disable
; endif
if ( framecount % 2 ) == 0
set mana to player.getav magicka
set mana to mana - 1
if mana <= 0
set sssDevilTrigger.On to 0
playSound sssSoundDevilTriggerOff
SetNumericGameSetting fVanityModeWheelMin 30.0
SetNumericGameSetting fVanityModeWheelMax 600.0
disable
PositionCell 2000,2000,8200,0,sssCell
else
player.modAV2 magicka -1
endif
endif
endif
if GetCombatTarget == player
StopCombat
endif
set myHit to apple
set myHit to player.GetCrosshairRef
if myHit != 0 && myHit != apple && myHit.IsActor && myHit.getdead != 1 && myHit != Player && myHit.getInFaction PlayerFaction == 0
StartCombat myHit
endif
set me to GetSelf
set myUser to Player
set myX to myUser.getpos x
set myY to myUser.getpos y
set myZ to myUser.getpos z
set angz to myUser.GetAngle z
set yang to myUser.GetAngle y
set angx to myUser.GetAngle x
set zPos to myUser.getpos z
if ( ( myX != myX2 ) || ( myY != myY2) || (MyZ != MyZ2) || ( angz != angz2) || (angx != angx2) )
set myX2 to myX
set myY2 to myY
set myZ2 to myZ
set angz2 to angz
set angx2 to angx
set zang to angz
if angz > 180
set angz to (angz) - 360
endif
set x to angz*0.0174532925
set x2 to x*x
set sin to x*(1-(x2/6)*(1-(x2/20)*(1-(x2/42)*(1-(x2/72)*(1-x2/110)))))
set cos to 1-0.5*x2*(1-(x2/12)*(1-(x2/30)*(1-(x2/56)*(1-x2/90))))
set dx to 10*sin
set dy to 10*cos
; vertical fly vector
set xang to angx*cos ; uses settings from Horizontal Vector
set yang to -angx*sin
set x to -angx*0.0174532925
set x2 to x*x
set sin to x*(1-(x2/6)*(1-(x2/20)*(1-(x2/42)*(1-(x2/72)*(1-x2/110)))))
set cos to 1-0.5*x2*(1-(x2/12)*(1-(x2/30)*(1-(x2/56)*(1-x2/90))))
set dz to 10*sin
; initial position vector (to add to player coords)
set xPos to -5*dx*cos + myX
set yPos to -5*dy*cos + myY
endif
me.SetAngle z zang
me.SetAngle y yang
me.SetAngle x xang
me.SetPos x Xpos
me.SetPos y Ypos
me.SetPos z zPos
if Voice == 1
set timer to timer + GetSecondsPassed
if timer > 4
set Voice to 0
endif
endif
if IsPowerAttacking == 1 && Voice == 0
set sssQuest.indexSoundDevilTriggerVoice to ( sssQuest.indexSoundDevilTriggerVoice + 1 ) % 6
set index to sssQuest.indexSoundDevilTriggerVoice
if index == 0
playSound sssSoundDevilTriggerVoice01
elseif index == 1
playSound sssSoundDevilTriggerVoice02
elseif index == 2
playSound sssSoundDevilTriggerVoice03
elseif index == 3
playSound sssSoundDevilTriggerVoice04
elseif index == 4
playSound sssSoundDevilTriggerVoice05
else
playSound sssSoundDevilTriggerVoice06
endif
set Voice to 1
set timer to 0.0
endif
end