Trolls script

Hi guys, i was wondering if someone knows where’s stored the script or whatever that makes trolls unkillable except fire/acid in nwn2. I saw that if i simply remove the basic damage script they become simply immortal then in game… Even if i put the default nw_c2_default6 whatsoever in the creature blueprint!

The ‘immortal’ property of trolls is set to TRUE by default. That property is set to FALSE through the ‘gb_troll_dmg’ OnDamaged script if it has taken fire/acid damage greater than is current HP. Then an EffectDeath is applied to it, killing it for good.

1 Like

LOL. And to think i changed the scripts there, and i’ve never noticed that. Aging is really catching up on me i suppose. Anyway, at this point it’s better edit the script rather than remove it. Otherwise, anytime someone uses trolls in a module i should have to go and check for it. Thanks for the answer by the way.

2 Likes

By the way, is there some small tutorial on how add a scripted effect to the special propriety that you can add to objects? I’m completely noob when it comes to stuff like that.

Not sure exactly what you mean here…You want to add an effect to an item/object through scripting? Don’t think there’s any tutorials for these kind of things, but if you are a bit more specific about what effect you want to add to what object maybe some of us here on the vault forums can help you.

Sure. I was replaying the wonderful halloween 2008 project, and old Elysian gave me the idea. It would be nice to make the chime of opening working like the flute he made on his halloween module. Like when the character uses it, he begins to play, start a melody and then you got the effect, like knock or whatsoever.
Alas, i have no idea how add those things. I could port models into many games without a problem, but it seems i couldn’t compile a script even if my life would depending on it…
I know that in the toolset when you create a new object, in “properties” you can add “unique effect” which is a scripted effect, but i have no idea how then you add the script to that very effect.

2 Likes

usually its done w/ tag-based scripting (nwn2-style, is based on nwn1-style).

Basic Scripting (not so basic) | The Neverwinter Vault

An item’s CastSpell:UniquePower can fire a script i_tagofitem_ac when player activates the item. It can be a bit complicated to hook up (even before writing the script). but Here’s a simple script that you can use to see if/when the item and module-scripts have been wired properly enough to start your custom code →

// 'i_tagofitem_ac'

void main()
{
    SendMessageToPC(GetFirstPC(FALSE), "i_tagofitem_ac");
}

(check that your toolset Options|Autosave is turned off – its on by default)

 
… poke away at it and get back in touch with whatever results :|

2 Likes

If you try kevL_s’ script and it works you can maybe then change it to something like this:

// 'i_tagofitem_ac'

void PlayCustomAnimationVoid(object oObject, string sAnimation, int iLoop = 1, float fSpeed = 1.f)
{
	PlayCustomAnimation(oObject, sAnimation, iLoop, fSpeed);
}

void main()
{

object oFluteplayer = GetObjectByTag("tagoffluteplayer"); //Change the tag to the tag of the flute player

PlayCustomAnimationVoid(oFluteplayer, "playflute");


}

EDIT: I don’t remember if you get a sound from the flute by using my script but otherwise you could try this (the additional code here is made by travus):

// 'i_tagofitem_ac'

void PlayCustomAnimationVoid(object oObject, string sAnimation, int iLoop = 1, float fSpeed = 1.f)
{
	PlayCustomAnimation(oObject, sAnimation, iLoop, fSpeed);
}

void main()
{

object oFluteplayer = GetObjectByTag("tagoffluteplayer"); //Change the tag to the tag of the flute player

PlayCustomAnimationVoid(oFluteplayer, "playflute");

	object oIP = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_ipoint ", GetLocation(oFluteplayer));
								//	do not remove this space	^ 	
	string sWave = "gui_flutesong02";	// <--- sound file name

	DelayCommand(0.2f, AssignCommand(oIP, PlaySound(sWave, TRUE)));	
	SetPlotFlag(oIP, FALSE);
	DestroyObject(oIP, 0.3f);	


}
1 Like

