Inheritance: MonoBehaviour
	/// <summary>
	/// 初始化公用数据
	/// </summary>
	public void initData()
	{
		if (gameObject != null) 
		{
			m_unit = gameObject.GetComponent<Unit>();
		}
	}
Example #2
0
 public float evaluate(Tile tile,Unit unit)
 {
     float value = 0f;
         value += positionValue(tile,unit);
         value += attackValue(tile,unit);
     return value;
 }
Example #3
0
 public static void PrintWebControl(Control ctrl, string Script)
 {
     StringWriter stringWrite = new StringWriter();
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     if (ctrl is WebControl)
     {
         Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
     }
     Page pg = new Page();
     pg.EnableEventValidation = false;
     if (Script != string.Empty)
     {
         pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
     }
     HtmlForm frm = new HtmlForm();
     pg.Controls.Add(frm);
     frm.Attributes.Add("runat", "server");
     frm.Controls.Add(ctrl);
     pg.DesignerInitialize();
     pg.RenderControl(htmlWrite);
     string strHTML = stringWrite.ToString();
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Write(strHTML);
     HttpContext.Current.Response.Write("<script>window.print();</script>");
     HttpContext.Current.Response.End();
 }
Example #4
0
 public void AddModifierObstacle(Modifier modifier, Unit unit)
 {
     if (Obstacle != null)
     {
         End();
     }
 }
Example #5
0
 public void AddUnit(Unit unit)
 {
     abilityUnit = unit;
     StartCast = Game.RawGameTime;
     EndCast = Game.RawGameTime + GetCastRange() / GetProjectileSpeed();
     StartPosition = unit.Position;
 }
Example #6
0
        public override void Use(EvadableAbility ability, Unit target)
        {
            var range = GetCastRange() - 60;
            BlinkPosition = Hero.NetworkPosition.Extend(BlinkPosition, range);
            var obtsacles = Pathfinder.GetIntersectingObstacles(BlinkPosition, Hero.HullRadius);

            if (obtsacles.Any())
            {
                bool success;
                BlinkPosition =
                    Pathfinder.CalculatePathFromObstacle(BlinkPosition, BlinkPosition, 5, out success).LastOrDefault();

                if (!success)
                {
                    //gg
                    return;
                }

                if (Hero.Distance2D(BlinkPosition) > range)
                {
                    // probably gg
                    BlinkPosition = Hero.NetworkPosition.Extend(BlinkPosition, range);
                }
            }

            Ability.UseAbility(BlinkPosition);
            Sleep();
        }
Example #7
0
        private static bool CheckTarget(Unit enemy, bool doubleOwnage = false)
        {
            if (enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, hero.NetworkPosition))
            {
                return false;
            }

            if (enemy.IsLinkensProtected() || enemy.IsMagicImmune())
            {
                return false;
            }

            if (!enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
            {
                return false;
            }

            var damage = AbilityDamage.CalculateDamage(dagon, hero, enemy);

            if (doubleOwnage)
            {
                damage *= 2;
            }

            return enemy.Health < damage;
        }
    Unit[] toUnits(Parameter.Stage stage)
    {
        var units = new List<Unit>();
        foreach (var enemy in stage.Enemies)
        {
            var job = enemy.Job;
            for(var i=0; i<enemy.Count; ++i)
            {
                var unit = new Unit(false, job.Hp, job.Attack, job.Defence, job.Move);
                units.Add(unit);
            }
        }

        var ps = stage.Formation.Positions;
        int len = stage.Formation.Positions.Length;
        for(int i=0; i<units.Count; ++i)
        {
            var p = ps[i % len];
            units[i].Leader = i < len ? ps[i].Leader : false;
            units[i].X = p.X;
            units[i].Y = p.Y;
        }

        return units.ToArray ();
    }
Example #9
0
	public override void RunEffect(Unit u, bool reapply = false)
	{
		base.RunEffect(u, reapply);

		//give shield
		u.shield += shieldAmount;
	}
