Exemple #1
0
 public override void OnUpdate()
 {
     if (!this.bActive)
     {
         this.xOwner.xTransform.v2ServerPos = this.xOwner.xTransform.v2Pos;
         return;
     }
     if (!this.bInited)
     {
         this.xOwner.xRenderComponent.SwitchAnimation((ushort)((byte)Program.GetTheGame().randomInLogic.Next(4)), Animation.CancelOptions.UseAnimationDefault);
         this.bAggro = true;
         this.bInited = true;
         this.iNumberOfPlayers = Program.GetTheGame().dixPlayers.Count;
     }
     if (this.xBullet != null)
     {
         this.xBullet.xEffect.xTransform.v2Pos += this.xBullet.v2TravelDir;
         if (this.xBullet.xEffect.xTransform.v2Pos.Y >= 310f)
         {
             this.xSwallowedPlayer.xEntity.xTransform.SetBoth(this.xBullet.xEffect.xTransform.v2Pos);
             Program.GetTheGame()._CollisionMaster_ApplyAndSendPlayerPushback(this.xSwallowedPlayer.xEntity, new Vector2(0f, -30f));
             this.xSwallowedPlayer.xEntity.xRenderComponent.SwitchAnimation(14, Animation.CancelOptions.IgnoreIfPlaying);
             Program.GetTheGame()._Player_TakeDamage(this.xSwallowedPlayer, 20, 0);
             this.xSwallowedPlayer.xEntity.xCollisionComponent.ActivateGroup(CollisionComponent.ColliderGroup.All);
             Program.GetTheGame()._EffectMaster_AddEffect(new SortedAnimated(this.xBullet.xEffect.xTransform.v2Pos, SortedAnimated.SortedAnimatedEffects.SlimeDeath));
             this.xBullet.xEffect.bToBeDestroyed = true;
             this.xBullet = null;
             this.xSwallowedPlayer = null;
         }
     }
     if (this.xTreat.xPlayerLockedOnto == this.xPlayerLockedOnto && !this.bIsLead)
     {
         if (Vector2.Distance(this.xTreat.xOwner.xTransform.v2Pos, this.xOwner.xTransform.v2Pos) > 70f)
         {
             this.fRotDir = this.xTreat.fRotDir;
         }
         else
         {
             this.fRotDir = -this.xTreat.fRotDir;
         }
     }
     if (this.v2RandMoveDir != Vector2.Zero)
     {
         float fSpeedBonus = 1f;
         this.xOwner.xTransform.v2Pos += this.xOwner.xBaseStats.fMovementSpeed * this.v2RandMoveDir * fSpeedBonus;
     }
     else if (Utility.IsWithinRange((int)this.xOwner.xRenderComponent.iActiveAnimation, 4, 7))
     {
         this.xOwner.xRenderComponent.SwitchAnimation((ushort)this.xOwner.byAnimationDirection, Animation.CancelOptions.IgnoreIfPlaying);
     }
     if (this.iDowned > 0)
     {
         this.iDowned--;
         ushort lol = 12;
         if (this.xOwner.byAnimationDirection == 3)
         {
             lol = 13;
         }
         if (this.iDowned == 0)
         {
             this.xOwner.xRenderComponent.SwitchAnimation(lol, Animation.CancelOptions.UseAnimationDefault);
         }
     }
     this.iCounter++;
     this.iTimeSinceLastAttack++;
     this.iNextHardUpdate--;
     this.iWannaCircleBaby--;
     if (this.enCurrentAction == Trick_Original.CurrentAction.Sucking)
     {
         if (this.xOwner.xRenderComponent.iActiveAnimation == 13)
         {
             List<WorldActor> lxTargets = Program.GetTheGame()._Enemy_GetTargetList(this, true);
             float fRange = 60f;
             float fSwallowRange = 10f;
             float fMaxEffect = 12f;
             float fMinEffect = 3f;
             float fClosest = 10000f;
             for (int i = 0; i < lxTargets.Count; i++)
             {
                 if (!(this.xOwner.xTransform.v2Pos == lxTargets[i].xTransform.v2Pos))
                 {
                     Vector2 v2Dir = Vector2.Normalize(this.xOwner.xTransform.v2Pos + new Vector2(0f, 8f) - lxTargets[i].xTransform.v2Pos);
                     if (this.xOwner.xTransform.v2Pos.Y + 8f <= lxTargets[i].xTransform.v2Pos.Y)
                     {
                         float fDistance = Vector2.Distance(this.xOwner.xTransform.v2Pos, lxTargets[i].xTransform.v2Pos);
                         fClosest = fDistance;
                         if (fDistance < fRange)
                         {
                             if (fDistance <= fSwallowRange)
                             {
                                 if (lxTargets[i].enEntityType == IEntity.EntityType.Player)
                                 {
                                     this.Swallow((lxTargets[i] as PlayerEntity).Owner);
                                     return;
                                 }
                             }
                             else
                             {
                                 float fEffect = (1f - fDistance / fRange) * (fMaxEffect - fMinEffect) + fMinEffect;
                                 lxTargets[i].xTransform.v2SmoothPush = v2Dir * fEffect;
                             }
                         }
                     }
                 }
             }
             if (this.iCounter >= 300 || fClosest > fRange)
             {
                 this.xOwner.xRenderComponent.SwitchAnimation(14, Animation.CancelOptions.IgnoreIfPlaying);
                 this.enCurrentAction = Trick_Original.CurrentAction.WaitTo0;
                 this.iCounter = -60;
             }
         }
     }
     else if (this.enCurrentAction == Trick_Original.CurrentAction.Swallowing)
     {
         if (this.xSwallowPlayerRC != null)
         {
             this.xSwallowPlayerRC.fVirtualHeight = 20f;
             TransformComponent expr_531_cp_0 = this.xSwallowPlayerRC.xTransform;
             expr_531_cp_0.v2Pos.Y = expr_531_cp_0.v2Pos.Y - 0.15f;
             this.xSwallowPlayerRC.fScale *= 0.96f;
             this.xSwallowPlayerRC.fRotation += 0.3f;
             this.xSwallowPlayerRC.fAlpha -= 0.025f;
         }
         if (this.iCounter == 1)
         {
             if (this.xSwallowedPlayer != null)
             {
                 this.xSwallowedPlayer.xEntity.xRenderComponent.SwitchAnimation(41000, Animation.CancelOptions.IgnoreIfPlaying);
             }
             SnatchRenderComponent expr_5BE_cp_0 = this.xSwallowPlayerRC;
             expr_5BE_cp_0.v2Offset.Y = expr_5BE_cp_0.v2Offset.Y - 15f;
             TransformComponent expr_5DF_cp_0 = this.xSwallowPlayerRC.xTransform;
             expr_5DF_cp_0.v2Pos.Y = expr_5DF_cp_0.v2Pos.Y - 15f;
         }
         if (this.iCounter == 36)
         {
             this.xOwner.xRenderComponent.SwitchAnimation(15, Animation.CancelOptions.IgnoreIfPlaying);
         }
         if (this.iCounter == 40)
         {
             Program.GetTheGame().xRenderMaster.UnregisterRenderComponenent(this.xSwallowPlayerRC);
             this.xSwallowPlayerRC = null;
         }
     }
     else if (this.enCurrentAction == Trick_Original.CurrentAction.Swallowed)
     {
         if (this.iCounter == 120)
         {
             this.xOwner.xRenderComponent.SwitchAnimation(22, Animation.CancelOptions.IgnoreIfPlaying);
         }
     }
     else if (this.enCurrentAction == Trick_Original.CurrentAction.WaitTo0)
     {
         if (this.iCounter == 0)
         {
             this.enCurrentAction = Trick_Original.CurrentAction.WaitingForlead;
         }
     }
     else if (this.xOwner.xRenderComponent.GetCurrentAnimation().bIsMoveCancellable)
     {
         if (this.enCurrentAction == Trick_Original.CurrentAction.Sumthin)
         {
             Vector2 v2Look = this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos;
             v2Look.Normalize();
             byte lolKuk = Utility.ConvertV2DirectionToClosestByteDirection(v2Look);
             this.xOwner.xRenderComponent.SwitchAnimation((ushort)lolKuk, Animation.CancelOptions.UseAnimationDefault);
         }
         if (this.iNextHardUpdate <= 0)
         {
             this.iNextHardUpdate = 10;
             Game1 Lord = Program.GetTheGame();
             Random knark = Program.GetTheGame().randomInLogic;
             Rectangle arg_732_0 = Program.GetTheGame().xLevelMaster.xCurrentLevel.recCurrentBounds;
             float fClosest2 = 50000f;
             PlayerEntity xClosestPlayer = null;
             if (this.bAggro)
             {
                 foreach (PlayerView xPlayer in Lord.dixPlayers.Values)
                 {
                     if (!xPlayer.xViewStats.bIsDead && this.xTreat.xSwallowedPlayer != xPlayer)
                     {
                         float fDist = Vector2.Distance(xPlayer.xEntity.xTransform.v2Pos, this.xOwner.xTransform.v2Pos);
                         if (fDist < this.fAggroDistance && fDist < fClosest2)
                         {
                             xClosestPlayer = xPlayer.xEntity;
                             fClosest2 = fDist;
                         }
                     }
                 }
             }
             if (xClosestPlayer == null)
             {
                 this.iWannaCircleBaby = 0;
             }
             if (xClosestPlayer != null)
             {
                 this.xPlayerLockedOnto = xClosestPlayer;
                 if (this.iWannaCircleBaby == 0)
                 {
                     this.iWannaCircleBaby = 60 + knark.Next(230);
                 }
                 if (this.bIsLead && knark.Next(2) == 0)
                 {
                     this.fRotDir *= -1;
                 }
                 Vector2 v2Dirr = this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos;
                 v2Dirr.Normalize();
                 this.fCurrentRotation = (float)Math.Atan2((double)v2Dirr.X, (double)(-(double)v2Dirr.Y));
                 float fDistance2 = Vector2.Distance(this.xPlayerLockedOnto.xTransform.v2Pos, this.xOwner.xTransform.v2Pos);
                 if (this.bIsLead && this.enCurrentAction == Trick_Original.CurrentAction.WaitingForlead && fDistance2 <= this.fFurthestAllowedDistance && fDistance2 >= this.fMinAttackDistance)
                 {
                     if (MathHelper.Distance(this.xOwner.xTransform.v2Pos.Y, this.xPlayerLockedOnto.xTransform.v2Pos.Y) < 10f)
                     {
                         if (this.xOwner.xTransform.v2Pos.X < this.xPlayerLockedOnto.xTransform.v2Pos.X)
                         {
                             this.byChosenDirection = 1;
                             this.enCurrentAction = Trick_Original.CurrentAction.SurroundingAsLead;
                         }
                         else
                         {
                             this.byChosenDirection = 3;
                             this.enCurrentAction = Trick_Original.CurrentAction.SurroundingAsLead;
                         }
                     }
                     else if (MathHelper.Distance(this.xOwner.xTransform.v2Pos.X, this.xPlayerLockedOnto.xTransform.v2Pos.X) < 10f)
                     {
                         if (this.xOwner.xTransform.v2Pos.Y < this.xPlayerLockedOnto.xTransform.v2Pos.Y)
                         {
                             this.byChosenDirection = 2;
                             this.enCurrentAction = Trick_Original.CurrentAction.SurroundingAsLead;
                         }
                         else
                         {
                             this.byChosenDirection = 0;
                             this.enCurrentAction = Trick_Original.CurrentAction.SurroundingAsLead;
                         }
                     }
                     this.v2RandMoveDir = Vector2.Zero;
                     this.iNextHardUpdate = 0;
                 }
                 bool bDidAttack = false;
                 if (this.enCurrentAction == Trick_Original.CurrentAction.WaitingForlead)
                 {
                     if (Vector2.Distance(this.v2TargetPos, this.xOwner.xTransform.v2Pos) < 10f)
                     {
                         this.fCurrentRotation += (float)this.fRotDir * 0.02f;
                     }
                     this.iNextHardUpdate = 5;
                     Vector2 v2Look2 = this.xPlayerLockedOnto.xTransform.v2Pos - this.xOwner.xTransform.v2Pos;
                     v2Look2.Normalize();
                     byte lolKuk2 = Utility.ConvertV2DirectionToClosestByteDirection(v2Look2);
                     this.xOwner.xRenderComponent.SwitchAnimation((ushort)(lolKuk2 + 4), Animation.CancelOptions.UseAnimationDefault);
                     float x = (float)Math.Cos((double)this.fCurrentRotation);
                     float y = (float)Math.Sin((double)this.fCurrentRotation);
                     this.v2TargetPos = this.xPlayerLockedOnto.xTransform.v2Pos + new Vector2(x * this.fTargetDistance, y * this.fTargetDistance);
                     if (this.xTreat.xPlayerLockedOnto == this.xPlayerLockedOnto && !this.bIsLead && (this.bGetToOtherSide || Vector2.Distance(this.xTreat.xOwner.xTransform.v2Pos, this.xOwner.xTransform.v2Pos) < 70f))
                     {
                         this.v2TargetPos = this.xPlayerLockedOnto.xTransform.v2Pos + (this.xPlayerLockedOnto.xTransform.v2Pos - this.xTreat.xOwner.xTransform.v2Pos);
                         this.bGetToOtherSide = true;
                     }
                     this.v2RandMoveDir = this.v2TargetPos - this.xOwner.xTransform.v2Pos;
                     this.v2RandMoveDir.Normalize();
                     if (!this.bIsLead && this.xTreat.byChosenDirection != 4)
                     {
                         this.enCurrentAction = Trick_Original.CurrentAction.SurroundingAsFollow;
                         this.v2RandMoveDir = Vector2.Zero;
                         this.byRandomFollowAdd = (byte)(Program.GetTheGame().randomInLogic.Next(3) + 1);
                         this.byChosenDirection = (byte)((this.xTreat.byChosenDirection + this.byRandomFollowAdd) % 4);
                     }
                 }
                 else if (this.enCurrentAction == Trick_Original.CurrentAction.Sumthin)
                 {
                     this.iNextHardUpdate = 10;
                     this.enCurrentAction = Trick_Original.CurrentAction.WaitingForlead;
                 }
                 else if (this.enCurrentAction == Trick_Original.CurrentAction.SurroundingAsFollow)
                 {
                     if (this.byChosenDirection == this.xTreat.byChosenDirection)
                     {
                         this.byRandomFollowAdd = (byte)(Program.GetTheGame().randomInLogic.Next(3) + 1);
                         this.byChosenDirection = (byte)((this.xTreat.byChosenDirection + this.byRandomFollowAdd) % 4);
                     }
                     if (this.xOwner.byAnimationDirection != this.xTreat.byChosenDirection && this.IsWithingRangeSomehow(fDistance2))
                     {
                         this.byChosenDirection = this.xOwner.byAnimationDirection;
                     }
                     this.v2TargetPos = this.xPlayerLockedOnto.xTransform.v2Pos + Utility.AnimationDirectionToVector2((int)((this.byChosenDirection + 2) % 4)) * 23f;
                     if (Vector2.Distance(this.v2TargetPos, this.xOwner.xTransform.v2Pos) > 8f)
                     {
                         this.v2RandMoveDir = this.v2TargetPos - this.xOwner.xTransform.v2Pos;
                         this.v2RandMoveDir.Normalize();
                         this.LookAt(this.xPlayerLockedOnto.xTransform.v2Pos);
                     }
                     else
                     {
                         this.v2RandMoveDir = Vector2.Zero;
                     }
                     if (this.xTreat.iTimeSinceLastAttack < this.iTimeBetweenAttacks && this.DistanceToTarget() > 70f)
                     {
                         this.enCurrentAction = Trick_Original.CurrentAction.WaitingForlead;
                         this.bIsLead = true;
                         this.xTreat.bIsLead = false;
                         this.byChosenDirection = 4;
                         this.xTreat.byChosenDirection = 4;
                     }
                     if ((this.xTreat.byChosenDirection + 2 + this.byRandomFollowAdd) % 4 != 2)
                     {
                         bDidAttack = this.TryAttack(fDistance2);
                     }
                 }
                 else if (this.enCurrentAction == Trick_Original.CurrentAction.SurroundingAsLead)
                 {
                     if (this.xOwner.byAnimationDirection != this.xTreat.xOwner.byAnimationDirection && this.IsWithingRangeSomehow(fDistance2))
                     {
                         this.byChosenDirection = this.xOwner.byAnimationDirection;
                     }
                     this.v2TargetPos = this.xPlayerLockedOnto.xTransform.v2Pos + Utility.AnimationDirectionToVector2((int)((this.byChosenDirection + 2) % 4)) * 23f;
                     if (Vector2.Distance(this.v2TargetPos, this.xOwner.xTransform.v2Pos) > 8f)
                     {
                         this.v2RandMoveDir = this.v2TargetPos - this.xOwner.xTransform.v2Pos;
                         this.v2RandMoveDir.Normalize();
                         this.LookAt(this.xPlayerLockedOnto.xTransform.v2Pos);
                     }
                     else
                     {
                         this.v2RandMoveDir = Vector2.Zero;
                     }
                     if (!this.bIsLead)
                     {
                         this.enCurrentAction = Trick_Original.CurrentAction.WaitingForlead;
                     }
                     bDidAttack = this.TryAttack(fDistance2);
                 }
                 if (!bDidAttack)
                 {
                     if (knark.Next(50) == 0 && this.iLastDirectionChange + 600 < this.iCounter)
                     {
                         this.fRotDir *= -1;
                         this.iLastDirectionChange = this.iCounter;
                     }
                     if (this.iWannaCircleBaby > 0 && knark.Next(25 + this.iNumberOfPlayers * 3) == 0)
                     {
                         this.enCurrentAction = Trick_Original.CurrentAction.Sumthin;
                         this.v2RandMoveDir = Vector2.Zero;
                         this.iNextHardUpdate = 30 + knark.Next(60);
                     }
                 }
             }
             else
             {
                 this.iNextHardUpdate = 10;
                 this.v2RandMoveDir = Vector2.Zero;
                 this.xOwner.xRenderComponent.SwitchAnimation((ushort)this.xOwner.xRenderComponent.GetCurrentAnimation().byAnimationDirection, Animation.CancelOptions.UseAnimationDefault);
             }
         }
     }
     this.xOwner.xTransform.v2ServerPos = this.xOwner.xTransform.v2Pos;
 }
Exemple #2
0
 public override void OnAnimationCallback(AnimationInstruction xIns)
 {
     if (xIns.xEvent.afAlterableValues[0] == 0f)
     {
         if (this.xSwallowedPlayer != null)
         {
             this.enCurrentAction = Trick_Original.CurrentAction.WaitTo0;
             this.iCounter = -60;
             this.xBullet = new Trick_Original.Bullet(Program.GetTheGame()._EffectMaster_AddEffect(new SortedAnimated(this.xOwner.xTransform.v2Pos + new Vector2(0f, 5f), SortedAnimated.SortedAnimatedEffects._Unique_EvergrindCity_BalloonSingle_Red)) as SortedAnimated, new Vector2(0f, 5f));
             this.v2RandMoveDir = Vector2.Zero;
             return;
         }
     }
     else if (xIns.xEvent.afAlterableValues[0] == 1f)
     {
         this.enCurrentAction = Trick_Original.CurrentAction.Swallowed;
         this.iCounter = 0;
     }
 }