Example #1
0
 public Buff(string buffName, float dur, BuffType type, Unit u) //no attacker specified = selfbuff, attacker aka source is same as attachedto
 {
     this.duration = dur;
     this.name = buffName;
     this.timeElapsed = 0;
     this.remove = false;
     this.attachedTo = u;
     this.attacker = u;
     this.buffType = type;
     this.movementSpeedPercentModifier = 0.0f;
 }
Example #2
0
 public Buff(string buffName, float dur, BuffType type, Unit u, Unit attacker)
 {
     this.duration = dur;
     this.name = buffName;
     this.timeElapsed = 0;
     this.remove = false;
     this.attachedTo = u;
     this.attacker = attacker;
     this.buffType = type;
     this.movementSpeedPercentModifier = 0.0f;
 }
Example #3
0
        public Projectile(Map map, int id, float x, float y, int collisionRadius, Unit owner, Target target, Spell originSpell, float moveSpeed, int projectileId, int flags = 0) : base(map, id, x, y, collisionRadius)
        {
            this.originSpell = originSpell;
            this.moveSpeed = moveSpeed;
            this.owner = owner;
            this.projectileId = projectileId;
            this.flags = flags;

            setTarget(target);

            if (!target.isSimpleTarget())
                ((GameObject)target).incrementAttackerCount();

            owner.incrementAttackerCount();
        }
Example #4
0
        public static void notifyTeleport(Unit u, float _x, float _y)
        {
            // Can't teleport to this point of the map
            if (!map.isWalkable(_x, _y))
            {
                _x = MovementVector.targetXToNormalFormat(u.getPosition().X);
                _y = MovementVector.targetYToNormalFormat(u.getPosition().Y);
            }
            else
            {
                u.setPosition(_x, _y);

                //TeleportRequest first(u.getNetId(), u.teleportToX, u.teleportToY, true);
                //sendPacket(currentPeer, first, Channel.CHL_S2C);

                _x = MovementVector.targetXToNormalFormat(_x);
                _y = MovementVector.targetYToNormalFormat(_y);
            }

            var second = new TeleportRequest(u.getNetId(), _x, _y, false);
            PacketHandlerManager.getInstace().broadcastPacketVision(u, second, Channel.CHL_S2C);
        }
Example #5
0
        public static void notifyUpdatedStats(Unit u, bool partial = true)
        {
            //if (u is Monster)
            //    return;
            var us = new SpawnParticle.UpdateStats(u, partial);
            var t = u as Turret;

            if (t != null)
            {
                PacketHandlerManager.getInstace().broadcastPacket(us, Channel.CHL_LOW_PRIORITY, ENet.PacketFlags.Unsequenced);
                return;
            }

            if (!partial)
            {
                PacketHandlerManager.getInstace().broadcastPacketTeam(u.getTeam(), us, Channel.CHL_LOW_PRIORITY, ENet.PacketFlags.Unsequenced);
            }
            else
            {
                PacketHandlerManager.getInstace().broadcastPacketVision(u, us, Channel.CHL_LOW_PRIORITY, ENet.PacketFlags.Unsequenced);
            }
        }
