Greetings all,
I am a complete novice with scripting, and usually I use lilacs to do all my scripting for me, but I am currently trying to create a script, that lilac cant assist me with (or at least I cant figure out how to do it).
Basically what I want to make is this:
OnUsed script of a portal: The module has 4 custom player "factions" in it, and players are assigned to a faction with a nondroppable item (Called tagname: FactionItem1, FactionItem2, FactionItem3, FactionItem4).
When a player without one of these four items attempts to use the portal, the PC should get a message saying he / she needs to first declare loyalty to one of the factions (and thus recieve one of the FactionItems).
Upon using the portal and holding one of the three Factions Items, I want a modulewide reputationadjustment to happen to the player as such:
FactionItem1 = - 100 adjustment to Faction2 and Faction 3 (at war with Faction 2 and Faction 3, neutral to Faction 4)
FactionItem2 = - 100 adjustment to Faction1 and Faction 3 (At war with Faction 1 and Faction 3, neutral to faction 4)
FactionItem3 = - 100 adjustment to Faction1 and Faction 2 (The Hostile Faction everyone is at war with).
FactionItem4 = - 100 adjustment to Faction 3. (Info: This is the "neutral" PC faction, only at war with Faction 3, which everyone is at war with).
And then teleport them to the corresponding FactionHomeWP. (Faction1HomeWP, Faction2HomeWP, Faction3HomeWP, Faction4HomeWP).
The script lilac gives me is this when I try to create it:
string sDeny;
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit:
http://nwvault.ign.c...=4683&id=625   */
//Put this script OnUsed
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
if (GetItemPossessedBy(oPC, "FactionItem1")== OBJECT_INVALID)
{
sDeny="You have to declare loyalty to one of the Kingdoms before entering";
SendMessageToPC(oPC, sDeny);
return;
}
object oTarget;
oTarget = GetObjectByTag("FactionNPC2");
AdjustReputation(oPC, oTarget, -100);
oTarget = GetObjectByTag("FactionNPC3");
AdjustReputation(oPC, oTarget, -100);
location lTarget;
oTarget = GetWaypointByTag("Faction1HomeWP");
lTarget = GetLocation(oTarget);
//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
AssignCommand(oPC, ClearAllActions());
DelayCommand(3.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));
oTarget = oPC;
//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON), GetLocation(oTarget));
}
I realise the above is only for one faction, and I am not even sure it works, but I have no idea how to add several checks into it, and do the correct thing based on which of the 4 FactionItems the PC is carrying..
Could anyone help please?
Thank you
Modifié par Arawan, 20 septembre 2010 - 11:48 .