Exemplo n.º 1
0
        public void Tick(VMAvatar avatar)
        {
            Ticked = true;
            if (PerHourChange != 0)
            {
                double rate = (PerHourChange / 60.0) / (30.0 * 5.0); //timed for 5 second minutes
                fractional += rate;
                if (Math.Abs(fractional) >= 1)
                {
                    var motive = avatar.GetMotiveData(Motive);
                    if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue)))
                    {
                        return;
                    }                                                                                           //we're already over, do nothing. (do NOT clamp)
                    motive     += (short)(fractional);
                    fractional %= 1.0;

                    if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue)))
                    {
                        motive = MaxValue;
                    }
                    //DO NOT CLEAR MOTIVE WHEN IT HITS MAX VALUE! fixes pet, maybe shower.
                    avatar.SetMotiveData(Motive, motive);
                }
            }
        }
Exemplo n.º 2
0
        public void Tick(VMAvatar avatar)
        {
            if (PerHourChange != 0)
            {
                double rate = (PerHourChange/60.0)/30.0;     //remember to fix when we implement the clock! right now assumes time for an hour is a realtime minute
                fractional += rate;
                if (Math.Abs(fractional) >= 1)
                {
                    var motive = avatar.GetMotiveData(Motive);
                    motive += (short)(fractional);
                    fractional %= 1.0;

                    if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue))) { motive = MaxValue; Clear(); }
                    avatar.SetMotiveData(Motive, motive);
                }
            }
        }
Exemplo n.º 3
0
        public void Tick(VMAvatar avatar)
        {
            if (PerHourChange != 0)
            {
                double rate = (PerHourChange / 60.0) / 30.0;     //remember to fix when we implement the clock! right now assumes time for an hour is a realtime minute
                fractional += rate;
                if (Math.Abs(fractional) >= 1)
                {
                    var motive = avatar.GetMotiveData(Motive);
                    motive     += (short)(fractional);
                    fractional %= 1.0;

                    if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue)))
                    {
                        motive = MaxValue; Clear();
                    }
                    avatar.SetMotiveData(Motive, motive);
                }
            }
        }
Exemplo n.º 4
0
        public void Tick(VMAvatar avatar)
        {
            Ticked = true;
            if (PerHourChange != 0)
            {
                double rate = (PerHourChange/60.0)/(30.0*5.0); //timed for 5 second minutes
                fractional += rate;
                if (Math.Abs(fractional) >= 1)
                {
                    var motive = avatar.GetMotiveData(Motive);
                    if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue))) { return; } //we're already over, do nothing. (do NOT clamp)
                    motive += (short)(fractional);
                    fractional %= 1.0;

                    if (((rate > 0) && (motive > MaxValue)) || ((rate < 0) && (motive < MaxValue))) { motive = MaxValue; }
                    //DO NOT CLEAR MOTIVE WHEN IT HITS MAX VALUE! fixes pet, maybe shower.
                    avatar.SetMotiveData(Motive, motive);
                }
            }
        }
Exemplo n.º 5
0
        public void Apply(VMAvatar avatar)
        {
            avatar.SkinTone = (AppearanceType)SkinTone;
            for (int i = 0; i < PersonDataMap.Length; i++)
            {
                avatar.SetPersonData((VMPersonDataVariable)PersonDataMap[i], PersonData[i]);
            }
            avatar.SetPersonData(VMPersonDataVariable.SkinColor, SkinTone);
            avatar.DefaultSuits = DefaultSuits;
            avatar.BodyOutfit   = new VMOutfitReference(BodyOutfit);
            avatar.HeadOutfit   = new VMOutfitReference(HeadOutfit);
            avatar.Name         = Name;
            ((VMTSOAvatarState)avatar.TSOState).Permissions = Permissions;
            ((VMTSOAvatarState)avatar.TSOState).Flags       = AvatarFlags;
            avatar.TSOState.Budget.Value = Budget;

            avatar.PersistID = PersistID;

            for (int i = 0; i < MotiveData.Length; i++)
            {
                avatar.SetMotiveData((VMMotive)i, MotiveData[i]);
            }
            avatar.MeToPersist = new Dictionary <uint, List <short> >();
            foreach (var obj in Relationships)
            {
                avatar.MeToPersist[obj.Target] = new List <short>(obj.Values);
            }

            ((VMTSOAvatarState)avatar.TSOState).JobInfo = OnlineJobInfo;
            if (IsWorker)
            {
                avatar.SetPersonData(VMPersonDataVariable.OnlineJobStatusFlags, 1); //validated immediately.
            }
            avatar.SkillLocks = SkillLock;
            ((VMTSOAvatarState)avatar.TSOState).IgnoredAvatars = IgnoredAvatars;
        }
