Author Topic: Door Guard script help?  (Read 380 times)

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Door Guard script help?
« on: November 08, 2011, 09:59:16 pm »


                Here is my gate guard script that worked great.Then somewhere down the line between spawining all the NPC and the mod growing this script fires if and when it wants to.

Why is it doing that and is there a btter way to script this?
I have this in  fail to open 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void main()

object oPC = GetClickingObject();

if (!GetIsPC(oPC)) return;

object oTarget1;

oTarget1 = GetObjectByTag("");

AssignCommand(oTarget1,ActionSpeakString(""));

object oTarget;

oTarget = GetObjectByTag("stonewallguard");

AssignCommand(oTarget,ActionSpeakString("*Peek's out of his helmet at you then moves to open the gate*"));

 object oDoor = GetObjectByTag("stonewallgate"); 

DelayCommand(4.5,SetLocked(oDoor,FALSE));

 DelayCommand(5.0,ActionOpenDoor(oDoor));
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
               
               

               


                     Modifié par Knight_Shield, 08 novembre 2011 - 10:02 .
                     
                  


            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Door Guard script help?
« Reply #1 on: November 09, 2011, 01:09:20 am »


               Try changing oTarget = GetObjectByTag("stonewallguard"); to oTarget = GetNearestObjectByTag("stonewallguard"); as I suspect you added multiple NPCs or even other objects in the module with that same tag.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Door Guard script help?
« Reply #2 on: November 09, 2011, 01:52:08 am »


               Yeah probably, but what's the point of oTarget1? It does nothing.
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Door Guard script help?
« Reply #3 on: November 09, 2011, 02:14:03 am »


               Nope didn't work.GetNearestObjectByTag

The way the script is supposed to work.
NPC guard near gate says speak string then gate opens after 2 seconds.That's the basic.

oTarget1 was for another guard to do his thing but I fired him .
               
               

               


                     Modifié par Knight_Shield, 09 novembre 2011 - 02:15 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Door Guard script help?
« Reply #4 on: November 09, 2011, 02:32:53 am »


               Oh. Well try assigning the guard to open the gate, and get rid of the lines referring to oTarget1 if you don't really need them. You could also try using:
ActionUnlockObject(oDoor);

Another way is:
  object oDoor = (GetNearestObject(OBJECT_TYPE_DOOR));
                {
                ActionDoCommand(ActionUnlockObject(oDoor));
                ActionDoCommand(ActionOpenDoor(oDoor));
                }
               
               

               


                     Modifié par ffbj, 09 novembre 2011 - 02:53 .
                     
                  


            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Door Guard script help?
« Reply #5 on: November 09, 2011, 05:19:45 pm »


               Ok been trying to get it to fire .Just not working.Do you think maybe because I havnt installed a persistent clock it could be messing with it?
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Door Guard script help?
« Reply #6 on: November 09, 2011, 11:02:27 pm »


               No I don't see how that would affect the script.  I know the one above works since I use it all the time, plus I have a persistent clock.