Aller au contenu

Photo

Assigning an action to multiple objects


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
Ed Venture

Ed Venture
  • Members
  • 102 messages

Hello,

Is it possible to assign commands to more than one object at a time ?

object oNPCa

object oNPCb

AssignCommand(oNPCa and oNPCb, ActionSpeakString(sString,nVolume));

 

Ed



#2
Shadooow

Shadooow
  • Members
  • 4 471 messages

Hello,

Is it possible to assign commands to more than one object at a time ?

object oNPCa

object oNPCb

AssignCommand(oNPCa and oNPCb, ActionSpeakString(sString,nVolume));

 

Ed

AssignCommand(oNPCa, ActionSpeakString(sString,nVolume));

AssignCommand(oNPCb, ActionSpeakString(sString,nVolume));


  • WhiteTiger aime ceci

#3
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

void doStuff(object oNPC)

{

AssignCommand(oNPC, ClearAllActions());

}

 

void main()

{

object oNPCa;

object oNPCb;

 

doStuff(oNPCa);

doStuff(oNPCb);

}


Modifié par WhiteTiger, 01 août 2014 - 10:04 .


#4
Proleric

Proleric
  • Members
  • 2 361 messages
For most practical purposes, yes.

Strictly speaking, the actions aren't exactly simultaneous, but they generally appear synchronised, provided the AI levels are identical and the action queues are cleared first.

For very precise synchronisation, such as troops marching in formation, it pays to disable all unnecessary AI and build in time or scripting for laggards to catch up.

#5
WhiZard

WhiZard
  • Members
  • 1 204 messages

No point in clearing the action queue for speaking strings.  If you want to have higher priority than the actions use SpeakString(), if you wish for the actions to resolve themselves, use ActionSpeakString().



#6
Ed Venture

Ed Venture
  • Members
  • 102 messages

Okay,

I want to apologize to you all. I was trying to be brief( Up early trying to get some work done before rushing to work).

I'll abreviate where I can.

Here is the set up. I placed 4 NPCs in an area. A trigger spawns 24 more NPCs. The 24 are divided into 3 factions(groups).

When the 24 are spawned, they are assigned 24 new tags. The script is set on HB of a placeable. It uses Set and GetLocalInt to controll the pace of actions in the area I know that before it's finished it's going to get big.

 

This is the chopped down version that I have so far.

 

object oPC

object oArea Tag

objects Tags of the placed NPCs

object Placeable OBJECT_SELF

if(GetArea(oPC) == oArea)//List of Variables only if PC is in Area &
 {
  if(GetIsNight())// if it is night.
  {

   24 objects Tags

   Various ints, strings,ect

// BEGIN SCRIPT//
   if(GetLocalInt(oCase,"Brawl") == 4)
   {
    AssignCommand(oShA,ActionSpeakString("When Her Boyfriend's Gone Away!",nVolS));
    SetLocalInt(oCase,"Brawl",5);
   }
   else
   {
   if(GetLocalInt(oCase,"Brawl") == 3)
   {
    AssignCommand(oShA,ActionSpeakString("3rd line?",nVolS));
    SetLocalInt(oCase,"Brawl",4);
   }
   else
   {
   if(GetLocalInt(oCase,"Brawl") == 2)
   {
    AssignCommand(oShA,ActionSpeakString("2nd line",nVolS));
    SetLocalInt(oCase,"Brawl",3);
   }
   else
   {
   if(GetLocalInt(oCase,"Brawl") == 1)
   {

    AssignCommand(oShA,ActionSpeakString("1st line of dirty song!",nVolS));
    SetLocalInt(oCase,"Brawl",2);
   }
   else
   {
    SetLocalInt(oCase,"Brawl",1);
   } // int 1
   } // int 2
   } // int 3
   } // int 4
  } //IsNight
 } //oArea
}

 

This is the first verse of the song(2 more to go). As it is currently writen, the first NPC sings all 4 lines and then starts from the beginning.

 What I am trying to do is to have some of the group of 8 singing, some drinking, some laughing and so on. The same for the other 16. It is eventualy going to turn into a barroom brawl.

 

And here is where being a noob sucks. I am not such a noob that I didn't know I could assign the commands individualy, but I am enough of a noob to scratch my head and look confused when I read White Tiger's post. From what I've read on the lexicon, it's called a wrapper function ? Don't get it.

 

So,if any of you could give me some help(small words and an ocassional slap on the back of the head), I would be most grateful.

 

Ed.



#7
Proleric

Proleric
  • Members
  • 2 361 messages
Code you want to use more than once (for different actors, say) can be packaged in a function.
 
The most efficient way to run a set of actions is to AssignCommand to a function:
void doStuff()
  {
    ActionSpeakString("Line 1",nVolS));
    ActionWait(5);
    ActionSpeakString("Line 2",nVolS));
    // ... and so on
  }
 
void main()
  {
    AssignCommand(oNPC1, doStuff());
    AssignCommand(oNPC2, doStuff());
  }
To vary which set of actions each actor is doing, you might choose their action using random().
 
The laughing / drinking action sets will need to run for the same overall time as the song (though a tavern obviously doesn't require military precision!)
 
If there is too much floating text, you might consider having just one or two speakers, with all the singers animated, so they seem to be singing in time.
 
I don't think I can be more specific without knowing your intentions in even more detail!
  • Ed Venture et WhiteTiger aiment ceci

#8
Ed Venture

Ed Venture
  • Members
  • 102 messages
Proleric,
Thank you. Your example made things much clearer to me. Seems to be working. Thanks again.
Ed
  • Proleric aime ceci