Aller au contenu

Photo

Stuck at moddind....I suck at scripting...


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

#1
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
 Hey there I'm quite new to this forum, was looking to get some help with my problem...
So here it is:

I want to make a group of NPC's attack the PC but when the PC dies I want to, make him go to another area like his been captured...

Sorry if it's a Noob question but I'm really stuck at this. :(

Well hope I can count on you guys... thanks in advance ;p




PS: I'm looking for people to help me make my project come to life, so if anyones interested in knowing what it is about and maybe help me in whatever you can, please send me a message or say something here on this post.
Thanks :D

#2
Baragg

Baragg
  • Members
  • 271 messages
In your case I would use the modules onplayerdeath and just before the PopGUI line I would have a check to determine if the PC is in a certain area. If they are in that certain area, fade to black, raise the PC(gotta raise em fore you can move them), move them to the captured area, fade in.



Unfortunately I am not conversant with fade and such, but I am sure someone else can tweak it for you.



What would be the tag of the area you want the capture to happen in?

#3
Baragg

Baragg
  • Members
  • 271 messages
Looking at the default ondeath there is already a call for the area tag on line 186. I may try to work this up.

#4
Baragg

Baragg
  • Members
  • 271 messages
Also do you use some method such as a nodrop item to store PC info on?

#5
Baragg

Baragg
  • Members
  • 271 messages
K, I tried not sure how this will work at this line here:

AssignCommand(oPlayer, JumpToLocation(GetLocation(GetWaypointByTag("CAPTURE_WAYPOINT_TAG"))));

You will need to replace CAPTURE_WAYPOINT_TAG with the tag of a waypoint to jump the PC to after being raised. Also the question about a nodrop item was so that if the PC has been captured in this area they could possibly go back to that area if you marked they have been captured once you could stop them from being captured again by calling that variable.

And this line:

if(sArea == "CAPTURE_AREA")//area where PC should be captured

You will need to repalce CAPTURE_AREA with the tag of the area you want the PC to be captured in.

Also you will see this line:

//SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);//not sure if this should be used or just return

I commented it out, cause I was unsure if this was how I needed to stop the PopUpGUI from coming up, I am pretty sure the return I used should stop it but if it doesn't comment out the return and comment in the other thing.

Note this is just the vanilla NWN ondeath with what I added.

[nwscript]
//::///////////////////////////////////////////////
//:: Death Script
//:: NW_O0_DEATH.NSS
//:: Copyright © 2008 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script handles the default behavior
that occurs when a player dies.

BK: October 8 2002: Overriden for Expansion

Deva Winblood: April 21th, 2008: Modified to
handle dismounts when PC dies while mounted.

*/
//:://////////////////////////////////////////////
//:: Created By: Brent Knowles
//:: Created On: November 6, 2001
//:://////////////////////////////////////////////

#include "x3_inc_horse"

/*
void ClearAllFactionMembers(object oMember, object oPlayer)
{
// AssignCommand(oMember, SpeakString("here"));
AdjustReputation(oPlayer, oMember, 100);
SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
object oClear = GetFirstFactionMember(oMember, FALSE);
while (GetIsObjectValid(oClear) == TRUE)
{
ClearPersonalReputation(oPlayer, oClear);
oClear = GetNextFactionMember(oMember, FALSE);
}
} */
void Raise(object oPlayer)
{
effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);

effect eBad = GetFirstEffect(oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPlayer)), oPlayer);

//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
{
//Remove effect if it is negative.
RemoveEffect(oPlayer, eBad);
}
eBad = GetNextEffect(oPlayer);
}
//Fire cast spell at event for the specified target
SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);
}


