Author Topic: How to get script to work on multiple npcs?  (Read 328 times)

Legacy_Bubba McThudd

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +0/-0
How to get script to work on multiple npcs?
« on: April 15, 2011, 11:54:52 pm »


                Greetings all,

I can't remember how to do this;

I want this script -

void main(){
object oPC = GetPCSpeaker();
object oTarget;oTarget = GetObjectByTag("GArmyC");
AssignCommand(oTarget, ClearAllActions());
AssignCommand(oTarget, ActionMoveToObject(GetObjectByTag("WP_GArmyC_01")));
}
- to apply to all npcs with the tag "GArmyC"

Any help would be most appreciated!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #1 on: April 16, 2011, 12:19:11 am »


               void main()
{


int nCount;
object oTarget = GetObjectByTag("WP_GArmyC_01" ,nCount);
while (GetIsObjectValid(oTarget))
{
AssignCommand(oTarget, ClearAllActions());
AssignCommand(oTarget, ActionMoveToObject(GetObjectByTag( "WP_GArmyC_01" )));
nCount++;
oTarget = GetObjectByTag("GArmyC",nCount);
}

}
               
               

               


                     Modifié par Lightfoot8, 18 avril 2011 - 05:54 .
                     
                  


            

Legacy_Bubba McThudd

  • Sr. Member
  • ****
  • Posts: 254
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #2 on: April 16, 2011, 02:54:53 am »


               Thanks!
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #3 on: April 18, 2011, 03:31:24 am »


               

Lightfoot8 wrote...

void main()
{
    int nCount = 0;
    object oTarget;

    while (GetIsObjectValid(oTarget))
    {
       nCount++;
       oTarget = GetObjectByTag("GArmyC",nCount);
   AssignCommand(oTarget, ClearAllActions());
       AssignCommand(oTarget, ActionMoveToObject(GetObjectByTag("WP_GArmyC_01")));
    }

}


Fixed..  :innocent:
               
               

               


                     Modifié par _Guile, 18 avril 2011 - 02:32 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #4 on: April 18, 2011, 06:01:12 am »


               You broke the script _Guile. Your while loop will never fire.  oTarget will never be a valid object on the first check of the while loop.  Therefore it will never do anything.   You should think this stuff through before you try to fix something.
               
               

               
            

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #5 on: May 03, 2011, 12:30:37 am »


               Hi, is this occuring after the PC has had a conversation with something, exactly where is this script being placed?
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #6 on: May 03, 2011, 12:42:52 am »


               It would be fired from the action taken when that line of the conversation is spoken.
The other place to use scripts in conversations is as starting conditionals, or the two choices at the end of the conversation which are, ends normal, or broken off. For instance for those last two the standard end of conversation calls walkwaypoints script so the npc will return to their nearest wp or walk waypoints if they have more than one. But here you have the option to add in some extra spice if a PC breaks off a conversation, and have the npc say or do something, after all there are those annoying pop-up tips which tell you that some npc's will be angered at this.
Probably too much information you are not really asking about, but just thought I would throw that in. It was a slow day in the salt mine.

Actually this looks as it would be placed at the end of the conversation, but instead of just having that single npc speaker return to their walkwaypoint, which could be achieved be simply using the default script and having the npc assigned waypoints, he wants all the nearby npc's with similar Tags,  to do the same thing, thus the customisation.
At least I think that was the point. 
               
               

               


                     Modifié par ffbj, 02 mai 2011 - 11:48 .
                     
                  


            

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #7 on: May 04, 2011, 04:21:04 pm »


               It's been awhile, yes I remember those options in conversation setup now....thanks.
               
               

               
            

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
How to get script to work on multiple npcs?
« Reply #8 on: May 04, 2011, 04:32:30 pm »


               It's been awhile, yes I remember those options in conversation setup now....thanks.