I am trying to spawn a trigger on the PC when a condition is met (Creature life is low).
On my first try nothing happened. Is that because the PC is already in the trigger - thus not "entering it" to set it off?
Any clues or suggestions would be cool.
*A bit more history....
A NPC Succubus is talking to the PC if the conv goes the way of combat everyone fights - that works fine.
I want the Succubus to give up if she is going to die (hp / 5) ((20%)) and start a conversation.
SO - I put "gtr_speak_node" in the trigger blueprint.
The rest goes back to the beginning and the end where it does not work.
Thanks for any help.
Spawning A Trigger
Débuté par
Morbane
, mai 06 2011 10:37
#1
Posté 06 mai 2011 - 10:37
#2
Posté 06 mai 2011 - 10:42
I thought it would be good to use gtr_speak_node because of the condition of combat freezing in the paramwters and combat can go anywhere so the spawn idea came up.
I am sure there is a workaround - I am ready to listen to anything nice and neat.
Thanks Again.
I am sure there is a workaround - I am ready to listen to anything nice and neat.
Thanks Again.
Modifié par Morbane, 06 mai 2011 - 10:43 .
#3
Posté 06 mai 2011 - 11:36
Use the OnDamaged event for the succubus. Have the script check the current HP percentage and when it is below 20%, ClearAllActions(TRUE) for everybody and start the convo.
I recommend you set the immortal flag to TRUE on the succubus initially. This will keep it from being killed by a very powerful blow before the 20% condition is met. If you want to be able to kill the thing later, just script the flag to be set to false when the 20% condition is met.
**Edited: Immortal flag, not plot flag.
I recommend you set the immortal flag to TRUE on the succubus initially. This will keep it from being killed by a very powerful blow before the 20% condition is met. If you want to be able to kill the thing later, just script the flag to be set to false when the 20% condition is met.
**Edited: Immortal flag, not plot flag.
Modifié par M. Rieder, 06 mai 2011 - 04:58 .
#4
Posté 06 mai 2011 - 11:37
...I think you could also do something similar with the ondeath event and just heal the NPC back to 1 hp and start the convo. I do this in the campaign I'm working on, but it was awhile back and I cant remember exactly how I did it (a sign that I am taking waaaayyy too long to finish!)
If you run into troubles, let me know and I'll look at the toolset when I have it in front of me.
If you run into troubles, let me know and I'll look at the toolset when I have it in front of me.
#5
Posté 06 mai 2011 - 11:38
Looking back at the question, I am wondering if I even answered it. My intent was to say to not try to start the convo with a trigger, but to script the conversation start and use the code to clear the combat state. Hope that makes sense.
#6
Posté 06 mai 2011 - 12:21
Thanks Matt - that all sounds good - all 3 entries. I will stick it all together and update this thread with how it turns out.
Thanks again.
ps
It is really late here so that update will be delayed about 10 hours or so, provided I actually go to sleep and not toolset until dawn.
Thanks again.
ps
It is really late here so that update will be delayed about 10 hours or so, provided I actually go to sleep and not toolset until dawn.
Modifié par Morbane, 06 mai 2011 - 12:24 .
#7
Posté 06 mai 2011 - 12:55
Here's a copy of one of my old posts that pretty much answers the same question, you will need to just edit the hitpoint calculations if you want. As it is, they will begin the convo when reduced to 5 or less hitpoints. The OnDamaged event gets fired AFTER hit point damage has been applied, so each time it should detect their current HP level after being hit for damage:
Here's an example for you. For this to work, set the NPC as Immortal = True in its properties. This will allow the NPC to take damage down to 1 hit point but not be killed.
In the NPCs OnDamaged script slot, have something like the following:
If you want the NPC to later become killable you will need to remove the Plot Flag when the time comes, and if you want them to become Hostile again you will need to later alter their faction back to Hostile
Here's an example for you. For this to work, set the NPC as Immortal = True in its properties. This will allow the NPC to take damage down to 1 hit point but not be killed.
In the NPCs OnDamaged script slot, have something like the following:
void main()
{
object oSelf = OBJECT_SELF;
location lLoc = GetLocation(oSelf);
int nHP = GetCurrentHitPoints(oSelf);
// If the NPC currently has 5 or Less Hit Point left
if(nHP <= 5)
{
// Search through all creatures in a 20 meter radius centered on oSelf
object oNPC = GetFirstObjectInShape(SHAPE_SPHERE, 20.0f, lLoc, FALSE, OBJECT_TYPE_CREATURE);
while(GetIsObjectValid(oNPC))
{
// Clear combat states for every creature found in search including PC party members
AssignCommand(oNPC, ClearAllActions(TRUE));
// Change NPCs to Commoner Faction so no longer hostile
if((!GetIsPC(oNPC)) && (!GetIsOwnedByPlayer(oNPC)) && (!GetIsPlayerCreated(oNPC)))
{
ChangeToStandardFaction(oNPC, STANDARD_FACTION_COMMONER);
}
oNPC = GetNextObjectInShape(SHAPE_SPHERE, 20.0f, lLoc, FALSE, OBJECT_TYPE_CREATURE);
}
// Have the NPC begin a conversation with PC
object oPC = GetFirstPC(TRUE); // In a SP module, this is the player’s originally created character
AssignCommand(oSelf, ActionStartConversation(oPC, "convo_name_here", FALSE, FALSE, TRUE, FALSE ));
}
// Else NPC is not yet at 5 or less Hitpoints, so fire normal OnDamaged script
else
{
ExecuteScript("nw_c2_default6", oSelf);
}
}If you want the NPC to later become killable you will need to remove the Plot Flag when the time comes, and if you want them to become Hostile again you will need to later alter their faction back to Hostile
Modifié par _Knightmare_, 06 mai 2011 - 01:01 .
#8
Posté 07 mai 2011 - 12:16
Thanks KM - I was hoping to hear from you. i'll plug that in a let you know...
#9
Posté 07 mai 2011 - 12:44
There is also a standard script for this. Can't remember the name, it was something unexpected. If I find it tonight I'll post it.
#10
Posté 07 mai 2011 - 03:39
Kaldor - I thought I remembered the same thing - that there was a standard script - but couldn't find it.
KM - I plugged in your script and tweaked it a bit - the encounter is now running as it should. Thanks!
KM - I plugged in your script and tweaked it a bit - the encounter is now running as it should. Thanks!
Modifié par Morbane, 07 mai 2011 - 03:39 .
#11
Posté 07 mai 2011 - 05:11
A number of old nwn1 standard scripts can be found by using open conversation/script and putting in "surr". The nwn2 specific standard scripts are the spawn script gb_surrender_sp that turns on the check for the on damaged event and the gb_surrender_ud script that causes the surrender to occur. I use a modified version of that script in King's festival called bb_surrender_ud that uses the changetostandardfaction function instead of the surrenderalltoenemies function.
Regards
Regards
#12
Posté 07 mai 2011 - 06:59
Nice
Well done Kaldor!
Well done Kaldor!
#13
Posté 07 mai 2011 - 11:44
NP there Morbane, glad it worked out for you!





Retour en haut







