Author Topic: Ending a module  (Read 835 times)

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« on: December 30, 2011, 05:24:03 pm »


               Okay, this may sound like a dumb question but how exactly do you end a module? I am working on a series of modules and have finished the first one. I'd like to be able to have the game save the character information at the end so players can carry on with the same character. I have looked at toolset manuals and searched online to no avail. I know it will require scripting and I have LilacSoul's Script Generator. Can I do this with the script generator? Any help is appreciated. Thanks! '<img'>
               
               

               


                     Modifié par UnrealJedi, 30 décembre 2011 - 05:24 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Ending a module
« Reply #1 on: December 30, 2011, 05:59:58 pm »


               You can just take the characters to the new module with the scripting function StartNewModule
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #2 on: December 31, 2011, 12:41:59 am »


               But what if the second module is not finished? I have seen others release modules in a series one at a time. They released the first while working on the second and so on....if there is no way to have the game save their character that's fine  but how can I end the module as if it were a standalone?

Thanks!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Ending a module
« Reply #3 on: December 31, 2011, 01:19:01 am »


               The Player can manualy save there character to the HD anytime they want to by simply clicking the options menu and selecting "save Character"

If you wanted to force the game to do that in a script, you would use ExportSingleCharacter
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Ending a module
« Reply #4 on: December 31, 2011, 02:20:40 am »


               This might be what you are looking for.  If the module doesn't exist it saves and exports the character.  You can adjust the behavior to your liking.


//Add these two lines to the OnClientEnter script
object oPC = GetEnteringObject();
if(GetLocalInt(oPC, "JUMPTONEXTMODULE"){ExecuteScript("transfer", oPC); return;}

---------------------------------------------------------

//Script name "transfer"
//Call this script both at the point of module completion and in OnClientEnter as noted above

void SaveAndEnd()
{
DoSinglePlayerAutoSave();
ExportSingleCharacter(OBJECT_SELF);
EndGame("INSERT_END_MOVIE_HERE");
}

void main()
{
StartNewModule("INSERT_NEXT_MODULE_HERE");
SetLocalInt(OBJECT_SELF, "JUMPTONEXTMODULE", TRUE);
DelayCommand(1.0, SaveAndEnd());
}
               
               

               


                     Modifié par WhiZard, 31 décembre 2011 - 02:21 .
                     
                  


            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #5 on: December 31, 2011, 04:01:52 am »


               Thanks Lightfoot and WhiZard. This helps greatly. Thanks a bunch!
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #6 on: January 26, 2012, 03:15:52 pm »


               Okay, I have been trying to use the scriptt WhiZard posted but I am confused as to why I need an OnClientEnter script. According to the NWN Lexicon, OnClientEnter scripts do not fire in single player modules (unless I am misreading the Lexicon).

I simply need a script that fires when a PC crosses a trigger. The way I am ending the module is that the PC falls into a magically-induced sleep. After the sleep happens, the script needs to save the character, run an ending movie I have created that simply says "To Be Continued...", and then return to the main menu. Instead of jumping to the next module I want to give the player the option of loading up the next one or taking a break and coming back to play the next module at a later time.

I have a script that successfully puts the PC to sleep but then nothing else happens. The PC just lays there asleep while his/her henchman just stands there. Nothing else happens.

I am at work or I would post my script. I can do that later tonight after I get home if it would help.

What am I missing?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Ending a module
« Reply #7 on: January 26, 2012, 04:17:16 pm »


               What Wiz's script is set op to do is End the module when that trans is crossed.   It the Next module in the set is in the players module vault it will start that module.   The reason is If there is no module yet and the player starts this module later with the character that compleated the module.   It will automaticly load the next module as soon as the Player fires up this module again without having to try the transistion again.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #8 on: January 26, 2012, 05:59:52 pm »


               Ah, that makes sense. Thanks!
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #9 on: February 01, 2012, 03:12:54 am »


               Okay, I am STILL having some problems with these scripts so
I am posting them here. I cannot recall how to do it in a window so I am
posting them in the body of this entry.



The OnClientEnter Script (compiled without a problem, but will it
still do its thing???)

/*69_client_enter

 OnClientEnter Module Event

 Checks for Leadership, if TRUE sets maximum
henchmen on PC

 Created by: 69MEH69

 Created on: Sep2004

*/

#include "69_hench_lib"

void main()

{

  object oPC = GetEnteringObject();

  int nLeadership = GetLocalInt(GetModule(),
"nLeadership");

  if(nLeadership == 1)

  {

    //SendMessageToPC(oPC, "Leadership =
1"); //Test

    SetMaxHenchmen69(oPC);

 object oPC =
GetEnteringObject();

if(GetLocalInt(oPC,
"JUMPTONEXTMODULE")){ExecuteScript("transfer", oPC);
return;}

}}



The Endgame Trigger Script (did not compile; I have notated where
the compiler states the issue is and the error)

/*   Script generated by

Lilac Soul's NWN
Script Generator, v. 2.3



For download info, please visit:

http://nwvault.ign.c...=4683&id=625    */

 //Put this
script OnEnter

void main()

{

 object oPC =
GetEnteringObject();

 if
(!GetIsPC(oPC)) return;

 if
(GetLocalInt(oPC, "talkedtokriston")!= 2)

   return;

object oTarget;

oTarget = oPC;

effect eEffect;

eEffect =
EffectSleep();

eEffect =
SupernaturalEffect(eEffect);



ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget, 60.0f);



DoSinglePlayerAutoSave();

ExportSingleCharacter(OBJECT_SELF);

EndGame("INSERT_END_MOVIE_HERE");

}

