Aller au contenu

Photo

A Noob in Perial: Requesting Simple Scripts


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

#1
Leyf

Leyf
  • Members
  • 28 messages
 Hello fellow NWN2 Modders! I have been vigorously trying to create my campaign and it is going very well so far! But I need help scripting some things that I know are easy, but I just cant figure out how to do it!

SCENARIO ONE: Phillip the cat is standing idle with a conversation ready, the PC talks to philip and he replies "No, I must go." At this point I want Phillip to start walking away down a desired Waypoint. I can't figure out how to create this script, or how to edit a script to add stuff into it (if necessary)

QUESTION: Im not sure if Camera Views are script based, but I would very much like to know how to use cameras, even in the simplest way

QUESTION: How do you make a cutscene?

QUESTION: How do i make an NPC only killable by a certain weapon?

SCRIPTING QUESTION: How do i have a NON Hostile NPC, become Hostile once somthing wrong in a Conversation has been chose? ie. "Hi, you're fat" After the PC says that, I want the normally friendly NPC to become hostile.

Any help is needed, I'd appreciate all the help possible or if you can provide an area where I can read up and learn this all myself. (I have already read the NWNToolset tutorial)

THANKS!

Modifié par Leyf, 30 janvier 2011 - 06:28 .


#2
El Condoro

El Condoro
  • Members
  • 148 messages
For Phil the Cat.

This is what I use for my merchants after they have pestered the PC and then move back to a Wp tagged "wp_origin" (I have made a blueprint of this, too). Put it in the last conversation node action list. They also face the direction/facing of the WP.

// After conversation NPC will return to original place
void main()
{
 object oNPC = OBJECT_SELF;
 object oOrigin = GetNearestObjectByTag("wp_origin");
 float fOrigin = GetFacing(oOrigin);
 
 ActionMoveToObject(oOrigin,FALSE,0.0);
 ClearAllActions();
 SetFacing(fOrigin);
}

#3
Leyf

Leyf
  • Members
  • 28 messages
thanks a bunch!

#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages

Leyf wrote...

SCENARIO ONE: Phillip the cat is standing idle with a conversation ready, the PC talks to philip and he replies "No, I must go." At this point I want Phillip to start walking away down a desired Waypoint. I can't figure out how to create this script, or how to edit a script to add stuff into it (if necessary)

On the conversation node use action script ga_move. If you want them to vanish after getting to the waypoint then use ga_force_exit.  There are many ga_ and gc_ scripts built in to help with common actions in conversations.

QUESTION: Im not sure if Camera Views are script based, but I would very much like to know how to use cameras, even in the simplest way

Camera views can be set in the conversations on each node.  You place the camera and name it and then refer to it in the conversation. Take a look at any cutscene in the OC to see how it is done.

QUESTION: How do you make a cutscene?

Cutscenes are really just conversations that have the Neverwinter Nights 1-style Dialog option in the properties of the conversation set to False. For a tutorial on this try the Cutscene Tutorial by jackyo123.

QUESTION: How do i make an NPC only killable by a certain weapon?

You would set the immortal property to true so they cannot be killed. Then you would provide an on hit script that checks to see what they were hit with. If it is the weapon you care about (by tag if a specific weapon or base item type if it is a family of weapons) then you allow the damage and set them to dead if the damage exceeds their hit points.  I posted some scripts for chopping down trees here. Not exactly the same situation but similar idea.

SCRIPTING QUESTION: How do i have a NON Hostile NPC, become Hostile once somthing wrong in a Conversation has been chose? ie. "Hi, you're fat" After the PC says that, I want the normally friendly NPC to become hostile.


See next post

Regards

Modifié par Kaldor Silverwand, 31 janvier 2011 - 01:58 .


#5
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages

// ga_bb_go_hostile

// By Brendan Bellina, Feb 2009

/*

	Based on x0_c2_go_hostile, which makes a creature hostile and killable

	Useful for hostiles that you want to have temporarily friendly --

	put them in a non-hostile faction, then use this to make them attack.

	Also unsets the plot flag and immortal flag.

	

	Parameters:

		string sTargetTag: tag of the creature to go hostile

			Defaults to OWNER

		string sShout: string to shout out

			If not passed as parm can be set by local variable AttackShout on the owner

			Defaults to none

*/



#include "ginc_param_const"

#include "nw_i0_generic"

	

void main(string sTargetTag = "", string sShout = "")

{

	object oPC =(GetPCSpeaker()==OBJECT_INVALID?OBJECT_SELF:GetPCSpeaker());

    object oTarget = GetTarget(sTargetTag, TARGET_OWNER);

	if (sShout == "") { sShout = GetLocalString(oTarget, "AttackShout"); }

	if (sShout != "") { AssignCommand(oTarget, ActionSpeakString(sShout)); }

	SetImmortal(oTarget, FALSE);

	SetPlotFlag(oTarget, FALSE);

	ChangeToStandardFaction(oTarget, STANDARD_FACTION_HOSTILE);

	AdjustReputation(oPC, oTarget, -100);

	DelayCommand(0.5, DetermineCombatRound(oPC));

	DelayCommand(0.7, AssignCommand(oTarget, ActionSpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK)));

}


Modifié par Kaldor Silverwand, 31 janvier 2011 - 01:59 .


#6
Leyf

Leyf
  • Members
  • 28 messages
WOW, thank you so much!

#7
Leyf

Leyf
  • Members
  • 28 messages
