From e6a2f6eab8d24ba468861c5d681a2045fdbbd864 Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Mon, 18 Jul 2022 21:41:30 +0200 Subject: [PATCH] Updates to animation system + rotating pokemon Also made useful tweaks to how battleflipped works --- .../BattleAnimations/BAEntityFaceRotate.vb | 54 +++++++++++++++++++ .../QueryObjects/AnimationQueryObject.vb | 46 +++++++++------- P3D/P3D.vbproj | 1 + P3D/Pokemon/Attacks/Fire/Ember.vb | 17 ++---- P3D/Pokemon/Attacks/Normal/Growl.vb | 8 +-- P3D/Pokemon/Attacks/Poison/PoisonSting.vb | 11 ++-- P3D/Pokemon/Attacks/Water/WaterGun.vb | 4 -- 7 files changed, 93 insertions(+), 48 deletions(-) create mode 100644 P3D/Battle/BattleAnimations/BAEntityFaceRotate.vb diff --git a/P3D/Battle/BattleAnimations/BAEntityFaceRotate.vb b/P3D/Battle/BattleAnimations/BAEntityFaceRotate.vb new file mode 100644 index 000000000..4ee959b3e --- /dev/null +++ b/P3D/Battle/BattleAnimations/BAEntityFaceRotate.vb @@ -0,0 +1,54 @@ +Public Class BAEntityFaceRotate + + Inherits BattleAnimation3D + + Dim TargetEntity As NPC + Dim TargetModel As Entity = Nothing + Dim EndFaceRotation As Integer + Dim TurnSteps As Integer = 0 + Dim TurnSpeed As Integer = 1 + Dim TurnTime As Single = 0.0F + Dim TurnDelay As Single = 0.0F + + Public Sub New(ByVal TargetEntity As NPC, ByVal TurnSteps As Integer, ByVal startDelay As Single, ByVal endDelay As Single, Optional ByVal EndFaceRotation As Integer = -1, Optional ByVal TurnSpeed As Integer = 1, Optional ByVal TurnDelay As Single = 0.25F, Optional TargetModel As Entity = Nothing) + MyBase.New(New Vector3(0.0F), TextureManager.DefaultTexture, New Vector3(1.0F), startDelay, endDelay) + If EndFaceRotation = -1 Then + Me.EndFaceRotation = TargetEntity.faceRotation + Else + Me.EndFaceRotation = EndFaceRotation + End If + Me.TargetModel = TargetModel + Me.TurnSteps = TurnSteps + Me.TargetEntity = TargetEntity + Me.TurnSpeed = TurnSpeed + Me.TurnDelay = TurnDelay + End Sub + + Public Overrides Sub DoActionActive() + If Me.TurnSteps > 0 Then + If Me.TurnTime <= 0.0F Then + Me.TargetEntity.faceRotation += Me.TurnSpeed + If Me.TargetEntity.faceRotation = 4 Then + Me.TargetEntity.faceRotation = 0 + End If + If Me.TargetModel IsNot Nothing Then + Me.TargetModel.Rotation = Entity.GetRotationFromInteger(Me.TargetEntity.faceRotation) + End If + Me.TurnSteps -= TurnSpeed.ToPositive() + Me.TurnTime = TurnDelay + Else + TurnDelay -= 0.1F + End If + Else + If Me.TargetEntity.faceRotation <> Me.EndFaceRotation Then + Me.TargetEntity.faceRotation = Me.EndFaceRotation + If Me.TargetModel IsNot Nothing Then + Me.TargetModel.Rotation = Entity.GetRotationFromInteger(Me.EndFaceRotation) + End If + Else + Me.Ready = True + End If + End If + End Sub + +End Class \ No newline at end of file diff --git a/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb b/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb index 187e3e7fc..1de9de2ac 100644 --- a/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb +++ b/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb @@ -105,21 +105,12 @@ Dim NewPosition As Vector3 If Not Position = Nothing Then If BattleFlipped = True Then - If CurrentEntity IsNot Nothing Then - NewPosition.X = CurrentEntity.Position.X - Position.X - NewPosition.Y = CurrentEntity.Position.Y + Position.Y - NewPosition.Z = CurrentEntity.Position.Z - Position.Z - Else - NewPosition = Position - End If + Position.X *= -1 + End If + If CurrentEntity IsNot Nothing Then + NewPosition = CurrentEntity.Position + Position Else - If CurrentEntity IsNot Nothing Then - NewPosition.X = CurrentEntity.Position.X + Position.X - NewPosition.Y = CurrentEntity.Position.Y + Position.Y - NewPosition.Z = CurrentEntity.Position.Z + Position.Z - Else - NewPosition = Position - End If + NewPosition = Position End If Else If CurrentEntity IsNot Nothing Then @@ -169,8 +160,12 @@ If Not BattleFlipped = Nothing Then If BattleFlipped = True Then - DestinationX -= DestinationX * 2.0F - DestinationZ -= DestinationZ * 2.0F + DestinationX *= -1.0F + DestinationZ *= -1.0F + If SpinZ = True Then + SpinXSpeed *= -1.0F + SpinZSpeed *= -1.0F + End If End If End If If CurrentEntity Is Nothing Then @@ -228,10 +223,25 @@ AnimationSequence.Add(baEntityRotate) If RotateModel IsNot Nothing Then - Dim baModelOpacity As BAEntityRotate = New BAEntityRotate(CType(RotateModel, Entity), False, RotationSpeedVector, EndRotation, startDelay, endDelay, DoXRotation, DoYRotation, DoZRotation, DoReturn) - AnimationSequence.Add(baModelOpacity) + Dim baModelRotate As BAEntityRotate = New BAEntityRotate(CType(RotateModel, Entity), False, RotationSpeedVector, EndRotation, startDelay, endDelay, DoXRotation, DoYRotation, DoZRotation, DoReturn) + AnimationSequence.Add(baModelRotate) End If + End Sub + + Public Sub AnimationTurnNPC(ByVal TurnSteps As Integer, ByVal startDelay As Single, ByVal endDelay As Single, Optional ByVal EndFaceRotation As Integer = -1, Optional ByVal TurnSpeed As Integer = 1, Optional ByVal TurnDelay As Single = 0.25F) + Dim TurnNPC As NPC = Nothing + Dim TurnModel As Entity = Nothing + If CurrentEntity IsNot Nothing Then + TurnNPC = CType(CurrentEntity, NPC) + If Me.CurrentModel IsNot Nothing Then + TurnModel = Me.CurrentModel + End If + End If + + Dim BAEntityFaceRotate As BAEntityFaceRotate = New BAEntityFaceRotate(TurnNPC, TurnSteps, startDelay, endDelay, EndFaceRotation, TurnSpeed, TurnDelay, TurnModel) + AnimationSequence.Add(BAEntityFaceRotate) + End Sub Public Sub AnimationScale(ByVal Entity As Entity, ByVal RemoveEntityAfter As Boolean, ByVal Grow As Boolean, ByVal EndSizeX As Single, ByVal EndSizeY As Single, ByVal EndSizeZ As Single, ByVal SizeSpeed As Single, ByVal startDelay As Single, ByVal endDelay As Single, Optional ByVal Anchors As String = "") Dim ScaleEntity As Entity diff --git a/P3D/P3D.vbproj b/P3D/P3D.vbproj index 21d4745de..0ef4f087a 100644 --- a/P3D/P3D.vbproj +++ b/P3D/P3D.vbproj @@ -27692,6 +27692,7 @@ + diff --git a/P3D/Pokemon/Attacks/Fire/Ember.vb b/P3D/Pokemon/Attacks/Fire/Ember.vb index 3cd1badab..00ec877a9 100644 --- a/P3D/Pokemon/Attacks/Fire/Ember.vb +++ b/P3D/Pokemon/Attacks/Fire/Ember.vb @@ -87,22 +87,13 @@ TextureYOffset = 32 End If Dim FireballEntity = MoveAnimation.SpawnEntity(New Vector3(-2.0, 0.0, 0.0), TextureManager.GetTexture("Textures\Battle\Fire\FireBall", New Rectangle(0, TextureYOffset, 32, 32), ""), New Vector3(0.5F), 1.0F) + MoveAnimation.AnimationMove(FireballEntity, True, -0.05, 0.0, 0.0, 0.05, False, True, 0.0, 1.0,, -0.5) - If BattleFlip = True Then - MoveAnimation.AnimationMove(FireballEntity, True, -0.05, 0.0, 0.0, 0.05, False, True, 0.0, 1.0,, 0.5) - Else - MoveAnimation.AnimationMove(FireballEntity, True, -0.05, 0.0, 0.0, 0.05, False, True, 0.0, 1.0,, -0.5) - End If MoveAnimation.AnimationPlaySound("Battle\Attacks\Fire\Ember_Hit", 4, 0) - Dim Fire1Position As Vector3 = New Vector3(-0.25, -0.25, -0.25) - Dim Fire3Position As Vector3 = New Vector3(0.25, -0.25, 0.25) - If BattleFlip = True Then - Fire1Position = New Vector3(-0.25, -0.25, 0.25) - Fire3Position = New Vector3(0.25, -0.25, -0.25) - End If - Dim FireEntity1 As Entity = MoveAnimation.SpawnEntity(Fire1Position, TextureManager.GetTexture("Textures\Battle\Fire\Ember", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 3, 0) + + Dim FireEntity1 As Entity = MoveAnimation.SpawnEntity(New Vector3(-0.25, -0.25, -0.25), TextureManager.GetTexture("Textures\Battle\Fire\Ember", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 3, 0) Dim FireEntity2 As Entity = MoveAnimation.SpawnEntity(New Vector3(0, -0.25, 0), TextureManager.GetTexture("Textures\Battle\Fire\Ember", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 3, 0) - Dim FireEntity3 As Entity = MoveAnimation.SpawnEntity(Fire3Position, TextureManager.GetTexture("Textures\Battle\Fire\Ember", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 3, 0) + Dim FireEntity3 As Entity = MoveAnimation.SpawnEntity(New Vector3(0.25, -0.25, 0.25), TextureManager.GetTexture("Textures\Battle\Fire\Ember", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 3, 0) MoveAnimation.AnimationChangeTexture(FireEntity1, False, TextureManager.GetTexture("Textures\Battle\Fire\Ember", New Rectangle(0, 32, 32, 32), ""), 3.75, 0) MoveAnimation.AnimationChangeTexture(FireEntity2, False, TextureManager.GetTexture("Textures\Battle\Fire\Ember", New Rectangle(0, 32, 32, 32), ""), 3.75, 0) diff --git a/P3D/Pokemon/Attacks/Normal/Growl.vb b/P3D/Pokemon/Attacks/Normal/Growl.vb index 2e943f380..588d838d9 100644 --- a/P3D/Pokemon/Attacks/Normal/Growl.vb +++ b/P3D/Pokemon/Attacks/Normal/Growl.vb @@ -66,12 +66,8 @@ Dim MoveAnimation As AnimationQueryObject = New AnimationQueryObject(CurrentEntity, BattleFlip) MoveAnimation.AnimationPlaySound(CStr(CurrentPokemon.Number), 0, 0,, True) - Dim SoundwaveEntity As Entity - ' If BattleFlip = False Then - SoundwaveEntity = MoveAnimation.SpawnEntity(New Vector3(0.25, -0.25, 0), TextureManager.GetTexture("Textures\Battle\Normal\Growl", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 0, 1) - 'Else - ' SoundwaveEntity = MoveAnimation.SpawnEntity(New Vector3(-0.25, -0.25, 0), TextureManager.GetTexture("Textures\Battle\Normal\Growl", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 0, 1) - 'End If + Dim SoundwaveEntity As Entity = MoveAnimation.SpawnEntity(New Vector3(0.25, -0.25, 0), TextureManager.GetTexture("Textures\Battle\Normal\Growl", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 0, 1) + MoveAnimation.AnimationChangeTexture(SoundwaveEntity, False, TextureManager.GetTexture("Textures\Battle\Normal\Growl", New Rectangle(0, 32, 32, 32), ""), 1, 1) MoveAnimation.AnimationChangeTexture(SoundwaveEntity, False, TextureManager.GetTexture("Textures\Battle\Normal\Growl", New Rectangle(0, 0, 32, 32), ""), 2, 1) MoveAnimation.AnimationChangeTexture(SoundwaveEntity, True, TextureManager.GetTexture("Textures\Battle\Normal\Growl", New Rectangle(0, 32, 32, 32), ""), 3, 1) diff --git a/P3D/Pokemon/Attacks/Poison/PoisonSting.vb b/P3D/Pokemon/Attacks/Poison/PoisonSting.vb index 745fa6993..28315724f 100644 --- a/P3D/Pokemon/Attacks/Poison/PoisonSting.vb +++ b/P3D/Pokemon/Attacks/Poison/PoisonSting.vb @@ -88,19 +88,16 @@ TextureYOffset = 16 End If - Dim Bubble1Position As Vector3 = New Vector3(-0.25, -0.25, -0.25) - Dim Bubble2Position As Vector3 = New Vector3(0, -0.25, 0) - Dim Bubble3Position As Vector3 = New Vector3(0.25, -0.25, 0.25) - If BattleFlip = True Then - Bubble1Position = New Vector3(-0.25, -0.25, 0.25) - Bubble3Position = New Vector3(0.25, -0.25, -0.25) - End If Dim StingerEntity As Entity = MoveAnimation.SpawnEntity(New Vector3(-2.0, 0, 0.0), TextureManager.GetTexture("Textures\Battle\Poison\Stinger", New Rectangle(0, TextureYOffset, 16, 16), ""), New Vector3(0.2F), 1) MoveAnimation.AnimationMove(StingerEntity, True, 0.0, 0.0, 0.0, 0.08, False, False, 0.0, 0.0) MoveAnimation.AnimationPlaySound("Battle\Attacks\Poison\PoisonSting_Hit", 1, 0) + Dim Bubble1Position As Vector3 = New Vector3(-0.25, -0.25, -0.25) + Dim Bubble2Position As Vector3 = New Vector3(0, -0.25, 0) + Dim Bubble3Position As Vector3 = New Vector3(0.25, -0.25, 0.25) + Dim BubbleEntity1 As Entity = MoveAnimation.SpawnEntity(Bubble1Position, TextureManager.GetTexture("Textures\Battle\Poison\Bubble", New Rectangle(0, 0, 32, 32), ""), New Vector3(0.5F), 1, 2, 1) MoveAnimation.AnimationChangeTexture(BubbleEntity1, False, TextureManager.GetTexture("Textures\Battle\Poison\Bubble", New Rectangle(0, 32, 32, 32), ""), 3, 1) diff --git a/P3D/Pokemon/Attacks/Water/WaterGun.vb b/P3D/Pokemon/Attacks/Water/WaterGun.vb index fa48cb108..5fcde42a9 100644 --- a/P3D/Pokemon/Attacks/Water/WaterGun.vb +++ b/P3D/Pokemon/Attacks/Water/WaterGun.vb @@ -71,10 +71,6 @@ Dim WaterDrop1Position As Vector3 = New Vector3(-0.25, 0.25, -0.25) Dim WaterDrop2Position As Vector3 = New Vector3(0, 0.25, 0) Dim WaterDrop3Position As Vector3 = New Vector3(0.25, 0.25, 0.25) - If BattleFlip = True Then - WaterDrop1Position = New Vector3(-0.25, 0.25, 0.25) - WaterDrop3Position = New Vector3(0.25, 0.25, -0.25) - End If Dim WaterDropEntity1 As Entity = MoveAnimation.SpawnEntity(WaterDrop1Position, TextureManager.GetTexture("Textures\Battle\Water\WaterGun", New Rectangle(0, 32, 16, 16), ""), New Vector3(0.5F), 0.75F, 5, 0) Dim WaterDropEntity2 As Entity = MoveAnimation.SpawnEntity(WaterDrop2Position, TextureManager.GetTexture("Textures\Battle\Water\WaterGun", New Rectangle(0, 32, 16, 16), ""), New Vector3(0.5F), 0.75F, 5, 0)