SolvedRandomTransition

Posts 1–4 of 4 · Page 1 of 1
RandomTransition
I made a Random timed transition. When I spawn the enemy, it picks the same number every time like it was already picked when it was spawned and it would never re pick the number. How would I make it pick a different number every time? Btw the states are strings with an integer within the quotes.

 
RandomTimedTransistion.cs
Code:
#region

using wServer.realm;
using System;

#endregion

namespace wServer.logic.transitions
{
    public class RandomTimedTransition : Transition
    {
        //State storage: cooldown timer

        private readonly bool randomized;
        private readonly int time;

        public RandomTimedTransition(int time, int min, int max, bool randomized = false)
            : base(new Random().Next(min, max).ToString())
        {
            this.time = time;
            this.randomized = randomized;
        }

        protected override bool TickCore(Entity host, RealmTime time, ref object state)
        {
            int cool;
            if (state == null) cool = randomized ? Random.Next(this.time) : this.time;
            else cool = (int) state;

            bool ret = false;
            if (cool <= 0)
            {
                ret = true;
                cool = this.time;
            }
            else
                cool -= time.thisTickTimes;

            state = cool;
            return ret;
        }
    }
}
As far as I can see you only use the int time and not min / max value?
Quote Originally Posted by cxydsaewq View Post
As far as I can see you only use the int time and not min / max value?
The min max are the range of states. If i had 4 states with the string as a number i would put 1-4. The problem is that it decides when wServer initializes. I need it to produce a new number everytime its used.
Bump......
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us