Exemplo n.º 1
0
    static void ActChaos(gamebook.Scenario SC, critters.Critter C)
    {
        /*The critter is gonna be acting chaotically right now.*/

        /*Determine a direction to move in. We don't want dir 5*/
        /*to be a valid choice.*/
        int D = rpgdice.Random(8) + 1;

        if (D > 4)
        {
            D += 1;
        }

        int t = 1;

        while (texmaps.TerrPass[SC.gb.map[C.M.x + texmaps.VecDir[D - 1, 0] - 1, C.M.y + texmaps.VecDir[D - 1, 1] - 1].terr - 1] < 1 && t <= 3)
        {
            D = rpgdice.Random(8) + 1;
            if (D > 4)
            {
                D += 1;
            }
            t += 1;
        }

        texmaps.WalkReport WR = WalkCritter(SC, texmaps.VecDir[D - 1, 0], texmaps.VecDir[D - 1, 1]);
        if (SC.CAct == null)
        {
            return;
        }

        if (WR.m != null)
        {
            /*Chaotic critters usually won't attack others of*/
            /*their own kind... usually. As a lazy way of*/
            /*checking this and making alliances, assume that any*/
            /*two models using the same letter to represent them*/
            /*are friendly.*/
            if (WR.m.kind == critters.MKIND_Critter && WR.m.gfx == C.M.gfx && rpgdice.Random(100) != 23)
            {
                if (texmaps.TileLOS(SC.gb.POV, C.M.x, C.M.y) && texmaps.OnTheScreen(SC.gb, C.M.x, C.M.y))
                {
                    rpgtext.DCGameMessage(critters.MonMan[C.crit - 1].name + " growls.");
                }
            }
            else if (WR.m.kind == dcchars.MKIND_Character || WR.m.kind == critters.MKIND_Critter)
            {
                if (rpgdice.Random(8) != 5)
                {
                    C.Target = WR.m;
                }

                CritterAttack(SC, C, WR.m.x, WR.m.y);
            }
        }
    }
Exemplo n.º 2
0
    static void ActAgressive(gamebook.Scenario SC, critters.Critter C)
    {
        /*This critter apparently has a target. Try to get as*/
        /*close to it as possible.*/

        /*Check, first of all, that we have a target.*/
        if (C.Target == null)
        {
            ActPassive(SC);
            return;
        }

        /*Next, on a random whim, check to make sure the target is*/
        /*still visible.*/
        if (rpgdice.Random(3) == 1 && C.Target == SC.PC.m && !C.Spotted)
        {
            int O = texmaps.CalcObscurement(C.M, C.Target, SC.gb);
            if (O == -1 || O > critters.MonMan[C.crit - 1].Sense)
            {
                C.Target = null;
                ActPassive(SC);
                return;
            }
        }
        else if (rpgdice.Random(10) == 3)
        {
            if (C.HP >= critters.MonMan[C.crit - 1].MaxHP)
            {
                int O = texmaps.CalcObscurement(C.M, C.Target, SC.gb);
                if (O == -1 || O > critters.MonMan[C.crit - 1].Sense)
                {
                    C.Target = null;
                    ActPassive(SC);
                    return;
                }
            }
        }

        /*Check to see whether or not our critter is gonna try a missile attack.*/
        if (TacRange(C) > 0 && rpgdice.Random(2) == 1 && texmaps.CalcObscurement(C.M, C.Target, SC.gb) > -1)
        {
            /* In addition to the above qualifiers, the critter will */
            /* only use a missile attack if its target is within visual */
            /* range or if it can be seen by the PC. */
            if (texmaps.Range(C.M, C.Target) < critters.MonMan[C.crit - 1].Sense || texmaps.TileLOS(SC.gb.POV, C.M.x, C.M.x))
            {
                CritterAttack(SC, C, C.Target.x, C.Target.y);
                return;
            }
        }

        /*We aren't gonna try a missile attack.*/
        /*Move towards the target.*/
        int DX = 0;
        int DY = 0;

        if (C.Target.x < C.M.x)
        {
            DX = -1;
        }
        else if (C.Target.x > C.M.x)
        {
            DX = 1;
        }

        if (C.Target.y < C.M.y)
        {
            DY = -1;
        }
        else if (C.Target.y > C.M.y)
        {
            DY = 1;
        }

        /*Check to see if we're in attack range.*/
        if (C.M.x + DX != C.Target.x || C.M.y + DY != C.Target.y)
        {
            /*Check for obstructions*/
            if (!MoveOK(SC, C.M.x + DX, C.M.y + DY))
            {
                if (MoveOK(SC, C.M.x + DX, C.M.y))
                {
                    DY = 0;
                }
                else if (MoveOK(SC, C.M.x, C.M.y + DY))
                {
                    DX = 0;
                }
                else if (rpgdice.Random(2) == 1)
                {
                    ActPassive(SC);
                    return;
                }
            }
        }

        texmaps.WalkReport WR = WalkCritter(SC, DX, DY);
        if (SC.CAct == null)
        {
            return;
        }

        if (WR.m != null)
        {
            /*The critter has walked into a model. Decide*/
            /*whether or not to attack.*/

            /*If the model is in the same square as the critter's target,*/
            /*it will be attacked. Before I just used to compare the*/
            /*target model with WR.M, but since adding clouds to the game*/
            /*I have to compare the position of WR.M to the position of*/
            /*the int}ed target. This is important just in case the*/
            /*critter is attempting to attack a hallucination-inducing*/
            /*cloud, and instead blunders into one of its own buddies...*/

            if (WR.m.x == C.Target.x && WR.m.y == C.Target.y)
            {
                CritterAttack(SC, C, WR.m.x, WR.m.y);
            }
        }
    }
Exemplo n.º 3
0
    public static bool PCMove(gamebook.Scenario SC, int D)
    {
        /*This procedure allows the PC to walk.*/


        int X2 = SC.PC.m.x + texmaps.VecDir[D - 1, 0];
        int Y2 = SC.PC.m.y + texmaps.VecDir[D - 1, 1];

        texmaps.WalkReport WR = texmaps.MoveModel(SC.PC.m, SC.gb, X2, Y2);

        if (WR.m != null)
        {
            if (WR.m.kind == critters.MKIND_Critter)
            {
                PCMeleeAttack(SC, WR.m.x, WR.m.y);
            }
            else if (WR.m.kind == cwords.MKIND_MPU)
            {
                mdlogon.MDSession(SC, WR.m);
            }
            else if (WR.m != SC.PC.m)
            {
                rpgtext.DCGameMessage("Blocked.");
            }
        }
        else if (WR.go)
        {
            /*Add special terrain messages and effects here.*/
            if (SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1] != null)
            {
                /*There's an item on the floor here.*/
                if (SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1].next != null)
                {
                    /*There are multiple items on the floor here.*/
                    rpgtext.DCGameMessage("There are several items on the floor here.");
                }
                else
                {
                    /*There is a single item on the floor here.*/
                    if (dcitems.Mergeable(SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1]) && SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1].charge > 1)
                    {
                        rpgtext.DCGameMessage("You find " + dcitems.ItemNameLong(SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1]) + " on the floor here.");
                    }
                    else
                    {
                        rpgtext.DCGameMessage("There is a " + dcitems.ItemNameShort(SC.ig.g[SC.PC.m.x - 1, SC.PC.m.y - 1]) + " on the floor here.");
                    }
                }
            }
            else if (texmaps.GetTerr(SC.gb, SC.PC.m.x, SC.PC.m.y) == 10)
            {
                if (rpgdice.Dice(10) > StepOnBlood)
                {
                    rpgtext.DCGameMessage("There are blood stains on the floor here.");
                }
                if (StepOnBlood < 20)
                {
                    StepOnBlood += 1;
                }
            }
            else if (texmaps.GetTerr(SC.gb, SC.PC.m.x, SC.PC.m.y) == texmaps.Chair)
            {
                rpgtext.DCGameMessage("There is a chair here.");
            }

            if (WR.trap != 0)
            {
                /*There's a trap here. The PC might just set it off!*/
                MightActivateTrap(SC);
            }

            /*Make sure the PC is still alive before providing*/
            /*more information.*/
            if (SC.PC.HP > 0)
            {
                /*Check the Monster Memory*/
                CheckMonsterMemory(SC);
                CheckForTraps(SC, 0);
                CheckForSecretDoors(SC, 0);

                /*Activate any plot points here.*/
                if (SC.gb.map[SC.PC.m.x - 1, SC.PC.m.y - 1].special > 0)
                {
                    gamebook.SetTrigger(SC, gamebook.PLT_MapSquare, SC.gb.map[SC.PC.m.x - 1, SC.PC.m.y - 1].special);
                }
            }
        }
        else if (WR.m == null && texmaps.TerrPass[texmaps.GetTerr(SC.gb, X2, Y2) - 1] > 0)
        {
            /*We haven't moved, and we didn't hit a model, so...*/
            /*it must be terrain stopping us!!!*/
            rpgtext.DCGameMessage("Slow progress...");
        }
        else if (D != 5)
        {
            /*This is a catch all, for walls and other miscellaneous things.*/
            rpgtext.DCGameMessage("Blocked.");
        }

        return(true);
    }