///////////////////////////////////////////////////////////////[ MAIN ]/////////
void main()
{
object oPlayer = GetLastPlayerDied();
object oHorse;
object oInventory;
string sID;
int nC;
string sT;
string sR;
int nCH;
int nST;
object oItem;
effect eEffect;
string sDB="X3SADDLEBAG"+GetTag(GetModule());

if (GetStringLength(GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE"))>0) sDB=GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE");
if (HorseGetIsMounted(oPlayer))
{ // Dismount and then die
//SetCommandable(FALSE,oPlayer);
//ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
DelayCommand(0.3,HORSE_SupportResetUnmountedAppearance(oPlayer));
DelayCommand(3.0,HORSE_SupportCleanVariables(oPlayer));
DelayCommand(1.0,HORSE_SupportRemoveACBonus(oPlayer));
DelayCommand(1.0,HORSE_SupportRemoveHPBonus(oPlayer));
DelayCommand(1.1,HORSE_SupportRemoveMountedSkillDecreases(oPlayer));
DelayCommand(1.1,HORSE_SupportAdjustMountedArcheryPenalty(oPlayer));
DelayCommand(1.2,HORSE_SupportOriginalSpeed(oPlayer));
if (!GetLocalInt(GetModule(),"X3_HORSE_NO_CORPSES"))
{ // okay to create lootable horse corpses
sR=GetSkinString(oPlayer,"sX3_HorseResRef");
sT=GetSkinString(oPlayer,"sX3_HorseMountTag");
nCH=GetSkinInt(oPlayer,"nX3_HorseAppearance");
nST=GetSkinInt(oPlayer,"nX3_HorseTail");
nC=GetLocalInt(oPlayer,"nX3_HorsePortrait");
if (GetStringLength(sR)>0&&GetStringLeft(sR,GetStringLength(HORSE_PALADIN_PREFIX))!=HORSE_PALADIN_PREFIX)
{ // create horse
oHorse=HorseCreateHorse(sR,GetLocation(oPlayer),oPlayer,sT,nCH,nST);
SetLootable(oHorse,TRUE);
SetPortraitId(oHorse,nC);
SetLocalInt(oHorse,"bDie",TRUE);
AssignCommand(oHorse,SetIsDestroyable(FALSE,TRUE,TRUE));
} // create horse
} // okay to create lootable horse corpses
oInventory=GetLocalObject(oPlayer,"oX3_Saddlebags");
sID=GetLocalString(oPlayer,"sDB_Inv");
if (GetIsObjectValid(oInventory))
{ // drop horse saddlebags
if (!GetIsObjectValid(oHorse))
{ // no horse created
HORSE_SupportTransferInventory(oInventory,OBJECT_INVALID,GetLocation(oPlayer),TRUE);
} // no horse created
else
{ // transfer to horse
HORSE_SupportTransferInventory(oInventory,oHorse,GetLocation(oHorse),TRUE);
//DelayCommand(2.0,PurgeSkinObject(oHorse));
//DelayCommand(3.0,KillTheHorse(oHorse));
//DelayCommand(1.8,PurgeSkinObject(oHorse));
} // transfer to horse
} // drop horse saddlebags
else if (GetStringLength(sID)>0)
{ // database based inventory
nC=GetCampaignInt(sDB,"nCO_"+sID);
while(nC>0)
{ // restore inventory
sR=GetCampaignString(sDB,"sR"+sID+IntToString(nC));
sT=GetCampaignString(sDB,"sT"+sID+IntToString(nC));
nST=GetCampaignInt(sDB,"nS"+sID+IntToString(nC));
nCH=GetCampaignInt(sDB,"nC"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"sR"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"sT"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"nS"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"nC"+sID+IntToString(nC));
if (!GetIsObjectValid(oHorse))
{ // no lootable corpse
oItem=CreateObject(OBJECT_TYPE_ITEM,sR,GetLocation(oPlayer),FALSE,sT);
} // no lootable corpse
else
{ // lootable corpse
oItem=CreateItemOnObject(sR,oHorse,nST,sT);
} // lootable corpse
if (GetItemStackSize(oItem)!=nST) SetItemStackSize(oItem,nST);
if (nCH>0) SetItemCharges(oItem,nCH);
nC--;
} // restore inventory
DeleteCampaignVariable(sDB,"nCO_"+sID);
//DelayCommand(2.0,PurgeSkinObject(oHorse));
if (GetIsObjectValid(oHorse)&&GetLocalInt(oHorse,"bDie")) DelayCommand(3.0,KillTheHorse(oHorse));
//DelayCommand(2.5,PurgeSkinObject(oHorse));
} // database based inventory
else if (GetIsObjectValid(oHorse))
{ // no inventory
//DelayCommand(1.0,PurgeSkinObject(oHorse));
DelayCommand(2.0,KillTheHorse(oHorse));
//DelayCommand(1.8,PurgeSkinObject(oHorse));
} // no inventory
//eEffect=EffectDeath();
//DelayCommand(1.6,ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer));
//DelayCommand(1.7,SetCommandable(TRUE,oPlayer));
//return;
} // Dismount and then die

// * increment global tracking number of times that I died
SetLocalInt(oPlayer, "NW_L_PLAYER_DIED", GetLocalInt(oPlayer, "NW_L_PLAYER_DIED") + 1);

// * BK: Automation Control. Autopcs ignore death
if (GetLocalInt(oPlayer, "NW_L_AUTOMATION") == 10)
{
Raise(oPlayer);
DelayCommand(1.0, ExecuteScript("crawl", OBJECT_SELF));
return; // Raise and return
}


// * Handle Spirit of the Wood Death
string sArea = GetTag(GetArea(oPlayer));
/*
if (sArea == "MAP_M2Q2F2" && GetDistanceBetweenLocations(GetLocation(GetObjectByTag("M2Q2F2_M2Q2G")), GetLocation(oPlayer))
{
int bValid;

Raise(oPlayer);
string sDestTag = "WP_M2Q2GtoM2Q2F";
object oSpawnPoint = GetObjectByTag(sDestTag);
AssignCommand(oPlayer,JumpToLocation(GetLocation(oSpawnPoint)));
return;

}
*/
// * in last level of the Sourcestone, move the player to the beginning of the area
// * May 16 2002: or the main area of the Snowglobe (to prevent plot logic problems).
// * May 21 2002: or Castle Never
if (sArea == "M4Q1D2" || sArea == "M3Q3C" || sArea == "MAP_M1Q6A")
{

//Raise(oPlayer);
//string sDestTag = "M4QD07_ENTER";
//object oSpawnPoint = GetObjectByTag(sDestTag);
// AssignCommand(oPlayer, DelayCommand(1.0, JumpToLocation(GetLocation(oSpawnPoint))));
// * MAY 2002: Just popup the YOU ARE DEAD panel at this point
DelayCommand(2.5, PopUpDeathGUIPanel(oPlayer,FALSE, TRUE, 66487));
return;
}

// * make friendly to Each of the 3 common factions
AssignCommand(oPlayer, ClearAllActions());
// * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}


if(sArea == "CAPTURE_AREA")//area where PC should be captured
{//Baragg
FadeToBlack(oPlayer);
Raise(oPlayer);
AssignCommand(oPlayer, ClearAllActions());
AssignCommand(oPlayer, JumpToLocation(GetLocation(GetWaypointByTag("CAPTURE_WAYPOINT_TAG"))));
FadeFromBlack(oPlayer);
//SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);//not sure if this should be used or just return
return;
}

DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));

}
///////////////////////////////////////////////////////////////[ MAIN ]/////////
[/nwscript]

Modifié par Baragg, 19 février 2011 - 06:51 .


#6
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
Hey, thanks for the quick response :)



Actually I'm quite new to madding and scripting. No i don't any method to store PC info,,,

