Server Totals
M'Chek - (2)
Wilderness - (0)
Ferrell - (0)
Elysia - (0)
Le'Or - (0)
Deglos - (0)
Visimontium - (0)
Underdark - (0)
Mikona - (0)
Total players: 2
Gallery

Links Menu

Attacking NPC triggers encounter?

Moderators: Nighthawk4, Dungeon Masters

Attacking NPC triggers encounter?

PostAuthor: szabot » Fri Apr 27, 2007 1:04 am

Can that be done, and if so, how?

What I have in mind is this: a PC is talking to an NPC; the conversation turns hostile; when the NPC turns hostile to the PC, this triggers an encounter, with a spawn point nearby. In other words, if you attack the NPC, or get him upset enough to attack you, a bunch of creatures spawn nearby to support him.

How do I do that? (And, I need details: *doesn't know scripting*)

Thanks. :)
User avatar
szabot
Team Member; Retired with Honors
 
Posts: 10694
Joined: Thu Jun 17, 2004 11:36 pm
Location: The Abyss
Timezone: Central (GMT-5)
DM Avatar: Wilsash

PostAuthor: Xiaou » Fri Apr 27, 2007 2:11 am

I know its possible and has been possible since the game came out. As to how its done..I dunno.
LMP: "That sounds ridiculous enough to be fan fiction." Zaroas: "Even worse; its canon."
User avatar
Xiaou
Team Member; Retired with Honors
 
Posts: 1859
Joined: Thu Jun 12, 2003 8:11 pm
Location: Denver?!
Timezone: GMT -7

PostAuthor: Alexandru Stanicu » Fri Apr 27, 2007 2:32 am

try playing with the conversation calling a script that spawns the critters. :)
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
 
Posts: 14082
Joined: Sun Oct 20, 2002 10:59 pm
Location: Texas
Timezone: CST
DM Avatar: The Hammer

PostAuthor: szabot » Fri Apr 27, 2007 2:55 am

Alexandru Stanicu wrote:try playing with the conversation calling a script that spawns the critters. :)


Ok, that's a good start, thanks. :)

I can have the NPC take an action when the PC says something, and that action can be to attack, which also fires an attack script.

Now the trick is to add to the script so it will summon creatures. That's the part I really have no idea about. :P

The generic "attack" script is:
#include "nw_i0_generic"

void main()
{

// Set the faction to hate the player, then attack the player
AdjustReputation(GetPCSpeaker(), OBJECT_SELF, -100);
DetermineCombatRound(GetPCSpeaker());
}


What do I add to summon critters?

However...hrm...I would also want the creatures to be summoned if a PC attacks the NPC without speaking to it first. Hm.
User avatar
szabot
Team Member; Retired with Honors
 
Posts: 10694
Joined: Thu Jun 17, 2004 11:36 pm
Location: The Abyss
Timezone: Central (GMT-5)
DM Avatar: Wilsash

PostAuthor: Alexandru Stanicu » Fri Apr 27, 2007 3:06 am

Code: Select all
void main()
{

object oPC = GetPCSpeaker();

object oTarget;
object oSpawn;
location lTarget;
oTarget = oPC;

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "nw_skeleton", lTarget);

oTarget = oSpawn;

SetIsTemporaryEnemy(oPC, oTarget);

AssignCommand(oTarget, ActionAttack(oPC));

AssignCommand(oTarget, DetermineCombatRound(oPC));

}



That snippet above will spawn a skeleton (bioware standard skele) next to the PC ad nthen it will attack.

A little tweaking and you should be good...you can also spawn them at a WP instead of next to the PC, and you cna add a visual effect if needed/wanted.

(creature must be specified by resref.)

As far as attacking when the NPC is attacked, just write the script and add it to the correct event (IIRC its something like on_attacked)
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
 
Posts: 14082
Joined: Sun Oct 20, 2002 10:59 pm
Location: Texas
Timezone: CST
DM Avatar: The Hammer

PostAuthor: szabot » Fri Apr 27, 2007 3:16 am

Ooooh, that's awesome, and it worked, too. :)

Could this part:
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "nw_skeleton", lTarget);