Example #6
0
            public UpdateStats(Unit u, bool partial = true) : base(PacketCmdS2C.PKT_S2C_CharStats, 0)
            {
                var stats = new PairList<byte, List<int>>();

                if (partial)
                    stats = u.getStats().getUpdatedStats();
                else
                    stats = u.getStats().getAllStats();

                var masks = new List<byte>();
                byte masterMask = 0;

                foreach (var p in stats)
                {
                    masterMask |= p.Item1;
                    masks.Add(p.Item1);
                }

                masks.Sort();

                buffer.Write((byte)1);
                buffer.Write((byte)masterMask);
                buffer.Write((int)u.getNetId());


                foreach (var m in masks)
                {
                    int mask = 0;
                    byte size = 0;

                    var updatedStats = stats[m];
                    updatedStats.Sort();
                    foreach (var it in updatedStats)
                    {
                        size += u.getStats().getSize(m, it);
                        mask |= it;
                    }
                    //if (updatedStats.Contains((int)FieldMask.FM1_SummonerSpells_Enabled))
                    //  System.Diagnostics.Debugger.Break();
                    buffer.Write((int)mask);
                    buffer.Write((byte)size);

                    for (int i = 0; i < 32; i++)
                    {
                        int tmpMask = (1 << i);
                        if ((tmpMask & mask) > 0)
                        {
                            if (u.getStats().getSize(m, tmpMask) == 4)
                            {
                                float f = u.getStats().getStat(m, tmpMask);
                                var c = BitConverter.GetBytes(f);
                                if (c[0] >= 0xFE)
                                {
                                    c[0] = (byte)0xFD;
                                }
                                buffer.Write(BitConverter.ToSingle(c, 0));
                            }
                            else if (u.getStats().getSize(m, tmpMask) == 2)
                            {
                                short stat = (short)Math.Floor(u.getStats().getStat(m, tmpMask) + 0.5);
                                buffer.Write(stat);
                            }
                            else
                            {
                                byte stat = (byte)Math.Floor(u.getStats().getStat(m, tmpMask) + 0.5);
                                buffer.Write(stat);
                            }
                        }
                    }
                }
            }
Example #7
0
        public override float getExperienceFor(Unit u)
        {
            var m = u as Minion;

            if (m == null)
                return 0.0f;

            switch (m.getType())
            {
                case MinionSpawnType.MINION_TYPE_MELEE:
                    return 58.88f;
                case MinionSpawnType.MINION_TYPE_CASTER:
                    return 29.44f;
                case MinionSpawnType.MINION_TYPE_CANNON:
                    return 92.0f;
            }

            return 0.0f;
        }
Example #8
0
        public override void die(Unit killer)
        {
            respawnTimer = 5000 + getStats().getLevel() * 2500;
            map.stopTargeting(this);

            var cKiller = killer as Champion;

            if (cKiller == null && championHitFlagTimer > 0)
            {
                cKiller = map.getObjectById(playerHitId) as Champion;
                Logger.LogCoreInfo("Killed by turret, minion or monster, but still  give gold to the enemy.");
            }

            if (cKiller == null)
            {
                PacketNotifier.notifyChampionDie(this, killer, 0);
                return;
            }

            cKiller.setChampionGoldFromMinions(0);

            float gold = map.getGoldFor(this);
            Logger.LogCoreInfo("Before: getGoldFromChamp: " + gold + " Killer:" + cKiller.killDeathCounter + "Victim: " + killDeathCounter);

            if (cKiller.killDeathCounter < 0)
                cKiller.killDeathCounter = 0;

            if (cKiller.killDeathCounter >= 0)
                cKiller.killDeathCounter += 1;

            if (killDeathCounter > 0)
                killDeathCounter = 0;

            if (killDeathCounter <= 0)
                killDeathCounter -= 1;

            if (gold > 0)
            {
                PacketNotifier.notifyChampionDie(this, cKiller, 0);
                return;
            }

            if (map.getKillReduction() && !map.getFirstBlood())
            {
                gold -= gold * 0.25f;
                //CORE_INFO("Still some minutes for full gold reward on champion kills");
            }

            if (map.getFirstBlood())
            {
                gold += 100;
                map.setFirstBlood(false);
            }

            PacketNotifier.notifyChampionDie(this, cKiller, (int)gold);

            cKiller.getStats().setGold(cKiller.getStats().getGold() + gold);
            PacketNotifier.notifyAddGold(cKiller, this, gold);

            //CORE_INFO("After: getGoldFromChamp: %f Killer: %i Victim: %i", gold, cKiller.killDeathCounter,this.killDeathCounter);

            map.stopTargeting(this);
        }