Should I? I'm really new at this, thought i would start a tiny campaign to try and learn the in's and out's before going for the big gold chunk ;p, thing is it started giving me problems right away cause to make a story i need logic (I can't work in a world that doesn't have any) so to be able to later maybe continue the story i started this bit, but to give it credibilityi need this starting point, which I couldn't do alone because I'm a noob both at scripting and modding...



Tell me something is there a way to only make the PC get unconscious, is it easier that way?



Thanks for the help by the way...

#7
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
OH almost forgot....noob question.... where do I put the scripts to interact directly with the PC such as the one i asked for? I know...really noob question...

#8
Greyfort

Greyfort
  • Members
  • 234 messages
Here is a modified on_death event. you goto module properties, then click on event tab, then in the event called on player death click on the ... and choose the script "dar_mod_ondeath"that you coppied and pasted from this forum. or Braggs script

script on death:

//
// File: dar_mod_ondeath
// created for: Dark Ruler

/*

In your case I would use the modules onplayerdeath and just before the
PopGUI line I would have a check to determine if the PC is in a certain area.
If they are in that certain area, fade to black, raise the PC(gotta raise em
fore you can move them), move them to the captured area, fade in.

*/

//::///////////////////////////////////////////////
//:: Death Script
//:: NW_O0_DEATH.NSS
//:: Copyright © 2008 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script handles the default behavior
that occurs when a player dies.

BK: October 8 2002: Overriden for Expansion

Deva Winblood: April 21th, 2008: Modified to
handle dismounts when PC dies while mounted.

*/
//:://////////////////////////////////////////////
//:: Created By: Brent Knowles
//:: Created On: November 6, 2001
//:://////////////////////////////////////////////

#include "x2_inc_switches"

#include "x3_inc_horse"

/*
void ClearAllFactionMembers(object oMember, object oPlayer)
{
// AssignCommand(oMember, SpeakString("here"));
AdjustReputation(oPlayer, oMember, 100);
SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
object oClear = GetFirstFactionMember(oMember, FALSE);
while (GetIsObjectValid(oClear) == TRUE)
{
ClearPersonalReputation(oPlayer, oClear);
oClear = GetNextFactionMember(oMember, FALSE);
}
} */
void Raise(object oPlayer)
{
effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);

effect eBad = GetFirstEffect(oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPlayer)), oPlayer);

//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
{
//Remove effect if it is negative.
RemoveEffect(oPlayer, eBad);
}
eBad = GetNextEffect(oPlayer);
}
//Fire cast spell at event for the specified target
SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);
}


