コード例 #1
0
        public static ShipUpgradeDetail GetCharmDetail(CharmType charmUpgrade)
        {
            ShipUpgradeDetail upgradeDetail = new ShipUpgradeDetail();

            upgradeDetail.m_UpgradeType = UpgradeType.Banner;

            switch (charmUpgrade)
            {
            case CharmType.BarrelOfLimes:
                upgradeDetail.m_UpgradeName    = "Barrel of Limes";
                upgradeDetail.GumpCollectionId = "BarrelOfLimesShipCharmUpgrade";

                upgradeDetail.CrewDamageMeleeDamageDealt    = .10;
                upgradeDetail.CrewDamageMeleeDamageReceived = .10;
                upgradeDetail.CrewHealingReceived           = .25;
                break;
            }

            if (upgradeDetail.m_UpgradeName == "")
            {
                return(null);
            }

            else
            {
                return(upgradeDetail);
            }
        }
コード例 #2
0
    public void setFromParent(Charm parent)
    {
        owner         = parent.owner;
        useGameObject = false;
        idName        = parent.idName;

        if (owner != null)
        {
            offsetID = owner.Charms.Count;
        }

        isDead        = parent.isDead;
        hasChangedPos = parent.hasChangedPos;

        storedCard = null;

        //protectDuringAISim = false;

        aiGoodCharmPoints = parent.aiGoodCharmPoints;
        aiBadCharmPoints  = parent.aiBadCharmPoints;

        costToAddToDeck = parent.costToAddToDeck;

        name = parent.name;

        className = parent.className;
        type      = parent.type;

        handSizeMod = parent.handSizeMod;

        generalTakeDamageMod = parent.generalTakeDamageMod;

        actionMod         = parent.actionMod;
        damageAtTurnStart = parent.damageAtTurnStart;


        selfDestructsAfterTurns     = parent.selfDestructsAfterTurns;
        turnsLeftBeforeSelfDestruct = parent.turnsLeftBeforeSelfDestruct;

        expiresAfterAttack = parent.expiresAfterAttack;

        sightRangeMod = parent.sightRangeMod;

        //do the charm's own setup
        setFromParentCustom(parent);

        //if a description was specified, overwrite whatever was going on
        description = parent.description;
    }