Exemplo n.º 6
0
        public void Tick(VMAvatar avatar, VMContext context)
        {
            var roomScore = context.GetRoomScore(context.GetRoomAt(avatar.Position));

            avatar.SetMotiveData(VMMotive.Room, roomScore);
            if (context.Clock.Minutes == LastMinute)
            {
                return;
            }
            if (avatar.GetPersonData(VMPersonDataVariable.Cheats) > 0)
            {
                return;
            }
            LastMinute = context.Clock.Minutes;

            UpdateCategory(context);
            int sleepState = (avatar.GetMotiveData(VMMotive.SleepState) == 0)?1:0;

            int moodSum = 0;

            for (int i = 0; i < 7; i++)
            {
                int lotMul   = LotMuls[i];
                int frac     = 0;
                var motive   = avatar.GetMotiveData(DecrementMotives[i]);
                var r_Hunger = FracMul(FlatSimMotives[0] * (100 + avatar.GetMotiveData(VMMotive.Hunger)), LotMuls[0]);
                switch (i)
                {
                case 0:
                    frac = r_Hunger; break;

                case 1:
                    frac = FracMul(FlatSimMotives[1], lotMul); break;

                case 2:
                    frac = FracMul(FlatSimMotives[2 + sleepState], lotMul); break;

                case 3:
                    frac = FracMul(FlatSimMotives[4 + sleepState], lotMul) + FracMul(r_Hunger, FlatSimMotives[6]); break;

                case 4:
                    frac = (FlatSimMotives[7] / (60 * FlatSimMotives[8]));
                    // TODO: wrong but appears to be close? need one which uses energy weight, which is about 2.4 on skills
                    break;

                case 5:
                    frac = (sleepState == 0) ? 0 : FracMul(FlatSimMotives[9], lotMul);
                    break;

                case 6:
                    frac = FlatSimMotives[10] +
                           FracMul((FlatSimMotives[11] * (100 + motive)), lotMul);
                    frac /= 2;     //make this less harsh right now, til I can work out how multiplayer bonus is meant to work
                    break;
                }

                MotiveFractions[i] += (short)frac;
                if (MotiveFractions[i] >= 1000)
                {
                    motive             -= (short)(MotiveFractions[i] / 1000);
                    MotiveFractions[i] %= 1000;
                    if (motive < -100)
                    {
                        motive = -100;
                    }
                    avatar.SetMotiveData(DecrementMotives[i], motive);
                }
                moodSum += motive;
            }
            moodSum += roomScore;

            avatar.SetMotiveData(VMMotive.Mood, (short)(moodSum / 8));
        }
Exemplo n.º 7
0
        public void Tick(VMAvatar avatar, VMContext context)
        {
            if (context.Clock.Minutes == LastMinute)
            {
                return;
            }
            LastMinute = context.Clock.Minutes;

            string category   = "Skills";
            string sleepState = (avatar.GetMotiveData(VMMotive.SleepState) == 0)?"Awake":"Asleep";

            int moodSum = 0;

            for (int i = 0; i < 7; i++)
            {
                if (avatar.IsPet && i == 5)
                {
                    return;
                }
                float lotMul   = LotMotives.GetNum(category + "_" + LotMotiveNames[i] + "Weight");
                float frac     = 0;
                var   motive   = avatar.GetMotiveData(DecrementMotives[i]);
                var   r_Hunger = (SimMotives.GetNum("HungerDecrementRatio") * (100 + avatar.GetMotiveData(VMMotive.Hunger))) * LotMotives.GetNum(category + "_HungerWeight");
                switch (i)
                {
                case 0:
                    frac = r_Hunger; break;

                case 1:
                    frac = (SimMotives.GetNum("ComfortDecrementActive") * lotMul); break;

                case 2:
                    frac = (SimMotives.GetNum("HygieneDecrement" + sleepState) * lotMul); break;

                case 3:
                    frac = (SimMotives.GetNum("BladderDecrement" + sleepState) * lotMul) + (SimMotives.GetNum("HungerToBladderMultiplier") * r_Hunger); break;

                case 4:
                    frac = (SimMotives.GetNum("EnergySpan") / (60 * SimMotives.GetNum("WakeHours")));
                    // TODO: wrong but appears to be close? need one which uses energy weight, which is about 2.4 on skills
                    break;

                case 5:
                    frac = (sleepState == "Asleep") ? 0 : (SimMotives.GetNum("EntDecrementAwake") * lotMul);
                    break;

                case 6:
                    frac  = (SimMotives.GetNum("SocialDecrementBase") + (SimMotives.GetNum("SocialDecrementMultiplier") * (100 + motive))) * lotMul;
                    frac /= 2;     //make this less harsh right now, til I can work out how multiplayer bonus is meant to work
                    break;
                }

                MotiveFractions[i] += (short)(frac * 1000);
                if (MotiveFractions[i] >= 1000)
                {
                    motive             -= (short)(MotiveFractions[i] / 1000);
                    MotiveFractions[i] %= 1000;
                    if (motive < -100)
                    {
                        motive = -100;
                    }
                    avatar.SetMotiveData(DecrementMotives[i], motive);
                }
                moodSum += motive;
            }
            avatar.SetMotiveData(VMMotive.Mood, (short)(moodSum / 7));
        }
