Beispiel #1
0
        public void OnUpdate(double diff)
        {
            _currentTime += diff;
            if (_currentTime >= (_lastUpdate + 1000))
            { //1% max mana per second
                ApiFunctionManager.LogInfo("Trying to regenerate Evelynn's mana");
                var manaRegenerated = _ownerUnit.GetStats().ManaPoints.Total / 100;
                var maxMana         = _ownerUnit.GetStats().ManaPoints.Total;
                var newMana         = _ownerUnit.GetStats().CurrentMana + manaRegenerated;
                if (maxMana >= newMana)
                {
                    _ownerUnit.GetStats().CurrentMana = newMana;
                }
                else
                {
                    _ownerUnit.GetStats().CurrentMana = maxMana;
                }

                _lastUpdate = _currentTime;
            }
        }
        public void OnFinishCasting(Champion owner, Spell spell, AttackableUnit target)
        {
            if (!owner.IsDead)
            {
                return;
            }

            owner.Respawn();

            ChampionStatModifier statMod = new ChampionStatModifier();

            statMod.MoveSpeed.PercentBonus = 125.0f / 100.0f;
            owner.AddStatModifier(statMod);
            ApiFunctionManager.AddParticleTarget(owner, "Global_SS_Revive.troy", owner);
            var visualBuff = ApiFunctionManager.AddBuffHUDVisual("SummonerReviveSpeedBoost", 12.0f, 1, owner);

            ApiFunctionManager.CreateTimer(12.0f, () =>
            {
                ApiFunctionManager.RemoveBuffHUDVisual(visualBuff);
                owner.RemoveStatModifier(statMod);
            });
        }
Beispiel #3
0
        public void StringToByteArrayTest()
        {
            byte[] shouldBe  = { 0xC6, 0x00, 0x10, 0x45, 0xF8 };
            var    byteArray = ApiFunctionManager.StringToByteArray("C6001045F8");

            CollectionAssert.AreEqual(shouldBe, byteArray);

            byteArray = ApiFunctionManager.StringToByteArray("C6 00 10 45 F8");
            CollectionAssert.AreEqual(shouldBe, byteArray);

            byteArray = ApiFunctionManager.StringToByteArray("C60010       45F8");
            CollectionAssert.AreEqual(shouldBe, byteArray);

            byteArray = ApiFunctionManager.StringToByteArray("C6001045F8      ");
            CollectionAssert.AreEqual(shouldBe, byteArray);

            byteArray = ApiFunctionManager.StringToByteArray("    C6001045F8");
            CollectionAssert.AreEqual(shouldBe, byteArray);

            byteArray = ApiFunctionManager.StringToByteArray("C600   1045  F8");
            CollectionAssert.AreEqual(shouldBe, byteArray);
        }
        public void OnFinishCasting(Champion owner, Spell spell, AttackableUnit target)
        {
            var     current = new Vector2(owner.X, owner.Y);
            var     to      = new Vector2(spell.X, spell.Y) - current;
            Vector2 trueCoords;

            if (to.Length() > 425)
            {
                to = Vector2.Normalize(to);
                var range = to * 425;
                trueCoords = current + range;
            }
            else
            {
                trueCoords = new Vector2(spell.X, spell.Y);
            }

            ApiFunctionManager.AddParticle(owner, "global_ss_flash.troy", owner.X, owner.Y);
            ApiFunctionManager.TeleportTo(owner, trueCoords.X, trueCoords.Y);

            ApiFunctionManager.AddParticleTarget(owner, "global_ss_flash_02.troy", owner);
        }
        public void OnFinishCasting(Champion owner, Spell spell, AttackableUnit target)
        {
            Champion champion = (Champion)target;

            if (champion.Team != owner.Team)
            {
                spell.AddProjectileTarget("LuluWTwo", target);
            }
            else
            {
                Particle p = ApiFunctionManager.AddParticleTarget(owner, "Lulu_W_buf_02.troy", target, 1);
                ApiFunctionManager.AddParticleTarget(owner, "Lulu_W_buf_01.troy", target, 1);
                float time       = 2.5f + 0.5f * spell.Level;
                var   buff       = ((ObjAIBase)target).AddBuffGameScript("LuluWBuff", "LuluWBuff", spell);
                var   visualBuff = ApiFunctionManager.AddBuffHUDVisual("LuluWBuff", time, 1, (ObjAIBase)target);
                ApiFunctionManager.CreateTimer(time, () =>
                {
                    ApiFunctionManager.RemoveParticle(p);
                    ApiFunctionManager.RemoveBuffHUDVisual(visualBuff);
                    owner.RemoveBuffGameScript(buff);
                });
            }
        }