This is extremely helpful but I don't know how to edit the script above :( I've tried many times to add the appropriate values to the script like above "sTargetTag" is the Tag of the creature, now where do I insert the creatures tag to let the script know what im talking about?

#8
Morbane

Morbane
  • Members
  • 1 883 messages
void main(string sTargetTag = "", string sShout = "")

inside the double quotes - put the npc's tag (or creature) in sTargetTag = " "

(It mentions this in the script comments at the top)

I should mention, that the script is for use in a conversation - but you can get it to work using my suggestion.

Modifié par Morbane, 31 janvier 2011 - 12:09 .


#9
Morbane

Morbane
  • Members
  • 1 883 messages
OR - you can make a wrapper - like so::

[new script]

void main()
{
ga_bb_go_hostile("npc tag", "something for them to say");
}

Just like that... but Kaldor's script above needs to have the name given in its comments and have been compiled in the tool set

Modifié par Morbane, 31 janvier 2011 - 12:15 .


#10
Leyf

Leyf
  • Members
  • 28 messages
So it would look like (string sTargetTag = "Monster") for an example anyway...

also, when im done editing a script, do i Save and Compile, rename, then just use the edited script right?

#11
Morbane

Morbane
  • Members
  • 1 883 messages
thats about it - but you should rename it first to be sure all remains in working order - the TS can be testy..

#12
MasterChanger

MasterChanger
  • Members
  • 686 messages

Leyf wrote...

So it would look like (string sTargetTag = "Monster") for an example anyway...
also, when im done editing a script, do i Save and Compile, rename, then just use the edited script right?


No, you're confusing defining/declaring a function with using that function as it's been defined. KnightMare's tutorial will explain the difference.

Modifié par MasterChanger, 31 janvier 2011 - 03:39 .


#13
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
You don't edit the script at all. Just create a new campaign script in toolset, name it ga_bb_go_hostile, paste in my code, and click the compile button. Done.  It is a general purpose conversation action script. You pass it parameters you do not need to hard-code values in it.

In your conversation, on the node upon you wish the creature to go hostile, add an action, specify ga_bb_go_hostile as the script. That's it. It defaults to the owner of the conversation. If you want a creature other than the owner of the conversation to go hostile then click the refresh button and put in the tag of the creature you want.

Regards

Modifié par Kaldor Silverwand, 31 janvier 2011 - 08:32 .


#14
Leyf

Leyf
  • Members
  • 28 messages
Ohh, I understand now! Jeez Kaldor, you're my savior yet again >.<



If you dont mind, I'd like to contact you in the future if I run along any snags again. But I took all your advice and im reading the guides you've suggested.

#15
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
Glad to help. Welcome to the wonderful world of NWN2 scripting. You can check in, but very few check out. Plan for a long stay.

#16
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
In another thread Shallina mentioned a standard script ga_hostile. I haven't looked but that probably does most of what mine does. It probably just doesn't do the shout that mine allows. If it does all you need then you can just use it and you don't have to mess with my script at all.

#17
Sgt KillEmAll

Sgt KillEmAll
  • Members
  • 11 messages
I must say, I've used Kaldor's hostile script and I liked it.

I like the shout part. Something about having my uber evil boss yell "Now you die!!" when he attacks that just makes me all squishy inside :)

#18
Leyf

Leyf
  • Members
  • 28 messages
Nice!

#19
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
;)

#20
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I can't find a ga_hostile function anyway. There is x0_c2_go_hostile which I based my script on. Besides the lack of a shout, it causes the NPC to attack the nearest player character rather than the speaker.

There is also the standard script x0_d1_go_hostile which lacks the shout and causes the NPC to attack the speaker.

My script attacks the speaker and has the option of a shout.

Here is a script that will attack the nearest PC and has the option of a shout:

// ga_bb_go_hostile_nearest
// By Brendan Bellina, Jan 2011
/*
	Based on x0_c2_go_hostile, which makes a creature hostile and killable
	Useful for hostiles that you want to have temporarily friendly --
	put them in a non-hostile faction, then use this to make them attack.
	Also unsets the plot flag and immortal flag.
	
	The creature will attack the nearest player character.
	
	Parameters:
		string sTargetTag: tag of the creature to go hostile
			Defaults to OWNER
		string sShout: string to shout out
			If not passed as parm can be set by local variable AttackShout on the owner
			Defaults to none
*/

#include "ginc_param_const"
#include "nw_i0_generic"
	
void main(string sTargetTag = "", string sShout = "")
{
    object oTarget = GetTarget(sTargetTag, TARGET_OWNER);
	if (sShout == "") { sShout = GetLocalString(oTarget, "AttackShout"); }
	if (sShout != "") { AssignCommand(oTarget, ActionSpeakString(sShout)); }
	SetImmortal(oTarget, FALSE);
	SetPlotFlag(oTarget, FALSE);
	ChangeToStandardFaction(oTarget, STANDARD_FACTION_HOSTILE);
    object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
	AdjustReputation(oPC, oTarget, -100);
	DelayCommand(0.5, DetermineCombatRound(oPC));
	DelayCommand(0.7, AssignCommand(oTarget, ActionSpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK)));
}

There is always more than one way to do things when it comes to NWN2 script.

Regards

Modifié par Kaldor Silverwand, 01 février 2011 - 04:04 .


#21
Leyf

Leyf
  • Members
  • 28 messages
awesome! So if you say somthing wrong, I can have an NPC attack! woo!