Aller au contenu

Photo

NWN2 End Game Script?


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

#1
Walker_Boh

Walker_Boh
  • Members
  • 11 messages
I have been trying to set up a scenario where the module ends if an NPC dies.  So far I have placed the End Game script: 

===========

// End the currently running game, play sEndMovie then return all players to the
// game's main menu.
void EndGame(string sEndMovie);

===========

.... on the On Death for the NPC in question.  Yet, nothing happens when that NPC dies.  Any help?

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Is that the whole script you posted?



Scripts need a void main() function in order to be run from a creature event. Scripts without a void main() function are only used as includes within other scripts.

#3
Walker_Boh

Walker_Boh
  • Members
  • 11 messages
Yes- that is all I had. Not sure how to place the syntax. Could you show me?



Thanks

#4
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
What you have there is a function (ie. a script command) that needs to be called from an actual script.

I suggest a read through my tutorial linked in sig below, should explain a bit about how to write your own scripts.

Give it a try writing the code yourself. If you have any problems, post what script you have so far, working or not, and we can help you from there.

Modifié par _Knightmare_, 05 décembre 2010 - 03:21 .


#5
Walker_Boh

Walker_Boh
  • Members
  • 11 messages
Will do. Thanks

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
By the way, good for you! Getting in there and reading the tutorials and writing you own code is a very good way to learn scripting, which is one of the most enjoyable part of modding, for me. Best of luck!

#7
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

M. Rieder wrote...

By the way, good for you! Getting in there and reading the tutorials and writing you own code is a very good way to learn scripting, which is one of the most enjoyable part of modding, for me. Best of luck!


Agreed. And its a great feeling when you get that first script to work as you wanted!

#8
Walker_Boh

Walker_Boh
  • Members
  • 11 messages
Guess I failed. Can someone give me a script to put on the OnDeath category? I'd like to end the mod if an NPC dies.

#9
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
This should work. Give it to the NPC in question on their death script. When they die, the music will stop, the game will face for the PC and then, 4 seconds later, the game will end.
EDIT: Forgot that delays are inconsistent with NPC death. So, this will end suddenly. Not too aesthetically appealing, but it should work.


void main()
{
object oDead=OBJECT_SELF;
MusicBattleStop(GetArea(oDead));
MusicBackgroundStop(GetArea(oDead));
FadeToBlack(GetFirstPC(), 3.0, 40.0);
EndGame("");
}

Modifié par Chaos Wielder, 11 décembre 2010 - 02:07 .


#10
Walker_Boh

Walker_Boh
  • Members
  • 11 messages
Thanks.  That works.  I have been messing with a script to kill the player(s) instead of just forcing an end to the game.  The scripts I try all fail. 


EG:

void main()
{

effect eEffect;
eEffect = EffectDamage(999, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_NORMAL);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);

}

Thank you again

#11
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
That doesn't work because you're not defining what oPC is. Nightmare's scripting tutorials--listed above in his signature--might be a good place to look. That said, here's a script that should work:



void main()

{

object oPC=GetFirstPC();



while(GetIsObjectValid(oPC))

{

effect eEffect;

eEffect = EffectDamage(999, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_NORMAL);



ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);

oPC=GetNextPC();

}

}

#12
Walker_Boh

Walker_Boh
  • Members
  • 11 messages
Thanks a lot.