[FSOD] Grenade Fix

Posts 1–10 of 10 · Page 1 of 1
[FSOD] Grenade Fix
replace Grenade.cs with this
Code:
#region

using System;
using wServer.networking.svrPackets;
using wServer.realm;
using wServer.realm.entities;
using wServer.realm.entities.player;

#endregion

namespace wServer.logic.behaviors
{
    public class Grenade : Behavior
    {
        //State storage: cooldown timer

        private readonly int damage;
        private readonly float radius;
        private readonly double range;
        private Cooldown coolDown;
        private double? fixedAngle;

        public Grenade(double radius, int damage, double range = 5,
            double? fixedAngle = null, Cooldown coolDown = new Cooldown())
        {
            this.radius = (float) radius;
            this.damage = damage;
            this.range = range;
            this.fixedAngle = fixedAngle*Math.PI/180;
            this.coolDown = coolDown.Normalize();
        }

        protected override void OnStateEntry(Entity host, RealmTime time, ref object state)
        {
            state = 0;
        }

        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            int cool = (int) state;

            if (cool <= 0)
            {
                if (host.HasConditionEffect(ConditionEffectIndex.Stunned)) return;

                Entity player = host.GetNearestEntity(range, null);
                if (player != null || fixedAngle != null)
                {
                    Position target;
                    if (fixedAngle != null)
                        target = new Position
                        {
                            X = host.X + (float)(range * Math.Cos(fixedAngle.Value)),
                            Y = host.Y + (float)(range * Math.Sin(fixedAngle.Value)),
                        };
                    else
                        target = new Position
                        {
                            X = player.X,
                            Y = player.Y,
                        };
                    host.Owner.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Throw,
                        Color = new ARGB(0xffff0000),
                        TargetId = host.Id,
                        PosA = target
                    }, null);
                    host.Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
                    {
                        world.BroadcastPacket(new AOEPacket
                        {
                            Position = target,
                            Radius = radius,
                            Damage = (ushort) damage,
                            EffectDuration = 0,
                            Effects = 0,
                            OriginType = (short)host.ObjectType
                        }, null);
                        world.Aoe(target, radius, true, p => { (p as IPlayer).Damage(damage, host as Character); });
                    }));
                }
                cool = coolDown.Next(Random);
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
        }
    }
}
Simple Fix by Me
Quote Originally Posted by Wojtasowy1234 View Post
this work for SD?
this say FSOD in title?
meaning no, it won't work, you can try but i highly doubt
it might work but might have to make a bit of changes, as i have never fooled around with SD i do not know but i know there is a dif.
Probably will work on SD considering how small the change is
What was wrong with them if you dont mind me asking?
Quote Originally Posted by NigrKiller View Post
What was wrong with them if you dont mind me asking?
I believe adding a fixed angle made them buggy
Can i add you on skype?
I have some problems with setting up your server..
Skype: Samuepop
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us