Example #10
0
        protected Line ChildElement(Unit left = default(Unit),
            Unit top = default(Unit),
            Unit innerHeight = default(Unit),
            bool breakable = false,
            bool followLineHeight = false,
            Unit border = default(Unit),
            bool keepWithNextLine = false,
            Behaviors behavior = null,
            IEnumerable<Line> children = null)
        {
            LayoutedElement element;
            if (children == null)
            {
                element = new LayoutedElement(new TestSpecification(), Children.Empty);
            }
            else
            {
                element = new LayoutedElement(new TestSpecification(), new Children(children.GroupBy(x => x.Top).SelectMany(x => x)));
            }

            element.Left = left;
            element.ForcedInnerHeight = innerHeight;
            element.Specification.FollowLineHeight = followLineHeight;
            element.Specification.Breakable = breakable;
            element.Specification.Margins = new Margins { Bottom = border, Left = border, Right = border, Top = border };
            element.Specification.Behavior = behavior ?? new NullBehavior();

            return new Line(top, keepWithNextLine, element);
        }
Example #11
0
        protected Line Element(Unit left = default(Unit),
            Unit top = default(Unit),
            Unit innerHeight = default(Unit),
            bool breakable = false,
            bool followLineHeight = false,
            Unit border = default(Unit),
            bool keepWithNextLine = false,
            Behaviors behavior = null,
            IEnumerable<Line> children = null)
        {
            // Top offsets are not allowed in real usage, so we fake one by adding an element
            if (lines.Count == 0 && top > 0.cm())
            {
                lines.Add(new Line(0.cm(), false, new LayoutedElement(new TestSpecification
                {
                    Breakable = true,
                    OrphanHeight = 0.cm(),
                    WidowHeight = 0.cm()
                }, Children.Empty)
                {
                    Name = "Spacer",
                    ForcedInnerHeight = top,
                }));
            }

            var line = ChildElement(left, top, innerHeight, breakable, followLineHeight, border, keepWithNextLine, behavior, children);
            lines.Add(line);
            return line;
        }
 public void Show(Unit Unit)
 {
     if(Unit == null)
         return;
     m_Unit = Unit;
     base.Show(true);
 }
 protected override void ReportGauge(string name, double value, Unit unit, MetricTags tags)
 {
     if (!double.IsNaN(value) && !double.IsInfinity(value))
     {
         Pack(name, value, tags);
     }
 }
 public CellGridStateUnitSelected(CellGrid cellGrid, Unit unit)
     : base(cellGrid)
 {
     _unit = unit;
     _pathsInRange = new List<Cell>();
     _unitsInRange = new List<Unit>();
 }
Example #15
0
 void OnEnable()
 {
     Owner = GetComponent<Unit>();
     MainController.Instance.FocusedUnit = Owner;
     MainController.Instance.SwitchSkill(0);
     MainController.Instance.MoveControlPad.Init(Owner);
 }
Example #16
0
        public static int DrunkardWalk(Unit unit)
        {
            MersenneTwister mt = new MersenneTwister();
            unit.MakeAMove((CardinalDirection)mt.Next(9));

            return 100;
        }
Example #17
0
    public void AddEnermy(Unit addUnit)
    {
        bool b_set = false;

        addUnit.m_ai.m_TeamType = eUnitType.Enermy;

        for (int i = 0; i < m_enermyUnitList.Count; ++i)
        {
            if(m_enermyUnitList[i] == null)
            {
                m_enermyUnitList[i] = addUnit;
                b_set = true;
                break;
            }
        }
        if(b_set == false)
        {
            m_enermyUnitList.Add(addUnit);
        }

        if(NewUnitCall != null)
        {
            NewUnitCall(addUnit);
        }
    }