コード例 #3
0
        public bool SetCharmedBy(Unit charmer, CharmType type, AuraApplication aurApp = null)
        {
            if (!charmer)
            {
                return(false);
            }

            // dismount players when charmed
            if (IsTypeId(TypeId.Player))
            {
                RemoveAurasByType(AuraType.Mounted);
            }

            if (charmer.IsTypeId(TypeId.Player))
            {
                charmer.RemoveAurasByType(AuraType.Mounted);
            }

            Contract.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player));
            Contract.Assert((type == CharmType.Vehicle) == IsVehicle());

            Log.outDebug(LogFilter.Unit, "SetCharmedBy: charmer {0} (GUID {1}), charmed {2} (GUID {3}), type {4}.", charmer.GetEntry(), charmer.GetGUID().ToString(), GetEntry(), GetGUID().ToString(), type);

            if (this == charmer)
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Unit {0} (GUID {1}) is trying to charm itself!", GetEntry(), GetGUID().ToString());
                return(false);
            }

            if (IsTypeId(TypeId.Player) && ToPlayer().GetTransport())
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Player on transport is trying to charm {0} (GUID {1})", GetEntry(), GetGUID().ToString());
                return(false);
            }

            // Already charmed
            if (!GetCharmerGUID().IsEmpty())
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) has already been charmed but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString());
                return(false);
            }

            CastStop();
            CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells)
            DeleteThreatList();

            Player playerCharmer = charmer.ToPlayer();

            // Charmer stop charming
            if (playerCharmer)
            {
                playerCharmer.StopCastingCharm();
                playerCharmer.StopCastingBindSight();
            }

            // Charmed stop charming
            if (IsTypeId(TypeId.Player))
            {
                ToPlayer().StopCastingCharm();
                ToPlayer().StopCastingBindSight();
            }

            // StopCastingCharm may remove a possessed pet?
            if (!IsInWorld)
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) is not in world but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString());
                return(false);
            }

            // charm is set by aura, and aura effect remove handler was called during apply handler execution
            // prevent undefined behaviour
            if (aurApp != null && aurApp.GetRemoveMode() != 0)
            {
                return(false);
            }

            _oldFactionId = getFaction();
            SetFaction(charmer.getFaction());

            // Set charmed
            charmer.SetCharm(this, true);

            Player player;

            if (IsTypeId(TypeId.Unit))
            {
                ToCreature().GetAI().OnCharmed(true);
                GetMotionMaster().MoveIdle();
            }
            else if (player = ToPlayer())
            {
                if (player.isAFK())
                {
                    player.ToggleAFK();
                }

                Creature creatureCharmer = charmer.ToCreature();
                if (charmer.IsTypeId(TypeId.Unit)) // we are charmed by a creature
                {
                    // change AI to charmed AI on next Update tick
                    NeedChangeAI = true;
                    if (IsAIEnabled)
                    {
                        IsAIEnabled = false;
                        player.GetAI().OnCharmed(true);
                    }
                }

                player.SetClientControl(this, false);
            }

            // charm is set by aura, and aura effect remove handler was called during apply handler execution
            // prevent undefined behaviour
            if (aurApp != null && aurApp.GetRemoveMode() != 0)
            {
                return(false);
            }

            // Pets already have a properly initialized CharmInfo, don't overwrite it.
            if (type != CharmType.Vehicle && GetCharmInfo() == null)
            {
                InitCharmInfo();
                if (type == CharmType.Possess)
                {
                    GetCharmInfo().InitPossessCreateSpells();
                }
                else
                {
                    GetCharmInfo().InitCharmCreateSpells();
                }
            }

            if (playerCharmer)
            {
                switch (type)
                {
                case CharmType.Vehicle:
                    SetFlag(UnitFields.Flags, UnitFlags.PlayerControlled);
                    playerCharmer.SetClientControl(this, true);
                    playerCharmer.VehicleSpellInitialize();
                    break;

                case CharmType.Possess:
                    AddUnitState(UnitState.Possessed);
                    SetFlag(UnitFields.Flags, UnitFlags.PlayerControlled);
                    charmer.SetFlag(UnitFields.Flags, UnitFlags.RemoveClientControl);
                    playerCharmer.SetClientControl(this, true);
                    playerCharmer.PossessSpellInitialize();
                    break;

                case CharmType.Charm:
                    if (IsTypeId(TypeId.Unit) && charmer.GetClass() == Class.Warlock)
                    {
                        CreatureTemplate cinfo = ToCreature().GetCreatureTemplate();
                        if (cinfo != null && cinfo.CreatureType == CreatureType.Demon)
                        {
                            // to prevent client crash
                            SetByteValue(UnitFields.Bytes0, 1, (byte)Class.Mage);

                            // just to enable stat window
                            if (GetCharmInfo() != null)
                            {
                                GetCharmInfo().SetPetNumber(Global.ObjectMgr.GeneratePetNumber(), true);
                            }

                            // if charmed two demons the same session, the 2nd gets the 1st one's name
                            SetUInt32Value(UnitFields.PetNameTimestamp, (uint)Time.UnixTime);     // cast can't be helped
                        }
                    }
                    playerCharmer.CharmSpellInitialize();
                    break;

                default:
                case CharmType.Convert:
                    break;
                }
            }
            return(true);
        }