Example #9
0
        public override void update(long diff)
        {
            //f**k LUA
            /* if (unitScript.isLoaded())
             {
                 try
                 {
                     unitScript.lua.get<sol::function>("onUpdate").call<void>(diff);
                 }
                 catch (sol::error e)
                 {
                     CORE_ERROR("%s", e.what());
                 }
             }*/

            if (isDead())
            {
                if (targetUnit != null)
                {
                    setTargetUnit(null);
                    autoAttackTarget = null;
                    isAttacking = false;
                    PacketNotifier.notifySetTarget(this, null);
                    initialAttackDone = false;
                }
                return;
            }

            if (targetUnit != null)
            {
                if (targetUnit.isDead() || !getMap().teamHasVisionOn(getTeam(), targetUnit))
                {
                    setTargetUnit(null);
                    isAttacking = false;
                    PacketNotifier.notifySetTarget(this, null);
                    initialAttackDone = false;

                }
                else if (isAttacking && autoAttackTarget != null)
                {
                    autoAttackCurrentDelay += diff / 1000.0f;
                    if (autoAttackCurrentDelay >= autoAttackDelay / stats.getAttackSpeedMultiplier())
                    {
                        if (!isMelee())
                        {
                            Projectile p = new Projectile(map, autoAttackProjId, x, y, 5, this, autoAttackTarget, null, autoAttackProjectileSpeed, 0);
                            map.addObject(p);
                            PacketNotifier.notifyShowProjectile(p);
                        }
                        else
                        {
                            autoAttackHit(autoAttackTarget);
                        }
                        autoAttackCurrentCooldown = 1.0f / (stats.getTotalAttackSpeed());
                        isAttacking = false;
                    }

                }
                else if (distanceWith(targetUnit) <= stats.getRange())
                {
                    refreshWaypoints();
                    nextAutoIsCrit = new Random().Next(0, 100) <= stats.getCritChance() * 100;
                    if (autoAttackCurrentCooldown <= 0)
                    {
                        isAttacking = true;
                        autoAttackCurrentDelay = 0;
                        autoAttackProjId = Game.GetNewNetID();
                        autoAttackTarget = targetUnit;

                        if (!initialAttackDone)
                        {
                            initialAttackDone = true;
                            PacketNotifier.notifyBeginAutoAttack(this, targetUnit, autoAttackProjId, nextAutoIsCrit);
                        }
                        else {
                            nextAttackFlag = !nextAttackFlag; // The first auto attack frame has occurred
                            PacketNotifier.notifyNextAutoAttack(this, targetUnit, autoAttackProjId, nextAutoIsCrit, nextAttackFlag);
                        }

                        var attackType = isMelee() ? AttackType.ATTACK_TYPE_MELEE : AttackType.ATTACK_TYPE_TARGETED;
                        PacketNotifier.notifyOnAttack(this, targetUnit, attackType);
                    }

                }
                else
                {
                    refreshWaypoints();
                }

            }
            else if (isAttacking)
            {
                if (autoAttackTarget == null || autoAttackTarget.isDead() || !getMap().teamHasVisionOn(getTeam(), autoAttackTarget))
                {
                    isAttacking = false;
                    initialAttackDone = false;
                    autoAttackTarget = null;
                }
            }

            base.update(diff);

            if (autoAttackCurrentCooldown > 0)
            {
                autoAttackCurrentCooldown -= diff / 1000.0f;
            }

            statUpdateTimer += diff;
            if (statUpdateTimer >= 500000)
            { // update stats (hpregen, manaregen) every 0.5 seconds
                stats.update(statUpdateTimer);
                statUpdateTimer = 0;
            }
        }
Example #10
0
 public void setAutoAttackTarget(Unit target)
 {
     autoAttackTarget = target;
 }
Example #11
0
 public void setDistressCall(Unit distress)
 {
     distressCause = distress;
 }
