Beispiel #1
0
 public CreateAction(int charIndex, ActiveChar character, CharSprite.ActionType action)
 {
     this.charIndex = charIndex;
     this.Action = action;
     this.charData = character.CharData;
     this.dir = character.CharDir;
 }
        private static void SetStatusAilment(ActiveChar character, Enums.StatusAilment ailment)
        {
            switch (ailment)
            {
            case Enums.StatusAilment.OK:
            {
                SetStatusAilment(character, ailment, 0);
            }
            break;

            case Enums.StatusAilment.Burn:
            {
                //on fire!
                SetStatusAilment(character, ailment, 0);
            }
            break;

            case Enums.StatusAilment.Freeze:
            {
                //frozen!
                SetStatusAilment(character, ailment, 1);
            }
            break;

            case Enums.StatusAilment.Poison:
            {
                //poisoned!
                SetStatusAilment(character, ailment, 1);
            }
            break;
            }
        }
Beispiel #3
0
        private static void ProcessWalk(ActiveChar character, ref bool moveMade)
        {
            if (character.dead)
            {
                return;
            }

            Loc2D loc = character.CharLoc;

            Operations.MoveInDirection8(ref loc, character.CharDir, 1);

            //check for blocking
            if (DirBlocked(character.CharDir, character))
            {
                return;
            }

            moveMade = true;

            if (character.Status == Enums.StatusAilment.Freeze)
            {
                return;
            }

            character.CharLoc = loc;

            Display.Screen.AddResult(new Results.CreateAction(CharIndex(character), character, Display.CharSprite.ActionType.Walk));

            Display.Screen.AddResult(new Results.Loc(CharIndex(character), loc));

            moveMade = true;

            //if void, add restart
            if (!Operations.IsInBound(CurrentMap.Width, CurrentMap.Height, character.CharLoc.X, character.CharLoc.Y))
            {
                //Lose();
                throw new Exception("Player out of bounds");
            }
            else
            {
                //god mode check
                if (Intangible)
                {
                    return;
                }

                Tile tile = CurrentMap.MapArray[character.CharLoc.X, character.CharLoc.Y];

                //if landed on certain tiles, present effects
                if (tile.Data.Type == Enums.TileType.Slippery)
                {
                    //if on ice, continue to slide
                    //but only if we're not blocked
                    if (!DirBlocked(character.CharDir, character))
                    {
                        ProcessWalk(character, ref moveMade);
                    }
                }
            }
        }
Beispiel #4
0
        public static void BeginFloor()
        {
            Display.Screen.AddResult(new Results.SetMap(CurrentMap, 0));

            for (int i = 0; i < MAX_TEAM_SLOTS; i++)
            {
                Display.Screen.AddResult(new Results.RemoveCharacter(i - MAX_TEAM_SLOTS));
                ActiveChar character = CharOfIndex(i - MAX_TEAM_SLOTS);
                if (!character.dead)
                {
                    Display.Screen.AddResult(new Results.SpawnCharacter(character, i - MAX_TEAM_SLOTS));
                }
            }
            currentCharIndex = -MAX_TEAM_SLOTS;
            SwitchFocus(-MAX_TEAM_SLOTS);

            Display.Screen.AddResult(new Results.BGM(CurrentMap.Music, true));

            //resync NPCs
            for (int i = 0; i < BasicMap.MAX_NPC_SLOTS; i++)
            {
                Display.Screen.AddResult(new Results.RemoveCharacter(i));
                if (!Npcs[i].dead)
                {
                    Display.Screen.AddResult(new Results.SpawnCharacter(Npcs[i], i));
                }
            }
            turnCount = 0;
            print     = true;
        }
        public static void RemoveExtraStatus(ActiveChar character, string name, bool sendInfo)
        {
            if (!character.VolatileStatus.ContainsKey(name))
            {
                return;
            }

            ExtraStatus statusToRemove = character.VolatileStatus[name];

            if (statusToRemove != null)
            {
                bool forme = false, sprite = false, type = false, ability = false, atkSpeed = false,
                     confusion = false, speedLimit = false, mobility = false, visibility = false,
                     darkness = false, swapLock = false, moves = false, extraStatus = false;

                //switch (name) {
                //    case "Confusion": {
                //            //if (sendInfo) hitlist.AddPacketToMap(map, PacketBuilder.CreateBattleMsg(character.Name + " is no longer confused!"));
                //            confusion = true;
                //            extraStatus = true;
                //        }
                //        break;
                //}

                character.VolatileStatus.Remove(name);

                RefreshCharacterTraits(character, forme, sprite, type, ability, atkSpeed, confusion, speedLimit, mobility, visibility, darkness, swapLock, moves, extraStatus);
            }
        }
Beispiel #6
0
        public static bool DirBlocked(Direction8 dir, ActiveChar character, Loc2D loc, bool inAir, int distance)
        {
            if (character == FocusedCharacter && Intangible)
            {
                Operations.MoveInDirection8(ref loc, dir, 1);
                if (!Operations.IsInBound(CurrentMap.Width, CurrentMap.Height, loc.X, loc.Y))
                {
                    return(true);
                }

                return(false);
            }

            Enums.WalkMode walkMode = Enums.WalkMode.Normal;

            if (inAir)
            {
                walkMode = Enums.WalkMode.Air;
            }

            for (int i = 0; i < distance; i++)
            {
                Operations.MoveInDirection8(ref loc, dir, 1);

                if (IsBlocked(loc, walkMode))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #7
0
        private static void ProcessDrop(ActiveChar character, int invSlot, ref bool moveMade)
        {
            if (!CanDrop(invSlot))
            {
                Display.Screen.AddResult(new Results.BattleMsg("Can't drop slot " + (invSlot + 1)));
                return;
            }
            Loc2D loc = character.CharLoc;

            if (!CanItemLand(loc))
            {
                Display.Screen.AddResult(new Results.BattleMsg("Can't drop here!"));
                return;
            }
            moveMade = true;
            int itemIndex = Inventory[invSlot];

            int mapSlot = CurrentMap.AddItem(new Item(itemIndex, 1, "", false, loc));

            Inventory[invSlot] = -1;

            Display.Screen.AddResult(new Results.SE("magic693"));
            Display.Screen.AddResult(new Results.AddItem(CurrentMap, mapSlot));

            Display.Screen.AddResult(new Results.BattleMsg(character.Name + " dropped a " + Data.GameData.ItemDex[itemIndex].Name + "."));
        }
Beispiel #8
0
        private static void ProcessMapTurnEnd(ActiveChar character)
        {
            if (!character.dead)
            {
                if (character.VolatileStatus.ContainsKey("MovementSpeed"))
                {
                    character.VolatileStatus["MovementSpeed"].Counter--;
                    if (character.VolatileStatus["MovementSpeed"].Counter <= 0)
                    {
                        AddExtraStatus(character, "MovementSpeed", 0, -1, 0);
                    }
                }

                if (character.MovementSpeed < 0)
                {
                    character.TurnCounter++;
                    if (character.TurnCounter > 0)
                    {
                        character.TurnCounter = character.MovementSpeed;
                    }
                }

                if (character.Status == Enums.StatusAilment.Burn)
                {
                    Display.Screen.BeginConcurrent();
                    DamageCharacter(character, 1, false);
                    character.StatusCounter--;
                    if (character.StatusCounter <= 0)
                    {
                        SetStatusAilment(character, Enums.StatusAilment.OK, 0);
                    }
                }
            }
        }
 public override void Process(Input input, ActiveChar character, ref bool moveMade)
 {
     if (input[Input.InputType.Enter] && !Processor.InputState[(int)Processor.InputType.Enter])
     {
         Choose(character, ref moveMade);
     }
     else if (input[Input.InputType.X] && !Processor.InputState[(int)Processor.InputType.X])
     {
         Choose(character, ref moveMade);
     }
     else if (input[Input.InputType.Z] && !Processor.InputState[(int)Processor.InputType.Z])
     {
         MenuManager.Menus.RemoveAt(0);
     }
     else
     {
         bool chooseDown = (input.Direction == Direction8.Down || input.Direction == Direction8.DownLeft || input.Direction == Direction8.DownRight);
         bool prevDown   = (Processor.oldDirection == Direction8.Down || Processor.oldDirection == Direction8.DownLeft || Processor.oldDirection == Direction8.DownRight);
         bool chooseUp   = (input.Direction == Direction8.Up || input.Direction == Direction8.UpLeft || input.Direction == Direction8.UpRight);
         bool prevUp     = (Processor.oldDirection == Direction8.Up || Processor.oldDirection == Direction8.UpLeft || Processor.oldDirection == Direction8.UpRight);
         if (chooseDown && (!prevDown || Processor.InputTime >= RenderTime.FromMillisecs(40)))
         {
             currentChoice = (currentChoice + 1) % Choices.Count;
         }
         else if (chooseUp && (!prevUp || Processor.InputTime >= RenderTime.FromMillisecs(40)))
         {
             currentChoice = (currentChoice + Choices.Count - 1) % Choices.Count;
         }
     }
 }
Beispiel #10
0
 public SpawnCharacter(ActiveChar character, int charIndex)
 {
     this.charIndex = charIndex;
     this.charLoc = character.CharLoc;
     this.charDir = character.CharDir;
     this.form = character.CharData;
 }
Beispiel #11
0
        public static void ProcessMenus(Input input, ActiveChar character, ref bool moveMade)
        {
            //process most recent menu
            Menus[0].Process(input, character, ref moveMade);

            //send all menus to display
        }
Beispiel #12
0
 protected override void Choose(ActiveChar character, ref bool moveMade)
 {
     if (Processor.Inventory[CurrentChoice] >= 0)
     {
         MenuManager.Menus.Insert(0, new ItemChosenMenu(CurrentChoice));
     }
 }
Beispiel #13
0
        public static void ProcessMenus(Input input, ActiveChar character, ref bool moveMade)
        {
            //process most recent menu
            Menus[0].Process(input, character, ref moveMade);

            //send all menus to display
        }
Beispiel #14
0
 public static int CharIndex(ActiveChar character)
 {
     if (character is Player)
     {
         return(Array.IndexOf(Players, character) - MAX_TEAM_SLOTS);
     }
     return(Array.IndexOf(Npcs, character));
 }
Beispiel #15
0
 public override void Process(Input input, ActiveChar character, ref bool moveMade)
 {
     if (input[Input.InputType.W] && !Processor.PrevInput[Input.InputType.W]) {
         MenuManager.Menus.RemoveAt(0);
     } else {
         base.Process(input, character, ref moveMade);
     }
 }
Beispiel #16
0
        private static void ProcessAIDecision(ActiveChar character)
        {
            //picks an action
            bool moveMade = false;

            Command command = character.Tactic.Think();

            ProcessDecision(command, character, ref moveMade);
        }
Beispiel #17
0
 public CreateAction(int charIndex, ActiveChar character, CharSprite.ActionType action, bool looping, bool inPlace)
 {
     this.charIndex = charIndex;
     this.Action = action;
     this.charData = character.CharData;
     this.dir = character.CharDir;
     this.Looping = looping;
     this.InPlace = inPlace;
 }
Beispiel #18
0
        private static void ProcessDir(Direction8 dir, ActiveChar character, ref bool moveMade)
        {
            if (character.Status == Enums.StatusAilment.Freeze)
            {
                return;
            }

            character.CharDir = dir;
            Display.Screen.AddResult(new Results.Dir(CharIndex(character), character.CharDir));
        }
Beispiel #19
0
 private static void ProcessRoundEnd(ActiveChar character)
 {
     if (!character.dead)
     {
         if (character.MovementSpeed >= 0)
         {
             character.TurnCounter = character.MovementSpeed;
         }
     }
 }
Beispiel #20
0
 public override void Process(Input input, ActiveChar character, ref bool moveMade)
 {
     if (input[Input.InputType.Q] && !Processor.InputState[(int)Processor.InputType.Q])
     {
         MenuManager.Menus.RemoveAt(0);
     }
     else
     {
         base.Process(input, character, ref moveMade);
     }
 }
 public static void RefreshCharacterVolatileStatus(ActiveChar character)
 {
     //volatile status
     //if (character.CharacterType == Enums.CharacterType.Recruit) {
     //    PacketBuilder.AppendVolatileStatus(((Recruit)character).Owner, hitlist);
     //} else if (character.CharacterType == Enums.CharacterType.MapNpc) {
     //    if (map != null) {
     //        PacketBuilder.AppendNpcVolatileStatus(map, hitlist, ((MapNpc)character).MapSlot);
     //    }
     //}
 }
Beispiel #22
0
        protected override void Choose(ActiveChar character, ref bool moveMade)
        {
            switch (CurrentChoice) {
                case 0: {
                    MenuManager.Menus.Clear();
                        Processor.ProcessDecision(new Command(Command.CommandType.Wait), character, ref moveMade);
                    }
                    break;
                case 1:
                    {
                        MenuManager.Menus.Clear();
                        Processor.StartDungeon(Processor.Seed);
                    }
                    break;
                case 2:
                    {
                        MenuManager.Menus.Clear();
                        Processor.StartDungeon(Processor.Rand.Next());
                    }
                    break;
                case 3: {
                        this.Visible = false;
                        MenuManager.Menus.Insert(0, new ReplayMenu());
                    }
                    break;
                case 4: {//item
                        MenuManager.Menus.RemoveAt(0);
                        Editors.EditorManager.OpenItemEditor();
                    }
                    break;
                case 5: {//move
                        MenuManager.Menus.RemoveAt(0);
                        Editors.EditorManager.OpenSpellEditor();
                    }
                    break;
                case 6: {//map
                    MenuManager.Menus.RemoveAt(0);
                    //Editors.EditorManager.OpenMapEditor();

                    break;
                }
                case 7: {//dungeon
                        MenuManager.Menus.RemoveAt(0);
                        Editors.EditorManager.OpenRDungeonEditor();
                    }
                    break;
                default: {
                    MenuManager.Menus.RemoveAt(0);
                    }
                    break;
            }
        }
        public static void RefreshCharacterTraits(ActiveChar character, bool forme, bool sprite, bool type, bool ability,
                                                  bool atkSpeed, bool confusion, bool speedLimit, bool mobility, bool visibility, bool darkness, bool swapLock, bool moves, bool extraStatus)
        {
            if (forme)
            {
                RefreshCharacterForme(character);
                sprite  = true;
                type    = true;
                ability = true;
            }

            if (sprite)
            {
                RefreshCharacterSprite(character);
            }

            if (type)
            {
                RefreshCharacterType(character);
                atkSpeed   = true;
                speedLimit = true;
                mobility   = true;
            }

            if (ability)
            {
                RefreshCharacterAbility(character);
                atkSpeed   = true;
                confusion  = true;
                speedLimit = true;
                mobility   = true;
                darkness   = true;
            }

            RefreshCharacterAttackSpeed(character);

            RefreshCharacterConfusion(character);

            RefreshCharacterSpeed(character);

            RefreshCharacterMobility(character);

            RefreshCharacterVisibility(character);

            RefreshCharacterDarkness(character);

            RefreshCharacterMoves(character);

            RefreshCharacterVolatileStatus(character);
        }
        public static void RefreshCharacterSpeed(ActiveChar character)
        {
            //Movement Speed

            int speed = 0;

            if (character.VolatileStatus.ContainsKey("MovementSpeed"))
            {
                speed += character.VolatileStatus["MovementSpeed"].Args[0];
            }

            character.MovementSpeed = speed;
            Display.Screen.AddResult(new Results.SetMovementSpeed(CharIndex(character), character.MovementSpeed));
        }
Beispiel #25
0
        private List <ActiveChar> GetSeenCharacters(bool includeSelf, bool includeAllies, bool includeFoes)
        {
            List <ActiveChar> seenChars = new List <ActiveChar>();

            for (int i = -Processor.MAX_TEAM_SLOTS; i < BasicMap.MAX_NPC_SLOTS; i++)
            {
                ActiveChar target = Processor.CharOfIndex(i);
                if (CanSeeCharacter(target) && Processor.IsTargeted(ControlledChar, target, includeSelf, includeAllies, includeFoes))
                {
                    seenChars.Add(target);
                }
            }
            return(seenChars);
        }
Beispiel #26
0
        public static void Process()
        {
            if (print && allowPrint)
            {
                Print();
                print = false;
            }

            bool moveMade = false;

            Display.Screen.BeginConcurrent();
            ProcessPlayerInput(CharOfIndex(currentCharIndex), ref moveMade);
            //if a move was made, everyone else gets a turn
            if (moveMade)
            {
                someoneMoved = true;

                PassToNextTurn();

                while (true)
                {
                    //all other characters get a turn, if they have one.
                    ActiveChar character = CharOfIndex(currentCharIndex);
                    if (!character.dead)
                    {
                        if (turnsTaken <= character.TurnCounter)
                        {
                            if (IsPlayerTurn())
                            {
                                SwitchFocus(currentCharIndex);
                                break;
                            }
                            else
                            {
                                someoneMoved = true;
                                ProcessAIDecision(character);
                            }
                        }
                    }

                    PassToNextTurn();
                }

                print = true;
            }
            Display.Screen.EndConcurrent();
            //CurrentInput.Reset();
        }
Beispiel #27
0
 private static void ProcessTurnEnd(ActiveChar character)
 {
     if (!character.dead)
     {
         if (character.Status == Enums.StatusAilment.Poison)
         {
             Display.Screen.BeginConcurrent();
             DeductPP(character, 1);
             character.StatusCounter--;
             if (character.StatusCounter <= 0)
             {
                 SetStatusAilment(character, Enums.StatusAilment.OK, 0);
             }
         }
     }
 }
Beispiel #28
0
        private static void ProcessPickup(ActiveChar character, ref bool moveMade)
        {
            Tile tile = CurrentMap.MapArray[character.CharLoc.X, character.CharLoc.Y];

            int freeSlot = FindInvSlot();

            if (tile.Data.Type == Enums.TileType.ChangeFloor)
            {
                //if we're at the stairs, we go on
                //a case for changing floor; leader only!
                if (character == Players[0])
                {
                    Display.Screen.AddResult(new Results.SE("magic135"));
                    //send changefloor result
                    Display.Screen.AddResult(new Results.Fade(Display.Screen.FadeType.FadeOut));
                    Display.Screen.AddResult(new Results.BattleMsg("Advanced to the next floor!"));
                    //character.CharLoc = new Loc2D(tile.Data2, tile.Data3);
                    //CurrentFloor = tile.Data1;
                    MoveToFloor(tile.Data.Data1);
                    Display.Screen.AddResult(new Results.Fade(Display.Screen.FadeType.FadeIn));
                }
            }

            int itemSlot = CurrentMap.GetItem(character.CharLoc);

            if (itemSlot == -1)
            {
                Display.Screen.AddResult(new Results.BattleMsg("Nothing there."));
                return;
            }

            if (freeSlot == -1)
            {
                Display.Screen.AddResult(new Results.BattleMsg("Inv full"));
                return;
            }
            moveMade = true;
            int itemIndex = CurrentMap.Items[itemSlot].ItemIndex;

            Inventory[freeSlot]        = itemIndex;
            CurrentMap.Items[itemSlot] = new Item();

            Display.Screen.AddResult(new Results.SE("magic130"));
            Display.Screen.AddResult(new Results.RemoveItem(itemSlot));

            Display.Screen.AddResult(new Results.BattleMsg(character.Name + " picked up a " + Data.GameData.ItemDex[itemIndex].Name + "."));
        }
Beispiel #29
0
        public Command Think()
        {
            try
            {
                List <ActiveChar> targets = GetSeenCharacters(false, false, true);

                if (targets.Count > 0)
                {
                    ActiveChar        target = targets[0];
                    List <Direction8> dirs   = FindPathToTarget(target.CharLoc, false);
                    if (dirs.Count == 0)
                    {
                        dirs = FindPathToTarget(target.CharLoc, true);
                    }
                    if (dirs.Count == 1)
                    {
                        return(new Command(Command.CommandType.Attack, (int)dirs[0]));
                    }
                    else if (ControlledChar.Status == Enums.StatusAilment.Freeze || ControlledChar.Status == Enums.StatusAilment.Sleep)
                    {
                        //attack if in front
                        return(new Command(Command.CommandType.Attack));
                    }
                    else if (dirs.Count > 1)
                    {
                        return(new Command(Command.CommandType.Move, (int)dirs[0]));//change to 8 to enable diagonal movement
                    }
                    else
                    {
                        //!?!?!?
                        return(new Command(Command.CommandType.Wait));
                    }
                }
                else
                {
                    //walk with purpose
                    return(new Command(Command.CommandType.Move, Processor.Rand.Next(8)));
                }
            }
            catch (Exception ex)
            {
                Logs.Logger.LogError(new Exception("AI Error\n", ex));
                return(new Command(Command.CommandType.Wait));
            }
        }
Beispiel #30
0
        private bool CanSeeCharacter(ActiveChar character)
        {
            if (character == null)
            {
                return(false);
            }
            int horizSight = HorizSight();
            int vertSight  = VertSight();

            if (character.CharLoc.X < ControlledChar.CharLoc.X - horizSight || character.CharLoc.X > ControlledChar.CharLoc.X + horizSight)
            {
                return(false);
            }
            if (character.CharLoc.Y < ControlledChar.CharLoc.Y - vertSight || character.CharLoc.Y > ControlledChar.CharLoc.Y + vertSight)
            {
                return(false);
            }

            return(true);
        }
Beispiel #31
0
 protected override void Choose(ActiveChar character, ref bool moveMade)
 {
     switch (CurrentChoice) {
         case 0: {//use
                 MenuManager.Menus.Clear();
                 Processor.ProcessDecision(new Command(Command.CommandType.Use, invSlot), character, ref moveMade);
             }
             break;
         case 1: {//throw
                 MenuManager.Menus.Clear();
                 Processor.ProcessDecision(new Command(Command.CommandType.Throw, invSlot), character, ref moveMade);
             }
             break;
         case 2: {//drop
                 MenuManager.Menus.Clear();
                 Processor.ProcessDecision(new Command(Command.CommandType.Drop, invSlot), character, ref moveMade);
             }
             break;
     }
 }
Beispiel #32
0
 public override void Process(Input input, ActiveChar character, ref bool moveMade)
 {
     if (input[Input.InputType.Enter] && !Processor.PrevInput[Input.InputType.Enter]) {
         Choose(character, ref moveMade);
     } else if (input[Input.InputType.X] && !Processor.PrevInput[Input.InputType.X]) {
         Choose(character, ref moveMade);
     } else if (input[Input.InputType.Z] && !Processor.PrevInput[Input.InputType.Z]) {
         MenuManager.Menus.RemoveAt(0);
     } else {
         bool chooseDown = (input.Direction == Direction8.Down || input.Direction == Direction8.DownLeft || input.Direction == Direction8.DownRight);
         bool prevDown = (Processor.PrevInput.Direction == Direction8.Down || Processor.PrevInput.Direction == Direction8.DownLeft || Processor.PrevInput.Direction == Direction8.DownRight);
         bool chooseUp = (input.Direction == Direction8.Up || input.Direction == Direction8.UpLeft || input.Direction == Direction8.UpRight);
         bool prevUp = (Processor.PrevInput.Direction == Direction8.Up || Processor.PrevInput.Direction == Direction8.UpLeft || Processor.PrevInput.Direction == Direction8.UpRight);
         if (chooseDown && (!prevDown || Processor.InputTime >= RenderTime.FromMillisecs(40)))
         {
             currentChoice = (currentChoice + 1) % Choices.Count;
         } else if (chooseUp && (!prevUp || Processor.InputTime >= RenderTime.FromMillisecs(40))) {
             currentChoice = (currentChoice + Choices.Count - 1) % Choices.Count;
         }
     }
 }
        protected override void Choose(ActiveChar character, ref bool moveMade)
        {
            switch (CurrentChoice)
            {
            case 0: {    //use
                MenuManager.Menus.Clear();
                Processor.ProcessDecision(new Command(Command.CommandType.Use, invSlot), character, ref moveMade);
            }
            break;

            case 1: {    //throw
                MenuManager.Menus.Clear();
                Processor.ProcessDecision(new Command(Command.CommandType.Throw, invSlot), character, ref moveMade);
            }
            break;

            case 2: {    //drop
                MenuManager.Menus.Clear();
                Processor.ProcessDecision(new Command(Command.CommandType.Drop, invSlot), character, ref moveMade);
            }
            break;
            }
        }
Beispiel #34
0
        private static void ProcessPlayerInput(ActiveChar character, ref bool moveMade)
        {
            if (MenuManager.Menus.Count > 0) {
                MenuManager.ProcessMenus(CurrentInput, character, ref moveMade);
                return;
            } else if (replayInputs.Count > 0 && !isLogging) {
                ProcessDecision(replayInputs[0], character, ref moveMade);
                replayInputs.RemoveAt(0);
                return;
            }

            Command command = new Command(Command.CommandType.None);

            bool jump = false;
            bool spell = false;
            bool turn = false;
            bool diagonal = false;

            #if GAME_MODE
            //menu button presses
            if (CurrentInput[Input.InputType.Enter] && !PrevInput[Input.InputType.Enter]) {
                MenuManager.Menus.Insert(0, new MainMenu());
            } else if (CurrentInput[Input.InputType.Q] && !PrevInput[Input.InputType.Q]) {
                MenuManager.Menus.Insert(0, new ItemMenu());
            } else if (CurrentInput[Input.InputType.W] && !PrevInput[Input.InputType.W]) {
                MenuManager.Menus.Insert(0, new SpellMenu());
            } else
            #endif
                //multi-button presses
            if (CurrentInput[Input.InputType.A]) {
                if (CurrentInput[Input.InputType.S] && !PrevInput[Input.InputType.S]) {
                    command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 0);
                } else if (CurrentInput[Input.InputType.D] && !PrevInput[Input.InputType.D]) {
                    command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 1);
                } else if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) {
                    command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 2);
                } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) {
                    command = new Logic.Gameplay.Command(Logic.Gameplay.Command.CommandType.Spell, 3);
                } else {
                    //keep move display
                    spell = true;
                    if (CurrentInput.Direction != Direction8.None) {
                        command = new Command(Command.CommandType.Dir);
                        command.AddArg((int)CurrentInput.Direction);
                    }
                }
            } else {
                if (CurrentInput[Input.InputType.Z]) {
                    jump = true;
                }
                if (CurrentInput[Input.InputType.S]) {
                    turn = true;
                }
                if (CurrentInput[Input.InputType.D]) {
                    diagonal = true;
                }

                //single button presses
                if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X]) {
                    if (jump) {
                        command = new Command(Command.CommandType.AltAttack);
                        command.AddArg((int)character.CharDir);
                        command.AddArg(1);
                    } else {
                        command = new Command(Command.CommandType.Attack);
                    }
                    jump = false;
                    turn = false;
                    diagonal = false;
                } else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C]) {
                    if (jump) {
                        command = new Command(Command.CommandType.Wait);
                    } else {
                        command = new Command(Command.CommandType.Pickup);
                    }
                    jump = false;
                    turn = false;
                    diagonal = false;
                }//directions
                else if (CurrentInput.Direction != Direction8.None) {
                    if (Display.Screen.DebugSpeed != Display.Screen.GameSpeed.Instant || PrevInput.Direction == Direction8.None)
                    {
                        Command.CommandType cmdType = Command.CommandType.None;
                        if (Operations.IsDiagonal(CurrentInput.Direction))
                            cmdType = Command.CommandType.Dir;
                        else if (InputTime > RenderTime.FromMillisecs(20) || PrevInput.Direction == Direction8.None)
                            cmdType = Command.CommandType.Dir;
                        if (InputTime > RenderTime.FromMillisecs(60) || Display.Screen.DebugSpeed == Display.Screen.GameSpeed.Instant) cmdType = Command.CommandType.Move;
                        if (jump) cmdType = Command.CommandType.AltAttack;
                        if (turn) cmdType = Command.CommandType.Dir;

                        if (!diagonal || Operations.IsDiagonal(CurrentInput.Direction))
                        {
                            command = new Command(cmdType);
                            command.AddArg((int)CurrentInput.Direction);
                        }
                        if (!turn)
                        {
                            jump = false;
                            diagonal = false;
                        }
                    }
                }
            }

            #if GAME_MODE
            Display.Screen.Jump = jump;
            Display.Screen.Spell = spell;
            Display.Screen.Turn = turn;
            Display.Screen.Diagonal = diagonal;
            #endif
            ProcessDecision(command, character, ref moveMade);
        }
Beispiel #35
0
 protected override void Choose(ActiveChar character, ref bool moveMade)
 {
     MenuManager.Menus.Clear();
     Processor.StartReplay(Choices[CurrentChoice].Text);
 }
Beispiel #36
0
 protected override void Choose(ActiveChar character, ref bool moveMade)
 {
     if (Processor.Inventory[CurrentChoice] >= 0) {
         MenuManager.Menus.Insert(0, new ItemChosenMenu(CurrentChoice));
     }
 }
Beispiel #37
0
        private static void ProcessTurnEnd(ActiveChar character)
        {
            if (!character.dead) {

                if (character.Status == Enums.StatusAilment.Poison) {
                    Display.Screen.BeginConcurrent();
                    DeductPP(character, 1);
                    character.StatusCounter--;
                    if (character.StatusCounter <= 0) {
                        SetStatusAilment(character, Enums.StatusAilment.OK, 0);
                    }
                }
            }
        }
Beispiel #38
0
 public static void ChangeAppearance(ActiveChar character, FormData data)
 {
     character.CharData = data;
     Display.Screen.AddResult(new Results.SpawnCharacter(character, CharIndex(character)));
 }
Beispiel #39
0
        private static void ProcessPlayerInput(ActiveChar character, ref bool moveMade)
        {
            if (MenuManager.Menus.Count > 0)
            {
                MenuManager.ProcessMenus(CurrentInput, character, ref moveMade);
                return;
            }
            else if (replayInputs.Count > 0 && !isLogging)
            {
                ProcessDecision(replayInputs[0], character, ref moveMade);
                replayInputs.RemoveAt(0);
                return;
            }

            Command command = new Command(Command.CommandType.None);

            bool jump     = false;
            bool spell    = false;
            bool turn     = false;
            bool diagonal = false;

#if GAME_MODE
            //menu button presses
            if (CurrentInput[Input.InputType.Enter] && !PrevInput[Input.InputType.Enter])
            {
                MenuManager.Menus.Insert(0, new MainMenu());
            }
            else if (CurrentInput[Input.InputType.Q] && !PrevInput[Input.InputType.Q])
            {
                MenuManager.Menus.Insert(0, new ItemMenu());
            }
            else if (CurrentInput[Input.InputType.W] && !PrevInput[Input.InputType.W])
            {
                MenuManager.Menus.Insert(0, new SpellMenu());
            }
            else
#endif
            //multi-button presses
            if (CurrentInput[Input.InputType.A])
            {
                if (CurrentInput[Input.InputType.S] && !PrevInput[Input.InputType.S])
                {
                    command = new Command(Command.CommandType.Spell, 0);
                }
                else if (CurrentInput[Input.InputType.D] && !PrevInput[Input.InputType.D])
                {
                    command = new Command(Command.CommandType.Spell, 1);
                }
                else if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X])
                {
                    command = new Command(Command.CommandType.Spell, 2);
                }
                else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C])
                {
                    command = new Command(Command.CommandType.Spell, 3);
                }
                else
                {
                    //keep move display
                    spell = true;
                    if (CurrentInput.Direction != Direction8.None)
                    {
                        command = new Command(Command.CommandType.Dir);
                        command.AddArg((int)CurrentInput.Direction);
                    }
                }
            }
            else
            {
                if (CurrentInput[Input.InputType.Z])
                {
                    jump = true;
                }
                if (CurrentInput[Input.InputType.S])
                {
                    turn = true;
                }
                if (CurrentInput[Input.InputType.D])
                {
                    diagonal = true;
                }

                //single button presses
                if (CurrentInput[Input.InputType.X] && !PrevInput[Input.InputType.X])
                {
                    if (jump)
                    {
                        command = new Command(Command.CommandType.AltAttack);
                        command.AddArg((int)character.CharDir);
                        command.AddArg(1);
                    }
                    else
                    {
                        command = new Command(Command.CommandType.Attack);
                    }
                    jump     = false;
                    turn     = false;
                    diagonal = false;
                }
                else if (CurrentInput[Input.InputType.C] && !PrevInput[Input.InputType.C])
                {
                    if (jump)
                    {
                        command = new Command(Command.CommandType.Wait);
                    }
                    else
                    {
                        command = new Command(Command.CommandType.Pickup);
                    }
                    jump     = false;
                    turn     = false;
                    diagonal = false;
                }//directions
                else if (CurrentInput.Direction != Direction8.None)
                {
                    if (Display.Screen.DebugSpeed != Display.Screen.GameSpeed.Instant || PrevInput.Direction == Direction8.None)
                    {
                        Command.CommandType cmdType = Command.CommandType.None;
                        if (Operations.IsDiagonal(CurrentInput.Direction))
                        {
                            cmdType = Command.CommandType.Dir;
                        }
                        else if (InputTime > RenderTime.FromMillisecs(20) || PrevInput.Direction == Direction8.None)
                        {
                            cmdType = Command.CommandType.Dir;
                        }
                        if (InputTime > RenderTime.FromMillisecs(60) || Display.Screen.DebugSpeed == Display.Screen.GameSpeed.Instant)
                        {
                            cmdType = Command.CommandType.Move;
                        }
                        if (jump)
                        {
                            cmdType = Command.CommandType.AltAttack;
                        }
                        if (turn)
                        {
                            cmdType = Command.CommandType.Dir;
                        }

                        if (!diagonal || Operations.IsDiagonal(CurrentInput.Direction))
                        {
                            command = new Command(cmdType);
                            command.AddArg((int)CurrentInput.Direction);
                        }
                        if (!turn)
                        {
                            jump     = false;
                            diagonal = false;
                        }
                    }
                }
            }

