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?
NWN2 End Game Script?
Débuté par
Walker_Boh
, déc. 05 2010 02:15
#1
Posté 05 décembre 2010 - 02:15
#2
Posté 05 décembre 2010 - 02:32
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.
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
Posté 05 décembre 2010 - 02:45
Yes- that is all I had. Not sure how to place the syntax. Could you show me?
Thanks
Thanks
#4
Posté 05 décembre 2010 - 03:19
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.
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
Posté 05 décembre 2010 - 03:23
Will do. Thanks
#6
Posté 05 décembre 2010 - 11:08
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
Posté 06 décembre 2010 - 12:18
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
Posté 11 décembre 2010 - 01:42
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_*
Posté 11 décembre 2010 - 02:05
Guest_Chaos Wielder_*
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("");
}
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
Posté 11 décembre 2010 - 03:51
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
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_*
Posté 11 décembre 2010 - 02:21
Guest_Chaos Wielder_*
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();
}
}
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
Posté 11 décembre 2010 - 04:55
Thanks a lot.





Retour en haut






