コード例 #1
0
ファイル: Unit.cs プロジェクト: horato/IntWarsSharp
        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;
            }
        }
コード例 #2
0
ファイル: Packet.cs プロジェクト: horato/IntWarsSharp
        public SpawnProjectile(Projectile p) : base(PacketCmdS2C.PKT_S2C_SpawnProjectile, p.getNetId())
        {
            float targetZ = p.getMap().getHeightAtLocation(p.getTarget().getX(), p.getTarget().getY());

            buffer.Write((float)p.getX());
            buffer.Write((float)p.getZ());
            buffer.Write((float)p.getY());
            buffer.Write((float)p.getX());
            buffer.Write((float)p.getZ());
            buffer.Write((float)p.getY());
            buffer.Write((long)0x000000003f510fe2); // unk
            buffer.Write((float)0.577f); // unk
            buffer.Write((float)p.getTarget().getX());
            buffer.Write((float)targetZ);
            buffer.Write((float)p.getTarget().getY());
            buffer.Write((float)p.getX());
            buffer.Write((float)p.getZ());
            buffer.Write((float)p.getY());
            buffer.Write((float)p.getTarget().getX());
            buffer.Write((float)targetZ);
            buffer.Write((float)p.getTarget().getY());
            buffer.Write((float)p.getX());
            buffer.Write((float)p.getZ());
            buffer.Write((float)p.getY());
            buffer.Write((int)0); // unk
            buffer.Write((float)p.getMoveSpeed()); // Projectile speed
            buffer.Write((long)0x00000000d5002fce); // unk
            buffer.Write((int)0x7f7fffff); // unk
            buffer.Write((byte)0);
            buffer.Write((byte)0x66);
            buffer.Write((byte)0);
            buffer.Write((int)p.getProjectileId()); // unk (projectile ID)
            buffer.Write((int)0); // Second net ID
            buffer.Write((byte)0); // unk
            buffer.Write(1.0f);
            buffer.Write((int)p.getOwner().getNetId());
            buffer.Write((int)p.getOwner().getNetId());

            var c = p.getOwner() as Champion;
            if (c != null)
                buffer.Write((int)c.getChampionHash());
            else
                buffer.Write((int)0);

            buffer.Write((int)p.getNetId());
            buffer.Write((float)p.getTarget().getX());
            buffer.Write((float)targetZ);
            buffer.Write((float)p.getTarget().getY());
            buffer.Write((float)p.getTarget().getX());
            buffer.Write((float)targetZ);
            buffer.Write((float)p.getTarget().getY());
            buffer.Write((uint)0x80000000); // unk
            buffer.Write((int)0x000000bf); // unk
            buffer.Write((uint)0x80000000); // unk
            buffer.Write((int)0x2fd5843f); // unk
            buffer.Write((int)0x00000000); // unk
            buffer.Write((short)0x0000); // unk
            buffer.Write((byte)0x2f); // unk
            buffer.Write((int)0x00000000); // unk
            buffer.Write((float)p.getX());
            buffer.Write((float)p.getZ());
            buffer.Write((float)p.getY());
            buffer.Write((long)0x0000000000000000); // unk
        }
コード例 #3
0
ファイル: Packet.cs プロジェクト: horato/IntWarsSharp
            public DestroyProjectile(Projectile p) : base(PacketCmdS2C.PKT_S2C_DestroyProjectile, p.getNetId())
            {

            }
コード例 #4
0
ファイル: Packet.cs プロジェクト: horato/IntWarsSharp
 public ShowProjectile(Projectile p) : base(PacketCmdS2C.PKT_S2C_ShowProjectile, p.getOwner().getNetId())
 {
     buffer.Write(p.getNetId());
 }
コード例 #5
0
ファイル: Spell.cs プロジェクト: horato/IntWarsSharp
        /**
         * Called by projectiles when they land / hit
         * In here we apply the effects : damage, buffs, debuffs...
         */
        public virtual void applyEffects(Unit t, Projectile p = null)
        {
            //F**k LUA
            /*LuaScript script(true);

            script.lua.set_function("getTarget", [&u]() { return u; });

            script.lua.set_function("dealPhysicalDamage", [this, &u](float amount) {
                owner->dealDamageTo(u, amount, DAMAGE_TYPE_PHYSICAL, DAMAGE_SOURCE_SPELL);
                return;
            });

            script.lua.set_function("dealMagicalDamage", [this, &u](float amount) {
                owner->dealDamageTo(u, amount, DAMAGE_TYPE_MAGICAL, DAMAGE_SOURCE_SPELL);
                return;
            });

            script.lua.set_function("destroyProjectile", [this, &p]() {
                p->setToRemove();
                p->getMap()->getGame()->notifyProjectileDestroy(p);
                return;
            });

            script.lua.set_function("getNumberObjectsHit", [this, &p]() {
                return p->getObjectsHit().size();
            });

            script.lua.set_function("addBuff", [this](Buff b, Unit * u){
                u->addBuff(new Buff(b));
                return;
            });

            loadLua(script); //comment this line for no reload on the fly, better performance

            try
            {
                script.lua.script("applyEffects()");
            }
            catch (sol::error e)
            {//lua error? don't crash the whole server
                CORE_ERROR("%s", e.what());
            }*/
        }
コード例 #6
0
ファイル: Spell.cs プロジェクト: horato/IntWarsSharp
        /**
         * Called when the spell is finished casting and we're supposed to do things
         * such as projectile spawning, etc.
         */
        public virtual void finishCasting()
        {
            doLua();

            state = SpellState.STATE_COOLDOWN;
            currentCooldown = getCooldown();

            var current = new Vector2(owner.getX(), owner.getY());
            var to = (new Vector2(x, y) - current);
            var trueCoords = current + (Vector2.Normalize(to) * 1150);

            var p = new Projectile(owner.getMap(), Game.GetNewNetID(), owner.getX(), owner.getY(), (int)lineWidth, owner, new Target(trueCoords.X, trueCoords.Y), this, projectileSpeed, (int)RAFHashManager.GetHash(spellName + "Missile"), projectileFlags > 0 ? (int)projectileFlags : flags);
            owner.getMap().addObject(p);
            PacketNotifier.notifyProjectileSpawn(p);
        }
コード例 #7
0
ファイル: PacketNotifier.cs プロジェクト: horato/IntWarsSharp
 public static void notifyShowProjectile(Projectile p)
 {
     var sp = new ShowProjectile(p);
     PacketHandlerManager.getInstace().broadcastPacket(sp, Channel.CHL_S2C);
 }
コード例 #8
0
ファイル: PacketNotifier.cs プロジェクト: horato/IntWarsSharp
 public static void notifyProjectileDestroy(Projectile p)
 {
     var dp = new SpawnParticle.DestroyProjectile(p);
     PacketHandlerManager.getInstace().broadcastPacket(dp, Channel.CHL_S2C);
 }