Example #12
0
        public virtual void dealDamageTo(Unit target, float damage, DamageType type, DamageSource source)
        {

            /* //F**k LUA
            if (unitScript.isLoaded())
            {
                try
                {
                    //damage = 
                    unitScript.lua.get<sol::function>("onDealDamage").call<void>(target, damage, type, source);
                }
                catch (sol::error e)
                {
                    CORE_ERROR("Error callback ondealdamage: %s", e.what());
                }
            }*/


            float defense = 0;
            float regain = 0;
            switch (type)
            {
                case DamageType.DAMAGE_TYPE_PHYSICAL:
                    defense = target.getStats().getArmor();
                    defense = ((1 - stats.getArmorPenPct()) * defense) - stats.getArmorPenFlat();

                    break;
                case DamageType.DAMAGE_TYPE_MAGICAL:
                    defense = target.getStats().getMagicArmor();
                    defense = ((1 - stats.getMagicPenPct()) * defense) - stats.getMagicPenFlat();
                    break;
            }

            switch (source)
            {
                case DamageSource.DAMAGE_SOURCE_SPELL:
                    regain = stats.getSpellVamp();
                    break;
                case DamageSource.DAMAGE_SOURCE_ATTACK:
                    regain = stats.getLifeSteal();
                    break;
            }

            //Damage dealing. (based on leagueoflegends' wikia)
            damage = defense >= 0 ? (100 / (100 + defense)) * damage : (2 - (100 / (100 - defense))) * damage;

            target.getStats().setCurrentHealth(Math.Max(0.0f, target.getStats().getCurrentHealth() - damage));
            if (!target.deathFlag && target.getStats().getCurrentHealth() <= 0)
            {
                target.deathFlag = true;
                target.die(this);
            }
            PacketNotifier.notifyDamageDone(this, target, damage, type);

            //Get health from lifesteal/spellvamp
            if (regain != 0)
            {
                stats.setCurrentHealth(Math.Min(stats.getMaxHealth(), stats.getCurrentHealth() + (regain * damage)));
                PacketNotifier.notifyUpdatedStats(this);
            }
        }
Example #13
0
 public SetHealth(Unit u) : base(PacketCmdS2C.PKT_S2C_SetHealth, u.getNetId())
 {
     buffer.Write((short)0x0000); // unk,maybe flags for physical/magical/true dmg
     buffer.Write((float)u.getStats().getMaxHealth());
     buffer.Write((float)u.getStats().getCurrentHealth());
 }
Example #14
0
        public ChampionDie(Champion die, Unit killer, int goldFromKill) : base(PacketCmdS2C.PKT_S2C_ChampionDie, die.getNetId())
        {
            buffer.Write(goldFromKill); // Gold from kill?
            buffer.Write((short)0);
            if (killer != null)
                buffer.Write(killer.getNetId());
            else
                buffer.Write((int)0);

            buffer.Write((short)0);
            buffer.Write((short)7);
            buffer.Write(die.getRespawnTimer() / 1000.0f); // Respawn timer, float
        }
Example #15
0
 public SetTarget2(Unit attacker, Unit attacked) : base(PacketCmdS2C.PKT_S2C_SetTarget2, attacker.getNetId())
 {
     if (attacked != null)
     {
         buffer.Write(attacked.getNetId());
     }
     else
     {
         buffer.Write((int)0);
     }
 }
Example #16
0
 public OnAttack(Unit attacker, Unit attacked, AttackType attackType) : base(ExtendedPacketCmd.EPKT_S2C_OnAttack, attacker.getNetId())
 {
     buffer.Write((short)attackType);
     buffer.Write(attacked.getX());
     buffer.Write(attacked.getZ());
     buffer.Write(attacked.getY());
     buffer.Write(attacked.getNetId());
 }
Example #17
0
 public StopAutoAttack(Unit attacker) : base(PacketCmdS2C.PKT_S2C_StopAutoAttack, attacker.getNetId())
 {
     buffer.Write((int)0); // Unk. Rarely, this is a net ID. Dunno what for.
     buffer.Write((short)3); // Unk. Sometimes "2", sometimes "11" when the above netId is not 0.
 }