///////////////////////////////////////////////////////////////[ MAIN ]/////////
void main()
{
object oPlayer = GetLastPlayerDied();
object oHorse;
object oInventory;
string sID;
int nC;
string sT;
string sR;
int nCH;
int nST;
object oItem;
effect eEffect;
string sDB="X3SADDLEBAG"+GetTag(GetModule());
if (GetStringLength(GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE"))>0) sDB=GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE");
if (HorseGetIsMounted(oPlayer))
{ // Dismount and then die
//SetCommandable(FALSE,oPlayer);
//ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
DelayCommand(0.3,HORSE_SupportResetUnmountedAppearance(oPlayer));
DelayCommand(3.0,HORSE_SupportCleanVariables(oPlayer));
DelayCommand(1.0,HORSE_SupportRemoveACBonus(oPlayer));
DelayCommand(1.0,HORSE_SupportRemoveHPBonus(oPlayer));
DelayCommand(1.1,HORSE_SupportRemoveMountedSkillDecreases(oPlayer));
DelayCommand(1.1,HORSE_SupportAdjustMountedArcheryPenalty(oPlayer));
DelayCommand(1.2,HORSE_SupportOriginalSpeed(oPlayer));
if (!GetLocalInt(GetModule(),"X3_HORSE_NO_CORPSES"))
{ // okay to create lootable horse corpses
sR=GetSkinString(oPlayer,"sX3_HorseResRef");
sT=GetSkinString(oPlayer,"sX3_HorseMountTag");
nCH=GetSkinInt(oPlayer,"nX3_HorseAppearance");
nST=GetSkinInt(oPlayer,"nX3_HorseTail");
nC=GetLocalInt(oPlayer,"nX3_HorsePortrait");
if (GetStringLength(sR)>0&&GetStringLeft(sR,GetStringLength(HORSE_PALADIN_PREFIX))!=HORSE_PALADIN_PREFIX)
{ // create horse
oHorse=HorseCreateHorse(sR,GetLocation(oPlayer),oPlayer,sT,nCH,nST);
SetLootable(oHorse,TRUE);
SetPortraitId(oHorse,nC);
SetLocalInt(oHorse,"bDie",TRUE);
AssignCommand(oHorse,SetIsDestroyable(FALSE,TRUE,TRUE));
} // create horse
} // okay to create lootable horse corpses
oInventory=GetLocalObject(oPlayer,"oX3_Saddlebags");
sID=GetLocalString(oPlayer,"sDB_Inv");
if (GetIsObjectValid(oInventory))
{ // drop horse saddlebags
if (!GetIsObjectValid(oHorse))
{ // no horse created
HORSE_SupportTransferInventory(oInventory,OBJECT_INVALID,GetLocation(oPlayer),TRUE);
} // no horse created
else
{ // transfer to horse
HORSE_SupportTransferInventory(oInventory,oHorse,GetLocation(oHorse),TRUE);
//DelayCommand(2.0,PurgeSkinObject(oHorse));
//DelayCommand(3.0,KillTheHorse(oHorse));
//DelayCommand(1.8,PurgeSkinObject(oHorse));
} // transfer to horse
} // drop horse saddlebags
else if (GetStringLength(sID)>0)
{ // database based inventory
nC=GetCampaignInt(sDB,"nCO_"+sID);
while(nC>0)
{ // restore inventory
sR=GetCampaignString(sDB,"sR"+sID+IntToString(nC));
sT=GetCampaignString(sDB,"sT"+sID+IntToString(nC));
nST=GetCampaignInt(sDB,"nS"+sID+IntToString(nC));
nCH=GetCampaignInt(sDB,"nC"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"sR"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"sT"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"nS"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"nC"+sID+IntToString(nC));
if (!GetIsObjectValid(oHorse))
{ // no lootable corpse
oItem=CreateObject(OBJECT_TYPE_ITEM,sR,GetLocation(oPlayer),FALSE,sT);
} // no lootable corpse
else
{ // lootable corpse
oItem=CreateItemOnObject(sR,oHorse,nST,sT);
} // lootable corpse
if (GetItemStackSize(oItem)!=nST) SetItemStackSize(oItem,nST);
if (nCH>0) SetItemCharges(oItem,nCH);
nC--;
} // restore inventory
DeleteCampaignVariable(sDB,"nCO_"+sID);
//DelayCommand(2.0,PurgeSkinObject(oHorse));
if (GetIsObjectValid(oHorse)&&GetLocalInt(oHorse,"bDie")) DelayCommand(3.0,KillTheHorse(oHorse));
//DelayCommand(2.5,PurgeSkinObject(oHorse));
} // database based inventory
else if (GetIsObjectValid(oHorse))
{ // no inventory
//DelayCommand(1.0,PurgeSkinObject(oHorse));
DelayCommand(2.0,KillTheHorse(oHorse));
//DelayCommand(1.8,PurgeSkinObject(oHorse));
} // no inventory
//eEffect=EffectDeath();
//DelayCommand(1.6,ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer));
//DelayCommand(1.7,SetCommandable(TRUE,oPlayer));
//return;
} // Dismount and then die

// * increment global tracking number of times that I died
SetLocalInt(oPlayer, "NW_L_PLAYER_DIED", GetLocalInt(oPlayer, "NW_L_PLAYER_DIED") + 1);

// * BK: Automation Control. Autopcs ignore death
if (GetLocalInt(oPlayer, "NW_L_AUTOMATION") == 10)
{
Raise(oPlayer);
DelayCommand(1.0, ExecuteScript("crawl", OBJECT_SELF));
return; // Raise and return
}


// * Handle Spirit of the Wood Death
string sArea = GetTag(GetArea(oPlayer));
/*
if (sArea == "MAP_M2Q2F2" && GetDistanceBetweenLocations(GetLocation(GetObjectByTag("M2Q2F2_M2Q2G")), GetLocation(oPlayer))
{
int bValid;

Raise(oPlayer);
string sDestTag = "WP_M2Q2GtoM2Q2F";
object oSpawnPoint = GetObjectByTag(sDestTag);
AssignCommand(oPlayer,JumpToLocation(GetLocation(oSpawnPoint)));
return;

}
*/
// * in last level of the Sourcestone, move the player to the beginning of the area
// * May 16 2002: or the main area of the Snowglobe (to prevent plot logic problems).
// * May 21 2002: or Castle Never
if (sArea == "M4Q1D2" || sArea == "M3Q3C" || sArea == "MAP_M1Q6A")
{

//Raise(oPlayer);
//string sDestTag = "M4QD07_ENTER";
//object oSpawnPoint = GetObjectByTag(sDestTag);
// AssignCommand(oPlayer, DelayCommand(1.0, JumpToLocation(GetLocation(oSpawnPoint))));
// * MAY 2002: Just popup the YOU ARE DEAD panel at this point
DelayCommand(2.5, PopUpDeathGUIPanel(oPlayer,FALSE, TRUE, 66487));
return;
}

// * make friendly to Each of the 3 common factions
AssignCommand(oPlayer, ClearAllActions());
// * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}
//
// // created for: Dark Ruler
if ( sArea =="Name of Area here")
{
object oWayJump=GetObjectByTag("name of waypoint to jump to here");
// fade..
FadeToBlack(oPlayer,3.7);
// raise heal
Raise( oPlayer);
// jump player to area
AssignCommand(oPlayer,ActionJumpToObject(oWayJump));
// un fade..
DelayCommand(7.3, FadeFromBlack(oPlayer,3.7));

}

DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));

}
///////////////////////////////////////////////////////////////[ MAIN ]/////////

note you need to create a waypoint and place in the area you want Player to be sent to.  You have to enter the tag of the waypoint in the script above, and the tag of the area player dies in.

Modifié par Greyfort, 19 février 2011 - 07:23 .


#9
Greyfort

Greyfort
  • Members
  • 234 messages
Note I found neither SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END); is not valid and return doesn't work.

DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH)); line is still fired
brags and my script were missing the include file #include "x2_inc_switches"
I Edited my script so it has the include in it now, it shows you ware to add the include in braggs script

Modifié par Greyfort, 19 février 2011 - 07:22 .


#10
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
Ok it was almost a complete success lol, thing is the PC went to the are dead...i had to respawn...is it something i'm doing incorrectly? sorry for the trouble and thanks guys :)

#11
Greyfort

Greyfort
  • Members
  • 234 messages
ok which script worked Baragg, or mine?

#12
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
yours did but the PC went to the WP dead...and the box withe the load, ressurrect, quit game stayed there...

#13
Greyfort

Greyfort
  • Members
  • 234 messages
ok try this, you will need to simply cut and paste these lines:

// fade..
FadeToBlack(oPlayer,FADE_SPEED_MEDIUM);
// raise heal
DelayCommand(1.0,Raise( oPlayer));
// jump player to area
DelayCommand(5.0,AssignCommand(oPlayer,ActionJumpToObject(oWayJump)) );
// un fade..
DelayCommand(7.3, FadeFromBlack(oPlayer,FADE_SPEED_MEDIUM));
return;

