Exemple #1
0
        public override void die(Unit killer)
        {
            if (RespawnTimer != null) //?
            {
                RespawnTimer.Stop();
            }

            RespawnTimer           = new System.Timers.Timer(RESPAWN_TIMER);
            RespawnTimer.AutoReset = false;
            RespawnTimer.Elapsed  += (a, b) =>
            {
                GetStats().CurrentHealth = GetStats().HealthPoints.Total;
                setState(InhibitorState.Alive);
                IsDead = false;
            };
            RespawnTimer.Start();
            TimerStartTime = DateTime.Now;

            if (killer != null && killer is Champion)
            {
                Champion c         = killer as Champion;
                c.GetStats().Gold += GOLD_WORTH;
                _game.PacketNotifier.notifyAddGold(c, this, GOLD_WORTH);
            }

            setState(InhibitorState.Dead, killer);
            RespawnAnnounced = false;

            base.die(killer);
        }
Exemple #2
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
        }