Exemplo n.º 8
0
        public void Tick(VMAvatar avatar, VMContext context)
        {
            var roomScore = context.GetRoomScore(context.GetRoomAt(avatar.Position));

            avatar.SetMotiveData(VMMotive.Room, roomScore);
            if (context.Clock.Minutes / 2 == LastMinute)
            {
                return;
            }
            LastMinute = context.Clock.Minutes / 2;
            var sleeping = (avatar.GetMotiveData(VMMotive.SleepState) != 0);

            int moodSum = 0;

            for (int i = 0; i < 7; i++)
            {
                int frac = 0;
                var dm   = DecrementMotives[i];
                if (avatar.HasMotiveChange(dm) && dm != VMMotive.Energy)
                {
                    continue;
                }
                var motive   = avatar.GetMotiveData(dm);
                var r_Hunger = ToFixed1000(Constants[5]) * (100 + avatar.GetMotiveData(VMMotive.Hunger));
                switch (i)
                {
                case 0:
                    frac = r_Hunger; break;

                case 1:
                    var active = avatar.GetPersonData(VMPersonDataVariable.ActivePersonality);
                    if (active > 666)
                    {
                        frac = ToFixed1000(Constants[14]);
                    }
                    else if (active < 666)
                    {
                        frac = ToFixed1000(Constants[15]);
                    }
                    else
                    {
                        frac = ToFixed1000(Constants[16]);
                    }
                    break;

                case 2:
                    frac = ToFixed1000(Constants[sleeping ? 11 : 10]); break;

                case 3:
                    frac = ToFixed1000(Constants[sleeping ? 13 : 12]) + FracMul(r_Hunger, ToFixed1000(Constants[4])); break;

                case 4:
                    if (sleeping)
                    {
                        frac = (context.Clock.Hours >= Constants[2]) ? ToFixed1000(Constants[3]) : 0;
                    }
                    else
                    {
                        frac = (ToFixed1000(Constants[0]) / (30 * (int)Constants[1]));
                    }
                    //energy span over wake hours. small energy drift applied if asleep during the day.
                    break;

                case 5:
                    frac = (sleeping)?0:ToFixed1000(Constants[8]);
                    break;

                case 6:
                    frac = ToFixed1000(Constants[6]) +
                           ToFixed1000(Constants[7]) * avatar.GetPersonData(VMPersonDataVariable.OutgoingPersonality);
                    break;
                }

                MotiveFractions[i] += (short)frac;
                if (MotiveFractions[i] >= 1000)
                {
                    motive             -= (short)(MotiveFractions[i] / 1000);
                    MotiveFractions[i] %= 1000;
                    if (motive < -100)
                    {
                        motive = -100;
                    }
                    avatar.SetMotiveData(DecrementMotives[i], motive);
                }
                moodSum += motive;
            }
            moodSum += roomScore;

            avatar.SetMotiveData(VMMotive.Mood, (short)(moodSum / 8));
        }