I belive the issue was the delays, i'm looking into the gui pop up issue will post that soon forgive the delay

EDIT NOTES:  you can change the delay on the fade from black probably doesnt need to be that long, I just set it that long to give effect of waking up

Modifié par Greyfort, 19 février 2011 - 08:53 .


#14
Greyfort

Greyfort
  • Members
  • 234 messages
I've run it several times, I'm not having the gui pop up window issue remove the include "x2_inc_switches" from the script its not needed. that may have caused the issue.

#15
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
19-02-2011 21:05:58: Error. 'be_captured_05' did not compile.

be_captured_05.nss(496): ERROR: UNEXPECTED END COMPOUND STATEMENT



....why is this giving me this error?

#16
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
I wrote this after the end of the first lines of code of the default script from the nwn...



//

// // created for: Dark Ruler

if ( sArea =="HottearDesert")

{

object oWayJump=GetObjectByTag("Captured_Cage00");

// fade..

FadeToBlack(oPlayer,FADE_SPEED_MEDIUM);

// raise heal

DelayCommand(1.0,Raise( oPlayer));

// jump player to area

DelayCommand(5.0,AssignCommand(oPlayer,ActionJumpToObject(oWayJump)) );

// un fade..

DelayCommand(7.3, FadeFromBlack(oPlayer,FADE_SPEED_MEDIUM));

return;

}

#17
Greyfort

Greyfort
  • Members
  • 234 messages
ok...Here is entire script.1) open new script file. paste the below script in new script be sure to remove the
voidmain()
{

} from the old file replacing it with the pasted script.  save file as dar_mod_ondeath

then goto module properties, events tab, goto player death event click on ... button and choose dar_mod_ondeath
then click ok



SCRIPT:

//
// File: dar_mod_ondeath
// created for: Dark Ruler

/*

In your case I would use the modules onplayerdeath and just before the
PopGUI line I would have a check to determine if the PC is in a certain area.
If they are in that certain area, fade to black, raise the PC(gotta raise em
fore you can move them), move them to the captured area, fade in.
//
// File: dar_mod_ondeath
// created for: Dark Ruler

/*

In your case I would use the modules onplayerdeath and just before the
PopGUI line I would have a check to determine if the PC is in a certain area.
If they are in that certain area, fade to black, raise the PC(gotta raise em
fore you can move them), move them to the captured area, fade in.

*/

//::///////////////////////////////////////////////
//:: Death Script
//:: NW_O0_DEATH.NSS
//:: Copyright © 2008 Bioware Corp.
//:://////////////////////////////////////////////
/*
    This script handles the default behavior
    that occurs when a player dies.

    BK: October 8 2002: Overriden for Expansion

    Deva Winblood:  April 21th, 2008: Modified to
    handle dismounts when PC dies while mounted.

*/
//:://////////////////////////////////////////////
//:: Created By: Brent Knowles
//:: Created On: November 6, 2001
//:://////////////////////////////////////////////

#include "x3_inc_horse"

 /*
void ClearAllFactionMembers(object oMember, object oPlayer)
{
//    AssignCommand(oMember, SpeakString("here"));
    AdjustReputation(oPlayer, oMember, 100);
    SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
    object oClear = GetFirstFactionMember(oMember, FALSE);
    while (GetIsObjectValid(oClear) == TRUE)
    {
        ClearPersonalReputation(oPlayer, oClear);
        oClear = GetNextFactionMember(oMember, FALSE);
    }
}   */
void Raise(object oPlayer)
{
        effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);

        effect eBad = GetFirstEffect(oPlayer);
        ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
        ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPlayer)), oPlayer);

        //Search for negative effects
        while(GetIsEffectValid(eBad))
        {
            if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
                GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
                GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
                GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
                {
                    //Remove effect if it is negative.
                    RemoveEffect(oPlayer, eBad);
                }
            eBad = GetNextEffect(oPlayer);
        }
        //Fire cast spell at event for the specified target
        SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);
}


