PrometheusTS Posted December 4, 2016 Share Posted December 4, 2016 (edited) Hello , I created a script set that needs to do the following : 1 Transform into a new race the NPC if attacked2 Transform back the NPC into human if the attack stops or if dies or enters bleedout ... The problems I am having is that 1 When the player starts interaction with the npc attacking it it starts combat then after when the transformationhappens it stops to fight , instead gets to non aggressive state ... 2 IF the player keeps attacking the transformed NPC and reaches the bleedout stage or death stage , the NPC transforms to human but soon after transforms back to monster state.... As starting base I used a mix of wolf and vampire transfomations , I created a different race for the monster so I adapted to that . How can I fix those errors? This is the first script that is attached to the npcScriptname Prom_Wolfwitchtransformation extends ActorQuest Property PROM_Wolfwitchgreet AutoSPELL Property WolfWitchChange AutoSPELL Property WolfWitchChangeback AutoFunction Transform() ; do nothing by defaultEndFunctionFunction Transformback() ; do nothing by defaultEndFunctionAuto State human Function Transform() GoToState("wolf") StopCombat() StopCombatAlarm() WolfWitchChange.Cast(self) ; SetAv("aggression", 3) ; SetAv("confidence", 4) StartCombat(Game.GetPlayer()) EndFunction Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) Transform() EndEventEndStateState wolfFunction Transformback() GoToState("human") StopCombatAlarm() WolfWitchChangeback.Cast(self) StopCombat()EndFunction Event OnEnterBleedout() Transformback() Debug.Trace("We entered bleedout...") SetAv("aggression", 0) endEventEvent OnDeath(Actor akKiller) Debug.Trace("We entered bleedout...") Transformback() ; SetAv("aggression", 0) endEventEvent OnBeginState() UnregisterForUpdate() ; being overly cautious EndEventEndStateState human Event OnBeginState() UnregisterForUpdate() ; being overly cautious EndEventEndStateEvent OnLoad() RegisterForSingleUpdate(1)EndEvent Thenthe other scrit that is instead for the animation fx tranformations one from human to monsterScriptname Prom_ZelataChange extends activemagiceffectVisualEffect property FeedBloodVFX autoIdle Property IdleVampireTransformation autoSound Property NPCVampireTransformation autoSound Property NPCVampireTransformationB2D autoSound Property NPCVampireTransformationB3D autoExplosion Property FXVampChangeExplosion autoRace Property Zelatarace AutoRace Property human AutoEvent OnEffectStart(Actor Target, Actor Caster)Debug.Trace("VAMPIRE: Starting change anim...")if (Target.GetActorBase().GetRace() != Zelatarace ) ; Add the tranformation wolf skin Armor effect ; Target.equipitem(VampireSkinFXArmor,False,True) RegisterForAnimationEvent(Target, "SetRace")Target.PlayIdle(IdleVampireTransformation)Utility.Wait(10)TransformIfNecessary(Target)endifEndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)Debug.Trace("VAMPIRE: Getting anim event -- " + akSource + " " + asEventName)if (asEventName == "SetRace")TransformIfNecessary(akSource as Actor)endifEndEventFunction TransformIfNecessary(Actor Target) if (Target == None); Debug.Trace("WEREWOLF: Trying to transform something that's not an actor; bailing out.", 2) return endif UnRegisterForAnimationEvent(Target, "SetRace") Actor PlayerRef = Game.GetPlayer() Race currRace = Target.GetRace() if (currRace != Zelatarace ); Debug.Trace("VAMPIRE: VISUAL: Setting race " + Zelatarace + " on " + Target) if (Target != Game.GetPlayer()); Debug.Trace("WEREWOLF: VISUAL: Target is not player, doing the transition here.") Target.SetRace(Zelatarace) ;TEEN WOLF target.placeatme(FXVampChangeExplosion) if target == PlayerRef DLC1VampireChangeStagger.Cast(Target, Target) endif else endif endifEndFunctionSPELL Property DLC1VampireChangeStagger Auto and one from monster to humanScriptname Prom_ZelataChangeBack extends activemagiceffectVisualEffect property FeedBloodVFX autoIdle Property IdleVampireTransformation autoSound Property NPCVampireTransformation autoSound Property NPCVampireTransformationB2D autoSound Property NPCVampireTransformationB3D autoExplosion Property FXVampChangeExplosion autoRace Property Zelatarace AutoRace Property human AutoSPELL Property DLC1VampireChangeStagger AutoEvent OnEffectStart(Actor Target, Actor Caster)Debug.Trace("VAMPIRE: Starting change anim...")if (Target.GetActorBase().GetRace() != human ) ; Add the tranformation wolf skin Armor effect ; Target.equipitem(VampireSkinFXArmor,False,True) RegisterForAnimationEvent(Target, "SetRace")Target.PlayIdle(IdleVampireTransformation)TransformbackIfNecessary(Target)endifEndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName)Debug.Trace("VAMPIRE: Getting anim event -- " + akSource + " " + asEventName)if (asEventName == "SetRace")TransformbackIfNecessary(akSource as Actor)endifEndEventFunction TransformbackIfNecessary(Actor Target) if (Target == None); Debug.Trace("WEREWOLF: Trying to transform something that's not an actor; bailing out.", 2) return endif UnRegisterForAnimationEvent(Target, "SetRace") Actor PlayerRef = Game.GetPlayer() Race currRace = Target.GetRace() if (currRace != Human) if (Target != Game.GetPlayer()) Target.SetRace(Human) ;TEEN WOLF target.placeatme(FXVampChangeExplosion) if target == PlayerRef DLC1VampireChangeStagger.Cast(Target, Target) endif else endif endifEndFunction Edited December 4, 2016 by PROMETHEUS_ts Link to comment Share on other sites More sharing options...
Lisselli Posted December 4, 2016 Share Posted December 4, 2016 (edited) Problem 1 and 2: It looks like the first script is working as intended. OnHit calls Transform() which then changes the State to Wolf. When the NPC(now a werewolf presumably) enters bleedout, TransformBack() is called and the State is back to Human state. His aggression is then changed to 0 which makes him non aggressive, when the player hits him again, it starts all over again. If that's not how you want it, what are you trying to accomplish? Edited December 4, 2016 by Lisselli Link to comment Share on other sites More sharing options...
PrometheusTS Posted December 4, 2016 Author Share Posted December 4, 2016 I want that the witch () transforms to a demivampire ( a model I did ) when the player either attacks her or after a wrong dialogue answer... Then if she enters bleedout she should get back to normal human form , if she dies also shoudl get to normal human form and should get to normal also if there is no longer a fight like if the player casts some kind of spell or if she is no longer anger at the player. Actually I woul dneed someone to help me script the whole thing as I am not a scripter really and I am getting mad at this lol ! Link to comment Share on other sites More sharing options...
PrometheusTS Posted December 5, 2016 Author Share Posted December 5, 2016 Any help? Link to comment Share on other sites More sharing options...
PrometheusTS Posted December 6, 2016 Author Share Posted December 6, 2016 Update, but still not working as intended. also I wanted that when she enters bleedout she asks mercy and asks the player to spare her , but not sure how to , I tried to force the bleedout but she doesnt go into that animation loop .The problem is that beeing in the autostate humanfinal it doesn't transform back to monster if attacked again ! Scriptname Prom_Wolfwitchtransformation extends Actor Quest Property PROM_Wolfwitchgreet Auto SPELL Property WolfWitchChange Auto SPELL Property WolfWitchChangeback Auto Faction Property Hyborianhutfaction Auto Actor Property wolf Auto Function Transform() ; do nothing by default EndFunction Function Transformback() ; do nothing by default EndFunction Auto State human Function Transform() GoToState("Demivampire") StopCombat() StopCombatAlarm() WolfWitchChange.Cast(self) SetAv("aggression", 3) SetAv("confidence", 4) StartCombat(Game.GetPlayer()) EndFunction Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if akAggressor == game.getPlayer() wolf.SetAv("aggression", 3) if PROM_Wolfwitchgreet.GetStage()<20 Transform() PROM_Wolfwitchgreet.SetStage(20) elseif (PROM_Wolfwitchgreet.GetStage()<35) && (PROM_Wolfwitchgreet.GetStage()>=20) PROM_Wolfwitchgreet.SetStage(22) elseif PROM_Wolfwitchgreet.GetStage()==35 PROM_Wolfwitchgreet.SetStage(45) elseif PROM_Wolfwitchgreet.GetStage()==40 PROM_Wolfwitchgreet.SetStage(45) endIf endIf EndEvent EndState State Demivampire Function Transformback() GoToState("humanfinal") StopCombatAlarm() WolfWitchChangeback.Cast(self) StopCombat() EndFunction Event OnEnterBleedout() Transformback() ;Debug.Trace("We entered bleedout...") SetAv("aggression", 0) Debug.SendAnimationEvent(self, "BleedOutStart") Utility.Wait(5.0) Debug.SendAnimationEvent(self, "BleedOutStop") endEvent Event OnDeath(Actor akKiller) ;Debug.Trace("We entered bleedout...") Transformback() ; SetAv("aggression", 0) Game.GetPlayer().AddToFaction(Hyborianhutfaction) wolf.RemoveFromFaction(Hyborianhutfaction) wolf.SetAv("aggression", 3) endEvent ; Event OnCombatStateChanged(Actor akTarget, int aeCombatState) ; if (aeCombatState == 0) ; if (PROM_Wolfwitchgreet.GetStage()<=35) ; Transformback() ; SetAv("aggression", 0) ; endIf ; endIf ; endEvent EndState State humanfinal Event OnBeginState() UnregisterForUpdate() ; being overly cautious EndEvent EndState Event OnLoad() RegisterForSingleUpdate(1) EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts