Example #1
0
 public GlobalCritterStealingEventArgs(Critter cr, Critter thief, Item item, int count)
 {
     this.Cr = cr;
     this.Thief = thief;
     this.Item = Item;
     this.Count = Count;
 }
Example #2
0
        public static void InitAnimalEvil(Critter critter)
        {
            var builder = new CritterBehaviorBuilder (critter);

            builder
                .Do (new CallReinforcements (BlackboardKeys.Attackers))
                .DoSequence ("3% to attack weakest animal from my team - fight over the area")
                    .Do (new AtFixedRate<CritterBlackboard> (Time.RealSecond (10)))
                    .Do (new AtChance<CritterBlackboard> (3))
                    .Do (new FindCritters (Find.Life).Choose (new Weakest ())).If (new SeesCritter ()).If (new IsTeamMember ())
                    .Do (new Attack ())
                .End ()
                .DoSequence ("10% to attack animal of same type from other team")
                    .Do (new AtFixedRate<CritterBlackboard> (Time.RealSecond (10)))
                    .Do (new AtChance<CritterBlackboard> (10))
                    .Do (new FindCritters (Find.Life).Choose (new BT.Random ())).If (new SeesCritter ()).IfNot (new IsTeamMember ())
                    .Do (new Attack ())
                .End ()
                .DoSequence ("Attack every non member and not same type critter")
                    .Do (new FindCritters (Find.Life)).IfNot (new AmAttacking ()).If (new SeesCritter ()).If (new IsTeamMember ()).IfNot (new IsSameType ())
                    .Do (new Attack ())
                .End ()
                .Do (new ProvideReinforcements ()).IfNot (new AmAttacking ());

            Global.RegisterBehaviorTask (builder.MainTask);
        }
Example #3
0
        public UInt16Array ChooseAttackPosition(Critter npc, Critter target, AttackChoice attackChoice)
        {
            var weapon = npc.GetItemById (attackChoice.WeaponId);
            if (weapon == null)
                return null;

            var weaponDistance = weapon.Proto.WeaponMaxDist (attackChoice.WeaponUse);
            var distance = Global.GetDistance (npc, target);

            if (weaponDistance < distance) {
                var direction = Global.GetDirection (npc, target);
                var hexX = npc.HexX;
                var hexY = npc.HexY;

                do {
                    npc.GetMap ().MoveHexByDir (ref hexX, ref hexY, direction, 1);
                } while(!npc.GetMap ().IsHexPassed (hexX, hexY));

                var result = new UInt16Array ();
                result.Add (hexX);
                result.Add (hexY);
                result.Add ((ushort)direction);
                return result;
            }

            return null;
        }
Example #4
0
 // called by engine
 bool RaiseAttack(Critter cr, Critter target)
 {
     if (Attack != null)
     {
         var e = new ItemAttackEventArgs(this, cr, target);
         Attack(this, e);
         return e.Prevent;
     }
     return false;
 }
Example #5
0
 // called by engine
 public bool RaiseUse(Critter cr, Critter on_critter, Item on_item, IntPtr on_scenery)
 {
     if (Use != null)
     {
         var e = new ItemUseEventArgs(this, cr, on_critter, on_item, Scenery.FromNative(on_scenery));
         Use(this, e);
         return e.Prevent;
     }
     return false;
 }
Example #6
0
        public static void InitGyro(Critter npc)
        {
            var builder = new CritterBehaviorBuilder(npc);

            builder
                .DoSequence("I am attacked")
                    .Do(new CallReinforcements(BlackboardKeys.Attackers, BlackboardKeys.SeenAttackers, BlackboardKeys.Killers))
            //TODO: maybe run to guard
                .End();

            Global.RegisterBehaviorTask(builder.MainTask);
        }
Example #7
0
        public static void InitAnimalGood(Critter critter)
        {
            var builder = new CritterBehaviorBuilder (critter);

            builder
                .Do (new CallReinforcements (BlackboardKeys.Attackers))
                .Do (new ProvideReinforcements ()).IfNot (new AmAttacking ())
                .DoSequence ("Move randomly every 10-20 seconds")
                    .Do (new AtFixedRate<CritterBlackboard> (Time.RealSecond (10), Time.RealSecond (20)))
                    .Do (new MoveRandomly (1, 5))
                .End ();

            Global.RegisterBehaviorTask (builder.MainTask);
        }
Example #8
0
 public static bool AddAttackPlane(this Critter npc, uint priority, Critter target, int minHp)
 {
     NpcPlane plane=Global.CreatePlane();
     plane.Type=PlaneType.Attack;
     plane.Priority=(priority==0?Priorities.Attack:priority);
     plane.Attack_TargId=target.Id;
     plane.Attack_MinHp=minHp;
     plane.Attack_IsGag=false;
     plane.Attack_GagHexX=0;
     plane.Attack_GagHexY=0;
     plane.Attack_LastHexY=target.HexY;
     plane.Attack_LastHexX=target.HexX;
     plane.Run=false;
     return npc.AddPlane(plane);
 }
Example #9
0
        public Critter ChooseNextTarget(Critter npc, Critter currentTarget)
        {
            var enemyStack = new UIntArray ();
            npc.GetEnemyStack (enemyStack);

            for (int i = 0; i < enemyStack.Length; i++) {
                if (enemyStack [i] != 0) {
                    var target = npc.GetMap ().GetCritter (enemyStack [i]);
                    if (target != null)
                        return target;
                }
            }

            return null;
        }
Example #10
0
        /**
         * Init methods for use in Mono
         */
        public static void InitGuard(Critter npc)
        {
            var builder = new CritterBehaviorBuilder(npc);

            builder
                .DoSequence()
                    .Do(new CallReinforcements(BlackboardKeys.Attackers, BlackboardKeys.SeenAttackers, BlackboardKeys.Killers))
                    .Do(new BT.Say(FOnline.Say.NormOnHead, TextMsg.Text, 70140))
                    .Do(new Attack(BlackboardKeys.Attackers))
                .End()
                .DoSelection()
                    .Do(new ProvideReinforcements())
                .End();

            Global.RegisterBehaviorTask(builder.MainTask);
        }
Example #11
0
        /**
         * Init methods for use in Mono
         */
        public static void InitGuard(Critter npc)
        {
            var builder = new CritterBehaviorBuilder(npc);

            builder
                .DoSequence()
                    .Do(new CallReinforcements(BlackboardKeys.Attackers, BlackboardKeys.SeenAttackers, BlackboardKeys.Killers))
                    .Do(new Attack(BlackboardKeys.Attackers))
                .End()
                .DoSelection()
                    .Do(new ProvideReinforcements())
                .End()
                .DoSequence()
                    .Do(new Patrol(Entire.Patrol))
                    .Do(new LookAround(3, Time.RealSecond(15)))
                .End();

            Global.RegisterBehaviorTask(builder.MainTask);
        }
        public static void InitCritter1(Critter npc)
        {
            var builder = new CritterBehaviorBuilder(npc);

            builder
                .Do(new TakeDrug(ItemPack.HealingDrugs).If(new IsHurt(70)))
                .DoSequence("Attack and call reinforcements")
                    .Do(new CallReinforcements(BlackboardKeys.Attackers, BlackboardKeys.SeenAttackers, BlackboardKeys.Killers))
                    .Do(new CallReinforcements(VirtualRealityReinforcements, BlackboardKeys.Attackers, BlackboardKeys.Killers))
                    .Do(new Attack(BlackboardKeys.Attackers))
                .End()
                .Do(new ProvideReinforcements()).IfNot(new AmAttacking())
                .Do(new ProvideReinforcements(VirtualRealityReinforcements)).IfNot(new AmAttacking()).If(new SeesCritter())
                .DoSequence("Find player and attack him")
                    .Do(new FindCritters(Find.Life | Find.OnlyPlayers).Choose(new Weakest())).If(new SeesCritter()).IfNot(new AmAttacking())
                    .Do(new Attack())
                .End();

            Global.RegisterBehaviorTask(builder.MainTask);
        }
Example #13
0
        /**
         * Init methods for use in Mono
         */
        public static void InitHumanEvil(Critter critter)
        {
            var builder = new CritterBehaviorBuilder (critter);

            builder
                .Do (new CallReinforcements (BlackboardKeys.Attackers))
                .Do (new TakeDrug (ItemPack.HealingDrugs)).If (new IsHurt (70))
                .DoSequence ("20% to find weakest player and attack him instead")
                    .Do (new AtFixedRate<CritterBlackboard> (Time.RealSecond (10)))
                    .Do (new AtChance<CritterBlackboard> (20))
                    .Do (new FindCritters (Find.Life | Find.OnlyPlayers).Choose (new Weakest ())).If (new SeesCritter ()).IfNot (new IsTeamMember ())
                    .Do (new Attack ())
                .End ()
                .DoSequence ("Attack every non member")
                    .Do (new FindCritters (Find.Life)).If (new SeesCritter ()).IfNot (new AmAttacking ()).IfNot (new IsTeamMember ())
                    .Do (new Attack ())
                .End ()
                .Do (new ProvideReinforcements ()).IfNot (new AmAttacking ());

            Global.RegisterBehaviorTask (builder.MainTask);
        }
Example #14
0
 public static bool AddAttackPlane(this Critter npc, uint priority, Critter target)
 {
     if(npc.IsPlayer)
     {
         Map map=npc.GetMap();
         uint loc=0;
         if(map != null) loc=map.GetLocation().GetProtoId();
         Global.Log("ERR: adding attack plane to player, loc pid={0}", loc);
     }
     NpcPlane plane=Global.CreatePlane();
     plane.Type=PlaneType.Attack;
     plane.Priority=(priority==0?Priorities.Attack:priority);
     plane.Attack_TargId=target.Id;
     plane.Attack_MinHp=Global.DeadHitPoints;
     plane.Attack_IsGag=false;
     plane.Attack_GagHexX=0;
     plane.Attack_GagHexY=0;
     plane.Attack_LastHexX=target.HexX;
     plane.Attack_LastHexY=target.HexY;
     plane.Run=false;
     return npc.AddPlane(plane);
 }
Example #15
0
        public AttackChoice ChooseAttack(Critter npc, Critter target)
        {
            var attackChoice = new AttackChoice ();
            var currentItem = npc.GetItemHand ();
            Item weaponItem = null;

            if (currentItem != null) {
                if (CanBeMyWeapon (npc, currentItem)) {
                    weaponItem = currentItem;
                }
            } else {
                weaponItem = null;
            }

            if (weaponItem == null) {
                return null;
            }
            attackChoice.WeaponId = weaponItem.Id;
            attackChoice.WeaponUse = 0;
            attackChoice.HitLocation = HitLocation.Uncalled;

            return attackChoice;
        }
Example #16
0
        private bool CanBeMyWeapon(Critter npc, Item item)
        {
            if (item.Type != ItemType.Weapon)
                return false;

            int skill = item.Proto.WeaponSkill (0);
            return skill == Skills.SmallGuns || skill == Skills.EnergyWeapons || skill == Skills.BigGuns;
        }
Example #17
0
 public CritterAttackedEventArgs(Critter cr, Critter attacker)
     : base(cr)
 {
     this.Attacker = attacker;
 }
Example #18
0
 public CritterFinishEventArgs(Critter cr, bool deleted)
     : base(cr)
 {
     this.Deleted = deleted;
 }
Example #19
0
 public bool RunDialog(Critter player, uint dialog_pack, ushort hx, ushort hy, bool ignore_distance)
 {
     return Global_RunDialogHex(player.ThisPtr, dialog_pack, hx, hy, ignore_distance);
 }
Example #20
0
 public bool RunDialog(Critter player, Critter npc, bool ignore_distance)
 {
     return Global_RunDialogNpc(player.ThisPtr, npc.ThisPtr, ignore_distance);
 }
Example #21
0
 public CritterSmthAttackEventArgs(Critter cr, Critter from_cr, Critter target)
     : base(cr, target)
 {
     this.From = from_cr;
 }
Example #22
0
 public CritterSmthStealingEventArgs(Critter cr, Critter from_cr, Critter thief, bool success, Item item, uint count)
     : base(cr, thief, success, item, count)
 {
     this.From = from_cr;
 }
Example #23
0
 public CritterSmthTurnBasedProcessEventArgs(Critter cr, Critter from_cr, Map map, bool begin_turn)
     : base(cr, map, begin_turn)
 {
     this.From = from_cr;
 }
Example #24
0
 public CritterTurnBasedProcessEventArgs(Critter cr, Map map, bool begin_turn)
     : base(cr)
 {
     this.Map       = map;
     this.BeginTurn = begin_turn;
 }
Example #25
0
 public CritterGlobalProcessEventArgs(Critter cr, GlobalProcessType type, Item car)
     : base(cr)
 {
     this.Type = type;
     this.Car  = car;
 }
Example #26
0
 public CritterVisEventArgs(Critter cr, Critter show_cr)
     : base(cr)
 {
     this.ShowCr = show_cr;
 }
Example #27
0
 public CritterSmthMoveItemEventArgs(Critter cr, Critter from_cr, Item item, ItemSlot from_slot)
     : base(cr, item, from_slot)
 {
     this.From = from_cr;
 }
Example #28
0
 public CritterSmthDropItemEventArgs(Critter cr, Critter from_cr, Item item)
     : base(cr, item)
 {
     this.From = from_cr;
 }
Example #29
0
 public void MoveItems(ItemArray items, Critter to_cr)
 {
     Global_MoveItemsCr(items.ThisPtr, to_cr.ThisPtr);
 }
Example #30
0
 public CritterSmthUseSkillEventArgs(Critter cr, Critter from_cr, int skill, Critter on_cr, Item on_item, Scenery on_scenery)
     : base(cr, skill, on_cr, on_item, on_scenery)
 {
     this.From = from_cr;
 }
