PostTossEnemyAtPlayer Behavior

Posts 1–7 of 7 · Page 1 of 1
TossEnemyAtPlayer Behavior
I'm not quite sure why this wasn't added yet, but I need it for thessal's corral bombs, so I put it together quickly.

This behavior lets a monster toss an enemy at a player instead of only at the angle and distance specified.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using wServer.realm;
using wServer.realm.entities;
using wServer.svrPackets;

namespace wServer.logic.attack
{
    class TossEnemyAtPlayer : Behavior
    {
        float range;
        short objType;

        private TossEnemyAtPlayer(float range, short objType)
        {
            this.range = range;
            this.objType = objType;
        }
        
        static readonly Dictionary<Tuple<float, short>, TossEnemyAtPlayer> instances = new Dictionary<Tuple<float, short>, TossEnemyAtPlayer>();
        public static TossEnemyAtPlayer Instance(float range, short objType)
        {
            var key = new Tuple<float, short>(range, objType);
            TossEnemyAtPlayer ret;
            if (!instances.TryGetValue(key, out ret))
                ret = instances[key] = new TossEnemyAtPlayer(range, objType);
            return ret;
        }

        Random rand = new Random();
        protected override bool TickCore(RealmTime time)
        {
            float dist = range;
            Entity player = GetNearestEntity(ref dist, null);
            if (player != null)
            {
                var chr = Host as Character;
                Position target = new Position()
                {
                    X = player.X,
                    Y = player.Y
                };
                
                chr.Owner.BroadcastPacket(new ShowEffectPacket()
                {
                    EffectType = EffectType.Throw,
                    Color = new ARGB(0xffffbf00),
                    TargetId = Host.Self.Id,
                    PosA = target
                }, null);
                
                chr.Owner.Timers.Add(new WorldTimer(1500, (world, t) =>
                {
                    Entity entity = Entity.Resolve(objType);
                    entity.Move(target.X, target.Y);
                    (entity as Enemy).Terrain = (chr as Enemy).Terrain;
                    world.EnterWorld(entity);
                }));
            } return true;
        }
    }
}
To add this, open up your solution, and navigate to wserver > logic > Attack in the solution explorer.

Right click on the attack folder > add > new item

Name it TossEnemyAtPlayer.cs, then click add

Then, just replace the entire contents of your newly created TossEnemyAtPlayer.cs with the once I posted up there.

Usage:
Code:
TossEnemyAtPlayer.Instance(RANGE, MONSTERID)
For example:

Code:
TossEnemyAtPlayer.Instance(10, 0x1702)
If the player is within the specified range (first number) it will toss the enemy. Otherwise it will do nothing. The MONSTERID is the id of the monster you want it to toss.
Holey shet. Pure and plain holey shet.

The possibilities... Bandit Leaders tossing other Bandit Leaders that toss more Bandit Leader while throwing even more Bandit Leaders.
TREMBLE BEFORE MY NOOBISH ARMY.

No wait... Bandit Leaders don't toss anything... crap, my evil plan went apeshit.
Just one word... AWESOME
Finnaly i can complete my DrTerrible Script
do you have the Green Bottle Behavior? cause i need it to compete mine.
Quote Originally Posted by rangewolf5 View Post
do you have the Green Bottle Behavior? cause i need it to compete mine.
Just use this in combination with a ringattack, and despawn after a while?
Quote Originally Posted by Lunati View Post
Just use this in combination with a ringattack, and despawn after a while?
Code:
Cooldown.Instance(3000, Ringattack.Instance(6, 6, projectileindex:0),
Cooldown.Instance(3010, Die.Instance)
no references so don't copy+paste
Quote Originally Posted by C453 View Post
Code:
Cooldown.Instance(3000, Ringattack.Instance(6, 6, projectileindex:0),
Cooldown.Instance(3010, Die.Instance)
no references so don't copy+paste
omfg thank you so much. ily <3
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?