Jump to content

How to script this?


Recommended Posts

Hello , I created a script set that needs to do the following :

 

 

1 Transform into a new race the NPC if attacked

2 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 npc

Scriptname Prom_Wolfwitchtransformation extends Actor
Quest Property PROM_Wolfwitchgreet Auto
SPELL Property WolfWitchChange Auto
SPELL Property WolfWitchChangeback Auto






Function Transform()
; do nothing by default
EndFunction

Function Transformback()
; do nothing by default
EndFunction


Auto 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()
EndEvent

EndState

State wolf

Function Transformback()
GoToState("human")
StopCombatAlarm()
WolfWitchChangeback.Cast(self)
StopCombat()
EndFunction



Event OnEnterBleedout()
Transformback()
Debug.Trace("We entered bleedout...")
SetAv("aggression", 0)

endEvent

Event OnDeath(Actor akKiller)
Debug.Trace("We entered bleedout...")
Transformback()
; SetAv("aggression", 0)

endEvent

Event OnBeginState()
UnregisterForUpdate() ; being overly cautious
EndEvent
EndState

State human
Event OnBeginState()
UnregisterForUpdate() ; being overly cautious
EndEvent
EndState


Event OnLoad()
RegisterForSingleUpdate(1)
EndEvent

 

 

Thenthe other scrit that is instead for the animation fx tranformations

 

one from human to monster

Scriptname Prom_ZelataChange extends activemagiceffect

VisualEffect property FeedBloodVFX auto
Idle Property IdleVampireTransformation auto
Sound Property NPCVampireTransformation auto
Sound Property NPCVampireTransformationB2D auto
Sound Property NPCVampireTransformationB3D auto
Explosion Property FXVampChangeExplosion auto
Race Property Zelatarace Auto
Race Property human Auto



Event 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)
endif



EndEvent


Event OnAnimationEvent(ObjectReference akSource, string asEventName)
Debug.Trace("VAMPIRE: Getting anim event -- " + akSource + " " + asEventName)
if (asEventName == "SetRace")
TransformIfNecessary(akSource as Actor)
endif
EndEvent

Function 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

endif
EndFunction




SPELL Property DLC1VampireChangeStagger Auto

 

and one from monster to human

Scriptname Prom_ZelataChangeBack extends activemagiceffect

VisualEffect property FeedBloodVFX auto
Idle Property IdleVampireTransformation auto
Sound Property NPCVampireTransformation auto
Sound Property NPCVampireTransformationB2D auto
Sound Property NPCVampireTransformationB3D auto
Explosion Property FXVampChangeExplosion auto
Race Property Zelatarace Auto
Race Property human Auto
SPELL Property DLC1VampireChangeStagger Auto



Event 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)
endif


EndEvent


Event OnAnimationEvent(ObjectReference akSource, string asEventName)
Debug.Trace("VAMPIRE: Getting anim event -- " + akSource + " " + asEventName)
if (asEventName == "SetRace")
TransformbackIfNecessary(akSource as Actor)
endif
EndEvent



Function 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

endif
EndFunction




 

Edited by PROMETHEUS_ts
Link to comment
Share on other sites

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 by Lisselli
Link to comment
Share on other sites

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...