Exemplo n.º 9
0
        public void Tick(VMAvatar avatar, VMContext context)
        {
            if (context.Clock.Minutes == LastMinute) return;
            LastMinute = context.Clock.Minutes;

            string category = "Skills";
            string sleepState = (avatar.GetMotiveData(VMMotive.SleepState) == 0)?"Awake":"Asleep";

            int moodSum = 0;

            for (int i = 0; i < 7; i++) {
                if (avatar.IsPet && i == 5) return;
                float lotMul = LotMotives.GetNum(category + "_" + LotMotiveNames[i] + "Weight");
                float frac = 0;
                var motive = avatar.GetMotiveData(DecrementMotives[i]);
                var r_Hunger = (SimMotives.GetNum("HungerDecrementRatio") * (100+avatar.GetMotiveData(VMMotive.Hunger))) * LotMotives.GetNum(category+"_HungerWeight");
                switch (i)
                {
                    case 0:
                        frac = r_Hunger; break;
                    case 1:
                        frac = (SimMotives.GetNum("ComfortDecrementActive") * lotMul); break;
                    case 2:
                        frac = (SimMotives.GetNum("HygieneDecrement" + sleepState) * lotMul); break;
                    case 3:
                        frac = (SimMotives.GetNum("BladderDecrement" + sleepState) * lotMul) + (SimMotives.GetNum("HungerToBladderMultiplier") * r_Hunger); break;
                    case 4:
                        frac = (SimMotives.GetNum("EnergySpan") / (60 * SimMotives.GetNum("WakeHours")));
                        // TODO: wrong but appears to be close? need one which uses energy weight, which is about 2.4 on skills
                        break;
                    case 5:
                        frac = (sleepState == "Asleep") ? 0 : (SimMotives.GetNum("EntDecrementAwake") * lotMul);
                        break;
                    case 6:
                        frac = (SimMotives.GetNum("SocialDecrementBase") + (SimMotives.GetNum("SocialDecrementMultiplier") * (100+motive))) * lotMul;
                        frac /= 2; //make this less harsh right now, til I can work out how multiplayer bonus is meant to work
                        break;
                }

                MotiveFractions[i] += (short)(frac * 1000);
                if (MotiveFractions[i] >= 1000)
                {
                    motive -= (short)(MotiveFractions[i] / 1000);
                    MotiveFractions[i] %= 1000;
                    if (motive < -100) motive = -100;
                    avatar.SetMotiveData(DecrementMotives[i], motive);
                }
                moodSum += motive;
            }
            avatar.SetMotiveData(VMMotive.Mood, (short)(moodSum / 7));
        }
Exemplo n.º 10
0
        public void Tick(VMAvatar avatar, VMContext context)
        {
            var roomScore = context.GetRoomScore(context.GetRoomAt(avatar.Position));

            avatar.SetMotiveData(VMMotive.Room, roomScore);
            if (context.Clock.Minutes == LastMinute)
            {
                return;
            }
            LastMinute = context.Clock.Minutes;

            string category   = CategoryNames[context.VM.TSOState.PropertyCategory];
            string sleepState = (avatar.GetMotiveData(VMMotive.SleepState) == 0)?"Awake":"Asleep";

            int moodSum = 0;

            for (int i = 0; i < 7; i++)
            {
                int lotMul   = ToFixed1000(LotMotives.GetNum(category + "_" + LotMotiveNames[i] + "Weight"));
                int frac     = 0;
                var motive   = avatar.GetMotiveData(DecrementMotives[i]);
                var r_Hunger = FracMul(ToFixed1000(SimMotives.GetNum("HungerDecrementRatio")) * (100 + avatar.GetMotiveData(VMMotive.Hunger)), ToFixed1000(LotMotives.GetNum(category + "_HungerWeight")));
                switch (i)
                {
                case 0:
                    frac = r_Hunger; break;

                case 1:
                    frac = FracMul(ToFixed1000(SimMotives.GetNum("ComfortDecrementActive")), lotMul); break;

                case 2:
                    frac = FracMul(ToFixed1000(SimMotives.GetNum("HygieneDecrement" + sleepState)), lotMul); break;

                case 3:
                    frac = FracMul(ToFixed1000(SimMotives.GetNum("BladderDecrement" + sleepState)), lotMul) + FracMul(r_Hunger, ToFixed1000(SimMotives.GetNum("HungerToBladderMultiplier"))); break;

                case 4:
                    frac = (ToFixed1000(SimMotives.GetNum("EnergySpan")) / (60 * (int)SimMotives.GetNum("WakeHours")));
                    // TODO: wrong but appears to be close? need one which uses energy weight, which is about 2.4 on skills
                    break;

                case 5:
                    frac = (sleepState == "Asleep") ? 0 : FracMul(ToFixed1000(SimMotives.GetNum("EntDecrementAwake")), lotMul);
                    break;

                case 6:
                    frac = ToFixed1000(SimMotives.GetNum("SocialDecrementBase")) +
                           FracMul((ToFixed1000(SimMotives.GetNum("SocialDecrementMultiplier")) * (100 + motive)), lotMul);
                    frac /= 2;     //make this less harsh right now, til I can work out how multiplayer bonus is meant to work
                    break;
                }

                MotiveFractions[i] += (short)frac;
                if (MotiveFractions[i] >= 1000)
                {
                    motive             -= (short)(MotiveFractions[i] / 1000);
                    MotiveFractions[i] %= 1000;
                    if (motive < -100)
                    {
                        motive = -100;
                    }
                    avatar.SetMotiveData(DecrementMotives[i], motive);
                }
                moodSum += motive;
            }
            moodSum += roomScore;

            avatar.SetMotiveData(VMMotive.Mood, (short)(moodSum / 8));
        }