///////////////////////////////////////////////////////////////[ MAIN ]/////////
void main()
{
    object oPlayer = GetLastPlayerDied();
    object oHorse;
    object oInventory;
    string sID;
    int nC;
    string sT;
    string sR;
    int nCH;
    int nST;
    object oItem;
    effect eEffect;
    string sDB="X3SADDLEBAG"+GetTag(GetModule());
    if (GetStringLength(GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE"))>0) sDB=GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE");
    if (HorseGetIsMounted(oPlayer))
    { // Dismount and then die
        //SetCommandable(FALSE,oPlayer);
        //ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
        DelayCommand(0.3,HORSE_SupportResetUnmountedAppearance(oPlayer));
        DelayCommand(3.0,HORSE_SupportCleanVariables(oPlayer));
        DelayCommand(1.0,HORSE_SupportRemoveACBonus(oPlayer));
        DelayCommand(1.0,HORSE_SupportRemoveHPBonus(oPlayer));
        DelayCommand(1.1,HORSE_SupportRemoveMountedSkillDecreases(oPlayer));
        DelayCommand(1.1,HORSE_SupportAdjustMountedArcheryPenalty(oPlayer));
        DelayCommand(1.2,HORSE_SupportOriginalSpeed(oPlayer));
        if (!GetLocalInt(GetModule(),"X3_HORSE_NO_CORPSES"))
        { // okay to create lootable horse corpses
            sR=GetSkinString(oPlayer,"sX3_HorseResRef");
            sT=GetSkinString(oPlayer,"sX3_HorseMountTag");
            nCH=GetSkinInt(oPlayer,"nX3_HorseAppearance");
            nST=GetSkinInt(oPlayer,"nX3_HorseTail");
            nC=GetLocalInt(oPlayer,"nX3_HorsePortrait");
            if (GetStringLength(sR)>0&&GetStringLeft(sR,GetStringLength(HORSE_PALADIN_PREFIX))!=HORSE_PALADIN_PREFIX)
            { // create horse
                oHorse=HorseCreateHorse(sR,GetLocation(oPlayer),oPlayer,sT,nCH,nST);
                SetLootable(oHorse,TRUE);
                SetPortraitId(oHorse,nC);
                SetLocalInt(oHorse,"bDie",TRUE);
                AssignCommand(oHorse,SetIsDestroyable(FALSE,TRUE,TRUE));
            } // create horse
        } // okay to create lootable horse corpses
        oInventory=GetLocalObject(oPlayer,"oX3_Saddlebags");
        sID=GetLocalString(oPlayer,"sDB_Inv");
        if (GetIsObjectValid(oInventory))
        { // drop horse saddlebags
            if (!GetIsObjectValid(oHorse))
            { // no horse created
                HORSE_SupportTransferInventory(oInventory,OBJECT_INVALID,GetLocation(oPlayer),TRUE);
            } // no horse created
            else
            { // transfer to horse
                HORSE_SupportTransferInventory(oInventory,oHorse,GetLocation(oHorse),TRUE);
                //DelayCommand(2.0,PurgeSkinObject(oHorse));
                //DelayCommand(3.0,KillTheHorse(oHorse));
                //DelayCommand(1.8,PurgeSkinObject(oHorse));
            } // transfer to horse
        } // drop horse saddlebags
        else if (GetStringLength(sID)>0)
        { // database based inventory
            nC=GetCampaignInt(sDB,"nCO_"+sID);
            while(nC>0)
            { // restore inventory
                sR=GetCampaignString(sDB,"sR"+sID+IntToString(nC));
                sT=GetCampaignString(sDB,"sT"+sID+IntToString(nC));
                nST=GetCampaignInt(sDB,"nS"+sID+IntToString(nC));
                nCH=GetCampaignInt(sDB,"nC"+sID+IntToString(nC));
                DeleteCampaignVariable(sDB,"sR"+sID+IntToString(nC));
                DeleteCampaignVariable(sDB,"sT"+sID+IntToString(nC));
                DeleteCampaignVariable(sDB,"nS"+sID+IntToString(nC));
                DeleteCampaignVariable(sDB,"nC"+sID+IntToString(nC));
                if (!GetIsObjectValid(oHorse))
                { // no lootable corpse
                    oItem=CreateObject(OBJECT_TYPE_ITEM,sR,GetLocation(oPlayer),FALSE,sT);
                } // no lootable corpse
                else
                { // lootable corpse
                    oItem=CreateItemOnObject(sR,oHorse,nST,sT);
                } // lootable corpse
                if (GetItemStackSize(oItem)!=nST) SetItemStackSize(oItem,nST);
                if (nCH>0) SetItemCharges(oItem,nCH);
                nC--;
            } // restore inventory
            DeleteCampaignVariable(sDB,"nCO_"+sID);
            //DelayCommand(2.0,PurgeSkinObject(oHorse));
            if (GetIsObjectValid(oHorse)&&GetLocalInt(oHorse,"bDie")) DelayCommand(3.0,KillTheHorse(oHorse));
            //DelayCommand(2.5,PurgeSkinObject(oHorse));
        } // database based inventory
        else if (GetIsObjectValid(oHorse))
        { // no inventory
            //DelayCommand(1.0,PurgeSkinObject(oHorse));
            DelayCommand(2.0,KillTheHorse(oHorse));
            //DelayCommand(1.8,PurgeSkinObject(oHorse));
        } // no inventory
        //eEffect=EffectDeath();
        //DelayCommand(1.6,ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer));
        //DelayCommand(1.7,SetCommandable(TRUE,oPlayer));
        //return;
    } // Dismount and then die

    // * increment global tracking number of times that I died
    SetLocalInt(oPlayer, "NW_L_PLAYER_DIED", GetLocalInt(oPlayer, "NW_L_PLAYER_DIED") + 1);

    // * BK: Automation Control. Autopcs ignore death
    if (GetLocalInt(oPlayer, "NW_L_AUTOMATION") == 10)
    {
        Raise(oPlayer);
        DelayCommand(1.0, ExecuteScript("crawl", OBJECT_SELF));
        return; // Raise and return
    }


    // * Handle Spirit of the Wood Death
     string sArea = GetTag(GetArea(oPlayer));
/*
    if (sArea == "MAP_M2Q2F2" && GetDistanceBetweenLocations(GetLocation(GetObjectByTag("M2Q2F2_M2Q2G")), GetLocation(oPlayer)) < 5.0 && GetLocalInt(GetModule(),"NW_M2Q2E_WoodsFreed") == 0)
    {
        int bValid;

        Raise(oPlayer);
        string sDestTag = "WP_M2Q2GtoM2Q2F";
        object oSpawnPoint = GetObjectByTag(sDestTag);
        AssignCommand(oPlayer,JumpToLocation(GetLocation(oSpawnPoint)));
        return;

    }
*/
    // * in last level of the Sourcestone, move the player to the beginning of the area
    // * May 16 2002: or the main area of the Snowglobe (to prevent plot logic problems).
    // * May 21 2002: or Castle Never
    if (sArea == "M4Q1D2" || sArea == "M3Q3C" || sArea == "MAP_M1Q6A")
    {

        //Raise(oPlayer);
        //string sDestTag = "M4QD07_ENTER";
        //object oSpawnPoint = GetObjectByTag(sDestTag);
//        AssignCommand(oPlayer, DelayCommand(1.0, JumpToLocation(GetLocation(oSpawnPoint))));
// * MAY 2002: Just popup the YOU ARE DEAD panel at this point
        DelayCommand(2.5, PopUpDeathGUIPanel(oPlayer,FALSE, TRUE, 66487));
        return;
    }

    // * make friendly to Each of the 3 common factions
    AssignCommand(oPlayer, ClearAllActions());
    // * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
    if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
    }
    if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
    }
    if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
    }