Example #18
0
        public NextAutoAttack(Unit attacker, Unit attacked, int futureProjNetId, bool isCritical, bool initial) : base(PacketCmdS2C.PKT_S2C_NextAutoAttack, attacker.getNetId())
        {
            buffer.Write(attacked.getNetId());
            if (initial)
                buffer.Write((short)0x80); // These flags appear to change only to 0x80 and 0x7F after the first autoattack.
            else
                buffer.Write((short)0x7F);

            buffer.Write(futureProjNetId);
            if (isCritical)
                buffer.Write((short)0x49);
            else
                buffer.Write((short)0x40); // unk -- seems to be flags related to things like critical strike (0x49)

            // not sure what this is, but it should be correct (or maybe attacked x z y?) - 4.18
            buffer.Write("\x40\x01\x7B\xEF\xEF\x01\x2E\x55\x55\x35\x94\xD3");
        }
Example #19
0
        /**
        * This is called by the AA projectile when it hits its target
        */
        public virtual void autoAttackHit(Unit target)
        {
            float damage = (nextAutoIsCrit) ? stats.getCritDamagePct() * stats.getTotalAd() : stats.getTotalAd();
            dealDamageTo(target, damage, DamageType.DAMAGE_TYPE_PHYSICAL, DamageSource.DAMAGE_SOURCE_ATTACK);

            //f**k LUA
            /*if (unitScript.isLoaded())
            {
                try
                {
                    unitScript.lua.get<sol::function>("onAutoAttack").call<void>(target);
                }
                catch (sol::error e)
                {
                    CORE_ERROR("Error callback ondealdamage: %s", e.what());
                }
            }*/
        }
Example #20
0
 public SpellAnimation(Unit u, string animationName) : base(PacketCmdS2C.PKT_S2C_SpellAnimation, u.getNetId())
 {
     buffer.Write((int)0x00000005); // unk
     buffer.Write((int)0x00000000); // unk
     buffer.Write((int)0x00000000); // unk
     buffer.Write(1.0f); // unk
     foreach (var b in Encoding.Default.GetBytes(animationName))
         buffer.Write(b);
     buffer.Write((byte)0);
 }
Example #21
0
        public virtual void die(Unit killer)
        {
            setToRemove();
            map.stopTargeting(this);

            PacketNotifier.notifyNpcDie(this, killer);

            float exp = map.getExperienceFor(this);
            var champs = map.getChampionsInRange(this, EXP_RANGE, true);
            //Cull allied champions
            champs.RemoveAll(l => l.getTeam() == getTeam());

            if (champs.Count > 0)
            {
                float expPerChamp = exp / champs.Count;
                foreach (var c in champs)
                    c.getStats().setExp(c.getStats().getExperience() + expPerChamp);
            }

            if (killer != null)
            {
                var cKiller = killer as Champion;

                if (cKiller == null)
                    return;

                float gold = map.getGoldFor(this);
                if (gold <= 0)
                    return;

                cKiller.getStats().setGold(cKiller.getStats().getGold() + gold);
                PacketNotifier.notifyAddGold(cKiller, this, gold);

                if (cKiller.killDeathCounter < 0)
                {
                    cKiller.setChampionGoldFromMinions(cKiller.getChampionGoldFromMinions() + gold);
                    Logger.LogCoreInfo("Adding gold form minions to reduce death spree: " + cKiller.getChampionGoldFromMinions());
                }

                if (cKiller.getChampionGoldFromMinions() >= 50 && cKiller.killDeathCounter < 0)
                {
                    cKiller.setChampionGoldFromMinions(0);
                    cKiller.killDeathCounter += 1;
                }
            }
        }
Example #22
0
        public SetAnimation(Unit u, List<Tuple<string, string>> animationPairs) : base(PacketCmdS2C.PKT_S2C_SetAnimation, u.getNetId())
        {
            buffer.Write((byte)animationPairs.Count);

            for (int i = 0; i < animationPairs.Count; i++)
            {
                buffer.Write((int)animationPairs[i].Item1.Length);
                foreach (var b in Encoding.Default.GetBytes(animationPairs[i].Item1))
                    buffer.Write(b);

                buffer.Write((int)animationPairs[i].Item2.Length);
                foreach (var b in Encoding.Default.GetBytes(animationPairs[i].Item2))
                    buffer.Write(b);
            }
        }
