Aller au contenu

Photo

Help Implementing Companion Behaviour during Puzzle Sequence


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

#1
UltimaPhoenix

UltimaPhoenix
  • Members
  • 24 messages
Hello all,

I have an interesting scripting challenge that I am trying to implement and your help would be greatly appreciated in helping me figure out how to do so properly.

There is a specific room with a puzzle the PC must solve. While in this room, the only companion at this point waits off to the side. If the player leaves the room before the puzzle is solved, the companion rejoins the party - and should wait off to the side again when the player returns. If the player solves the puzzle, the companion rejoins the party and offers praise. The companion also offers to solve the puzzle for the player, or will offer hints if the player wants to figure out the solution instead.

Is the above clear enough?

Any help is, again, greatly appreciated.
-UltimaPhoenix

#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
I would have a trigger fire when the PC enters the room that has the companion say something like "This is an interesting puzzle. I have some ideas about it if you want some help." Also set a global variable to indicate you are in the puzzle room. Have a trigger outside the room entrance reset the global variable when leaving the room.



Then have the companion's conversation check for the global variable, and if in the room handle the cases of asking for help and requesting the solution.



Regards

#3
UltimaPhoenix

UltimaPhoenix
  • Members
  • 24 messages
After a great deal of effort, I finally managed to figure out the solution by using global variables. Four, to be precise. One ensures that the intro to the area only occurs once. Another ensures that the right conversation plays when you are exiting without finishing the puzzle and upon your return, and another cancels out all conversations dealing with the puzzle once said puzzle is completed. The final variable alters your companion's attitude toward you based on whether you completed the puzzle yourself or not. I consider this a major accomplishment for me as I am brand-spanking new to modding. Minus my days with the StarCraft editor, of course.



Next, I need to know how to make the companion give you hints and offer to solve the puzzle when the player wants either service. This would occur when the player is inside the room with the companion waiting off to the side (the companion is removed from the party via ga_roster_remove). How do I implement this?

#4
Shaughn78

Shaughn78
  • Members
  • 637 messages
Back to the variables and checks, don't forget to do an on client enter script to check the variables and ensure everything is correct should the player save during the puzzle. When they load the save game you will want to make sure that everything is working correctly.



-Is the companion in the room with the player?

If they are the easiest thing would be to use their conversation. Make a new node that has conditions checking for the puzzle being in effect. (not in party & global variable set to true). Then the player would be able to talk to them about the puzzle and get help and hints dempending on what they have already figured out and done. Just make sure this node is towards the top.

#5
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

UltimaPhoenix wrote...

Next, I need to know how to make the companion give you hints and offer to solve the puzzle when the player wants either service. This would occur when the player is inside the room with the companion waiting off to the side (the companion is removed from the party via ga_roster_remove). How do I implement this?


Shaughn78's suggestion is sound.

If you want the hints convo to be a seperate convo itself, and not part of the NPC's normal/main convo, try a script like the following in the NPC's OnConversation script slot, some edits will be needed by you in the script:

void main()
{
object oPC = GetFirstPC();
object oNPC = OBJECT_SELF;
// If the PC is in the puzzle room and the puzzle is not yet solved
if((GetGlobalInt("In_Puzzle_Room") == 1) && (GetGlobalInt("Puzzle_Solved") != 1))
      {
      // Have the NPC begin the "Hints" convo when spoken to by PC
      // Clear all NPC actions first
      AssignCommand(oNPC, ClearAllActions());
      AssignCommand(oNPC, ActionStartConversation(oPC, "Name of Hint_Convo_Here", FALSE, FALSE, TRUE, FALSE)); 
       }

// Else execute the normal OnConversation script
// This should then fire the "normal" NPC convo if one is attached to their blueprint
else
      {
      ExecuteScript("nw_c2_default4", oNPC);
      }
}

Script here not tested but should compile.

Modifié par _Knightmare_, 26 janvier 2011 - 02:29 .


#6
UltimaPhoenix

UltimaPhoenix
  • Members
  • 24 messages
I should almost be done with this puzzle sequence, and thank you each for your help. You have each given me some great ideas and I would like to ensure you know that I appreciate your assistance.



The final thing I should need help with is the creation of the oncliententer script. How do I set it to look for and properly set the variables that I've set? I can imagine it would also be relatively simple to include the other few variables that I will set throughout the module, yes?

#7
Shaughn78

Shaughn78
  • Members
  • 637 messages
If this puzzle is in one area I would create the on client enter for that specific area. Getting the variables would be the same as any other script.

You need to id the PC, getfirstenteringPC

Check your variables to see if the puzzle is active and un solved.

Verify that the companion is not in the party and is a valid object or within a distance of his spot (I assume you used a waypoint to place him once removed from party)

If these things are in place have the client enter make them happen. Same with anothing else that should have happened or shouldn't happen yet.

This script will likely just be a backup to make sure everything is correct. The same thing could be done with a heart beat too.