What really bothers me is also that at least in the previous toolset (the nwn1 one) there was the option of open and edit scripts, but in this crappy nwn2 toolset i don’t even uncerstand how to load them. For making things quicker i simply exported the flute and then i exported the script after having removed the not necessary parts, ending with something more or less as you showed here, but then in game, nothing?
More important then: for exporting a script you exporting it like .erf? Then you put it in override or…?
And it auto loads if the names are correct?

Hmm, it’s quite easy to create new scripts and edit them…I have worked extremely little in the NWN1 toolset but from what I have been able to tell, opening and creating scripts are just as easy in both the toolsets.

Just doulbe click in the white area when in “Scripts” and you create a new script.

I highly recommend using and installing this:
https://neverwintervault.org/project/nwn2/other/tool/powerbar

Here’s a good basic tutorial:

EDIT: For exporting scripts you can export them as a .erf file, but if you use Directory Mode (highly recommend that) you can just move scripts from your directory module folder to another directory module folder. Or, even better, if you use Campaign Mode you put all your scripts in the Campaign folder and you can move scripts back and forth from there. It’s a bit hard to explain if you haven’t got into the basics of the Toolset yet, so watch the video first, I think.
You can put scipts in the override too, but I really don’t recommend that.

@andgalf i assume this is for player-usage rather than building a module … (hence i suggest /override so its available in all modules/campaigns)
 

Unfortunately the Chime of Opening doesn’t use a script; it has itemproperty CastSpell:Knock instead of CastSpell:UniquePower.

The Chime item could be copied to your MyDocs/Nwn2/Override folder and modified, but that doesn’t guarantee that when you get a Chime ingame it will be your custom version.

if you want to try it anyway, you don’t need to fool around with .ERFs. Find the Chime in blueprints, rightclick, CopyBlueprint->Global. This makes a copy of the .UTI file to your MyDocs/Nwn2/Override folder as x0_it_mthnmisc040.UTI. You should now see 2 ChimesOfOpening in the toolset’s blueprints panel.

Select the one with the extra “0” on the end: x0_it_mthnmisc040

Go to its Properties|Behavior|ItemProperties slot. Remove CastSpell:Knock and add CastSpell:UniquePower. Click the itemproperty and set its charge/usage to what you want. Then select it in the blueprints panel again and right click → SaveToFile, navigate to your MyDocs/Nwn2/Override folder and overwrite the previous file: x0_it_mthnmisc040.UTI.

If you want a better name for the resref, under its Properties|Basics, change the ResourceName, Tag, and TemplateResref slots to something like “chime_uniquepower”. This changes the filename from x0_it_mthnmisc040.UTI to chime_uniquepower.UTI.

do right click → SaveToFile again to update the blueprint. Now you need a script for it …

// 'i_chime_uniquepower_ac'
/*
	Item event script OnActivateItem.
*/

void PlayFluteAni(object oActivator)
{
	PlayCustomAnimation(oActivator, "playflute", FALSE);
}

void main()
{
	object oActivator = GetItemActivator();

	AssignCommand(oActivator, PlaySound("gui_flutesong02"));
	DelayCommand(0.75f, PlayFluteAni(oActivator));
}

save that in MyDocs/Nwn2/Override folder (or better in a subfolder, along with your .UTI file) as i_chime_uniquepower_ac.nss (or use whatever tag you’ve chosen, between i_ and _ac)

You’ll need to close and reopen the toolset for the toolset to pick up that new script.

Then do File|Open Conversation/Script and browse to the script (or use the FileFilter). Press Save & Compile [F7] and an .ncs file ought to appear alongside the .nss file in your folder.

Load the game and open the console →

`
debugmode 1
giveitem chime_uniquepower
debugmode 0
`

all things equal … enjoy chime that sounds like a flute …

1 Like

Oh, sorry. My mistake.

Absolutely. Totally agree.

1 Like

oh, one thing i forgot in all that …

actually cast a knock spell …

 
/l8r tho