...be changed to trigger an encounter instead (so that it will summon multiple creatures, and they'll depend on the level of the PC)?

Hm, also: the NPC and summoned creature are attacking one another. Possibly because the NPC is commoner faction? Any way around that?
User avatar
szabot
Team Member; Retired with Honors
 
Posts: 10694
Joined: Thu Jun 17, 2004 11:36 pm
Location: The Abyss
Timezone: Central (GMT-5)
DM Avatar: Wilsash

PostAuthor: Alexandru Stanicu » Fri Apr 27, 2007 10:53 am

You can play with it firing trigger.

As for the NPC and the spawn attacking each other, try ahving the script change the NPC's faction to hostile. :)
I ain't as good as I once was, But I'm as good once as I ever was...


:devil: 4evar!
User avatar
Alexandru Stanicu
Legacy DM
Legacy DM
 
Posts: 14082
Joined: Sun Oct 20, 2002 10:59 pm
Location: Texas
Timezone: CST
DM Avatar: The Hammer

PostAuthor: Deider » Fri Apr 27, 2007 1:02 pm

Unless it's been changed in an update, the CreateObject function can't create triggers. This was a thorn in the side of folks who wanted to make their own custom encounter systems for many years. And in your case, you really don't want a trigger anyway, because for a trigger to be activated a PC has to step over it, and he can't step over a trigger if he's talking to an NPC, now can he? Better to use Alex's method, just substitute the skeleton for a function that calls a bunch of creatures to beat up on the PC.

Oh yeah, take this post with a grain of salt, because I'm drunker than Tigg's mom after she's gotten a new ass tattoo.
I like gnomes.
User avatar
Deider
Uber Posting Whor3
 
Posts: 7995
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8

PostAuthor: Papainhell » Fri Apr 27, 2007 1:55 pm

Create a normal spawn and set it to false, then when the conversation goes hostile set the spawn to true, then delay and reset back to false for reset.
Image
Playing as:
Master Odel Helmsplitter
Odel Helmsplitter- Hammer Fist Stylist, monk of The Order of The Dragon.
User avatar
Papainhell
Sage
 
Posts: 2141
Joined: Wed Oct 01, 2003 1:09 am
Location: Kodiak, Alaska (for now)
Timezone: Time?

PostAuthor: Nob » Fri Apr 27, 2007 2:00 pm

OnUserDefined.
"Andrinor grant me the patience not to kill those who screw things up through stupidity, the power to incinerate those who screw things up on purpose, and the wisdom to distinguish between one and the other." -The War Mage's Serenity Prayer
User avatar
Nob
Elder DM
Elder DM
 
Posts: 7630
Joined: Mon Jun 30, 2003 1:19 am
DM Avatar: Dead but still a Dreamer

PostAuthor: szabot » Fri Apr 27, 2007 4:02 pm

Thanks, all. I really need details, though. Basically, I need someone to write the script for me, because I do not know how to write them (is there a resource somewhere for learning how to do that?). All I can give in return is a heap of thanks and credit in the comments for the script. :)

So far, using what Alex posted, except: changed the skele out for an ooze, but I still want many oozes; added back in the AdjustReputation line, because with Alex's code, the NPC didn't turn hostile.

So:
Code: Select all
void main()
{

object oPC = GetPCSpeaker();

object oTarget;
object oSpawn;
location lTarget;
oTarget = oPC;

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "pud_blk_eld", lTarget);

oTarget = oSpawn;

SetIsTemporaryEnemy(oPC, oTarget);

AdjustReputation(GetPCSpeaker(), OBJECT_SELF, -100);

AssignCommand(oTarget, ActionAttack(oPC));

AssignCommand(oTarget, DetermineCombatRound(oPC));

}



Alexandru Stanicu wrote:As for the NPC and the spawn attacking each other, try ahving the script change the NPC's faction to hostile. :)


The code does make the NPC hostile, but does that mean his ~faction~ becomes hostile, too? If so, why would he and the ooze attack one another? If not, what line do I need to add to change his faction?

Deider wrote:Better to use Alex's method, just substitute the skeleton for a function that calls a bunch of creatures to beat up on the PC.


How do I make it summon a bunch of creatures rather than just one?

Papainhell wrote:Create a normal spawn and set it to false, then when the conversation goes hostile set the spawn to true, then delay and reset back to false for reset.


That's all Greek to me. :P

Thanks again. ;)
User avatar
szabot
Team Member; Retired with Honors
 
