1again (01-17-2014),CrazyJani (01-19-2014),Dragonlord3344 (01-27-2014),Lunati (01-21-2014),TJRAE%TJAJAZetjtjtjjt (10-23-2014)
Hey everyone! I held on to this code for a while, until I realized there would be no point in doing so. The Spiral Attack behavior is a non-returning behavior that is basically ring attacks with incrementally growing offsets to look like a spiral. This code is especially designed to save space, so you won't fill up your behaviors with huge blocks of RingAttack.Instance(...).
Create a new file in wServer/logic/attack called "SpiralAttack.cs"
Paste the below code in:
Usage: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 InfiniteSpiralAttack : Behavior { int cooldown; int arms; float offsetIncrement; int projectileIndex; int incrementMultiplier = 0; private InfiniteSpiralAttack(int cooldown, int arms, float offsetIncrement, int projectileIndex) { this.cooldown = cooldown; this.arms = arms; this.offsetIncrement = offsetIncrement; this.projectileIndex = projectileIndex; } static readonly Dictionary<Tuple<int, int, float, int>, InfiniteSpiralAttack> instances = new Dictionary<Tuple<int, int, float, int>, InfiniteSpiralAttack>(); public static InfiniteSpiralAttack Instance(int cooldown, int arms, float offsetIncrement = 1, int projectileIndex = 0) { var key = new Tuple<int, int, float, int>(cooldown, arms, offsetIncrement, projectileIndex); InfiniteSpiralAttack ret; if (!instances.TryGetValue(key, out ret)) ret = instances[key] = new InfiniteSpiralAttack(cooldown, arms, offsetIncrement, projectileIndex); return ret; } Random rand = new Random(); protected override bool TickCore(RealmTime time) { Behavior behav = RingAttack.Instance(arms, 0, (offsetIncrement * (float)Math.PI / 180) * incrementMultiplier, projectileIndex); int remainingTick; object o; if (!Host.StateStorage.TryGetValue(Key, out o)) remainingTick = rand.Next(0, cooldown); else remainingTick = (int)o; remainingTick -= time.thisTickTimes; bool ret; if (remainingTick <= 0) { if (behav != null) behav.Tick(Host, time); if (behav != null) incrementMultiplier += 1; remainingTick = rand.Next((int)(cooldown * 0.95), (int)(cooldown * 1.05)); ret = true; } else ret = false; Host.StateStorage[Key] = remainingTick; return ret; } } }
COOLDOWN = Millisecond interval between each ring attack
ARMS = Number of projectiles fired at once
offsetIncrement = The size of the offset increment. For most spirals, this value would be from 5 to 20.
projectileIndex = ID of projectile used in the behavior
1again (01-17-2014),CrazyJani (01-19-2014),Dragonlord3344 (01-27-2014),Lunati (01-21-2014),TJRAE%TJAJAZetjtjtjjt (10-23-2014)
This would have been nice to use while making Forbidden Jungle behavior.. Oh well.. I don't code anymore.
So i guess it doesn't matter.
Nice release anyway.. @ProHackBot999
i'm actually just a horny boy
Im a complete noob could you pretty please make an example line showing how its used?
something like
Cooldown.Instance(1500, PredictiveMultiAttack.Instance(25, 10 * (float)Math.PI / 180, 4, 1, projectileIndex: 1)),
except with the spiral. I would be very happy if you did thanks
InfiniteSpiralAttack.Instance(1500, 4, 10, projectileIndex: 0)
The first variable is the cooldown, which means in this example the spiral will trigger a ring every 1500 ms.
The second variable is the arms, which is exactly the same as the number of shots in a RingAttack, where each shot will be equally spaced over 6~ radians.
The third variable is the offsetIncrement. Every time the spiral is triggered, it fires off a ring attack that is slightly offset from the last one. This is the number of circular degrees that the spiral offsets every trigger.
The fourth variable is the projectile Index, which takes data from the projectile XML.
I hope that's a good enough explanation!