Example #18
0
 public static void DisplayScrollingCombatText(Unit unit, String text, ClientCommon.Font font)
 {
     Vector3 pos = Vector3.Project(unit.Position,
         Program.Instance.Device.Viewport.X,
         Program.Instance.Device.Viewport.Y,
         Program.Instance.Device.Viewport.Width,
         Program.Instance.Device.Viewport.Height,
         Program.Instance.Device.Viewport.MinZ,
         Program.Instance.Device.Viewport.MaxZ,
         GameScene.Camera.View * GameScene.Camera.Projection);
     Control f;
     scrollingCombatTexts.Add(new ScrollingCombatText
     {
         Timeout = 1,
         Unit = unit,
         Text = f = new Control(Program.Instance.InterfaceManager)
         {
             Size = new Vector2(300, 100),
             Background = new TextGraphic(Program.Instance.GlyphCache)
             {
                 Text = text,
                 Font = font,
                 Anchor = Orientation.Bottom
             }
         }
     });
     f.Position = pos - new Vector3(f.Size.X/2, f.Size.Y, 0);
     Program.Instance.InterfaceManager.Add(f);
 }
Example #19
0
 /// <summary>
 /// Creates new X10 extended message.
 /// </summary>
 /// <param name="house">Valid range is A-P.</param>
 /// <param name="unit">Valid units are 01-16.</param>
 /// <param name="command">Only commands ExtendedCode and ExtendedData are valid for extended messages.</param>
 /// <param name="extendedCommand">Byte 0-255. Make sure that either extended command or data is above 0.</param>
 /// <param name="extendedData">Byte 0-255. Make sure that either extended command or data is above 0.</param>
 public ExtendedMessage(House house, Unit unit, Command command, byte extendedCommand, byte extendedData)
     : base(house, unit, command)
 {
     Validate(extendedCommand, extendedData);
     ExtendedCommand = extendedCommand;
     ExtendedData = extendedData;
 }
Example #20
0
        public Tombstone(Unit unit)
        {
            this.unit = unit;
            PositionCorrection = new Vector2(25);
            var level = (uint)char.GetNumericValue(unit.Name.Last());
            Radius =
                Ability.GetAbilityDataByName(AbilityName)
                    .AbilitySpecialData.First(x => x.Name == "radius")
                    .GetValue(level - 1);
            Duration =
                Ability.GetAbilityDataByName(AbilityName)
                    .AbilitySpecialData.First(x => x.Name == "duration")
                    .GetValue(level - 1);
            Position = unit.Position;
            Texture = Drawing.GetTexture("materials/ensage_ui/other/tombstone");
            Handle = unit.Handle;
            TextureSize = new Vector2(40);
            EndTime = Game.RawGameTime + Duration;
            ShowTimer = Menu.TimerEnabled(AbilityName);

            if (Menu.RangeEnabled(AbilityName))
            {
                ParticleEffect = new ParticleEffect("particles/ui_mouseactions/drag_selected_ring.vpcf", Position);
                ParticleEffect.SetControlPoint(1, new Vector3(128, 128, 128));
                ParticleEffect.SetControlPoint(2, new Vector3(Radius, 255, 0));
            }
        }
	// Sets damage done by one round of attacking.
    // Must be re-set after doing this; assumes within countering range.
	public AttackRound(Unit attackerIn, int attackerWaterCost, Unit defenderIn) {
        attacker = attackerIn;
		defender = defenderIn;

        utility = expectedDamage = expectedCounterDamage = 0;
        dieDef = dieAtk = false;

        // Store current stats.
        waterAtk = attacker.getCurrentWater();
        clayDef = defender.getClay();

        attacker.setCurrentWater(waterAtk - attackerWaterCost);

		expectedDamage = calculateExpectedDamage(attacker, defender);

        // Assume defender looses appropriate amount of clay before counter.
        if ((clayDef - expectedDamage) > 0)
        {
            defender.setClay(clayDef - expectedDamage);
            expectedCounterDamage = calculateExpectedDamage(defender, attacker);
        }
        else
        {
            defender.setClay(0);
            dieDef = true;
        }

        if ((attacker.getClay() - expectedDamage) < 0)
        {
            dieAtk = true;
        }

		// Calculates a utility value using expected damage values
		utility = calculateUtility();
    }
