Aller au contenu

Photo

OK, I give up (n00b questions)


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

#1
Mighty Ponygirl

Mighty Ponygirl
  • Members
  • 6 messages
I do apologize in advance. I've googled to no avail. I'm trying to get back into scripting for NWN2 but there's a middle step that feels like it's missing -- a lot of the tutorials I'm reading are really basic "this is what a variable is" stuff or really niche cookbook-style scripts for doing specific things.

One big problem I'm having that is compounding this issue is that I can't seem to figure out the Script Logging option. It seems like I could muddle through a bit and just output a bunch of stuff to the log to see how the script is behaving, but I don't know what I'm doing wrong there. In the nwnplayer.ini script in the program directory, I've set Enable Logging=1, and then in the user directory's nwn2player.ini script, I've set  Scripts Print to Log=1 (and then Script Print to Screen=1 for good measure). I put PrintString (GetName(OBJECT_SELF) + " [description]") in a script I know is triggered but nothing is printing to the screen as far as I can tell and I have not been able to locate a log file.

OK, so my actual problem at hand (please don't laugh).

It's really quite standard: PC is charged with getting an item back from an NPC, and beating it out of him is an option, with the idea that he will surrender and re-open negotiations. So on the Conversation Node where the PC is all "let's do this then," I've attached an action for ga_attack (I've also tried ga_attack_target with the same result).

Then, on the object for the NPC, I've set him to immortal, and I've copied the ga_surrender_ud script and attached the new script to his onDamage action. Changes to this copy of the script: Before the ActionStartConversation function, I did a SetImmortal(OBJECT_SELF, FALSE) step just so that if you decide not to accept his surrender, you can finish him off. All other changes I made were an attempt to fix the problem I'm having -- which is that he'll stop fighting but stay aggro at me, and no trigger the conversation.  I'm using the stock object oPC declaration that came with the script.

Here's what I'm getting:
The onDamage trigger and SurrenderAllToEnemies appears to be working (he stop fighting when his HP drops below 25%).
Adding AdjustReputation (both him to me and me to him) don't seem to be doing anything, he's still aggro at me. I might not be doing this right, though, as there is very little on Factions/Reputation in all of the tutorials and resources I've found.
Adding SetIsTemporaryFriend(OBJECT_SELF, oPC, FALSE, 0) doesn't appear to work, nor does it work when I switch the first two parameters. ( I brought this out during the proces of trying to fix the previous "not working" thing).
I know it's at least hitting those items, because the SetImmortal function comes after that and it's working correctly (if I start fighting him again after he stops fighting but is still aggro at me, I kill him).
ActionStartConversation(oPC) is not working, and I'm assuming that it has to do with the fact that he's still aggro at me.

So I'm not really sure what's going on here, if I had to guess I would say it has to do with the declaration of oPC: GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC) since the stuff that doesn't seem to be working references oPC

So there's my problem -- any help would be much appreciated.

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
How are you defining oPC?


To make the NPC friendly, You could use:

SetStandardFaction()
SetFaction()

If you use SetStandardFaction, just set the NPC to STANDARD_FACTION_DEFENDER.
If you use SetFaction(), you will want to make a neutral faction that is neutral to everything (very useful by the way), then create a neutral creature with an easy to remember tag (I use "neutral_faction"). Hide that neutral creature in its own area. Then in the function SetFaction() you can reference the neutral faction creature and then the NPC will be neutral to everyone and stop being agressive. That also should allow the convo to fire.

If you still have problems, try posting the code so we can have a better look. Good luck!

#3
Mighty Ponygirl

Mighty Ponygirl
  • Members
  • 6 messages
Thanks, I'll give it a try and report back!

Andi n response to your question, the standard ga_surrender_ud script declares oPC as this:
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);

#4
kevL

kevL
  • Members
  • 4 075 messages
- just gonna put in a few ambiguous words about Logging.

The log file is found in your client temp folder, something like:
<user>\\local settings\\temp\\nwn2\\logs\\ nwclientLog1.txt

It gets deleted and re-created each time the game is run.


