Ejemplo n.º 1
0
        public override void AI()
        {
            if (FirstFrame)
            {
                if (Main.rand.NextFloat() < 0.99f)
                {
                    Main.NewText(Main.player[Main.myPlayer].name + " noticed a cloaked figure " + GuardianBountyQuest.GetDirectionText(npc.Center - Main.player[Main.myPlayer].Center) + " of their position.", MainMod.MysteryCloseColor);
                }
                else
                {
                    Main.NewText("A cloaked figure to the " + GuardianBountyQuest.GetDirectionText(npc.Center - Main.player[Main.myPlayer].Center) + " has came to skunk you.", MainMod.MysteryCloseColor);
                }

                FirstFrame = false;
            }
            bool SomeoneTalkingToMe = false;

            for (int i = 0; i < 255; i++)
            {
                if (Main.player[i].active && Main.player[i].talkNPC == npc.whoAmI)
                {
                    SomeoneTalkingToMe = true;
                    break;
                }
            }
            if (DialogueStep > 1 && !SomeoneTalkingToMe)
            {
                DialogueStep = 1;
            }
            Idle = true;
            base.AI();
        }
Ejemplo n.º 2
0
 public override void AI()
 {
     if (npc.ai[2] == 0)
     {
         if ((Math.Abs(Main.player[Main.myPlayer].Center.X - npc.Center.X) >= NPC.sWidth * 0.5f + NPC.safeRangeX ||
              Math.Abs(Main.player[Main.myPlayer].Center.Y - npc.Center.Y) >= NPC.sHeight * 0.5f + NPC.safeRangeY))
         {
             Main.NewText("A Giant Raccoon appeared to the " + GuardianBountyQuest.GetDirectionText(npc.Center - Main.player[Main.myPlayer].Center) + " of " + Main.player[Main.myPlayer].name + " position.", MainMod.MysteryCloseColor);
         }
         npc.ai[2] = 1;
     }
     if (!Main.dayTime)
     {
         bool PlayerInRange = false;
         bool TalkingWithMe = false;
         for (int p = 0; p < 255; p++)
         {
             Player pl = Main.player[p];
             if (pl.active)
             {
                 if (pl.talkNPC == npc.whoAmI)
                 {
                     TalkingWithMe = true;
                 }
                 if ((Math.Abs(pl.Center.X - npc.Center.X) >= NPC.sWidth * 0.5f + NPC.safeRangeX ||
                      Math.Abs(pl.Center.Y - npc.Center.Y) >= NPC.sHeight * 0.5f + NPC.safeRangeY))
                 {
                     PlayerInRange = true;
                     if (pl.Center.X < npc.Center.X)
                     {
                         npc.direction = -1;
                     }
                     else
                     {
                         npc.direction = 1;
                     }
                 }
             }
         }
         if (!TalkingWithMe)
         {
             Idle = true;
         }
         else
         {
         }
         if (PlayerInRange)
         {
             Main.NewText("The Raccoon vanished in the sunset.", 225, 200, 0);
             npc.active = false;
             npc.life   = 0;
             return;
         }
     }
     Idle = true;
     npc.dontTakeDamage = npc.dontTakeDamageFromHostiles = npc.dontCountMe = true;
     base.AI();
 }
