Author Topic: Script to make NPC attack when nearby door is bludgeoned??  (Read 260 times)

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
Script to make NPC attack when nearby door is bludgeoned??
« on: June 15, 2013, 12:06:23 am »


               Hello. I am trying to get an NPC to attack the PC when you try to bludgeon through a door nearby. My guess is that it wold be a script in the door's OnAttacked script - an object to find nearest NPC named so and so, or some such. But I don't know how to do it. Any help regarding this is manifestly appreciated! Thanx.
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Script to make NPC attack when nearby door is bludgeoned??
« Reply #1 on: June 15, 2013, 12:19:17 am »


               This is an incredibly basic draft. You may want to do a lot more than this, but it gets the job done.

void main()
{
    object oPC    = GetLastAttacker();
    object oGuard = GetNearestObjectByTag("Guard");

    AssignCommand(oGuard, ClearAllActions());
    AssignCommand(oGuard, ActionSpeakString("You asked for it!"));
    AssignCommand(oGuard, ActionAttack(oPC));
}

               
               

               


                     Modifié par Squatting Monk, 14 juin 2013 - 11:21 .
                     
                  


            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
Script to make NPC attack when nearby door is bludgeoned??
« Reply #2 on: June 15, 2013, 01:18:14 am »


               It worked! The line of dialogue is awesome. Your kung fu is the baddest, monk.
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
Script to make NPC attack when nearby door is bludgeoned??
« Reply #3 on: June 15, 2013, 01:18:51 am »


               double post
               
               

               


                     Modifié par Groove Widdit, 15 juin 2013 - 12:20 .
                     
                  


            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Script to make NPC attack when nearby door is bludgeoned??
« Reply #4 on: June 15, 2013, 01:40:48 am »


               <Blatant Self-Promotion Warning>

I have a whole bunch of scripts that I posted some time ago that handles this and a whole bunch of other solutions to the pc bashing door problem. I called it "Fun Doors" and if you try the demo module (but read the read me first) you'll see why. I also included a table of what script does what and what resources each uses, so you can grab just the scripts you need. As the download is less than 112kb it is no great wait to get it. Just follow the link on its name to get it from the new vault.

TR
               
               

               
            

Legacy_Groove Widdit

  • Sr. Member
  • ****
  • Posts: 293
  • Karma: +0/-0
Script to make NPC attack when nearby door is bludgeoned??
« Reply #5 on: June 19, 2013, 07:29:55 am »


               Okay.