Beispiel #6
0
        public virtual void LoadLua()
        {
            _scriptEngine = new LuaScriptEngine();

            _scriptEngine.Execute("package.path = 'LuaLib/?.lua;' .. package.path");
            _scriptEngine.Execute(@"
                function onAutoAttack(target)
                end");
            _scriptEngine.Execute(@"
                function onUpdate(diff)
                end");
            _scriptEngine.Execute(@"
                function onDealDamage(target, damage, type, source)
                end");
            _scriptEngine.Execute(@"
                function onDie(killer)
                end");
            _scriptEngine.Execute(@"
                function onDamageTaken(attacker, damage, type, source)
                end");

            ApiFunctionManager.AddBaseFunctionToLuaScript(_scriptEngine);
        }
Beispiel #7
0
        public void LoadLua(IScriptEngine scriptEngine)
        {
            var    config = _game.Config;
            string scriptloc;

            if (Slot > 3)
            {
                scriptloc = config.ContentManager.GetSpellScriptPath("Global", _spellName);
            }
            else
            {
                scriptloc = config.ContentManager.GetSpellScriptPath(Owner.Model, getStringForSlot());
            }
            scriptEngine.Execute("package.path = 'LuaLib/?.lua;' .. package.path");
            scriptEngine.Execute(@"
                function onFinishCasting()
                end");
            scriptEngine.Execute(@"
                function applyEffects()
                end");
            scriptEngine.Execute(@"
                function onUpdate(diff)
                end");
            scriptEngine.Execute(@"
                function onStartCasting()
                end");
            ApiFunctionManager.AddBaseFunctionToLuaScript(scriptEngine);
            scriptEngine.SetGlobalVariable("owner", Owner);
            scriptEngine.SetGlobalVariable("spellLevel", Level);
            scriptEngine.SetGlobalVariable("totalCooldown", getCooldown());
            scriptEngine.RegisterFunction("getOwnerLevel", Owner.GetStats(), typeof(Stats).GetMethod("GetLevel"));
            scriptEngine.RegisterFunction("getChampionModel", Owner, typeof(Spell).GetMethod("GetChampionModel"));
            scriptEngine.SetGlobalVariable("spell", this);
            scriptEngine.SetGlobalVariable("projectileSpeed", ProjectileSpeed);
            scriptEngine.SetGlobalVariable("coefficient", Coefficient);
            scriptEngine.RegisterFunction("addProjectile", this, typeof(Spell).GetMethod("AddProjectile", new[] { typeof(string), typeof(float), typeof(float), typeof(bool) }));
            scriptEngine.RegisterFunction("addProjectileTarget", this, typeof(Spell).GetMethod("AddProjectileTarget", new[] { typeof(string), typeof(Target), typeof(bool) }));
            scriptEngine.RegisterFunction("getEffectValue", this, typeof(Spell).GetMethod("getEffectValue", new[] { typeof(int) }));
            scriptEngine.RegisterFunction("spellAnimation", this, typeof(Spell).GetMethod("spellAnimation", new[] { typeof(string), typeof(Unit) }));
            scriptEngine.RegisterFunction("setAnimation", this, typeof(Spell).GetMethod("setAnimation", new[] { typeof(string), typeof(string), typeof(Unit) }));
            scriptEngine.RegisterFunction("resetAnimations", this, typeof(Spell).GetMethod("resetAnimations", new[] { typeof(Unit) }));
            scriptEngine.RegisterFunction("getOtherSpellLevel", this, typeof(Spell).GetMethod("getOtherSpellLevel", new[] { typeof(short) }));
            scriptEngine.RegisterFunction("addPlaceable", this, typeof(Spell).GetMethod("AddPlaceable", new[] { typeof(float), typeof(float), typeof(string), typeof(string) }));
            scriptEngine.RegisterFunction("addProjectileCustom", this, typeof(Spell).GetMethod("AddProjectileCustom", new[] { typeof(string), typeof(float), typeof(float), typeof(float), typeof(float), typeof(bool) }));
            scriptEngine.RegisterFunction("addProjectileCustomTarget", this, typeof(Spell).GetMethod("AddProjectileCustomTarget", new[] { typeof(string), typeof(float), typeof(float), typeof(Target), typeof(bool) }));
            scriptEngine.RegisterFunction("setCooldown", this, typeof(Spell).GetMethod("SetCooldown", new[] { typeof(byte), typeof(float) }));
            scriptEngine.RegisterFunction("lowerCooldown", this, typeof(Spell).GetMethod("LowerCooldown", new[] { typeof(byte), typeof(float) }));
            scriptEngine.RegisterFunction("addLaser", this, typeof(Spell).GetMethod("AddLaser", new[] { typeof(float), typeof(float), typeof(bool) }));

            /*scriptEngine.RegisterFunction("addMovementSpeedBuff", this, typeof(Spell).GetMethod("addMovementSpeedBuff", new Type[] { typeof(Unit), typeof(float), typeof(float) }));
             *
             * public void addMovementSpeedBuff(Unit u, float amount, float duration)
             * {
             *  Buff b = new Buff(duration);
             *  b.setMovementSpeedPercentModifier(amount);
             *  u.AddBuff(b);
             *  u.GetStats().addMovementSpeedPercentageModifier(b.getMovementSpeedPercentModifier());
             * }*/

            scriptEngine.Load(scriptloc); //todo: abstract class that loads a lua file for any lua
        }
Beispiel #8
0
 public void OnStartCasting(Champion owner, Spell spell, AttackableUnit target)
 {
     ApiFunctionManager.AddParticleTarget(owner, "ezreal_bow.troy", owner, 1, "L_HAND");
 }
 public void OnFinishCasting(Champion owner, Spell spell, AttackableUnit target)
 {
     spell.spellAnimation("SPELL2", owner);
     ApiFunctionManager.AddParticleTarget(owner, "Evelynn_W_cas.troy", owner);
     FrenzyBuff = owner.AddBuffGameScript("EveFrenzy", "EveFrenzy", spell, 3.0f, true);
 }
Beispiel #10
0
        public void LoadLua(LuaScript script)
        {
            var    config = owner.GetGame().Config;
            string scriptloc;

            if (getSlot() > 3)
            {
                scriptloc = config.ContentManager.GetSpellScriptPath("Global", spellName);
            }
            else
            {
                scriptloc = config.ContentManager.GetSpellScriptPath(owner.getType(), getStringForSlot());
            }
            script.lua.DoString("package.path = 'LuaLib/?.lua;' .. package.path");
            script.lua.DoString(@"
                function onFinishCasting()
                end");
            script.lua.DoString(@"
                function applyEffects()
                end");
            ApiFunctionManager.AddBaseFunctionToLuaScript(script);
            script.lua.RegisterFunction("getOwner", this, typeof(Spell).GetMethod("getOwner"));
            script.lua.RegisterFunction("getOwnerX", owner, typeof(Champion).GetMethod("getX"));
            script.lua.RegisterFunction("getOwnerY", owner, typeof(Champion).GetMethod("getY"));
            script.lua.RegisterFunction("getSpellLevel", this, typeof(Spell).GetMethod("getLevel"));
            script.lua.RegisterFunction("getOwnerLevel", owner.GetStats(), typeof(Stats).GetMethod("GetLevel"));
            script.lua.RegisterFunction("getChampionModel", owner, typeof(Champion).GetMethod("getModel"));
            script.lua.RegisterFunction("getCastTarget", this, typeof(Spell).GetMethod("getTarget"));
            script.lua.RegisterFunction("getSpellToX", this, typeof(Spell).GetMethod("getX"));
            script.lua.RegisterFunction("getSpellToY", this, typeof(Spell).GetMethod("getY"));
            script.lua.RegisterFunction("getRange", this, typeof(Spell).GetMethod("getRange"));
            script.lua.RegisterFunction("getProjectileSpeed", this, typeof(Spell).GetMethod("getProjectileSpeed"));
            script.lua.RegisterFunction("getCoefficient", this, typeof(Spell).GetMethod("getCoefficient"));
            script.lua.RegisterFunction("addProjectile", this, typeof(Spell).GetMethod("addProjectile", new Type[] { typeof(string), typeof(float), typeof(float) }));
            script.lua.RegisterFunction("addProjectileTarget", this, typeof(Spell).GetMethod("addProjectileTarget", new Type[] { typeof(string), typeof(Target) }));
            script.lua.RegisterFunction("getEffectValue", this, typeof(Spell).GetMethod("getEffectValue", new Type[] { typeof(int) }));

            /*script.lua.set_function("addMovementSpeedBuff", [this](Unit* u, float amount, float duration) { // expose teleport to lua
             *  Buff* b = new Buff(duration);
             *  b->setMovementSpeedPercentModifier(amount);
             *  u->addBuff(b);
             *  u->GetStats().addMovementSpeedPercentageModifier(b->getMovementSpeedPercentModifier());
             * return;
             * });*/

            /*
             * script.lua.set_function("addProjectileCustom", [this](const std::string&name, float projSpeed, float toX, float toY) {
             *  Projectile* p = new Projectile(owner->getMap(), GetNewNetID(), owner->getX(), owner->getY(), lineWidth, owner, new Target(toX, toY), this, projectileSpeed, RAFFile::getHash(name), projectileFlags ? projectileFlags : flags);
             *  owner->getMap()->addObject(p);
             *  owner->getMap()->getGame()->notifyProjectileSpawn(p);
             *
             *  return;
             * });
             *
             * script.lua.set_function("addProjectileTargetCustom", [this](const std::string&name, float projSpeed, Target *t) {
             *  Projectile* p = new Projectile(owner->getMap(), GetNewNetID(), owner->getX(), owner->getY(), lineWidth, owner, t, this, projectileSpeed, RAFFile::getHash(name), projectileFlags ? projectileFlags : flags);
             *  owner->getMap()->addObject(p);
             *  owner->getMap()->getGame()->notifyProjectileSpawn(p);
             *
             *  return;
             * });
             *
             *
             * //For spells that don't require SpawnProjectile, but for which we still need to track the projectile server-side
             *
             * script.lua.set_function("addServerProjectile", [this](float toX, float toY) {
             *  Projectile* p = new Projectile(owner->getMap(), futureProjNetId, owner->getX(), owner->getY(), lineWidth, owner, new Target(toX, toY), this, projectileSpeed, 0, projectileFlags ? projectileFlags : flags);
             *  owner->getMap()->addObject(p);
             *
             *  return;
             * });
             *
             * script.lua.set_function("spellAnimation", [this](const std::string&animation, Unit* u) {
             *  owner->getMap()->getGame()->notifySpellAnimation(u, animation);
             *  return;
             * });
             *
             * // TODO: Set multiple animations
             * script.lua.set_function("setAnimation", [this](const std::string&animation1, const std::string&animation2, Unit* u) {
             *  std::vector < std::pair < std::string, std::string>> animationPairs;
             *  animationPairs.push_back(std::make_pair(animation1, animation2));
             *
             *  owner->getMap()->getGame()->notifySetAnimation(u, animationPairs);
             *  return;
             * });
             *
             * script.lua.set_function("resetAnimations", [this](Unit * u) {
             *  std::vector < std::pair < std::string, std::string>> animationPairs;
             *  owner->getMap()->getGame()->notifySetAnimation(u, animationPairs);
             *  return;
             * });*/

            script.loadScript(scriptloc); //todo: abstract class that loads a lua file for any lua
        }
 public void OnUpdate(double diff)
 {
     _ownerUnit.RemoveStatModifier(_statMod);
     ApiFunctionManager.RemoveBuffHUDVisual(_visualBuff);
     _statMod.MoveSpeed.FlatBonus = _currentStatMod;
 }
Beispiel #12
0
 public void OnDeactivate(ObjAIBase unit)
 {
     ApiFunctionManager.RemoveBuffHUDVisual(_visualBuff);
 }
Beispiel #13
0
        public void OnFinishCasting(Champion owner, Spell spell, AttackableUnit target)
        {
            var      units = ApiFunctionManager.GetChampionsInRange(owner, 850, true);
            Champion mostWoundedAlliedChampion = null;
            float    lowestHealthPercentage    = 100;
            float    maxHealth;
            float    newHealth;

            for (var i = 0; i <= units.Count - 1; i++)
            {
                var value = units[i];
                if (owner.Team == value.Team && i != 0)
                {
                    var currentHealth = value.GetStats().CurrentHealth;
                    maxHealth = value.GetStats().HealthPoints.Total;
                    if (currentHealth * 100 / maxHealth < lowestHealthPercentage && owner != value)
                    {
                        lowestHealthPercentage    = currentHealth * 100 / maxHealth;
                        mostWoundedAlliedChampion = value;
                    }
                }
            }

            if (mostWoundedAlliedChampion != null)
            {
                newHealth = mostWoundedAlliedChampion.GetStats().CurrentHealth + 75 + owner.GetStats().GetLevel() * 15;
                maxHealth = mostWoundedAlliedChampion.GetStats().HealthPoints.Total;
                if (newHealth >= maxHealth)
                {
                    mostWoundedAlliedChampion.GetStats().CurrentHealth = maxHealth;
                }
                else
                {
                    mostWoundedAlliedChampion.GetStats().CurrentHealth = newHealth;
                }

                ApiFunctionManager.AddBuffHUDVisual("SummonerHeal", 1.0f, 1, mostWoundedAlliedChampion, 1.0f);
                ChampionStatModifier statMod2 = new ChampionStatModifier();
                statMod2.MoveSpeed.PercentBonus = 30 / 100.0f;
                mostWoundedAlliedChampion.AddStatModifier(statMod2);
                ApiFunctionManager.CreateTimer(1.0f, () => { mostWoundedAlliedChampion.RemoveStatModifier(statMod2); });
                ApiFunctionManager.AddParticleTarget(mostWoundedAlliedChampion, "global_ss_heal_02.troy",
                                                     mostWoundedAlliedChampion);
                ApiFunctionManager.AddParticleTarget(mostWoundedAlliedChampion, "global_ss_heal_speedboost.troy",
                                                     mostWoundedAlliedChampion);
            }

            newHealth = owner.GetStats().CurrentHealth + 75 + owner.GetStats().GetLevel() * 15;
            maxHealth = owner.GetStats().HealthPoints.Total;
            if (newHealth >= maxHealth)
            {
                owner.GetStats().CurrentHealth = maxHealth;
            }
            else
            {
                owner.GetStats().CurrentHealth = newHealth;
            }

            ApiFunctionManager.AddBuffHUDVisual("SummonerHeal", 1.0f, 1, owner, 1.0f);
            ChampionStatModifier statMod = new ChampionStatModifier();

            statMod.MoveSpeed.PercentBonus = 30 / 100.0f;
            owner.AddStatModifier(statMod);
            ApiFunctionManager.CreateTimer(1.0f, () => { owner.RemoveStatModifier(statMod); });
            ApiFunctionManager.AddParticleTarget(owner, "global_ss_heal.troy", owner);
            ApiFunctionManager.AddParticleTarget(owner, "global_ss_heal_speedboost.troy", owner);
        }
Beispiel #14
0
        public override void update(float diff)
        {
            base.update(diff);

            if (this.isMovementUpdated())
            {
                if (IsRecalling)
                {
                    ApiFunctionManager.RemoveBuffHUDVisual(_visualBuff);
                    ApiFunctionManager.RemoveParticle(_addParticle);
                    IsRecalling = false;
                }
                _canRecall = false;
            }

            if (!IsDead && MoveOrder == MoveOrder.MOVE_ORDER_ATTACKMOVE && TargetUnit != null)
            {
                var            objects          = _game.ObjectManager.GetObjects();
                var            distanceToTarget = 9000000.0f;
                AttackableUnit nextTarget       = null;
                var            range            = Math.Max(Stats.Range.Total, DETECT_RANGE);

                foreach (var it in objects)
                {
                    var u = it.Value as AttackableUnit;

                    if (u == null || u.IsDead || u.Team == Team || GetDistanceTo(u) > range)
                    {
                        continue;
                    }

                    if (GetDistanceTo(u) < distanceToTarget)
                    {
                        distanceToTarget = GetDistanceTo(u);
                        nextTarget       = u;
                    }
                }

                if (nextTarget != null)
                {
                    TargetUnit = nextTarget;
                    _game.PacketNotifier.NotifySetTarget(this, nextTarget);
                }
            }

            if (!Stats.IsGeneratingGold() && _game.GameTime >= _game.Map.MapGameScript.FirstGoldTime)
            {
                Stats.SetGeneratingGold(true);
                _logger.LogCoreInfo("Generating Gold!");
            }

            if (RespawnTimer > 0)
            {
                RespawnTimer -= diff;
                if (RespawnTimer <= 0)
                {
                    Respawn();
                }
            }

            var isLevelup = LevelUp();

            if (isLevelup)
            {
                _game.PacketNotifier.NotifyLevelUp(this);
                _game.PacketNotifier.NotifyUpdatedStats(this, false);
            }

            foreach (var s in Spells.Values)
            {
                s.update(diff);
            }

            if (_championHitFlagTimer > 0)
            {
                _championHitFlagTimer -= diff;
                if (_championHitFlagTimer <= 0)
                {
                    _championHitFlagTimer = 0;
                }
            }
        }
 private void SelfWasDamaged()
 {
     ApiFunctionManager.LogInfo("Ezreal was damaged");
 }
Beispiel #16
0
        public void OnFinishCasting(IObjAiBase owner, ISpell spell, IAttackableUnit target)
        {
            spell.AddProjectileTarget("pirate_parley_mis", target);

            ApiFunctionManager.AddParticleTarget(owner, "pirate_parley_tar.troy", owner);
        }
 public void OnActivate(Champion owner)
 {
     ApiFunctionManager.LogInfo("Ezreal Passive OnActivate");
     ApiEventManager.OnChampionDamageTaken.AddListener(this, owner, SelfWasDamaged);
 }
Beispiel #18
0
 public void OnDeactivate(ObjAIBase unit)
 {
     _ownerUnit.RemoveStatModifier(_statMod);
     ApiFunctionManager.RemoveBuffHUDVisual(_visualBuff);
 }
 public void OnStartCasting(Champion owner, Spell spell, AttackableUnit target)
 {
     ApiFunctionManager.AddParticleTarget(owner, "Kassadin_Base_cas.troy", owner, 1, "L_HAND");
 }