Ejemplo n.º 3
0
        public override void AI()
        {
            if (npc.ai[2] == 0)
            {
                npc.ai[2] = 1;
                npc.ai[3] = -3;
                npc.TargetClosest(false);
                Main.NewText("A huge Terra Guardian appeared " + GuardianBountyQuest.GetDirectionText(npc.Center - Main.player[npc.target].Center) + " near to " + Main.player[npc.target].name + ".");
            }
            if (npc.direction == 0)
            {
                npc.direction = 1;
            }
            bool JustSpottedPlayer = false;

            if (!SpottedPlayer)
            {
                Rectangle rect = new Rectangle((int)npc.Center.X, (int)npc.Center.Y, 300, 300);
                rect.Y -= rect.Height / 2;
                if (npc.direction < 0)
                {
                    rect.X -= rect.Width;
                }
                for (int p = 0; p < 255; p++)
                {
                    if (Main.player[p].active && Main.player[p].getRect().Intersects(rect) &&
                        Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[p].position, Main.player[p].width, Main.player[p].height))
                    {
                        SpottedPlayer     = true;
                        JustSpottedPlayer = true;
                        npc.target        = p;
                        if (Main.player[p].Center.X < npc.Center.X)
                        {
                            npc.direction = -1;
                        }
                        else
                        {
                            npc.direction = 1;
                        }
                        break;
                    }
                }
            }
            if (!RequestTaken)
            {
                this.Idle = true;
                npc.ai[0]++;
                if (SpottedPlayer)
                {
                    if (JustSpottedPlayer)
                    {
                        SayMessage("*Hey! Can you hear me? Come closer so we can talk, please.*");
                    }
                }
                else
                {
                    if (npc.ai[0] >= (300 + 60 * npc.ai[1]))
                    {
                        npc.ai[1] = 3 + Main.rand.Next(4);
                        npc.ai[0] = 0;
                        string Message = "";
                        switch (Main.rand.Next(5))
                        {
                        case 0:
                            Message = "*Is there really a town around here?*";
                            break;

                        case 1:
                            Message = "*I'm so hungry... I've been walking for days...*";
                            break;

                        case 2:
                            Message = "*I need to take some rest...*";
                            break;

                        case 3:
                            Message = "*Why are all the creatures here so aggressive?*";
                            break;

                        case 4:
                            Message = "*I wonder if there is someone nearby...*";
                            break;
                        }
                        SayMessage(Message);
                    }
                    npc.TargetClosest(false);
                }
                if (Main.player[npc.target].talkNPC == npc.whoAmI || SpottedPlayer)
                {
                    Idle = false;
                    if (Main.player[npc.target].Center.X < npc.Center.X)
                    {
                        npc.direction = -1;
                    }
                    else
                    {
                        npc.direction = 1;
                    }
                }
            }
            else if (RequestComplete)
            {
                if (HuggingPlayer != -1)
                {
                    Player player = Main.player[Main.myPlayer];
                    player.immuneTime    = 3;
                    player.immuneNoBlink = true;
                    PlayerMod pm = player.GetModPlayer <PlayerMod>();
                    bool      ControllingGuardian = pm.ControllingGuardian;
                    bool      ItemUsed = false, JumpUsed = false, MoveUsed = false;
                    if (ControllingGuardian)
                    {
                        pm.Guardian.ImmuneTime    = 3;
                        pm.Guardian.ImmuneNoBlink = true;
                        ItemUsed = pm.Guardian.LastAction && pm.Guardian.ItemAnimationTime == 0;
                        JumpUsed = pm.Guardian.LastJump;
                        MoveUsed = (pm.Guardian.LastMoveLeft) ||
                                   (pm.Guardian.LastMoveUp) ||
                                   (pm.Guardian.LastMoveRight) ||
                                   (pm.Guardian.LastMoveDown);
                    }
                    else
                    {
                        ItemUsed = player.controlUseItem;
                        JumpUsed = player.controlJump;
                        MoveUsed = (player.controlLeft) || (player.controlUp) || (player.controlRight) || (player.controlDown);
                    }
                    if (PlayerMod.PlayerMountedOnGuardian(player))
                    {
                        foreach (TerraGuardian guardian in pm.GetAllGuardianFollowers)
                        {
                            if (guardian.Active && guardian.PlayerMounted)
                            {
                                guardian.ToggleMount(true, false);
                            }
                        }
                    }
                    string Message = null;
                    if (HugPassed && HuggingPlayer > -1 && (ItemUsed || JumpUsed || MoveUsed))
                    {
                        if (ComplaintCooldown == 0)
                        {
                            switch (Main.rand.Next(3))
                            {
                            case 0:
                                Message = "*You can just talk to me if that's enough.*";
                                break;

                            case 1:
                                Message = "*Do you want me to stop? Talk to me again.*";
                                break;

                            case 2:
                                Message = "*Had enough of hugs? Talk to me so I can stop.*";
                                break;
                            }
                        }
                        ComplaintCooldown = 30;
                    }
                    else if (ItemUsed)
                    {
                        if (ComplaintCooldown == 0)
                        {
                            npc.ai[0] -= Main.rand.Next(19, 41);
                            if (player.inventory[player.selectedItem].damage > 0)
                            {
                                switch (Main.rand.Next(5))
                                {
                                case 0:
                                    Message = ("*Be careful! That can hurt someone!*");
                                    break;

                                case 1:
                                    Message = ("*Hey! Are you trying to hurt me?*");
                                    break;

                                case 2:
                                    Message = ("*You're doing the complete oposite of what a hug should do!*");
                                    break;

                                case 3:
                                    Message = ("*You'll end up hurting someone with that.*");
                                    break;

                                case 4:
                                    Message = ("*Keep that off my skin!*");
                                    break;
                                }
                            }
                            else
                            {
                                switch (Main.rand.Next(5))
                                {
                                case 0:
                                    Message = ("*What are you doing?*");
                                    break;

                                case 1:
                                    Message = ("*Can you stop doing that?*");
                                    break;

                                case 2:
                                    Message = ("*Hey! Watch out!*");
                                    break;

                                case 3:
                                    Message = ("*Do you easily get bored?*");
                                    break;

                                case 4:
                                    Message = ("*Why are you doing that?*");
                                    break;
                                }
                            }
                        }
                        ComplaintCooldown = 30;
                    }
                    else if (JumpUsed)
                    {
                        if (ComplaintCooldown == 0)
                        {
                            npc.ai[0] -= Main.rand.Next(23, 54);
                            switch (Main.rand.Next(5))
                            {
                            case 0:
                                Message = ("*Oof! Hey! My stomach!*");
                                break;

                            case 1:
                                Message = ("*Ouch! Are you a cat or something?*");
                                break;

                            case 2:
                                Message = ("*Urgh. Don't hit my belly!*");
                                break;

                            case 3:
                                Message = ("*Hey! Why the aggression?*");
                                break;

                            case 4:
                                Message = ("*Urrrf... (Breathing for a moment) Gasp! You took out all my air with that kick! Why?! Tell me why you did that?*");
                                break;
                            }
                        }
                        ComplaintCooldown = 30;
                    }
                    else if (MoveUsed)
                    {
                        if (ComplaintCooldown == 0)
                        {
                            npc.ai[0] -= Main.rand.Next(14, 33);
                            switch (Main.rand.Next(5))
                            {
                            case 0:
                                Message = ("*What are you doing?*");
                                break;

                            case 1:
                                Message = ("*It's hard to hug with you like that.*");
                                break;

                            case 2:
                                Message = ("*If you want me to stop, just tell me.*");
                                break;

                            case 3:
                                Message = ("*Are you tense or something? Stop that.*");
                                break;

                            case 4:
                                Message = ("*You'll end up falling if you keep doing that.*");
                                break;
                            }
                        }
                        ComplaintCooldown = 30;
                    }
                    else
                    {
                        if (ComplaintCooldown > 0)
                        {
                            ComplaintCooldown--;
                        }
                        npc.ai[0]++;
                        if (ControllingGuardian)
                        {
                            if (pm.Guardian.ItemAnimationTime == 0 && !pm.Guardian.MoveLeft && !pm.Guardian.MoveRight)
                            {
                                pm.Guardian.LookingLeft = npc.direction == 1;
                            }
                        }
                        else
                        {
                            if (player.itemAnimation == 0 && !player.controlLeft && !player.controlRight)
                            {
                                player.direction = -npc.direction;
                            }
                        }
                        if (HugPassed && npc.ai[0] % (60 * 10) == 0)
                        {
                            switch (Main.rand.Next(4))
                            {
                            case 0:
                                Message = "*You want some more hug? I don't mind.*";
                                break;

                            case 1:
                                Message = "*(Humming)*";
                                break;

                            case 2:
                                Message = "*Talk to me If you had enough.*";
                                break;

                            case 3:
                                Message = "*Warm.*";
                                break;
                            }
                        }
                        else if (npc.ai[0] >= (PlayerHasVladimir ? 0.3f : (Main.expertMode ? 1.2f : 0.5f)) * 60 * 60)
                        {
                            if (!HugPassed)
                            {
                                HugPassed = true;
                                Message   = "*Thank you, I was really needing that. I think this world could make use of someone like me. Call me Vladimir, It's my name.*";
                                npc.ai[0] = 1;
                            }
                        }
                        else if (player.talkNPC == npc.whoAmI && npc.ai[0] % (60 * 10) == 0)
                        {
                            switch (Main.rand.Next(5))
                            {
                            case 0:
                                Message = ("*You don't know how much I missed doing that.*");
                                break;

                            case 1:
                                Message = ("*It's good to feel another warm body after so much travel.*");
                                break;

                            case 2:
                                Message = ("*Just some more.*");
                                break;

                            case 3:
                                Message = ("*Thanks for the fishs, by the way.*");
                                break;

                            case 4:
                                Message = ("*Are there more people like you in this world?*");
                                break;
                            }
                        }
                    }
                    if (Message != null)
                    {
                        if (player.talkNPC == npc.whoAmI)
                        {
                            Main.npcChatText = Message;
                        }
                        else
                        {
                            SayMessage(Message);
                        }
                    }
                    Vector2 HugPosition = Base.MountShoulderPoints.GetPositionFromFrameVector(BodyAnimationFrame);
                    if (npc.direction < 0)
                    {
                        HugPosition.X = Base.SpriteWidth - HugPosition.X;
                    }
                    HugPosition.X -= Base.SpriteWidth * 0.5f;
                    HugPosition.Y -= Base.SpriteHeight;
                    HugPosition.X  = HugPosition.X * npc.scale + npc.position.X + npc.width * 0.5f;
                    HugPosition.Y  = HugPosition.Y * npc.scale + npc.position.Y + npc.height;
                    if (npc.ai[0] < -200)
                    {
                        switch (Main.rand.Next(5))
                        {
                        case 0:
                            Message = "*Alright, there you go. Happy?*";
                            break;

                        case 1:
                            Message = "*It was just a hug, why were you moving around like crazy?*";
                            break;

                        case 2:
                            Message = "*Does hugs makes you uncomfortable or something?*";
                            break;

                        case 3:
                            Message = "*Need to use the toilet or something?*";
                            break;

                        case 4:
                            Message = "*Is It the environment or me?*";
                            break;
                        }
                        HugPosition   = npc.Center;
                        HuggingPlayer = -1;
                    }
                    if (MessageTime <= 0 && !HasHugCommentHappened)
                    {
                        HasHugCommentHappened = true;
                        pm.CompanionReaction(GuardianBase.MessageIDs.VladimirRecruitPlayerGetsHugged);
                    }
                    if (ControllingGuardian)
                    {
                        pm.Guardian.Position      = HugPosition;
                        pm.Guardian.Position.Y   += pm.Guardian.Height * 0.5f;
                        pm.Guardian.Velocity.Y    = -pm.Guardian.Mass;
                        pm.Guardian.ImmuneTime    = 3;
                        pm.Guardian.ImmuneNoBlink = true;
                    }
                    else
                    {
                        player.Center     = HugPosition;
                        player.velocity.Y = -Player.defaultGravity;
                    }
                    if (!player.active)
                    {
                        SayMessage("*Where did that person go?*");
                        HuggingPlayer = -1;
                    }
                }
                else
                {
                    npc.TargetClosest();
                }
            }
            else if (RequestTaken)
            {
                npc.TargetClosest();
                float Distance = npc.Center.X - Main.player[npc.target].Center.X;
                if (Math.Abs(Distance) >= 68f)
                {
                    if (Distance < 0)
                    {
                        MoveRight = true;
                    }
                    else
                    {
                        MoveLeft = true;
                    }
                }
                if (npc.Distance(Main.player[npc.target].Center) >= 520f)
                {
                    npc.position    = Main.player[npc.target].position;
                    npc.position.Y -= Base.SpriteHeight - Player.defaultHeight;
                }
            }
            if (HuggingPlayer > -1)
            {
                DrawInFrontOfPlayers.Add(HuggingPlayer);
            }
            base.AI();
        }
