Exemplo n.º 1
0
 private void PlayerCollideHook(On.Player.orig_Collide orig, Player self, PhysicalObject otherObject, int myChunk, int otherChunk)
 {
     orig.Invoke(self, otherObject, myChunk, otherChunk);
     if (self.playerState.slugcatCharacter == PlayerManager.GetCustomPlayer("Electric").SlugcatIndex)
     {
         for (int i = 0; i < EVars.Count; i++)
         {
             if (EVars[i].ply == self)
             {
                 if (otherObject is Creature && EVars[i].chargedActive && EVars[i].stunDelay == 0f)
                 {
                     if (!(otherObject is BigEel) && !(otherObject is Centipede) && !(otherObject is Fly) && !(otherObject as Creature).dead)
                     {
                         if (otherObject is Player && (otherObject as Player).playerState.slugcatCharacter == PlayerManager.GetCustomPlayer("Electric").SlugcatIndex)
                         {
                             return;
                         }
                         if (!(otherObject is Player) && (otherObject as Creature).abstractCreature.abstractAI.RealAI.friendTracker != null && (otherObject as Creature).abstractCreature.abstractAI.RealAI.friendTracker.Utility() > 0f)
                         {
                             return;
                         }
                         (otherObject as Creature).Violence(self.firstChunk, new Vector2?(Custom.DirVec(self.firstChunk.pos, otherObject.bodyChunks[otherChunk].pos) * 5f), otherObject.bodyChunks[otherChunk], null, Creature.DamageType.Electric, 0.8f, (!(otherObject is Player)) ? (270f * Mathf.Lerp((otherObject as Creature).Template.baseStunResistance, 1f, 0.5f)) : 140f);
                         self.room.AddObject(new CreatureSpasmer(otherObject as Creature, false, (otherObject as Creature).stun));
                         EVars[i].stunDelay = 300f;
                         self.room.PlaySound(SoundID.Jelly_Fish_Tentacle_Stun, self.firstChunk.pos);
                         self.room.AddObject(new Explosion.ExplosionLight(self.firstChunk.pos, 150f, 0.85f, 4, new Color(0.7f, 0.7f, 1f)));
                         EVars[i].chargedTimer -= 20f;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 private static void Player_Collide(On.Player.orig_Collide orig, Player self, PhysicalObject otherObject, int myChunk, int otherChunk)
 {
     if (otherObject is Creature)
     {
         if (self.animation == Player.AnimationIndex.BellySlide)
         {
             (otherObject as Creature).Stun((!self.longBellySlide) ? 2 : 4);
             if (!self.longBellySlide && self.rollCounter > 11)
             {
                 self.rollCounter = 11;
             }
             BodyChunk mainBodyChunk = self.mainBodyChunk;
             mainBodyChunk.vel.x = mainBodyChunk.vel.x + (float)self.rollDirection * 3f;
         }
         if (self.Sleeping)
         {
             self.sleepCounter = 0;
         }
     }
     if (self.Consious)
     {
         if (self.FoodInStomach < self.MaxFoodInStomach && otherObject is Fly && self.Grabability(otherObject) == Player.ObjectGrabability.OneHand)
         {
             for (int i = 0; i < 2; i++)
             {
                 if (self.grasps[i] == null)
                 {
                     self.room.PlaySound((!(otherObject as Fly).dead) ? SoundID.Fly_Caught : SoundID.Fly_Caught_Dead, otherObject.firstChunk);
                     if (!(otherObject as Fly).everBeenCaughtByPlayer)
                     {
                         (otherObject as Fly).everBeenCaughtByPlayer = true;
                         if (self.room.game.session is StoryGameSession)
                         {
                             self.DepleteSwarmRoom();
                         }
                     }
                     self.SlugcatGrab(otherObject, i);
                     break;
                 }
             }
         }
         else if (self.wantToPickUp > 0 && self.CanIPickThisUp(otherObject))
         {
             if (!(otherObject is Spear) || (otherObject as Spear).mode != Weapon.Mode.StuckInWall || CanAffordPull(self))                 //"Don't pickup spear in wall unless affordable"
             {
                 if (self.Grabability(otherObject) == Player.ObjectGrabability.TwoHands)
                 {
                     self.SlugcatGrab(otherObject, 0);
                 }
                 else
                 {
                     self.SlugcatGrab(otherObject, self.FreeHand());
                 }
                 self.wantToPickUp = 0;
             }
         }
     }
     if (self.jumpChunkCounter >= 0 && self.bodyMode == Player.BodyModeIndex.Default && myChunk == 1 && self.bodyChunks[1].pos.y > otherObject.bodyChunks[otherChunk].pos.y - otherObject.bodyChunks[otherChunk].rad / 2f)
     {
         self.jumpChunkCounter = 5;
         self.jumpChunk        = otherObject.bodyChunks[otherChunk];
     }
 }