here's a couple of include files with debug functions:
ginc_debug
x0_i0_debug

there's also an interesting script:
x2_dm_aidebug


Now some thoughts on .ini files. I don't believe the nwn.ini or nwnplayer.ini have any effect at all anymore (i could be wrong). Further, I don't believe that nwn2.ini or nwn2player.ini in the ProgramFiles->NwN2 folder have any relevance either (maybe for multiplayer?). Mine are all dated to 2008 (ha).

Personally i Go with the MyDocs->NwN2 folder, nwn2.ini & nwn2player.ini

and in the latter I've got these turned on (I've got everything turned on, not that it does much, but I do get prints to Log)

[Game Options]
ClientChatLogging=1
Debug Text=1

[Server Options]
Scripts Print To Log=1
Scripts Print To Screen=1


The last two seem more important to running a server. But in SP I've never had a script print to screen nor gotten a notice of a script running in the logfile, unless it failed (which might be default anyways). I think the options under [Game Options] have more impact; chatting gets logged and so do PrettyMessages and stuff from the debug includes.


All that said, however, I find Debugging right to the chat window w/

SendMessageToPC(GetFirstPC(FALSE), "DEBUG this!!")

works wonders :)


Ps. i Think "Enable Logging" is an NwN1 (only) option


pps. if anyone sees errors, Pls point them out.

Modifié par kevL, 17 octobre 2011 - 08:43 .


#5
Mighty Ponygirl

Mighty Ponygirl
  • Members
  • 6 messages
... well, I'm halfway there. He's no longer aggro, and I can click on him to start talking to him again, but he's not starting the conversation himself.

Instead of using the _attack script to start battle, I'm changing his faction to Hostile. Here's what the last part of the script looks like:

            SurrenderAllToEnemies(OBJECT_SELF);
            object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
            SurrenderAllToEnemies(oPC);
            
            ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER);
            SetImmortal(OBJECT_SELF, FALSE);
                        
            ActionStartConversation(OBJECT_SELF);

(NOTE, originally, the ActionStartConversation was for oPC, but I changed that while trying to debug -- neither one seems to work. I've also tried indicating the conversation name as a string in the second parameter without any improvement).

#6
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Check out this thread and the script I posted there: http://social.biowar...84179/1#5291337

#7
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

Mighty Ponygirl wrote...

... well, I'm halfway there. He's no longer aggro, and I can click on him to start talking to him again, but he's not starting the conversation himself.

Instead of using the _attack script to start battle, I'm changing his faction to Hostile. Here's what the last part of the script looks like:

            SurrenderAllToEnemies(OBJECT_SELF);
            object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
            SurrenderAllToEnemies(oPC);
            
            ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_COMMONER);
            SetImmortal(OBJECT_SELF, FALSE);
                        
            ActionStartConversation(OBJECT_SELF);

(NOTE, originally, the ActionStartConversation was for oPC, but I changed that while trying to debug -- neither one seems to work. I've also tried indicating the conversation name as a string in the second parameter without any improvement).




I think for ActionStartConversation() to work like that, there needs to be a conversation referenced in the conversation field of the properties tab on the NPC, otherwise the conversation needs to be reference in the function.

#8
Mighty Ponygirl

Mighty Ponygirl
  • Members
  • 6 messages
BTW, the SendMessageToPC *is* a much better solution. :D

#9
Mighty Ponygirl

Mighty Ponygirl
  • Members
  • 6 messages
Well, he does have his own conversation referenced on his properties sheet (it's how you start the fight with him in the first place), but even tricking out the ActionStartConversation() script all the way to the last parameter
ActionStartConversation(OBJECT_SELF, "dudes_surrender_convo", TRUE, TRUE);
or
ActionStartConversation(oPC, "dudes_surrender_convo", TRUE, TRUE);

doesn't seem to be doing it.

:(

#10
Mighty Ponygirl

Mighty Ponygirl
  • Members
  • 6 messages
Knightmare! That did it! Thank you so much!

(OK, onwards and upwards!)

#11
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
No problem. Good luck with your next venture. :)