StartNewModule("INSERT_NEXT_MODULE_HERE"); 
//compiler doesn't like this line and
gives an INVALID DECLARATION TYPE error

SetLocalInt(OBJECT_SELF,
"JUMPTONEXTMODULE", TRUE);

DelayCommand(1.0,
SaveAndEnd());









If I put in a "void main()" before the bolded line above then the
compiler gives me an UNKNOWN STATE IN COMPILER ERROR.



Any insight is greatly appreciated!



Thanks guys!
               
               

               


                     Modifié par UnrealJedi, 01 février 2012 - 03:18 .
                     
                  


            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #10 on: February 01, 2012, 03:19:07 am »


               Apologies it is so spread out...I tried getting the formatting right. It keeps screwing up on me.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Ending a module
« Reply #11 on: February 01, 2012, 11:15:30 pm »


               

UnrealJedi wrote...

Okay, I am STILL having some problems with these scripts so
I am posting them here. I cannot recall how to do it in a window so I am
posting them in the body of this entry.

The OnClientEnter Script (compiled without a problem, but will it still do its thing???)
/*69_client_enter
 OnClientEnter Module Event
 Checks for Leadership, if TRUE sets maximum henchmen on PC
 Created by: 69MEH69
 Created on: Sep2004
*/

#include "69_hench_lib"

void main()
{
  object oPC = GetEnteringObject();
  if(GetLocalInt(oPC, "JUMPTONEXTMODULE")){ExecuteScript("transfer", oPC); return;}
  int nLeadership = GetLocalInt(GetModule(), "nLeadership");
  if(nLeadership == 1)
  {
    //SendMessageToPC(oPC, "Leadership = 1"); //Test
    SetMaxHenchmen69(oPC);
  }
}

You have defined oPC twice. All you need to do is put the conditional immediately after the oPC declaration as shown above.

The Endgame Trigger Script (did not compile; I have notated where
the compiler states the issue is and the error)

For the end game condition you should just do an execute script (as shown below) to initiate the ending sequence.

/*   Script generated by Lilac Soul's NWN Script Generator, v. 2.3
For download info, please visit: http://nwvault.ign.c...=4683&id=625    */
 //Put this script OnEnter

void main()
{
 object oPC = GetEnteringObject();
 if(!GetIsPC(oPC)) return;
 if(GetLocalInt(oPC, "talkedtokriston")!= 2)
   return;
object oTarget;
oTarget = oPC;
effect eEffect;
eEffect = EffectSleep();
eEffect = SupernaturalEffect(eEffect);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
ExecuteScript("transfer", oPC);
}


Now you can just use the script I gave you above for the "transfer" script, (name it accordingly) and you should be done.  Just so that you have the correct code for "transfer" I am reposting it below

//Script name "transfer"
//Call this script both at the point of module completion and in OnClientEnter as noted above

void SaveAndEnd()
{
DoSinglePlayerAutoSave();
ExportSingleCharacter(OBJECT_SELF);
EndGame("INSERT_END_MOVIE_HERE");
}

void main()
{
StartNewModule("INSERT_NEXT_MODULE_HERE");
SetLocalInt(OBJECT_SELF, "JUMPTONEXTMODULE", TRUE);
DelayCommand(1.0, SaveAndEnd());
}
                       


               
               

               


                     Modifié par WhiZard, 01 février 2012 - 11:22 .
                     
                  


            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #12 on: February 02, 2012, 05:08:41 am »


               Thank you! I can't wait to give this a go. I really appreciate all of your help. As a husband, father, full-time employee, and full time college student learning scripting is not high on my time or priority list. I sincerely appreciate the assistance you have given.
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Ending a module
« Reply #13 on: February 02, 2012, 01:07:11 pm »


               Just took another quick look at these. I see where I defined the PC twice, as you aid. I complete missed that but now I know what to watch for in the future. Also, I wasn't aware of the Execute Script function. That makes life a bit easier...thanks again...
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Ending a module
« Reply #14 on: February 03, 2012, 09:50:27 pm »


               Another poster PMed me about a point which you might not have grasped.
There are two names I used that you will need to replace with the appropriate name you use.
These are:
INSERT_END_MOVIE_HERE
INSERT_NEXT_MODULE_HERE

Edit: fixing misspelling
               
               

               


                     Modifié par WhiZard, 04 février 2012 - 12:35 .