Ejemplo n.º 4
0
 public override void AI()
 {
     if (AiStage > 1)
     {
         if (npc.target == -1 || npc.target == 256)
         {
             AiStage = 1;
             SayMessage("*Funny, where did the Terrarian I was talking with to went?*");
         }
         else if (!Main.player[npc.target].active)
         {
             AiStage = 1;
             SayMessage("*Funny, where did the Terrarian I was talking with to went?*");
         }
         else if (Main.player[npc.target].dead)
         {
             AiStage = 1;
             SayMessage("*Well, that was an awful sight.*");
         }
     }
     if (AiStage == 0)
     {
         Idle          = true;
         AiStage       = 1;
         npc.direction = (Main.rand.NextDouble() < 0.5 ? -1 : 1);
         Main.NewText("Something appeared to the " + GuardianBountyQuest.GetDirectionText(npc.Center - Main.player[Main.myPlayer].Center) + " of " + Main.player[Main.myPlayer].name + ".", MainMod.MysteryCloseColor);
     }
     else if (AiStage == 1)
     {
         Idle = true;
         Rectangle FoV = new Rectangle(0, -150, 250, 300);
         if (npc.direction < 0)
         {
             FoV.X = -FoV.Width;
         }
         FoV.X += (int)npc.Center.X;
         FoV.Y += (int)npc.Center.Y;
         for (int p = 0; p < 255; p++)
         {
             if (Main.player[p].active && !Main.player[p].dead && Main.player[p].getRect().Intersects(FoV) && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[p].position, Main.player[p].width, Main.player[p].height))
             {
                 //Player found!
                 npc.target = p;
                 if (PlayerMod.PlayerHasGuardian(Main.player[p], GuardianBase.Malisha))
                 {
                     DialogueTime = SayMessage("*Hey, It's you again.*"); //Add later the dialogue
                     AiStage      = 150;
                 }
                 else
                 {
                     AiStage      = 2;
                     DialogueTime = SayMessage("*A Terrarian! I must have really arrived.*");
                 }
                 if (npc.Center.X - Main.player[p].Center.X > 0)
                 {
                     npc.direction = -1;
                 }
                 else
                 {
                     npc.direction = 1;
                 }
                 break;
             }
         }
     }
     else if (AiStage == 2)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             if (PlayerUsingDryadSet(player))
             {
                 DialogueTime = SayMessage("*Look at how It's dressed! This must be the right place.*");
             }
             else
             {
                 DialogueTime = SayMessage("*Wait, why is It using clothes?*");
             }
             AiStage = 3;
         }
     }
     else if (AiStage == 3)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             float Distance = player.Center.X - npc.Center.X;
             if (Math.Abs(Distance) > 96)
             {
                 if (Distance > 0)
                 {
                     MoveRight = true;
                 }
                 else
                 {
                     MoveLeft = true;
                 }
             }
             else
             {
             }
         }
     }
     else if (AiStage == 100)
     {
         npc.TargetClosest(false);
         Player player = Main.player[npc.target];
         Idle = true;
     }
     else if (AiStage == 150)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             DialogueTime = SayMessage("*I think this isn't a naturalist colony, either, right?*");
             AiStage      = 151;
         }
     }
     else if (AiStage == 151)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             DialogueTime = SayMessage("*Well, whatever. I'm here If you need my knowledge. Or feel like wanting to be a guinea pig. You pick.*");
             AiStage      = 152;
         }
     }
     else if (AiStage == 152)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             PlayerMod.AddPlayerGuardian(Main.player[npc.target], GuardianBase.Malisha);
             NpcMod.AddGuardianMet(GuardianBase.Malisha);
             WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
             //npc.Transform(ModContent.NPCType<GuardianNPC.List.PantherGuardian>());
         }
     }
     else
     {
         Player player = Main.player[npc.target];
         //Dialogue Checks
         if (player.talkNPC != npc.whoAmI)
         {
             DialogueTime = SayMessage("*How rude! Speak to me when possible then.*");
             AiStage      = 100;
         }
     }
     base.AI();
 }