Author Topic: Condition for resting in a specific area?  (Read 316 times)

Legacy_Mr. Versipellis

  • Full Member
  • ***
  • Posts: 236
  • Karma: +0/-0
Condition for resting in a specific area?
« on: August 01, 2012, 05:47:52 pm »


               I'd like the PC to be ambushed in my module, but only if they rest in a specific area. Presumably I'd have to edit the module's OnRest event - but how would I set up a condition to let the script get the PC's area?
               
               

               
            

Legacy_Kato -

  • Hero Member
  • *****
  • Posts: 747
  • Karma: +0/-0
Condition for resting in a specific area?
« Reply #1 on: August 01, 2012, 06:16:59 pm »


               object oArea = GetArea(GetLastPCRested());

if there's already the line: object oPC = GetLastPCRested();
Then simply replace GetLastPCRested() by oPC

Kato
               
               

               
            

Legacy_Mr. Versipellis

  • Full Member
  • ***
  • Posts: 236
  • Karma: +0/-0
Condition for resting in a specific area?
« Reply #2 on: August 01, 2012, 11:22:15 pm »


               

Kato_Yang wrote...

object oArea = GetArea(GetLastPCRested());

if there's already the line: object oPC = GetLastPCRested();
Then simply replace GetLastPCRested() by oPC

Kato

That's not what I meant, sorry. I want a script to go: "When the PC rests, IF they're resting in area x, spawn some creatures to attack her, ELSE, carry on as normal".
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Condition for resting in a specific area?
« Reply #3 on: August 02, 2012, 12:46:54 am »


               Kato was simply showing you how to get the area so that you can check against the area when determining whether to launch the ambush.
               
               

               
            

Legacy_Mr. Versipellis

  • Full Member
  • ***
  • Posts: 236
  • Karma: +0/-0
Condition for resting in a specific area?
« Reply #4 on: August 02, 2012, 11:21:57 am »


               Feeling pretty dumb right now. So what does that function "get" - the tag or resref of the area?
               
               

               
            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Condition for resting in a specific area?
« Reply #5 on: August 02, 2012, 11:40:14 am »


               

Mr. Versipellis wrote...

Feeling pretty dumb right now. So what does that function "get" - the tag or resref of the area?


Neither. It gets you an object reference to the area object. That lets you treat it like any other object. If you wanted its tag or resref, you'd use string sArea = GetTag(oArea) or string sArea = GetResRef(oArea).

So if the tag of the area you want the ambush to occur in is "ambush_area," you could do the following:

object oArea = GetArea(GetLastPCRested());
string sArea = GetTag(oArea);
if (sArea == "ambush_area") {
   // Insert ambush code here
}
               
               

               


                     Modifié par AndarianTD, 02 août 2012 - 10:46 .
                     
                  


            

Legacy_Mr. Versipellis

  • Full Member
  • ***
  • Posts: 236
  • Karma: +0/-0
Condition for resting in a specific area?
« Reply #6 on: August 02, 2012, 04:24:53 pm »


               Got it - this seems to be working perfectly. Is there a way of cancelling the PC's rest as well? I'm sure I've seen it used somewhere but I'm not sure which "include" it was found in.