logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
A noob question on a script

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Mavryek



Joined: 11 Dec 2007
Posts: 6

PostPosted: Wed Jan 02, 2008 20:21    Post subject: A noob question on a script Reply with quote

I am using the VG system for factions and I would like to lock down some doors and gates based on player factions.

The script that sets a players faction is straight forward but I am very new to scripting and therefore do not know what edits need to be done to make a script that looks at the players faction and if equal to the one the door is looking for it will open or unlock for them. Any help would be great. Here is a copy of the script that shows how the faction is set on the PC.

#include "vg_factions_inc"
void main()
{
object oPC = GetPCSpeaker();
object oGuildJournal = GetItemPossessedBy(oPC,"pgs_item_journal"); // Guild Journal Used to store region
SetLocalString(oGuildJournal,"Region","01");
// Set up the factions if factions are turned on.
if (GetLocalInt(GetModule(),"Factions")==1)
{
SetOrigFaction(oPC,12);
JoinFaction(oPC,12);
}
}
_________________
Mavryek
Back to top
View user's profile Send private message
Squatting Monk



Joined: 28 Jun 2007
Posts: 76

PostPosted: Thu Jan 10, 2008 2:26    Post subject: Reply with quote

Well, I'm not familiar with the system you're talking about (if you could give me a link to it on the Vault I could look into it some more), but one of the things to remember is that PCs don't belong to factions. Now, you could set a persistent int that identifies them with a group, but it won't involve any of the functions you'd use when checking factions normally.

The script in question is a conversation script and has nothing to do with unlocking doors. If I were to design a script to do what you're saying, though, it would go on the OnUsed event and look something like this...

Code:

#include "aps_include"
void main()
{
   object oPC          = GetLastUsedBy();
   string sPCFaction   = GetPersistentString(oPC, "pc_faction");
   string sDoorFaction = GetLocalString(OBJECT_SELF, "door-faction");
   
   if (sPCFaction == sDoorFaction)
      SetLocked(OBJECT_SELF, FALSE);
   else
      SetLocked(OBJECT_SELF, TRUE);
}


That's just me, but other ways could work. Note that you'd want to set a local variable on every door that would use this script. The easiest way to do that is by going to the Variables button under the Advanced tab in the door's properties.

Let me know if this doesn't fit your needs and I'll see what I can work out for you.
Back to top
View user's profile Send private message
Mavryek



Joined: 11 Dec 2007
Posts: 6

PostPosted: Thu Jan 10, 2008 5:29    Post subject: Reply with quote

http://nwvault.ign.com/View.php?view=Other.Detail&id=1206

This is the link to the base module we used with the script sets involved

The way factions are set up is through the Messanger of the Gods conversation and an INT is set on the PC inside the Journal they get when first logging in there character

So in our case Loyalists would be set with an INT = 13
and
Rebels set with an INT = 12

These two factions are to be hostile to one another (NPC of opposite sides should be hostile to the PCs) and I would like to use these same faction INT to keep the opposite side PCs from entering the enemies cities

If possible.

Thanks for any help you can provide
_________________
Mavryek
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group