Example #31
0
 public CritterChangeItemOnMapEventArgs(Critter cr, Item item)
     : base(cr)
 {
     this.Item = item;
 }
Example #32
0
 public CritterUseSkillOnMeEventArgs(Critter cr, Critter who_use, int skill)
     : base(cr)
 {
     this.WhoUse = who_use;
     this.Skill  = skill;
 }
Example #33
0
 public CritterEventArgs(Critter cr)
 {
     this.Cr = cr;
 }
Example #34
0
 public CritterUseItemOnMeEventArgs(Critter cr, Critter who_use, Item item)
     : base(cr)
 {
     this.WhoUse = who_use;
     this.Item   = item;
 }
Example #35
0
 public CritterSmthAttackedEventArgs(Critter cr, Critter from_cr, Critter attacker)
     : base(cr, attacker)
 {
     this.From = from_cr;
 }
Example #36
0
 public bool RunDialog(Critter player, Critter npc, uint dialog_pack, bool ignore_distance)
 {
     return Global_RunDialogNpcDlgPack(player.ThisPtr, npc.ThisPtr, dialog_pack, ignore_distance);
 }
Example #37
0
 public CritterSmthKnockoutEventArgs(Critter cr, Critter from_cr, uint anim2_begin, uint anim2_idle, uint anim2_end, uint lost_ap, uint knock_dist)
     : base(cr, anim2_begin, anim2_idle, anim2_end, lost_ap, knock_dist)
 {
     this.From = from_cr;
 }
Example #38
0
 public CritterAttackEventArgs(Critter cr, Critter target)
     : base(cr)
 {
     this.Target = target;
 }
Example #39
0
 public CritterDeadEventArgs(Critter cr, Critter killer)
     : base(cr)
 {
     this.Killer = killer;
 }
Example #40
0
 public ItemChoice ChooseItem(Critter npc, Critter target)
 {
     throw new NotImplementedException ();
 }
Example #41
0
 public MapInOutCritterEventArgs(Map map, Critter cr)
     : base(map)
 {
     this.Cr = cr;
 }
Example #42
0
 public SkillChoice ChooseSkill(Critter npc, Critter target)
 {
     throw new NotImplementedException ();
 }
Example #43
0
 // called by engine
 void RaiseCritterDead(Critter cr, Critter killer)
 {
     if (CritterDead != null)
         CritterDead (this, new MapCritterDeadEventArgs (this, cr, killer));
 }
Example #44
0
 public void MoveItem(Item item, uint count, Critter to_cr)
 {
     Global_MoveItemCr(item.ThisPtr, count, to_cr.ThisPtr);
 }
Example #45
0
 // called by engine
 void RaiseTurnBasedProcess(Critter cr, bool begin_turn)
 {
     if (TurnBasedProcess != null)
         TurnBasedProcess (this, new MapTurnBasedProcessEventArgs (this, cr, begin_turn));
 }
Example #46
0
 public MapCritterDeadEventArgs(Map map, Critter cr, Critter killer)
     : base(map)
 {
     this.Cr = cr;
     this.Killer = killer;
 }
Example #47
0
 public CritterSmthUseItemEventArgs(Critter cr, Critter from_cr, Item item, Critter on_cr, Item on_item, Scenery on_scenery)
     : base(cr, item, on_cr, on_item, on_scenery)
 {
     this.From = from_cr;
 }
Example #48
0
 public MapTurnBasedProcessEventArgs(Map map, Critter cr, bool begin_turn)
     : base(map)
 {
     this.Cr = cr;
     this.BeginTurn = begin_turn;
 }
Example #49
0
 public CritterMoveItemEventArgs(Critter cr, Item item, ItemSlot from_slot)
     : base(cr)
 {
     this.Item     = item;
     this.FromSlot = from_slot;
 }
Example #50
0
 // called by engine
 void RaiseOutCritter(Critter cr)
 {
     if (OutCritter != null)
         OutCritter (this, new MapInOutCritterEventArgs (this, cr));
 }
Example #51
0
 public CritterDropItemEventArgs(Critter cr, Item item)
     : base(cr)
 {
     this.Item = Item;
 }
Example #52
0
 public uint GetVisibleLocations(ushort wx, ushort wy, uint radius, Critter visible_for, LocationArray locations)
 {
     return Global_GetVisibleLocations(wx, wy, radius, visible_for.ThisPtr, (IntPtr)locations);
 }
Example #53
0
 public CritterSmthDeadEventArgs(Critter cr, Critter from_cr, Critter killer)
     : base(cr)
 {
     this.From   = from_cr;
     this.Killer = killer;
 }