Example #23
0
        public void setTargetUnit(Unit target)
        {
            if (target == null) // If we are unsetting the target (moving around)
            {
                if (targetUnit != null) // and we had a target
                    targetUnit.setDistressCall(null); // Unset the distress call	
                                                      // TODO: Replace this with a delay?
            }
            else
            {
                target.setDistressCall(this); // Otherwise set the distress call
            }

            targetUnit = target;
            refreshWaypoints();
        }
Example #24
0
 public FaceDirection(Unit u, float relativeX, float relativeY, float relativeZ) : base(PacketCmdS2C.PKT_S2C_FaceDirection, u.getNetId())
 {
     buffer.Write(relativeX);
     buffer.Write(relativeZ);
     buffer.Write(relativeY);
     buffer.Write((byte)0);
     buffer.Write((float)0.0833); // Time to turn ?
 }
Example #25
0
        public int classifyTarget(Unit target)
        {
            /*
Under normal circumstances, a minionç—´ behavior is simple. Minions follow their attack route until they reach an enemy to engage. 
Every few seconds, they will scan the area around them for the highest priority target. When a minion receives a call for help 
from an ally, it will evaluate its current target in relation to the target designated by the call. It will switch its attack 
to the new target if and only if the new target is of a higher priority than their current target. Minions prioritize targets 
in the following order:

    1. An enemy champion designated by a call for help from an allied champion. (Enemy champion attacking an Allied champion)
    2. An enemy minion designated by a call for help from an allied champion. (Enemy minion attacking an Allied champion)
    3. An enemy minion designated by a call for help from an allied minion. (Enemy minion attacking an Allied minion)
    4. An enemy turret designated by a call for help from an allied minion. (Enemy turret attacking an Allied minion)
    5. An enemy champion designated by a call for help from an allied minion. (Enemy champion attacking an Allied minion)
    6. The closest enemy minion.
    7. The closest enemy champion.
*/

            if (target.targetUnit != null && target.targetUnit.isInDistress()) // If an ally is in distress, target this unit. (Priority 1~5)
            {
                if (target is Champion && target.targetUnit is Champion) // If it's a champion attacking a friendly champion
                    return 1;
                else if (target is Minion && target.targetUnit is Champion) // If it's a minion attacking a friendly champion.
                    return 2;
                else if (target is Minion && target.targetUnit is Minion) // Minion attacking minion
                    return 3;
                else if (target is Turret && target.targetUnit is Minion) // Turret attacking minion
                    return 4;
                else if (target is Champion && target.targetUnit is Minion) // Champion attacking minion
                    return 5;
            }

            var m = target as Minion;
            if (m != null)
            {
                switch (m.getType())
                {
                    case MinionSpawnType.MINION_TYPE_MELEE:
                        return 6;
                    case MinionSpawnType.MINION_TYPE_CASTER:
                        return 7;
                    case MinionSpawnType.MINION_TYPE_CANNON:
                    case MinionSpawnType.MINION_TYPE_SUPER:
                        return 8;
                }
            }

            if (target is Champion)
                return 9;

            return 10;

            /*Turret* t = dynamic_cast<Turret*>(target);

            // Turrets before champions
            if (t) {
               return 6;
            }

            Minion* m = dynamic_cast<Minion*>(target);

            if (m) {
               switch (m.getType()) {
                  case MINION_TYPE_MELEE:
                     return 4;
                  case MINION_TYPE_CASTER:
                     return 5;
                  case MINION_TYPE_CANNON:
                  case MINION_TYPE_SUPER:
                     return 3;
               }
            }

            Champion* c = dynamic_cast<Champion*>(target);
            if (c) {
               return 7;
            }

            //Trap (Shaco box) return 1
            //Pet (Tibbers) return 2

            return 10;*/
        }