コード例 #4
0
        public bool SetCharmedBy(Unit charmer, CharmType type, AuraApplication aurApp = null)
        {
            if (!charmer)
            {
                return(false);
            }

            // dismount players when charmed
            if (IsTypeId(TypeId.Player))
            {
                RemoveAurasByType(AuraType.Mounted);
            }

            if (charmer.IsTypeId(TypeId.Player))
            {
                charmer.RemoveAurasByType(AuraType.Mounted);
            }

            Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player));
            Cypher.Assert((type == CharmType.Vehicle) == (GetVehicleKit() && GetVehicleKit().IsControllableVehicle()));

            Log.outDebug(LogFilter.Unit, "SetCharmedBy: charmer {0} (GUID {1}), charmed {2} (GUID {3}), type {4}.", charmer.GetEntry(), charmer.GetGUID().ToString(), GetEntry(), GetGUID().ToString(), type);

            if (this == charmer)
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Unit {0} (GUID {1}) is trying to charm itself!", GetEntry(), GetGUID().ToString());
                return(false);
            }

            if (IsTypeId(TypeId.Player) && ToPlayer().GetTransport())
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Player on transport is trying to charm {0} (GUID {1})", GetEntry(), GetGUID().ToString());
                return(false);
            }

            // Already charmed
            if (!GetCharmerGUID().IsEmpty())
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) has already been charmed but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString());
                return(false);
            }

            CastStop();
            CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells)

            Player playerCharmer = charmer.ToPlayer();

            // Charmer stop charming
            if (playerCharmer)
            {
                playerCharmer.StopCastingCharm();
                playerCharmer.StopCastingBindSight();
            }

            // Charmed stop charming
            if (IsTypeId(TypeId.Player))
            {
                ToPlayer().StopCastingCharm();
                ToPlayer().StopCastingBindSight();
            }

            // StopCastingCharm may remove a possessed pet?
            if (!IsInWorld)
            {
                Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) is not in world but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString());
                return(false);
            }

            // charm is set by aura, and aura effect remove handler was called during apply handler execution
            // prevent undefined behaviour
            if (aurApp != null && aurApp.GetRemoveMode() != 0)
            {
                return(false);
            }

            _oldFactionId = GetFaction();
            SetFaction(charmer.GetFaction());

            // Pause any Idle movement
            PauseMovement(0, 0, false);

            // Remove any active voluntary movement
            GetMotionMaster().Clear(MovementGeneratorPriority.Normal);

            // Stop any remaining spline, if no involuntary movement is found
            Func <MovementGenerator, bool> criteria = movement => movement.Priority == MovementGeneratorPriority.Highest;

            if (!GetMotionMaster().HasMovementGenerator(criteria))
            {
                StopMoving();
            }

            // Set charmed
            charmer.SetCharm(this, true);

            Player player = ToPlayer();

            if (player)
            {
                if (player.IsAFK())
                {
                    player.ToggleAFK();
                }

                player.SetClientControl(this, false);
            }

            // charm is set by aura, and aura effect remove handler was called during apply handler execution
            // prevent undefined behaviour
            if (aurApp != null && aurApp.GetRemoveMode() != 0)
            {
                return(false);
            }

            // Pets already have a properly initialized CharmInfo, don't overwrite it.
            if (type != CharmType.Vehicle && GetCharmInfo() == null)
            {
                InitCharmInfo();
                if (type == CharmType.Possess)
                {
                    GetCharmInfo().InitPossessCreateSpells();
                }
                else
                {
                    GetCharmInfo().InitCharmCreateSpells();
                }
            }

            if (playerCharmer)
            {
                switch (type)
                {
                case CharmType.Vehicle:
                    AddUnitFlag(UnitFlags.Possessed);
                    playerCharmer.SetClientControl(this, true);
                    playerCharmer.VehicleSpellInitialize();
                    break;

                case CharmType.Possess:
                    AddUnitFlag(UnitFlags.Possessed);
                    charmer.AddUnitFlag(UnitFlags.RemoveClientControl);
                    playerCharmer.SetClientControl(this, true);
                    playerCharmer.PossessSpellInitialize();
                    AddUnitState(UnitState.Possessed);
                    break;

                case CharmType.Charm:
                    if (IsTypeId(TypeId.Unit) && charmer.GetClass() == Class.Warlock)
                    {
                        CreatureTemplate cinfo = ToCreature().GetCreatureTemplate();
                        if (cinfo != null && cinfo.CreatureType == CreatureType.Demon)
                        {
                            // to prevent client crash
                            SetClass(Class.Mage);

                            // just to enable stat window
                            if (GetCharmInfo() != null)
                            {
                                GetCharmInfo().SetPetNumber(Global.ObjectMgr.GeneratePetNumber(), true);
                            }

                            // if charmed two demons the same session, the 2nd gets the 1st one's name
                            SetPetNameTimestamp((uint)GameTime.GetGameTime());     // cast can't be helped
                        }
                    }
                    playerCharmer.CharmSpellInitialize();
                    break;

                default:
                case CharmType.Convert:
                    break;
                }
            }

            AddUnitState(UnitState.Charmed);

            if (!IsPlayer() || !charmer.IsPlayer())
            {
                // AI will schedule its own change if appropriate
                UnitAI ai = GetAI();
                if (ai != null)
                {
                    ai.OnCharmed(false);
                }
                else
                {
                    ScheduleAIChange();
                }
            }
            return(true);
        }