//
// // created for: Dark Ruler
if ( sArea =="Area Tag Here")
{
SendMessageToPC  (oPlayer," you are unconsious...");

object oWayJump=GetObjectByTag("Way point tag here");
// fade..
FadeToBlack(oPlayer,FADE_SPEED_MEDIUM);
// raise heal
DelayCommand(1.0,Raise( oPlayer));
// jump player to area
DelayCommand(5.0,AssignCommand(oPlayer,ActionJumpToObject(oWayJump)) );
// un fade..
DelayCommand(7.3, FadeFromBlack(oPlayer,FADE_SPEED_MEDIUM));
return;
}


    DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
}
///////////////////////////////////////////////////////////////[ MAIN ]/////////

this should stop any error you got from this file, replace the area tag with your area name and way point tag with your waypoint tag.  I hope that helps a bit better.

Modifié par Greyfort, 19 février 2011 - 09:27 .


#18
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
So do you know why? Itried to modify it but without success....

#19
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
Yeah I figured it out, lol. thanks for all the help ;p. I know I was a pain the ass :D



Thanks alot really!

#20
Greyfort

Greyfort
  • Members
  • 234 messages
No problem we are here to help each other.

#21
Baragg

Baragg
  • Members
  • 271 messages
Just thought we could have simply made the GUI pop up an else statement.

#22
Dark Ruler

Dark Ruler
  • Members
  • 16 messages
How could we do that? explain your idea to me.... another thing, how could i change the reputation for the PC on the say hostile faction from 0 to 50 when dying and changing areas?... sorry for the trouble...

#23
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages




Neverwinter Nights: Factions, Shouts and Attacking My Enemy

#24
Baragg

Baragg
  • Members
  • 271 messages
Here is my earlier with the PopUp encased in an "else" node, that should make is so the GUI does not come up if the pc dies in that area. Also added in 2 possibilities for adjusting the rep. The one I did not comment out will adjust the PCs party's rep with the entire faction of the hostile faction.

[nwscript]
//::///////////////////////////////////////////////
//:: Death Script
//:: NW_O0_DEATH.NSS
//:: Copyright © 2008 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script handles the default behavior
that occurs when a player dies.

BK: October 8 2002: Overriden for Expansion

Deva Winblood: April 21th, 2008: Modified to
handle dismounts when PC dies while mounted.

*/
//:://////////////////////////////////////////////
//:: Created By: Brent Knowles
//:: Created On: November 6, 2001
//:://////////////////////////////////////////////

#include "x3_inc_horse"

/*
void ClearAllFactionMembers(object oMember, object oPlayer)
{
// AssignCommand(oMember, SpeakString("here"));
AdjustReputation(oPlayer, oMember, 100);
SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
object oClear = GetFirstFactionMember(oMember, FALSE);
while (GetIsObjectValid(oClear) == TRUE)
{
ClearPersonalReputation(oPlayer, oClear);
oClear = GetNextFactionMember(oMember, FALSE);
}
} */
void Raise(object oPlayer)
{
effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);

effect eBad = GetFirstEffect(oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPlayer)), oPlayer);

//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
{
//Remove effect if it is negative.
RemoveEffect(oPlayer, eBad);
}
eBad = GetNextEffect(oPlayer);
}
//Fire cast spell at event for the specified target
SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);
}


