This is completely made by @pLolz I'm just posting it.
Just a simple little code to run a behavior with a random chance.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using wServer.cliPackets;
using wServer.svrPackets;
using wServer.realm.setpieces;
using db;
using wServer.realm;
using wServer.realm.entities;
using wServer.logic;
namespace wServer.logic
{
public class RandomDo : Behavior
{
int percent;
Behavior result;
public RandomDo(int percent, Behavior result)
{
this.result = result;
this.percent = percent;
}
protected override bool TickCore(RealmTime time)
{
var enemy = Host as Enemy;
if (new Random().Next(1, 100) <= percent)
return result.Tick(Host, time);
return false;
}
}
}
Add it to wServer>Logic
Usage: new RandomDo(Chance, Behavior)
For Example: new RandomDo(10, new Setkey (-1, 1))