#if GAME_MODE
            Display.Screen.Jump     = jump;
            Display.Screen.Spell    = spell;
            Display.Screen.Turn     = turn;
            Display.Screen.Diagonal = diagonal;
#endif
            ProcessDecision(command, character, ref moveMade);
        }
Beispiel #40
0
        private static void ProcessAIDecision(ActiveChar character)
        {
            //picks an action
            bool moveMade = false;

            Command command = character.Tactic.Think();

            ProcessDecision(command, character, ref moveMade);
        }
Beispiel #41
0
        private static void ProcessDir(Direction8 dir, ActiveChar character, ref bool moveMade)
        {
            if (character.Status == Enums.StatusAilment.Freeze) {
                return;
            }

            character.CharDir = dir;
            Display.Screen.AddResult(new Results.Dir(CharIndex(character), character.CharDir));
        }
Beispiel #42
0
 public Defeated(int charIndex, ActiveChar character)
 {
     this.charIndex = charIndex;
     this.charData = character.CharData;
     this.dir = character.CharDir;
 }
Beispiel #43
0
        private static void ProcessDrop(ActiveChar character, int invSlot, ref bool moveMade)
        {
            if (!CanDrop(invSlot)) {
                Display.Screen.AddResult(new Results.BattleMsg("Can't drop slot " + (invSlot + 1)));
                return;
            }
            Loc2D loc = character.CharLoc;
            if (!CanItemLand(loc)) {
                Display.Screen.AddResult(new Results.BattleMsg("Can't drop here!"));
                return;
            }
            moveMade = true;
            int itemIndex = Inventory[invSlot];

            int mapSlot = CurrentMap.AddItem(new Item(itemIndex, 1, "", false, loc));

            Inventory[invSlot] = -1;

            Display.Screen.AddResult(new Results.SE("magic693"));
            Display.Screen.AddResult(new Results.AddItem(CurrentMap, mapSlot));

            Display.Screen.AddResult(new Results.BattleMsg(character.Name + " dropped a " + Data.GameData.ItemDex[itemIndex].Name + "."));
        }
Beispiel #44
0
        private static void ProcessMapTurnEnd(ActiveChar character)
        {
            if (!character.dead) {
                if (character.VolatileStatus.ContainsKey("MovementSpeed")) {
                    character.VolatileStatus["MovementSpeed"].Counter--;
                    if (character.VolatileStatus["MovementSpeed"].Counter <= 0) {
                        AddExtraStatus(character, "MovementSpeed", 0, -1, 0);
                    }
                }

                if (character.MovementSpeed < 0) {
                    character.TurnCounter++;
                    if (character.TurnCounter > 0) character.TurnCounter = character.MovementSpeed;
                }

                if (character.Status == Enums.StatusAilment.Burn) {
                    Display.Screen.BeginConcurrent();
                    DamageCharacter(character, 1, false);
                    character.StatusCounter--;
                    if (character.StatusCounter <= 0) {
                        SetStatusAilment(character, Enums.StatusAilment.OK, 0);
                    }
                }
            }
        }
Beispiel #45
0
        private static void ProcessPickup(ActiveChar character, ref bool moveMade)
        {
            Tile tile = CurrentMap.MapArray[character.CharLoc.X, character.CharLoc.Y];

            int freeSlot = FindInvSlot();

            if (tile.Data.Type == Enums.TileType.ChangeFloor) {
                //if we're at the stairs, we go on
                //a case for changing floor; leader only!
                if (character == Players[0]) {
                    Display.Screen.AddResult(new Results.SE("magic135"));
                    //send changefloor result
                    Display.Screen.AddResult(new Results.Fade(Display.Screen.FadeType.FadeOut));
                    Display.Screen.AddResult(new Results.BattleMsg("Advanced to the next floor!"));
                    //character.CharLoc = new Loc2D(tile.Data2, tile.Data3);
                    //CurrentFloor = tile.Data1;
                    MoveToFloor(tile.Data.Data1);
                    Display.Screen.AddResult(new Results.Fade(Display.Screen.FadeType.FadeIn));
                }
            }

            int itemSlot = CurrentMap.GetItem(character.CharLoc);
            if (itemSlot == -1)
            {
                Display.Screen.AddResult(new Results.BattleMsg("Nothing there."));
                return;
            }

            if (freeSlot == -1) {
                Display.Screen.AddResult(new Results.BattleMsg("Inv full"));
                return;
            }
            moveMade = true;
            int itemIndex = CurrentMap.Items[itemSlot].ItemIndex;
            Inventory[freeSlot] = itemIndex;
            CurrentMap.Items[itemSlot] = new Item();

            Display.Screen.AddResult(new Results.SE("magic130"));
            Display.Screen.AddResult(new Results.RemoveItem(itemSlot));

            Display.Screen.AddResult(new Results.BattleMsg(character.Name + " picked up a " + Data.GameData.ItemDex[itemIndex].Name + "."));
        }
Beispiel #46
0
 public static bool DirBlocked(Direction8 dir, ActiveChar character)
 {
     return DirBlocked(dir, character, false);
 }
Beispiel #47
0
 public static int CharIndex(ActiveChar character)
 {
     if (character is Player) return (Array.IndexOf(Players, character) - MAX_TEAM_SLOTS);
     return Array.IndexOf(Npcs, character);
 }
Beispiel #48
0
 protected override void Choose(ActiveChar character, ref bool moveMade)
 {
     MenuManager.Menus.Clear();
     Processor.ProcessDecision(new Command(Command.CommandType.Spell, CurrentChoice), character, ref moveMade);
 }
Beispiel #49
0
        //the intention, and its result to that frame
        //"choose the action to partake in"
        public static void ProcessDecision(Command command, ActiveChar character, ref bool moveMade)
        {
            //translates commands into actions
            if (character == FocusedCharacter && command.Type != Command.CommandType.None && isLogging)
            {
                Logs.Logger.LogJourney(command);
            }

            switch (command.Type)
            {
            case Command.CommandType.Dir:
            {
                ProcessDir((Direction8)command[0], character, ref moveMade);
            }
            break;

            case Command.CommandType.Move:
            {
                Display.Screen.BeginRunModeConcurrent(CharIndex(character));
                //takes a dir argument
                //Display.Screen.ResultList.Add(new Results.StartTag("Move"));
                if (command.ArgCount > 0)
                {
                    ProcessDir((Direction8)command[0], character, ref moveMade);
                }
                ProcessWalk(character, ref moveMade);
                //Display.Screen.ResultList.Add(new Results.EndTag());
            }
            break;

#if GAME_MODE
            case Command.CommandType.Attack: {
                Display.Screen.BeginConcurrent();
                //takes a dir argument
                if (command.ArgCount > 0)
                {
                    ProcessDir((Direction8)command[0], character, ref moveMade);
                }
                Attack(character, ref moveMade);
            }
            break;

            case Command.CommandType.Pickup:
            {
                Display.Screen.BeginConcurrent();
                //takes an index argument
                ProcessPickup(character, ref moveMade);
            }
            break;

            case Command.CommandType.Use:
            {
                Display.Screen.BeginConcurrent();
                //takes an index argument
                ProcessItemUse(character, command[0], ref moveMade);
            }
            break;

            case Command.CommandType.Throw:
            {
                Display.Screen.BeginConcurrent();
                //takes an index argument
                ProcessThrow(character, command[0], ref moveMade);
            }
            break;

            case Command.CommandType.Drop:
            {
                Display.Screen.BeginConcurrent();
                //takes an index argument
                ProcessDrop(character, command[0], ref moveMade);
            }
            break;

            case Command.CommandType.Spell:
            {
                Display.Screen.BeginConcurrent();
                //takes an index argument
                UseMove(character, command[0], ref moveMade);
            }
            break;
#endif
            case Command.CommandType.Wait:
            {
                moveMade = true;
            }
            break;

            default: break;
            }
            if (moveMade)
            {
                ProcessTurnEnd(character);
            }
        }
