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)); }