Example #26
0
        public Dash(Unit u, float toX, float toY, float dashSpeed) : base(PacketCmdS2C.PKT_S2C_Dash, 0)
        {
            buffer.Write((short)1); // nb updates ?
            buffer.Write((byte)5); // unk
            buffer.Write((int)u.getNetId());
            buffer.Write((byte)0); // unk
            buffer.Write((float)dashSpeed); // Dash speed
            buffer.Write((int)0); // unk
            buffer.Write((float)u.getX());
            buffer.Write((float)u.getY());
            buffer.Write((int)0); // unk
            buffer.Write((byte)0);

            buffer.Write((int)0x4c079bb5); // unk
            buffer.Write((uint)0xa30036df); // unk
            buffer.Write((int)0x200168c2); // unk

            buffer.Write((byte)0x00); // Vector bitmask on whether they're int16 or byte

            MovementVector from = u.getMap().toMovementVector(u.getX(), u.getY());
            MovementVector to = u.getMap().toMovementVector(toX, toY);

            buffer.Write((short)from.x);
            buffer.Write((short)from.y);
            buffer.Write((short)to.x);
            buffer.Write((short)to.y);
        }
Example #27
0
        public Spell castSpell(byte slot, float x, float y, Unit target, int futureProjNetId, int spellNetId)
        {
            if (slot >= spells.Count)
                return null;

            Spell s = spells[slot];

            s.setSlot(slot);//temporary hack until we redo spells to be almost fully lua-based

            if ((s.getCost() * (1 - stats.getSpellCostReduction())) > stats.getCurrentMana() || s.getState() != SpellState.STATE_READY)
                return null;

            s.cast(x, y, target, futureProjNetId, spellNetId);
            stats.setCurrentMana(stats.getCurrentMana() - (s.getCost() * (1 - stats.getSpellCostReduction())));
            return s;
        }
Example #28
0
 public AddGold(Champion richMan, Unit died, float gold) : base(PacketCmdS2C.PKT_S2C_AddGold, richMan.getNetId())
 {
     buffer.Write(richMan.getNetId());
     if (died != null)
     {
         buffer.Write(died.getNetId());
     }
     else
     {
         buffer.Write((int)0);
     }
     buffer.Write(gold);
 }
Example #29
0
        public override void dealDamageTo(Unit target, float damage, DamageType type, DamageSource source)
        {
            base.dealDamageTo(target, damage, type, source);

            var cTarget = target as Champion;
            if (cTarget == null)
                return;

            cTarget.setChampionHitFlagTimer(15 * 1000); //15 seconds timer, so when you get executed the last enemy champion who hit you gets the gold
            cTarget.playerHitId = id;
            //CORE_INFO("15 second execution timer on you. Do not get killed by a minion, turret or monster!");
        }
Example #30
0
        public override float getGoldFor(Unit u)
        {
            var m = u as Minion;
            if (m == null)
            {
                var c = u as Champion;
                if (c == null)
                    return 0.0f;

                float gold = 300.0f; //normal gold for a kill
                if (c.getKillDeathCounter() < 5 && c.getKillDeathCounter() >= 0)
                {
                    if (c.getKillDeathCounter() == 0)
                        return gold;
                    for (int i = c.getKillDeathCounter(); i > 1; --i)
                        gold += gold * 0.165f;

                    return gold;
                }

                if (c.getKillDeathCounter() >= 5)
                    return 500.0f;

                if (c.getKillDeathCounter() < 0)
                {
                    float firstDeathGold = gold - gold * 0.085f;

                    if (c.getKillDeathCounter() == -1)
                        return firstDeathGold;

                    for (int i = c.getKillDeathCounter(); i < -1; ++i)
                        firstDeathGold -= firstDeathGold * 0.2f;

                    if (firstDeathGold < 50)
                        firstDeathGold = 50;

                    return firstDeathGold;
                }

                return 0.0f;
            }

            switch (m.getType())
            {
                case MinionSpawnType.MINION_TYPE_MELEE:
                    return 19.0f + ((0.5f) * (int)(gameTime / (180 * 1000)));
                case MinionSpawnType.MINION_TYPE_CASTER:
                    return 14.0f + ((0.2f) * (int)(gameTime / (90 * 1000)));
                case MinionSpawnType.MINION_TYPE_CANNON:
                    return 40.0f + ((1.0f) * (int)(gameTime / (180 * 1000)));
            }

            return 0.0f;
        }