Beispiel #50
0
 public override void Process(Input input, ActiveChar character, ref bool moveMade)
 {
     base.Process(input, character, ref moveMade);
 }
Beispiel #51
0
        private static void ProcessWalk(ActiveChar character, ref bool moveMade)
        {
            if (character.dead) return;

            Loc2D loc = character.CharLoc;
            Operations.MoveInDirection8(ref loc, character.CharDir, 1);

            //check for blocking
            if (DirBlocked(character.CharDir, character)) {
                return;
            }

            moveMade = true;

            if (character.Status == Enums.StatusAilment.Freeze) {
                return;
            }

            character.CharLoc = loc;

            Display.Screen.AddResult(new Results.CreateAction(CharIndex(character), character, Display.CharSprite.ActionType.Walk));

            Display.Screen.AddResult(new Results.Loc(CharIndex(character), loc));

            moveMade = true;

            //if void, add restart
            if (!Operations.IsInBound(CurrentMap.Width, CurrentMap.Height, character.CharLoc.X, character.CharLoc.Y)) {
                //Lose();
                throw new Exception("Player out of bounds");
            } else {
                //god mode check
                if (Intangible)
                    return;

                Tile tile = CurrentMap.MapArray[character.CharLoc.X, character.CharLoc.Y];

                //if landed on certain tiles, present effects
                if (tile.Data.Type == Enums.TileType.Slippery)
                {
                    //if on ice, continue to slide
                    //but only if we're not blocked
                    if (!DirBlocked(character.CharDir, character))
                    {
                        ProcessWalk(character, ref moveMade);
                    }
                }

            }
        }
Beispiel #52
0
 protected override void Choose(ActiveChar character, ref bool moveMade)
 {
     MenuManager.Menus.Clear();
     Processor.StartReplay(Choices[CurrentChoice].Text);
 }
Beispiel #53
0
 private static void ProcessRoundEnd(ActiveChar character)
 {
     if (!character.dead) {
         if (character.MovementSpeed >= 0) {
             character.TurnCounter = character.MovementSpeed;
         }
     }
 }
Beispiel #54
0
        //the intention, and its result to that frame
        //"choose the action to partake in"
        public static void ProcessDecision(Command command, ActiveChar character, ref bool moveMade)
        {
            //translates commands into actions
            if (character == FocusedCharacter && command.Type != Command.CommandType.None && isLogging) {
                Logs.Logger.LogJourney(command);
            }

            switch (command.Type) {
                case Command.CommandType.Dir: {
                        ProcessDir((Direction8)command[0], character, ref moveMade);
                    }
                    break;
                case Command.CommandType.Move:
                    {
                        Display.Screen.BeginRunModeConcurrent(CharIndex(character));
                        //takes a dir argument
                        //Display.Screen.ResultList.Add(new Results.StartTag("Move"));
                        if (command.ArgCount > 0) {
                            ProcessDir((Direction8)command[0], character, ref moveMade);
                        }
                        ProcessWalk(character, ref moveMade);
                        //Display.Screen.ResultList.Add(new Results.EndTag());
                    }
                    break;
                    #if GAME_MODE
                    case Command.CommandType.Attack: {
                        Display.Screen.BeginConcurrent();
                        //takes a dir argument
                        if (command.ArgCount > 0) {
                            ProcessDir((Direction8)command[0], character, ref moveMade);
                        }
                        Attack(character, ref moveMade);
                    }
                    break;
                    case Command.CommandType.Pickup:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessPickup(character, ref moveMade);
                    }
                    break;
                    case Command.CommandType.Use:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessItemUse(character, command[0], ref moveMade);
                    }
                    break;
                    case Command.CommandType.Throw:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessThrow(character, command[0], ref moveMade);
                    }
                    break;
                    case Command.CommandType.Drop:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        ProcessDrop(character, command[0], ref moveMade);
                    }
                    break;
                    case Command.CommandType.Spell:
                    {
                        Display.Screen.BeginConcurrent();
                        //takes an index argument
                        UseMove(character, command[0], ref moveMade);
                    }
                    break;
            #endif
                    case Command.CommandType.Wait:
                    {
                        moveMade = true;
                    }
                    break;
                    default: break;
            }
            if (moveMade) {
                ProcessTurnEnd(character);
            }
        }
Beispiel #55
0
 public AI(ActiveChar controlledChar)
 {
     ControlledChar = controlledChar;
 }
Beispiel #56
0
        public static bool DirBlocked(Direction8 dir, ActiveChar character, Loc2D loc, bool inAir, int distance)
        {
            if (character == FocusedCharacter && Intangible)
            {
                Operations.MoveInDirection8(ref loc, dir, 1);
                if (!Operations.IsInBound(CurrentMap.Width, CurrentMap.Height, loc.X, loc.Y))
                    return true;

                return false;
            }

            Enums.WalkMode walkMode = Enums.WalkMode.Normal;

            if (inAir)
                walkMode = Enums.WalkMode.Air;

            for (int i = 0; i < distance; i++) {

                Operations.MoveInDirection8(ref loc, dir, 1);

                if (IsBlocked(loc, walkMode))
                    return true;
            }

            return false;
        }
Beispiel #57
0
 public override void Process(Input input, ActiveChar character, ref bool moveMade)
 {
     base.Process(input, character, ref moveMade);
 }
Beispiel #58
0
 public static bool DirBlocked(Direction8 dir, ActiveChar character, bool inAir, int distance)
 {
     return DirBlocked(dir, character, character.CharLoc, inAir, distance);
 }
Beispiel #59
0
 public abstract void Process(Input input, ActiveChar character, ref bool moveMade);
Beispiel #60
0
 public static bool DirBlocked(Direction8 dir, ActiveChar character, bool inAir)
 {
     return DirBlocked(dir, character, inAir, 1);
 }