Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Lab Assistant
Original Poster
#1 Old 10th Nov 2014 at 5:21 PM Last edited by ArtUrlWWW : 11th Nov 2014 at 7:05 PM.
Default [SOLVED] How to make animation for many sims?
Hi.
How to make animation for many sims - count of the sims unknown (may be from 1 to 10 sims) at all moment and they are must do one animation?
As I know, there are two options - play animation with code, for one sims at time:
Code:
StateMachineClient stateMachineClient = StateMachineClient.Acquire(this.Actor, "single_animation");
            stateMachineClient.SetActor("x", this.Target);
            stateMachineClient.EnterState("x", "Enter");
            stateMachineClient.SetParameter("AnimationClip", "a_han_2");
            stateMachineClient.RequestState("x", "Animate");

In this way only one sim will play animation, but not all at once will play.
Or, in other way - may use JAZZ, for example, for 2 sims. How to make JAZZ for unknown count of the sims - I don't know.
Any idea how to implement it?
Advertisement
Lab Assistant
Original Poster
#2 Old 10th Nov 2014 at 8:21 PM
Found solution:
Code:
stateMachineClient.RequestState(false, "x", "Animate");
Inventor
#3 Old 11th Nov 2014 at 8:32 AM
This seems like an interesting topic to me, but I'm not sure if I get your question.
You want an unknown number of sims to play the same animation at the same time?
Is it a iteration problem (maybe you can use a list) or a synchronization problem?

Setting "yield" to false helps you solve what exactly?
I have to admit I'm not completely sure how yield works,
even looking at the code: does it decide between wait for a possible
current animation to finish (true) and interrupt it to play the new one (false)?
Lab Assistant
Original Poster
#4 Old 11th Nov 2014 at 7:03 PM
Hi.
You want an unknown number of sims to play the same animation at the same time?
Yep. For example - 5 men sims must do same anim at same time.
Setting "yield" to false helps you solve what exactly?
Yep.
I didn't look code of the libs deeply, but it looks, like
Code:
  stateMachineClient.RequestState("x", "Animate");

is the analog of the
Code:
stateMachineClient.RequestState(true, "x", "Animate");

When I changed yield to false, it solved my problem.
yield = true looks like "wait until current animation will be ended and stop execution of the mod's code"
and
yield = false looks like "don't wait until current animation will be ended, play animation now and execute code of the mod".
For example:
Code:
household = Target.Household;
            if (household != null)
            {
                sims = household.Sims;
                foreach (Sim member in sims)
                {
                    float positionRnd = 0.7f;

                    float lastRnd = 0.5f;

                    for (int x = 0; x <= 300; x++)
                    {
                        // Random randObj1 = new Random();  
                        // randObj1.NextDouble
                        //Convert.( randObj1.Next(200)/100;   
                        positionRnd = GetRandomNumber(lastRnd+0.5f, lastRnd+1f);
                    }
                    lastRnd = positionRnd;

                    member.RemoveAllInteractions();
                    member.Autonomy.mAutonomyDisabledCount = int.MaxValue / 2;

                    member.SetPosition(Actor.Position + Actor.ForwardVector * positionRnd);

                    StateMachineClient stateMachineClient = StateMachineClient.Acquire(this.Actor, "single_animation");
              
                    stateMachineClient.SetActor("x", member);
                    stateMachineClient.EnterState("x", "Enter");
                    stateMachineClient.SetParameter("AnimationClip", "a_my_anim");
                    stateMachineClient.RequestState(false, "x", "Animate");


                    this.Actor.ShowTNSIfSelectable("!!! " + " " + positionRnd + " " + member.Name + " !!!", StyledNotification.NotificationStyle.kSimTalking);
                }
            }


When false, then foreach cycle will be wait for the end of the anim and ShowTNSIfSelectable message will show only after anim will ends. It's very dirty code, from my experiments module.
I mentally rest from work by programming in Sims.
Further experiments I have not moved. I learn one or other functional and move on to the next. I love it when my brain is constantly engaged in programming.
Inventor
#5 Old 11th Nov 2014 at 7:26 PM
I like this guy!

Look, without a proper context I didn't really get what your code is meant to do,
but that iteration looks very bad:
Code:
for (int x = 0; x <= 300; x++)
{
      // Random randObj1 = new Random();  
      // randObj1.NextDouble
      //Convert.( randObj1.Next(200)/100;   
      positionRnd = GetRandomNumber(lastRnd+0.5f, lastRnd+1f);
}

That's useless, remove the "for" and leave only "positionRnd = ..."
Lab Assistant
Original Poster
#6 Old 11th Nov 2014 at 8:30 PM
Did you have Skype? My Skype is ArtUrlWWW1 .
No, it's not mistake, it's my paranoic feature .
For cycle is for More unique generated value.
It's too many chance to get similar value at the second call of the Random and in cycle change to get similar value is lowest.
It not necessary to do, it's just my paranoid caprice.
Lab Assistant
Original Poster
#7 Old 11th Nov 2014 at 8:36 PM
Wow!
I was not wrong in my assumption!
Look, it's really
Code:
 stateMachineClient.RequestState("x", "Animate");

is wrapper for the
Code:
stateMachineClient.RequestState(true, "x", "Animate");

))))

Code:
namespace Sims3.SimIFace
{
	[Persistable]
	public sealed class StateMachineClient : IDisposable, IPersistPostLoad
	
****************	
	
private static readonly bool DefaultYield = true;

***************

public void RequestState(string actorName, string stateName)
		{
			this.RequestState(StateMachineClient.DefaultYield, actorName, stateName, StateMachineClient.DefaultRequestFlags, StateMachineClient.DefaultTimeout, StateMachineClient.DefaultBridgeClient, StateMachineClient.DefaultBridgeActorName, StateMachineClient.DefaultBridgeOrigin);
		}



)))))))))))))))))))))))
Inventor
#8 Old 12th Nov 2014 at 8:02 AM
Thanks for the explanation about yield.

Quote: Originally posted by ArtUrlWWW
For cycle is for More unique generated value.
It's too many chance to get similar value at the second call of the Random and in cycle change to get similar value is lowest.


I disagree but I'm not gonna argue, do as you like.

But now I'm wondering: does the pseudo random number generator of the game
use a fixed seed to generate numbers? Do we have to "initialize" the seed before
calling the generator to avoid getting always the same sequence of numbers?
My head can explode if I try to answer this myself, help me!
Lab Assistant
Original Poster
#9 Old 12th Nov 2014 at 4:45 PM
What is "does the pseudo random number generator of the game" ?
Please provide example of the code.
I disagree but I'm not gonna argue, do as you like.
Good position. I know, what it is incorrect. I rest. It is a pleasure to write the code the way I want to. This is my whim.
Inventor
#10 Old 12th Nov 2014 at 5:13 PM
I was wondering if, before calling one of the many methods that generate a random number
(for example RandomUtil.getInt(4)), you have to initialize the random number generator
(RNG) to get a new seed, something like what you did in your example HERE:
Code:
Random random = new Random();
double input = random.NextDouble() * (maximum - minimum) + minimum;

It's probably a silly question and I'm assuming that the game uses a seed to generate a
sequence of pseudo random numbers, but sometimes I'm paranoid too ^^

Sorry for hijacking your thread, this is Off Topic here.
Back to top