コード例 #5
0
    public void setup(Unit _owner, bool _useGameObject, string _idName)
    {
        owner         = _owner;
        useGameObject = _useGameObject;
        idName        = _idName;

        if (owner != null)
        {
            offsetID = owner.Charms.Count - 1;
        }

        isDead        = false;
        hasChangedPos = false;

        protectDuringAISim = false;

        storedCard = null;

        costToAddToDeck = 3;

        Debug.Log(idName);
        Debug.Log(node);
        name = node ["name"].InnerText;

        className = CharmClass.Charm;
        type      = CharmType.Equipment;        //default to equipment for no solid reason

        //check general values

        handSizeMod = 0;
        if (node ["hand_size_mod"] != null)
        {
            handSizeMod = int.Parse(node ["hand_size_mod"].InnerText);
        }

        generalTakeDamageMod = 0;
        if (node["general_take_damage_mod"] != null)
        {
            generalTakeDamageMod = int.Parse(node["general_take_damage_mod"].InnerText);
        }


        selfDestructsAfterTurns     = false;
        turnsLeftBeforeSelfDestruct = -1;
        if (node ["turns_to_self_destruct"] != null)
        {
            selfDestructsAfterTurns     = true;
            turnsLeftBeforeSelfDestruct = int.Parse(node ["turns_to_self_destruct"].InnerText);
        }

        expiresAfterAttack = false;
        if (node ["expires_after_attack"] != null)
        {
            expiresAfterAttack = bool.Parse(node ["expires_after_attack"].InnerXml);
        }

        actionMod = 0;
        if (node["action_mod"] != null)
        {
            actionMod = int.Parse(node["action_mod"].InnerText);
        }

        damageAtTurnStart = 0;
        if (node["damage_at_turn_start"] != null)
        {
            damageAtTurnStart = int.Parse(node["damage_at_turn_start"].InnerText);
        }

        sightRangeMod = 0;
        if (node["sight_range_mod"] != null)
        {
            sightRangeMod = float.Parse(node["sight_range_mod"].InnerText);
            //this may change what the unit can see at the moment they get this charm
            if (owner != null)
            {
                Debug.Log("love to do it " + owner.getSightRange());
                owner.setVisibleTiles();
            }
        }

        aiGoodCharmPoints = 0;
        aiBadCharmPoints  = 0;

        //do the charm's own setup
        setupCustom();

        //if a description was specified, overwrite whatever was going on
        if (node ["desc"] != null)
        {
            description = node ["desc"].InnerText;
        }

        //check if an alternate ai value was provided
        if (node ["ai_good_points"] != null)
        {
            aiGoodCharmPoints = float.Parse(node ["ai_good_points"].InnerText);
        }
        if (node ["ai_bad_points"] != null)
        {
            aiBadCharmPoints = float.Parse(node ["ai_bad_points"].InnerText);
        }
    }