Beispiel #1
0
        public ChatChannelLua(LuaScript script)
        {
            Script = script;

            Script.ReloadFile();

            Name = (string) Script["Name"];
            Description = (string) (Script["Description"] ?? string.Empty);
            Alias = (string) (Script["Alias"] ?? string.Empty);
        }
Beispiel #2
0
        public CommandLua(Server server, LuaScript script) : base(server)
        {
            Script = script;

            Script["World"] = World;

            Script.ReloadFile();

            Name = (string) Script["Name"];
            Description = (string) (Script["Description"] ?? string.Empty);
            Aliases = Lua.ToLuaTable(Script["Aliases"]).ToList().Select(obj => obj.ToString().Replace("\"", ""));
            Permissions = ParsePermissionFlags((string) (Script["Permission"] ?? string.Empty));
        }
Beispiel #3
0
 private void AddListBindingEntry(LuaScript entry)
 {
     listBinding.Add(entry);
 }
Beispiel #4
0
 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 2)
     {
         Task.Run(() =>
        {
            string[] files1 = Directory.GetFiles("Scripts\\", "*.lua");
            string[] files2 = Directory.GetFiles("Scripts\\libs", "*.lua");
            int num = Enumerable.Aggregate<string, int>(Enumerable.Select<string, string>(files1, new Func<string, string>(Path.GetFileNameWithoutExtension)), 0, (current, scriptName) => current ^ scriptName.GetHashCode()) ^ Enumerable.Aggregate<string, int>(Enumerable.Select<string, string>(files2, new Func<string, string>(Path.GetFileNameWithoutExtension)), 0, (current, scriptName) => current ^ scriptName.GetHashCode());
            if (num == _scriptListChecksum)
                return;
            _scriptListChecksum = num;
            Dictionary<string, bool> dictionary = new Dictionary<string, bool>();
            foreach (LuaScript luaScript in listBinding)
                dictionary[luaScript.ScriptName] = luaScript.LoadScript;
            Invoke(new Action(ClearBindingSource));
            foreach (string name in Enumerable.Select<string, string>(files1, new Func<string, string>(Path.GetFileNameWithoutExtension)))
            {
                LuaScript luaScript = new LuaScript(name);
                if (dictionary.ContainsKey(luaScript.ScriptName))
                    luaScript.LoadScript = dictionary[luaScript.ScriptName];
                Invoke(new Action<LuaScript>(AddListBindingEntry), luaScript);
            }
        });
     }
     else
     {
         if (tabControl1.SelectedIndex != 3)
             return;
         _scriptConfigClass.Clear();
         foreach (string category in Enumerable.Select<string, string>(Directory.GetFiles("Scripts\\Config\\", "*.txt"), new Func<string, string>(Path.GetFileNameWithoutExtension)))
         {
             string[] strArray = File.ReadAllLines(Path.Combine("Scripts\\Config\\", category + ".txt"));
             Regex regex = new Regex("([\\w|-]*)[\\W]*=[\\W]*([\\w|-]*)", RegexOptions.Compiled);
             foreach (string input in strArray)
             {
                 if (regex.IsMatch(input))
                 {
                     Match match = regex.Match(input);
                     object obj = string.Compare(match.Groups[2].Value, "true", StringComparison.OrdinalIgnoreCase) != 0 ? (string.Compare(match.Groups[2].Value, "false", StringComparison.OrdinalIgnoreCase) != 0 ? match.Groups[2].Value : (object)false) : true;
                     _scriptConfigClass.Add(new CustomProperty(category, match.Groups[1].Value, obj, false, true));
                 }
             }
         }
         scriptConfigGrid.Refresh();
     }
 }
Beispiel #5
0
        public void loadLua(LuaScript script)
        {
            //Fuck LUA
            /*std::string scriptloc = "../../lua/champions/" + owner->getType() + "/" + getStringForSlot() + ".lua"; //lua/championname/(q/w/e/r), example: /lua/Ezreal/q, also for stuff like nidalee cougar they will have diff folders!

            CORE_INFO("Spell script loc is: %s", scriptloc.c_str());

            script.lua.script("package.path = '../../lua/lib/?.lua;' .. package.path"); //automatically load vector lib so scripters dont have to worry about path
            script.lua.set_function("getOwnerX", [this]() { return owner->getX(); });
            script.lua.set_function("getOwnerY", [this]() { return owner->getY(); });
            script.lua.set_function("getSpellLevel", [this]() { return getLevel(); });
            script.lua.set_function("getOwnerLevel", [this]() { return owner->getStats().getLevel(); });
            script.lua.set_function("getChampionModel", [this]() { return owner->getModel(); });
            script.lua.set_function("getCastTarget", [this]() { return this->target; });

            script.lua.set_function("setChampionModel", [this](const std::string&newModel) {
                owner->setModel(newModel);
                return;
            });
            script.lua.set_function("getSpellToX", [this]() { return x; });
            script.lua.set_function("getSpellToY", [this]() { return y; });
            script.lua.set_function("getRange", [this]() { return castRange; });
            script.lua.set_function("teleportTo", [this](float _x, float _y) { // expose teleport to lua
                owner->getMap()->getGame()->notifyTeleport(owner, _x, _y);
                return;
            });
            script.lua.set_function("isWalkable", [this](float _x, float _y) {
                return owner->getMap()->isWalkable(_x, _y);
            });

            /*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;
            });*/
            //Fuck LUA
            /*
            script.lua.set_function("addBuff", [this](Buff b, Unit * u){
                u->addBuff(new Buff(b));
                return;
            });

            script.lua.set_function("getEffectValue", [this](uint32 effectNo) {
                if (effectNo >= effects.size() || level >= effects[effectNo].size())
                {
                    return 0.f;
                }
                return effects[effectNo][level];
            });

            script.lua.set_function("getOwner", [this]() { return owner; });

            script.lua.set_function("getTeam", [this](Object * o) { return o->getTeam(); });
            script.lua.set_function("isDead", [this](Unit * u) { return u->isDead(); });

            script.lua.set_function("getProjectileSpeed", [this]() { return projectileSpeed; });
            script.lua.set_function("getCoefficient", [this]() { return coefficient; });

            script.lua.set_function("addProjectile", [this](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(spellName + "Missile"), projectileFlags ? projectileFlags : flags);
                owner->getMap()->addObject(p);
                owner->getMap()->getGame()->notifyProjectileSpawn(p);

                return;
            });

            script.lua.set_function("addProjectileTarget", [this](Target * t) {
                Projectile* p = new Projectile(owner->getMap(), GetNewNetID(), owner->getX(), owner->getY(), lineWidth, owner, t, this, projectileSpeed, RAFFile::getHash(spellName + "Missile"), projectileFlags ? projectileFlags : flags);
                owner->getMap()->addObject(p);
                owner->getMap()->getGame()->notifyProjectileSpawn(p);

                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("addParticle", [this](const std::string&particle, float toX, float toY) {
                Target* t = new Target(toX, toY);
                owner->getMap()->getGame()->notifyParticleSpawn(owner, t, particle);
                delete t;
                return;
            });

            script.lua.set_function("addParticleTarget", [this](const std::string&particle, Target* u) {
                owner->getMap()->getGame()->notifyParticleSpawn(owner, u, particle);
                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.lua.set_function("dashTo", [this](Unit * u, float x, float y, float dashSpeed) {
                u->dashTo(x, y, dashSpeed);
                u->setTargetUnit(0);
                owner->getMap()->getGame()->notifyDash(u, x, y, dashSpeed);
                return;
            });

            script.lua.set_function("getUnitsInRange", [this](Target * t, float range, bool isAlive) {
                return owner->getMap()->getUnitsInRange(t, range, isAlive);
            });

            script.lua.set_function("getChampionsInRange", [this](Target * t, float range, bool isAlive) {
                return owner->getMap()->getChampionsInRange(t, range, isAlive);
            });

            try
            {
                script.loadScript(scriptloc); //todo: abstract class that loads a lua file for any lua
            }
            catch (sol::error e)
            {//lua error? don't crash the whole server
                CORE_ERROR("Error in spell script: %s", e.what());
            }
            */
        }