Example #22
0
 public void CancelBuildingPlacement()
 {
     findingPlacement = false;
     Destroy(tempBuilding.gameObject);
     tempBuilding = null;
     tempCreator = null;
 }
        public void OneUnitDefaultName()
        {
            var meter = new Unit("meter");
            var oneMeter = new Measurement(meter, 1M);

            oneMeter.ToString().Should().Be("1 meter");
        }
 public void OunceAndPound(Unit unit, Unit servingSizeUnit)
 {
     sut.Unit = unit;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsFalse(sut.AreNutrientsPerServingUsable);
     product.ServingSizeValue = 1;
     product.ServingSizeUnit = servingSizeUnit;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsTrue(sut.AreNutrientsPerServingUsable);
     product.EnergyPerServing = 0;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsFalse(sut.AreNutrientsPerServingUsable);
     sut.Unit = Unit.ServingSize;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsFalse(sut.AreNutrientsPerServingUsable);
     product.EnergyPerServing = 100;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsFalse(sut.AreNutrientsPer100gUsable);
     Assert.IsTrue(sut.AreNutrientsPerServingUsable);
     product.EnergyPer100g = 0;
     sut.Unit = unit;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsFalse(sut.AreNutrientsPer100gUsable);
     Assert.IsTrue(sut.AreNutrientsPerServingUsable);
 }
Example #25
0
 //Cancel the currently displayed action
 public void CancelAction()
 {
     selectedUnit = null;
     m_tiles.ClearSelectedTiles();
     m_hud.HideUnitInfo();
     e_playerState = PlayerState.Default;
 }
Example #26
0
 public static bool ChainStun(Unit unit, double delay, string except, bool onlychain)
 {
     var chain = false;
     var stunned = false;
     string[] modifiersList =
     {
         "modifier_shadow_demon_disruption", "modifier_obsidian_destroyer_astral_imprisonment_prison",
         "modifier_eul_cyclone", "modifier_invoker_tornado", "modifier_bane_nightmare",
         "modifier_shadow_shaman_shackles",
         "modifier_crystal_maiden_frostbite", "modifier_ember_spirit_searing_chains",
         "modifier_axe_berserkers_call",
         "modifier_lone_druid_spirit_bear_entangle_effect", "modifier_meepo_earthbind",
         "modifier_naga_siren_ensnare",
         "modifier_storm_spirit_electric_vortex_pull", "modifier_treant_overgrowth", "modifier_cyclone",
         "modifier_sheepstick_debuff", "modifier_shadow_shaman_voodoo", "modifier_lion_voodoo",
         "modifier_brewmaster_storm_cyclone",
         "modifier_puck_phase_shift", "modifier_dark_troll_warlord_ensnare",
         "modifier_invoker_deafening_blast_knockback"
     };
     var modifiers = unit.Modifiers.OrderByDescending(x => x.RemainingTime);
     foreach (var m in modifiers.Where(m => (m.IsStunDebuff || modifiersList.Contains(m.Name)) && (except == null || m.Name == except)))
     {
         stunned = true;
         var remainingTime = m.RemainingTime;
         if (m.Name == "modifier_eul_cyclone" || m.Name == "modifier_invoker_tornado")
             remainingTime += 0.07f;
         chain = remainingTime <= delay;
     }
     return ((((!(stunned || unit.IsStunned()) || chain) && !onlychain) || (onlychain && chain)));
 }
Example #27
0
 public static bool AttackUnit(Unit unit, TimeSpan timeout)
 {
     if (unit.Type == UnitType.Monster
         && unit.GetAttributeInteger(UnitAttribute.Is_NPC) == 0
         && unit.GetAttributeInteger(UnitAttribute.Is_Helper) == 0
         && unit.GetAttributeInteger(UnitAttribute.Invulnerable) == 0)
     {
         switch (Me.SNOId)
         {
             case SNOActorId.Barbarian_Male:
             case SNOActorId.Barbarian_Female:
                 //return Classes.Barbarian.AttackUnit(unit, timeout);
                 break;
             case SNOActorId.WitchDoctor_Male:
             case SNOActorId.WitchDoctor_Female:
                 //return Classes.WitchDoctor.AttackUnit(unit, timeout);
                 break;
             case SNOActorId.Wizard_Male:
             case SNOActorId.Wizard_Female:
                 //return Classes.Wizard.AttackUnit(unit, timeout);
                 break;
             case SNOActorId.Demonhunter_Male:
             case SNOActorId.Demonhunter_Female:
                 return DemonHunter.AttackUnit(unit, timeout);
             case SNOActorId.Monk_Male:
             case SNOActorId.Monk_Female:
                 return Monk.AttackUnit(unit, timeout);
         }
     }
     return false;
 }
    protected override void OnShow()
    {
        if(m_Unit == null)
            m_Unit = base.Player.CurrentPartyUnit;

        Prepare();
    }
Example #29
0
        public override void Update(Unit unit, IGame game)
        {
            base.Update(unit, game);

            if ((game.Time - unit.BirthTime) > FleeTime)
                unit.setState(UnitFactories.States.Create(unit.Name, "fleeing"), game);
        }
Example #30
0
 public static void Cast(this Ability ability, Unit unit)
 {
     if (ability.IsReady() && unit.IsValidTarget(ability.CastRange))
     {
         ability.UseAbility(unit);
     }
 }