Posts: 10694
Joined: Thu Jun 17, 2004 11:36 pm
Location: The Abyss
Timezone: Central (GMT-5)
DM Avatar: Wilsash

PostAuthor: Kinarr » Fri Apr 27, 2007 4:14 pm

Sounds like a good opportunity for you to learn how to script. ;)

This is a little outdated, but still the best resource for learning how to script, and you'll always refer back to it:
http://nwnlexicon.avlis.org/lexicon/

Get the downloadable version here:
http://nwvault.ign.com/View.php?view=Ot ... ail&id=298
User avatar
Kinarr
CCC
CCC
 
Posts: 978
Joined: Sat Jun 26, 2004 5:39 pm
Location: Oregon
Timezone: GMT-8

PostAuthor: Tigg » Fri Apr 27, 2007 4:18 pm

Deider wrote:Oh yeah, take this post with a grain of salt, because I'm drunker than Tigg's mom after she's gotten a new ass tattoo.


OK liephus, I'll take it with a grain of salt, heh. Hopefully I'm immune to mom jokes by now. ;)
User avatar
Tigg
Elder Sage
 
Posts: 3491
Joined: Wed Feb 09, 2005 11:18 pm
Location: Into the sunset/Hyboria

PostAuthor: szabot » Thu Jun 07, 2007 5:36 pm

Thanks for all who have helped so far. I've got it to the below:

Code: Select all
#include "nw_i0_generic"

void main()
{

object oPC = GetPCSpeaker();

object oTarget;
object oSpawn;
location lTarget;
oTarget = oPC;

lTarget = GetLocation(oTarget);

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "pud_blk_eld", lTarget);

oTarget = oSpawn;

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ZEP_BLACKPUDDL", lTarget);

oTarget = oSpawn;

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "ZEP_BLACKPUDDL", lTarget);

oTarget = oSpawn;

ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_HOSTILE);

SetIsTemporaryEnemy(oPC, oTarget);

AssignCommand(oTarget, ActionAttack(oPC));

AssignCommand(oTarget, DetermineCombatRound(oPC));

}


It summons the creatures, turns the NPC to hostile (so he is the same faction as the summoned creatures), but he usually just stands there instead of attacking the PC (although sometimes he will start attacking). Any idea what's going on with him not always attacking right away?

Thanks!
User avatar
szabot
Team Member; Retired with Honors
 
Posts: 10694
Joined: Thu Jun 17, 2004 11:36 pm
Location: The Abyss
Timezone: Central (GMT-5)
DM Avatar: Wilsash

PostAuthor: PsiOmega » Thu Jun 07, 2007 5:41 pm

Try to add the line "AssignCommand(oTarget, ClearAllActions());" without the quotes before the other two AssignCommand lines.

That should sort it out.
User avatar
PsiOmega
CCC
CCC
 
Posts: 4901
Joined: Tue Jun 08, 2004 4:55 pm
Location: Sweden
Timezone: GMT+1/+2 (DST)

PostAuthor: szabot » Thu Jun 07, 2007 5:59 pm

That worked, thanks! :good:
User avatar
szabot
Team Member; Retired with Honors
 
Posts: 10694
Joined: Thu Jun 17, 2004 11:36 pm
Location: The Abyss
Timezone: Central (GMT-5)
DM Avatar: Wilsash

PostAuthor: girlysprite » Thu Jun 07, 2007 6:12 pm

Also lookfor Lilcas script generator in the nwnvault. great help for both simple and complex scripting.
Gaming doesn't make people voilent, lag does

<Dimotane> I think deep down, when we're honest with ourselves... we're all a pregnant male elf.
User avatar
girlysprite
Silver Contributor
 
Posts: 3661
Joined: Mon Apr 12, 2004 2:38 pm
Location: In my little pony ranch

PostAuthor: badjabadjabadja » Sun Sep 16, 2007 1:28 am

..translation from Girlysprite's post

look for Lilac Soul's script generator

//end translation

((sorries GS.. couldn't resist :P ))

This tool lets you create scripts even if you can't script at all!

:D

badjabadjabadja
QA Resource
 
Posts: 2144
Joined: Fri Jan 13, 2006 3:38 pm
Location: South Wales UK
Timezone: GMT (+1)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot]