scriptname dragonActorSCRIPT extends actor {Base Actor Script for all Dragons} ; _____________ ;| | ;| SETUP | ;|_____________| ImageSpaceModifier property dragonFOVfx auto {FX played for various impacts in dragon combat} float property deathFXrange = 1024.0 auto {max range to play death FX on player} actor property player auto hidden {For quick reference and clean-looking script} float property FOVfalloff auto hidden {choosing not to expose this and clutter the prop list in CS, since it won't be touched often} sound property NPCDragonFlyby auto {Sound played when dragon passes by a target} explosion property knockBackExplosion auto {explosion used to knock back enemies} ; NOTE - the dragon breed/skin settings are deprecated and have no effect. armor property SnowDragonSkin auto {deprecated - do not use} armor property TundraDragonSkin auto {deprecated - do not use} armor property forestDragonSkin auto {deprecated - do not use} int property dragonBreed = 0 auto {deprecated - do not use} ImpactDataSet Property FXDragonTakeoffImpactSet Auto {Impact data set to use for the dragon takeoff} ImpactDataSet Property FXDragonLandingImpactSet Auto {Impact data set to use for the dragon landing} ImpactDataSet Property FXDragonTailstompImpactSet Auto {Impact data set to use for the tailstomp} ;*****ADDED FOR DLC2-------------- bool MiraakIntroductionHappened bool MiraakAppeared Location Property DLC2ApocryphaLocation Auto WorldSpace Property DLC2ApocryphaWorld auto ;*****---------------------------- ; _____________ ;| | ;| EVENTS | ;|_____________| EVENT onInit() ; just initialize any variables, etc. player = game.GetForm(0x14) as Actor ; store player reference FOVfalloff = 1600 ; range at which impact doesn't play FOV if deathFXrange == 0 deathFXrange = 1000 endif if !isDead() && isGhost() ; redundancy check to prevent invincible, "ghosted" dragons from respawning. setGhost(FALSE) endif gotoState("alive") endEVENT EVENT onReset() ; if we're resetting a previously-killed dragon, make sure it's not a ghost. setGhost(FALSE) endEVENT EVENT onLoad() ; change markings based on breed of this dragon ; first, support random selection ; if dragonBreed == 4 ; dragonBreed = utility.randomInt(0,3) ; endif ; then assign the markings, either way. ; if dragonBreed == 1 ; equipItem(snowDragonSkin) ; elseif dragonBreed == 2 ; equipItem(tundraDragonSkin) ; elseif dragonBreed == 3 ; equipItem(forestDragonSkin) ; endif ; Block rewritten by USKP which fixes bug of respawned dragons not burning up or giving the player a soul if !isDead() if isGhost() ; redundancy check to prevent invincible, "ghosted" dragons from respawning. setGhost(FALSE) endif ; Block rewritten by tarlazo to fix a possible rare glitch as consequence of animation events registered for a dead dragon registerForAnimationEvent(self, "DragonLandEffect") registerForAnimationEvent(self, "DragonForcefulLandEffect") registerForAnimationEvent(self, "DragonTakeoffEffect") registerForAnimationEvent(self, "DragonBiteEffect") registerForAnimationEvent(self, "DragonTailAttackEffect") registerForAnimationEvent(self, "DragonLeftWingAttackEffect") registerForAnimationEvent(self, "DragonRightWingAttackEffect") registerForAnimationEvent(self, "DragonPassByEffect") registerForAnimationEvent(self, "flightCrashLandStart") ; Considered temp for showing injury FX test registerForAnimationEVENT(self, "DragonKnockbackEvent") gotoState("alive") endif ; registerForAnimationEvent(self, "DragonLandEffect") ; registerForAnimationEvent(self, "DragonForcefulLandEffect") ; registerForAnimationEvent(self, "DragonTakeoffEffect") ; registerForAnimationEvent(self, "DragonBiteEffect") ; registerForAnimationEvent(self, "DragonTailAttackEffect") ; registerForAnimationEvent(self, "DragonLeftWingAttackEffect") ; registerForAnimationEvent(self, "DragonRightWingAttackEffect") ; registerForAnimationEvent(self, "DragonPassByEffect") ; registerForAnimationEvent(self, "flightCrashLandStart") ; Considered temp for showing injury FX test ; registerForAnimationEVENT(self, "DragonKnockbackEvent") endEVENT Event OnLocationChange(Location akOldLoc, Location akNewLoc) if !isDead() && isGhost() ; redundancy check to prevent invincible, "ghosted" dragons from respawning. setGhost(FALSE) endif EndEvent STATE alive Event OnCombatStateChanged(Actor akTarget, int aeCombatState) if !isDead() && isGhost() ; redundancy check to prevent invincible, "ghosted" dragons from respawning. setGhost(FALSE) endif endEvent EVENT onAnimationEvent(objectReference deliverator, string eventName) ; debug.trace("AnimEvent: " + eventName + " delivered by Dragon ("+self+") ") if (eventName == "DragonLandEffect") ; ;debug.trace("Dragon AnimPayLoad: DragonLandEffect") game.shakeCamera(self, 1) game.shakeController(95, 95, 2) KnockAreaEffect(1, getLength()) animateFOV() ; call the FOV function PlayImpactEffect(FXDragonTakeoffImpactSet, "NPC Pelvis", 0, 0, -1, 512) elseIf (eventName == "DragonForcefulLandEffect") ; ;debug.trace("Dragon AnimPayLoad: DragonForcefulLandEffect") PlayImpactEffect(FXDragonLandingImpactSet, "NPC Pelvis", 0, 0, -1, 512) KnockAreaEffect(1, 2*getLength()) ;notification ("Dragon Forceful Land Effect") elseIf (eventName == "DragonTakeoffEffect") ; debug.trace("Dragon AnimPayLoad: DragonTakeoffEffect") PlayImpactEffect(FXDragonTakeoffImpactSet, "NPC Tail8", 0, 0, -1, 2048) elseIf (eventName == "DragonBiteEffect") ;Removed spit effect on 6/1/10. Leaving logic in case we need to sub in other fx or sounds. ; ;debug.trace("Dragon ("+self+") AnimPayLoad: DragonBiteEffect") ;DragonBiteFX.Play(Self, 2) ;notification ("Dragon Bite Effect") elseIf (eventName == "DragonTailAttackEffect") ; ;debug.trace(" Dragon AnimPayoload: DragonTailAttackEffect") PlayImpactEffect(FXDragonTailstompImpactSet, "NPC Tail8", 0, 0, -1, 512) ;notification("Dragon Tail Attack Effect") elseIf (eventName == "DragonLeftWingAttackEffect") ; ;debug.trace("Dragon AnimPayLoad: DragonLeftWingAttackEffect") PlayImpactEffect(FXDragonTailstompImpactSet, "NPC LHand", 0, 0, -1, 512) ;notification ("Dragon Left Wing Attack Effect") elseIf (eventName == "DragonRightWingAttackEffect") ; ;debug.trace("Dragon AnimPayLoad: DragonRightWingAttackEffect") PlayImpactEffect(FXDragonTailstompImpactSet, "NPC RHand", 0, 0, -1, 512) ;notification ("Dragon Right Wing Attack Effect") elseIf (eventName == "DragonPassByEffect") NPCDragonFlyby.Play(self) game.shakeCamera(self, 0.85) game.shakeController(0.65, 0.65, 0.5) ;elseIf (eventName == "flightCrashLandStart") ;Removed by mark since leaking magic is a bust. May replace with leaking blood at some point as a second test. ; apply injury FX art when I crash land. ;FXinjuryLeaks.play(self, -1) elseIf (eventName == "DragonKnockbackEvent") ; dragon needs to stagger everyone in radius a bit larger than my length ; ;debug.trace(self + " is knocking back actors within " + 1.5*getLength() + " of self @ " + self.x + ", " + self.y) ;self.placeAtMe(knockBackExplosion) KnockAreaEffect(1, 1.5*getLength()) animateFOV(1.5*getLength()) endif endEVENT EVENT onDeath(actor killer) DispelAllSpells() gotoState("deadDisintegrated") endEVENT endSTATE STATE deadDisintegrated ; nothing happens here - just dead endSTATE ; _____________ ;| | ;| FUNCTIONS | ;|_____________| function AnimateFOV(float fFOVfalloff = 1600.0) ; Function that animates FOV with an ismod. Declaring here in case needed frequently float playerDist = player.getDistance(self) ; get and store the player's current distance from me if playerDist < fFOVfalloff float FOVpower = (1- (1/(fFOVfalloff/(playerDist)))) ; consider offset to compensate for collision size if FOVpower > 1.0 FOVpower = 1.0 ; clamp to prevent wacky values endif dragonFOVfx.apply(FOVpower) ;animated FOV effect. Strength based on distance from player endif endFunction