Example #31
0
    public void UltraWebGrid1_InitializeLayout(object sender,
                                               Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
    {
        string[] ItemId = ItemIds.Split(',');
        foreach (Infragistics.WebUI.UltraWebGrid.UltraGridColumn c in e.Layout.Bands[0].Columns)
        {
            c.Width = Unit.Pixel(10);
            c.Header.ClickAction           = HeaderClickAction.Select;
            c.Header.Style.HorizontalAlign = HorizontalAlign.Center;
            c.Header.Style.VerticalAlign   = VerticalAlign.Middle;
            c.Header.Style.Font.Bold       = true;
            c.AllowResize    = AllowSizing.NotSet;
            c.AllowUpdate    = AllowUpdate.No;
            c.CellStyle.Wrap = true;
            if (c.Key.Equals("ContainerName"))
            {
                c.Header.RowLayoutColumnInfo.SpanY = 2;
            }
            else
            {
                c.Header.RowLayoutColumnInfo.OriginY = 1;
            }
            if (c.Key.Contains("~"))
            {
                c.Header.Caption = c.Key.Split('~')[1];
            }
            if (c.Key.Contains("ChunkValue"))
            {
                c.Width = Unit.Pixel(300);
            }
        }
        objDT_ItemName = new DataTable();
        objDT_ItemName.Columns.Add("ItemName");
        DataRow[] drCurrent = null;
        for (int i = 0; i < ItemId.Length; i++)
        {
            DataRow dr = objDT_ItemName.NewRow();
            drCurrent = objDS.Tables[0].Select("ItemId = '" + ItemId[i] + "'");
            if (drCurrent[0]["LevelId"].ToString().Equals("7"))
            {
                dr["ItemName"] = drCurrent[0]["ItemNumber"] + " [" + drCurrent[0]["LevelName"].ToString() + "]";
            }
            else
            {
                dr["ItemName"] = drCurrent[0]["ItemName"] + " [" + drCurrent[0]["LevelName"].ToString() + "]";
            }
            objDT_ItemName.Rows.Add(dr);
        }
        objDT_ItemName.AcceptChanges();
        int count       = 1;
        int headerindex = 0;

        foreach (DataRow r in objDT_ItemName.Rows)
        {
            Infragistics.WebUI.UltraWebGrid.ColumnHeader ch = new ColumnHeader(true);
            ch.Style.Width                 = Unit.Pixel(0);
            ch.Caption                     = r["ItemName"].ToString();
            ch.Style.HorizontalAlign       = HorizontalAlign.Center;
            ch.Style.VerticalAlign         = VerticalAlign.Middle;
            ch.Style.Font.Bold             = true;
            ch.Style.Width                 = Unit.Pixel(330);
            ch.RowLayoutColumnInfo.OriginY = 0;
            ch.RowLayoutColumnInfo.OriginX = count;
            ch.RowLayoutColumnInfo.SpanX   = 4;
            //count takes care of SpanX for the ItemName/ItemNumber Header
            count = ch.RowLayoutColumnInfo.OriginX + ch.RowLayoutColumnInfo.SpanX;
            e.Layout.Bands[0].HeaderLayout.Add(ch);
        }
    }
Example #32
0
            public static double DrawConvertedSizeField(string label, double size, Unit storeAs, Unit displayAs, float minWidth)
            {
                size = Convert(storeAs, displayAs, size);
#if UNITY_5
                size = EditorGUILayout.DoubleField(label, size, GUILayout.MinWidth(minWidth));
#else
                size = EditorGUILayout.FloatField(label, (float)size, GUILayout.MinWidth(minWidth));
#endif
                return(Convert(displayAs, storeAs, size));
            }
Example #33
0
 public void SetUnit(Unit unit)
 {
     SetUnit(unit, false);
 }
 public void PreInitialize()
 {
     genericUnitPrefab = Resources.Load <Unit>("Prefabs/Units/GenericUnit");
     unitDictionnary   = new Dictionary <Vector3Int, Unit>();
 }
 /// <summary>
 /// Check the Unit Type and return true if the Type T passed is equals to it
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="unit"></param>
 /// <returns></returns>
 public bool CheckUnitType <T>(Unit unit) where T : class
 {
     return(unit.GetType().Equals(typeof(T)));
 }
Example #36
0
 /// <summary>
 /// Sets the Position from a Unit.
 /// </summary>
 private void SetFromUnit(Unit unit)
 {
     this.shapePosition = ShapePosition.Undefined;
     this.position      = unit;
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the LeftPosition class from Unit.
 /// </summary>
 private LeftPosition(Unit value)
 {
     this.shapePosition = ShapePosition.Undefined;
     this.position      = value;
     this.notNull       = !value.IsNull;
 }
Example #38
0
 public override void PassengerBoarded(Unit passenger, sbyte seatId, bool apply)
 {
     GetScript().ProcessEventsFor(apply ? SmartEvents.PassengerBoarded : SmartEvents.PassengerRemoved, passenger, (uint)seatId, 0, apply);
 }
Example #39
0
 public override void IsSummonedBy(Unit summoner)
 {
     GetScript().ProcessEventsFor(SmartEvents.JustSummoned, summoner);
 }
Example #40
0
 public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker)
 {
     if (invoker != null)
         GetScript().mLastInvoker = invoker.GetGUID();
     GetScript().SetScript9(e, entry);
 }
Example #41
0
 public override void SpellHitTarget(Unit target, SpellInfo spell)
 {
     GetScript().ProcessEventsFor(SmartEvents.SpellhitTarget, target, 0, 0, false, spell);
 }
Example #42
0
 public override void DamageDealt(Unit victim, ref uint damage, DamageEffectType damageType)
 {
     GetScript().ProcessEventsFor(SmartEvents.DamagedTarget, victim, damage);
 }
Example #43
0
 public override void KilledUnit(Unit victim)
 {
     GetScript().ProcessEventsFor(SmartEvents.Kill, victim);
 }
Example #44
0
 public override void HealReceived(Unit by, uint addhealth)
 {
     GetScript().ProcessEventsFor(SmartEvents.ReceiveHeal, by, addhealth);
 }
Example #45
0
 public override void SpellHit(Unit unit, SpellInfo spellInfo)
 {
     GetScript().ProcessEventsFor(SmartEvents.SpellHit, unit, 0, 0, false, spellInfo);
 }
Example #46
0
 public override void SpellHit(Unit caster, SpellInfo spell)
 {
     GetScript().ProcessEventsFor(SmartEvents.SpellHit, caster, 0, 0, false, spell);
 }
Example #47
0
 public virtual void OnSpellClick(Unit clicker, ref bool result)
 {
 }
Example #48
0
 public override bool CanAIAttack(Unit victim)
 {
     return !me.HasReactState(ReactStates.Passive);
 }
Example #49
0
 // Called when owner attacks something
 public virtual void OwnerAttacked(Unit target)
 {
 }
Example #50
0
 public override void OnLootStateChanged(uint state, Unit unit)
 {
     GetScript().ProcessEventsFor(SmartEvents.GoLootStateChanged, unit, state);
 }
Example #51
0
 // Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
 public virtual void AttackedBy(Unit attacker)
 {
 }
Example #52
0
 public virtual void PassengerBoarded(Unit passenger, sbyte seatId, bool apply)
 {
 }
Example #53
0
 // Called when hit by a spell
 public virtual void SpellHit(Unit caster, SpellInfo spell)
 {
 }
Example #54
0
 // Called when owner takes damage
 public virtual void OwnerAttackedBy(Unit attacker)
 {
 }
Example #55
0
 public virtual void IsSummonedBy(Unit summoner)
 {
 }
Example #56
0
 // Called when spell hits a target
 public virtual void SpellHitTarget(Unit target, SpellInfo spell)
 {
 }
Example #57
0
 // Called when the creature kills a unit
 public virtual void KilledUnit(Unit victim)
 {
 }
Example #58
0
 public virtual void SummonedCreatureDies(Creature summon, Unit killer)
 {
 }
Example #59
0
 // Called when the creature is killed
 public virtual void JustDied(Unit killer)
 {
 }
Example #60
0
        public void DoZoneInCombat(Creature creature = null, float maxRangeToNearestTarget = 250.0f)
        {
            if (!creature)
            {
                creature = me;
            }

            if (!creature.CanHaveThreatList())
            {
                return;
            }

            Map map = creature.GetMap();

            if (!map.IsDungeon())                                  //use IsDungeon instead of Instanceable, in case Battlegrounds will be instantiated
            {
                Log.outError(LogFilter.Server, "DoZoneInCombat call for map that isn't an instance (creature entry = {0})", creature.IsTypeId(TypeId.Unit) ? creature.ToCreature().GetEntry() : 0);
                return;
            }

            if (!creature.HasReactState(ReactStates.Passive) && creature.GetVictim() == null)
            {
                Unit nearTarget = creature.SelectNearestTarget(maxRangeToNearestTarget);
                if (nearTarget != null)
                {
                    creature.GetAI().AttackStart(nearTarget);
                }
                else if (creature.IsSummon())
                {
                    Unit summoner = creature.ToTempSummon().GetSummoner();
                    if (summoner != null)
                    {
                        Unit target = summoner.GetAttackerForHelper();
                        if (target == null && summoner.CanHaveThreatList() && !summoner.GetThreatManager().IsThreatListEmpty())
                        {
                            target = summoner.GetThreatManager().GetHostilTarget();
                        }
                        if (target != null && (creature.IsFriendlyTo(summoner) || creature.IsHostileTo(target)))
                        {
                            creature.GetAI().AttackStart(target);
                        }
                    }
                }
            }

            // Intended duplicated check, the code above this should select a victim
            // If it can't find a suitable attack target then we should error out.
            if (!creature.HasReactState(ReactStates.Passive) && creature.GetVictim() == null)
            {
                Log.outError(LogFilter.Server, "DoZoneInCombat called for creature that has empty threat list (creature entry = {0})", creature.GetEntry());
                return;
            }

            var playerList = map.GetPlayers();

            if (playerList.Empty())
            {
                return;
            }

            foreach (var player in playerList)
            {
                if (player.IsGameMaster())
                {
                    continue;
                }

                if (player.IsAlive())
                {
                    creature.SetInCombatWith(player);
                    player.SetInCombatWith(creature);
                    creature.AddThreat(player, 0.0f);
                }

                /* Causes certain things to never leave the threat list (Priest Lightwell, etc):
                 * foreach (var unit in player.m_Controlled)
                 * {
                 *  me.SetInCombatWith(unit);
                 *  unit.SetInCombatWith(me);
                 *  me.AddThreat(unit, 0.0f);
                 * }*/
            }
        }