///////////////////////////////////////////////////////////////[ MAIN ]/////////
void main()
{
object oPlayer = GetLastPlayerDied();
object oHorse;
object oInventory;
string sID;
int nC;
string sT;
string sR;
int nCH;
int nST;
object oItem;
effect eEffect;
string sDB="X3SADDLEBAG"+GetTag(GetModule());

if (GetStringLength(GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE"))>0) sDB=GetLocalString(GetModule(),"X3_SADDLEBAG_DATABASE");
if (HorseGetIsMounted(oPlayer))
{ // Dismount and then die
//SetCommandable(FALSE,oPlayer);
//ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
DelayCommand(0.3,HORSE_SupportResetUnmountedAppearance(oPlayer));
DelayCommand(3.0,HORSE_SupportCleanVariables(oPlayer));
DelayCommand(1.0,HORSE_SupportRemoveACBonus(oPlayer));
DelayCommand(1.0,HORSE_SupportRemoveHPBonus(oPlayer));
DelayCommand(1.1,HORSE_SupportRemoveMountedSkillDecreases(oPlayer));
DelayCommand(1.1,HORSE_SupportAdjustMountedArcheryPenalty(oPlayer));
DelayCommand(1.2,HORSE_SupportOriginalSpeed(oPlayer));
if (!GetLocalInt(GetModule(),"X3_HORSE_NO_CORPSES"))
{ // okay to create lootable horse corpses
sR=GetSkinString(oPlayer,"sX3_HorseResRef");
sT=GetSkinString(oPlayer,"sX3_HorseMountTag");
nCH=GetSkinInt(oPlayer,"nX3_HorseAppearance");
nST=GetSkinInt(oPlayer,"nX3_HorseTail");
nC=GetLocalInt(oPlayer,"nX3_HorsePortrait");
if (GetStringLength(sR)>0&&GetStringLeft(sR,GetStringLength(HORSE_PALADIN_PREFIX))!=HORSE_PALADIN_PREFIX)
{ // create horse
oHorse=HorseCreateHorse(sR,GetLocation(oPlayer),oPlayer,sT,nCH,nST);
SetLootable(oHorse,TRUE);
SetPortraitId(oHorse,nC);
SetLocalInt(oHorse,"bDie",TRUE);
AssignCommand(oHorse,SetIsDestroyable(FALSE,TRUE,TRUE));
} // create horse
} // okay to create lootable horse corpses
oInventory=GetLocalObject(oPlayer,"oX3_Saddlebags");
sID=GetLocalString(oPlayer,"sDB_Inv");
if (GetIsObjectValid(oInventory))
{ // drop horse saddlebags
if (!GetIsObjectValid(oHorse))
{ // no horse created
HORSE_SupportTransferInventory(oInventory,OBJECT_INVALID,GetLocation(oPlayer),TRUE);
} // no horse created
else
{ // transfer to horse
HORSE_SupportTransferInventory(oInventory,oHorse,GetLocation(oHorse),TRUE);
//DelayCommand(2.0,PurgeSkinObject(oHorse));
//DelayCommand(3.0,KillTheHorse(oHorse));
//DelayCommand(1.8,PurgeSkinObject(oHorse));
} // transfer to horse
} // drop horse saddlebags
else if (GetStringLength(sID)>0)
{ // database based inventory
nC=GetCampaignInt(sDB,"nCO_"+sID);
while(nC>0)
{ // restore inventory
sR=GetCampaignString(sDB,"sR"+sID+IntToString(nC));
sT=GetCampaignString(sDB,"sT"+sID+IntToString(nC));
nST=GetCampaignInt(sDB,"nS"+sID+IntToString(nC));
nCH=GetCampaignInt(sDB,"nC"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"sR"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"sT"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"nS"+sID+IntToString(nC));
DeleteCampaignVariable(sDB,"nC"+sID+IntToString(nC));
if (!GetIsObjectValid(oHorse))
{ // no lootable corpse
oItem=CreateObject(OBJECT_TYPE_ITEM,sR,GetLocation(oPlayer),FALSE,sT);
} // no lootable corpse
else
{ // lootable corpse
oItem=CreateItemOnObject(sR,oHorse,nST,sT);
} // lootable corpse
if (GetItemStackSize(oItem)!=nST) SetItemStackSize(oItem,nST);
if (nCH>0) SetItemCharges(oItem,nCH);
nC--;
} // restore inventory
DeleteCampaignVariable(sDB,"nCO_"+sID);
//DelayCommand(2.0,PurgeSkinObject(oHorse));
if (GetIsObjectValid(oHorse)&&GetLocalInt(oHorse,"bDie")) DelayCommand(3.0,KillTheHorse(oHorse));
//DelayCommand(2.5,PurgeSkinObject(oHorse));
} // database based inventory
else if (GetIsObjectValid(oHorse))
{ // no inventory
//DelayCommand(1.0,PurgeSkinObject(oHorse));
DelayCommand(2.0,KillTheHorse(oHorse));
//DelayCommand(1.8,PurgeSkinObject(oHorse));
} // no inventory
//eEffect=EffectDeath();
//DelayCommand(1.6,ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer));
//DelayCommand(1.7,SetCommandable(TRUE,oPlayer));
//return;
} // Dismount and then die

// * increment global tracking number of times that I died
SetLocalInt(oPlayer, "NW_L_PLAYER_DIED", GetLocalInt(oPlayer, "NW_L_PLAYER_DIED") + 1);

// * BK: Automation Control. Autopcs ignore death
if (GetLocalInt(oPlayer, "NW_L_AUTOMATION") == 10)
{
Raise(oPlayer);
DelayCommand(1.0, ExecuteScript("crawl", OBJECT_SELF));
return; // Raise and return
}


// * Handle Spirit of the Wood Death
string sArea = GetTag(GetArea(oPlayer));
/*
if (sArea == "MAP_M2Q2F2" && GetDistanceBetweenLocations(GetLocation(GetObjectByTag("M2Q2F2_M2Q2G")), GetLocation(oPlayer))
{
int bValid;

Raise(oPlayer);
string sDestTag = "WP_M2Q2GtoM2Q2F";
object oSpawnPoint = GetObjectByTag(sDestTag);
AssignCommand(oPlayer,JumpToLocation(GetLocation(oSpawnPoint)));
return;

}
*/
// * in last level of the Sourcestone, move the player to the beginning of the area
// * May 16 2002: or the main area of the Snowglobe (to prevent plot logic problems).
// * May 21 2002: or Castle Never
if (sArea == "M4Q1D2" || sArea == "M3Q3C" || sArea == "MAP_M1Q6A")
{

//Raise(oPlayer);
//string sDestTag = "M4QD07_ENTER";
//object oSpawnPoint = GetObjectByTag(sDestTag);
// AssignCommand(oPlayer, DelayCommand(1.0, JumpToLocation(GetLocation(oSpawnPoint))));
// * MAY 2002: Just popup the YOU ARE DEAD panel at this point
DelayCommand(2.5, PopUpDeathGUIPanel(oPlayer,FALSE, TRUE, 66487));
return;
}

// * make friendly to Each of the 3 common factions
AssignCommand(oPlayer, ClearAllActions());
// * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}


if(sArea == "CAPTURE_AREA")//area where PC should be captured
{//Baragg
FadeToBlack(oPlayer);
Raise(oPlayer);
AssignCommand(oPlayer, ClearAllActions());
AssignCommand(oPlayer, JumpToLocation(GetLocation(GetWaypointByTag("CAPTURE_WAYPOINT_TAG"))));
FadeFromBlack(oPlayer);
//AdjustReputation(oPlayer, GetNearestPerceivedEnemy(oPlayer), 50);
AdjustReputationWithFaction(oPlayer, GetNearestPerceivedEnemy(oPlayer), 50);
}
else
{
DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
}

}
///////////////////////////////////////////////////////////////[ MAIN ]/////////
[/nwscript]

Modifié par Baragg, 20 février 2011 - 08:52 .


#25
Baragg

Baragg
  • Members
  • 271 messages
Might need to adjust those fade in, out to look right.