Aller au contenu

Photo

Condition for resting in a specific area?


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

#1
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages
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?

#2
Kato -

Kato -
  • Members
  • 392 messages
object oArea = GetArea(GetLastPCRested());

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

Kato

#3
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages

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".

#4
henesua

henesua
  • Members
  • 3 883 messages
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.

#5
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages
Feeling pretty dumb right now. So what does that function "get" - the tag or resref of the area?

#6
AndarianTD

AndarianTD
  • Members
  • 706 messages

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 .


#7
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages
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.