PDA

View Full Version : TSL Scripting Appearance Changes


dangen77
04-11-2007, 02:45 PM
Hello All,

I'm currently working on 2 new area mods, both are large and both will take a long time (I've already worked on them for 3 months). I'm retexturing the areas, so they look different. Anyways, in one of the mods, I'm creating a space station and I want the PC and Company to be wearing a space suit (#279 in appearance .2DA) when they enter the first area of the mod (right after the character selection). Once they enter the space station I want to call another script, by means of a trigger, that will change their appearance back to normal. And of course when they leave the space station, i also want to call a script that will put them back in their space suits. When they enter the ebon hawk, they should change back into their normal appearance. Is this possible? I'm not a scripting whiz, so I really need some sample scripts.

Thanks in advance.

stoffe
04-11-2007, 03:45 PM
I want the PC and Company to be wearing a space suit (#279 in appearance .2DA) when they enter the first area of the mod (right after the character selection). Once they enter the space station I want to call another script, by means of a trigger, that will change their appearance back to normal. And of course when they leave the space station, i also want to call a script that will put them back in their space suits. When they enter the ebon hawk, they should change back into their normal appearance. Is this possible? I'm not a scripting whiz, so I really need some sample scripts.


The easiest way to handle this for temporary appearance changes is to apply a disguise effect to the characters while they should have the space suit look, and remove the effect when they should go back to normal.

You can make two custom functions that equips and unequips the space suits on the party members you currently bring along that you can call from other scripts, like this:


// ST: st_spacesuits.nss

// ST: Equip the space suits
void ST_EquipSpaceSuits() {
if (GetGlobalBoolean("G_PER_In_Space_Suit"))
return;

SetGlobalBoolean("G_PER_In_Space_Suit", TRUE);
SetPlayerRestrictMode(TRUE);
effect eSuit = EffectDisguise( DISGUISE_TYPE_ENVIRONMENTSUIT_02 );

int iParty;
for (iParty = 0; iParty < GetPartyMemberCount(); iParty++) {
object oParty = GetPartyMemberByIndex(iParty);
if (GetIsObjectValid(oParty)) {
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSuit, oParty);
}
}
}

// ST: Unequip the space suits
void ST_UnequipSpaceSuits() {
if (!GetGlobalBoolean("G_PER_In_Space_Suit"))
return;

SetGlobalBoolean("G_PER_In_Space_Suit", FALSE);
SetPlayerRestrictMode(FALSE);

int iParty;
for (iParty = 0; iParty < GetPartyMemberCount(); iParty++) {
object oParty = GetPartyMemberByIndex(iParty);
if (GetIsObjectValid(oParty)) {
effect eEff = GetFirstEffect(oParty);
while (GetIsEffectValid(eEff)) {
if (GetEffectType(eEff) == EFFECT_TYPE_DISGUISE) {
RemoveEffect(oParty, eEff);
eEff = GetFirstEffect(oParty);
}
else {
eEff = GetNextEffect(oParty);
}
}
}
}
}


If you put those in an include file (st_spacesuits.nss in this example) you can re-use them from your trigger scripts easily, like:

Example trigger OnEnter script to put party in space suits:

#include "st_spacesuits"

void main() {
if ((GetEnteringObject() == GetFirstPC()) && !GetGlobalBoolean("G_PER_In_Space_Suit")) {
SetGlobalFadeOut();
SetFadeUntilScript();
ST_EquipSpaceSuits();
SetGlobalFadeIn(0.0, 1.0);
}
}


Example trigger OnEnter script to remove space suits from party:

#include "st_spacesuits"

void main() {
if ((GetEnteringObject() == GetFirstPC()) && GetGlobalBoolean("G_PER_In_Space_Suit")) {
SetGlobalFadeOut();
SetFadeUntilScript();
ST_UnequipSpaceSuits();
SetGlobalFadeIn(0.0, 1.0);
}
}


Important: Make sure the spacesuit areas are set as Unescapable so the player can't change their active party members while in spacesuits. If it's not a separate area rather than a part of an otherwise indoor area you could toggle this via the script as well if needed to make the party selection disabled only while in spacesuits.