Jump to content

Home

Scripting issue


Darth InSidious

Recommended Posts

void CreateObjectVoid(int nObjectType, string sTemplate, location lLoc)
{
   CreateObject(nObjectType, sTemplate, lLoc);
}




#include "k_inc_force"

void main()
{ 

   object oSource = OBJECT_SELF; 
   object oTarget = GetSpellTargetObject();
   object oSomb = GetObjectByTag("di_somb");
   object oWeapLeft = GetItemInSlot( INVENTORY_SLOT_LEFTWEAPON, GetFirstPC() );
   object oWeapRight = GetItemInSlot( INVENTORY_SLOT_RIGHTWEAPON, GetFirstPC() );

   effect eParal = EffectStunned();

AssignCommand(oSource, ClearAllActions());
AssignCommand(oSource, ClearAllEffects());

DelayCommand(1.0, AssignCommand(oSource, ActionPlayAnimation( ANIMATION_LOOPING_MEDITATE, 1.0, 12.0 )));
DelayCommand(1.1, DrawGroundBeams(3.25, 6.0));
DelayCommand(1.1, ApplyEffectToObject(1, eParal, oSource, 12.0f));
DelayCommand(6.0, RemoveEffect(oSource, eParal));
DelayCommand(6.0, AssignCommand(GetFirstPC(), ActionUnequipItem(oWeapLeft)));
DelayCommand(6.1, AssignCommand(GetFirstPC(), ActionUnequipItem(oWeapRight)));
CreateItemOnObject("di_somb",oSource);
DelayCommand(6.2, ActionEquipItem(GetObjectByTag("di_somb"), INVENTORY_SLOT_RIGHTWEAPON, TRUE));
DelayCommand(24.0, ActionUnequipItem(GetObjectByTag("di_somb")));
DelayCommand(24.0, DestroyObject(GetObjectByTag("di_somb")));
DelayCommand(24.1, ActionEquipItem(oWeapLeft, INVENTORY_SLOT_LEFTWEAPON));
DelayCommand(24.1, ActionEquipItem(oWeapRight, INVENTORY_SLOT_RIGHTWEAPON));

}

For some reason this script is quite glitchy. The weapon won't equip until I try an attack, rather than right away, and I seem to be unable to both stun the Caster and have them meditate.

 

Also, I wanted to delay the CreateItemOnObject function. Is there any workaround for this?

 

Thanks.

Link to comment
Share on other sites

For some reason this script is quite glitchy. The weapon won't equip until I try an attack, rather than right away, and I seem to be unable to both stun the Caster and have them meditate.

 

Assuming the equipping/unequipping of the item is supposed to happen on the caster (you used the caster and the party leader a bit mixed) and that this is a force power script maybe the altered variant below will work?

 

The problem with using stun is that this effect comes with its own built-in animation and visual effect which will override your meditation animation when applied. So instead of stunning you can try to disable the character temporarily instead while the meditation animation plays.

 

#include "k_inc_force"

void ST_Meditate(object oTarget, float fDuration);

void main() { 
   object oSource    = OBJECT_SELF; 
   object oSomb      = CreateItemOnObject("di_somb", oSource);
   object oWeapLeft  = GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON);
   object oWeapRight = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON);

   ClearAllActions();
   ClearAllEffects(); // ST: Is this power really supposed to strip all buffs when used?

   // ST: This function has not been implemented anywhere in the script?
   // DelayCommand( 1.1, DrawGroundBeams(3.25, 6.0));

   // ST: Try to disable character instead of stun to not interrupt the meditation
   DelayCommand( 1.0, ST_Meditate(oSource, 4.8));

   DelayCommand( 6.0, ActionUnequipItem(oWeapLeft, TRUE));
   DelayCommand( 6.1, ActionUnequipItem(oWeapRight, TRUE));
   DelayCommand( 6.2, ActionEquipItem(oSomb, INVENTORY_SLOT_RIGHTWEAPON, TRUE));
   DelayCommand(24.0, ActionUnequipItem(oSomb));
   DelayCommand(24.1, DestroyObject(oSomb));
   DelayCommand(24.1, ActionEquipItem(oWeapLeft, INVENTORY_SLOT_LEFTWEAPON));
   DelayCommand(24.1, ActionEquipItem(oWeapRight, INVENTORY_SLOT_RIGHTWEAPON));
}


void ST_Meditate(object oTarget, float fDuration) {
   AssignCommand(oTarget, ClearAllActions());

   if (oTarget == GetFirstPC()) 
       NoClicksFor(fDuration);

   AssignCommand(oTarget, PlayAnimation( ANIMATION_LOOPING_MEDITATE, 1.0, fDuration ));

   SetCommandable(FALSE, oTarget);
   DelayCommand(fDuration, SetCommandable(TRUE, oTarget));
}

 

The danger with this script if it can be used anywhere is that the caster will get to keep the "di_somb" item permanently if they transition to another area before the 24 seconds have elapsed. Unfortunately I don't think there is much you can do about that though unless it only can be used under controlled circumstances.

 

Also, I wanted to delay the CreateItemOnObject function. Is there any workaround for this?

 

You can place it within a custom wrapper function that you then delay, though the downside to that is that you won't have any reliable way of getting an object reference to the item you just created. In this case it's in my opinion better to just create the item from the start, get the object reference and then use that for the delayed Equip/Unequip actions.

 

Alternatively if you had not needed need an object reference you could just create the object inside the delayed EquipItem function call (but that wouldn't work in this case since you need to do things with this item later on).

Link to comment
Share on other sites

Thanks for the swift response. :)

Assuming the equipping/unequipping of the item is supposed to happen on the caster (you used the caster and the party leader a bit mixed)

Yes, it's meant to, but I was rather tired when writing this script so it may well be a bit garbled...apologies. :)

and that this is a force power script

Also an affirmative. :)

The problem with using stun is that this effect comes with its own built-in animation and visual effect which will override your meditation animation when applied. So instead of stunning you can try to disable the character temporarily instead while the meditation animation plays.

Thanks for the tip! Is that the void ST_Meditate function in the source below?

 

#include "k_inc_force"

void ST_Meditate(object oTarget, float fDuration);

void main() { 
   object oSource    = OBJECT_SELF; 
   object oSomb      = CreateItemOnObject("di_somb", oSource);
   object oWeapLeft  = GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON);
   object oWeapRight = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON);

   ClearAllActions();
   ClearAllEffects(); // ST: Is this power really supposed to strip all buffs when used? (DI: Yes.  )

   // ST: This function has not been implemented anywhere in the script? (DI: I didn't post the void DrawGroundBeams since it's effectively a separate issue in the script. )
   // DelayCommand( 1.1, DrawGroundBeams(3.25, 6.0));

   // ST: Try to disable character instead of stun to not interrupt the meditation
   DelayCommand( 1.0, ST_Meditate(oSource, 4.8));

   DelayCommand( 6.0, ActionUnequipItem(oWeapLeft, TRUE));
   DelayCommand( 6.1, ActionUnequipItem(oWeapRight, TRUE));
   DelayCommand( 6.2, ActionEquipItem(oSomb, INVENTORY_SLOT_RIGHTWEAPON, TRUE));
   DelayCommand(24.0, ActionUnequipItem(oSomb));
   DelayCommand(24.1, DestroyObject(oSomb));
   DelayCommand(24.1, ActionEquipItem(oWeapLeft, INVENTORY_SLOT_LEFTWEAPON));
   DelayCommand(24.1, ActionEquipItem(oWeapRight, INVENTORY_SLOT_RIGHTWEAPON));
}


void ST_Meditate(object oTarget, float fDuration) {
   AssignCommand(oTarget, ClearAllActions());

   if (oTarget == GetFirstPC()) 
       NoClicksFor(fDuration);

   AssignCommand(oTarget, PlayAnimation( ANIMATION_LOOPING_MEDITATE, 1.0, fDuration ));

   SetCommandable(FALSE, oTarget);
   DelayCommand(fDuration, SetCommandable(TRUE, oTarget));
}

 

The danger with this script if it can be used anywhere is that the caster will get to keep the "di_somb" item permanently if they transition to another area before the 24 seconds have elapsed. Unfortunately I don't think there is much you can do about that though unless it only can be used under controlled circumstances.

That was an issue that I thought of, but since you mostly can't transition during a battle, and it will take up a lot of FP....

 

You can place it within a custom wrapper function that you then delay, though the downside to that is that you won't have any reliable way of getting an object reference to the item you just created. In this case it's in my opinion better to just create the item from the start, get the object reference and then use that for the delayed Equip/Unequip actions.

 

Alternatively if you had not needed need an object reference you could just create the object inside the delayed EquipItem function call (but that wouldn't work in this case since you need to do things with this item later on).

Is there any way to remove the "received item:" pop-up box, in this case?

Link to comment
Share on other sites

Thanks for the tip! Is that the void ST_Meditate function in the source below?

 

Yes, it is a custom function which is attempting to prevent the character from taking any actions for the specified duration. It clears and locks the action queue of the object, and if it's the main character it will prevent clicking as well. You way want to remove the last mentioned part if the character still should be able to command their allies while meditating. :)

 

Is there any way to remove the "received item:" pop-up box, in this case?

 

Not in Kotor1, though in TSL the last parameter to the CreateItemOnObject() function may be set to TRUE to hide the feedback message, like:

object oSomb      = CreateItemOnObject("di_somb", oSource, 1, TRUE);

Link to comment
Share on other sites

Here is what I used in a cutscene for my lightsaber force power mod to get the lightsabers powered around the player:

 

SetLightsaberPowered(oSource, TRUE)); // obviously not needed if it is not a lightsaber 
SetFakeCombatState(oSource, TRUE )); 
AssignCommand(oSource, PlayAnimation( ANIMATION_LOOPING_READY, 1.0, -1.0 ) ));
CreatureFlourishWeapon( oSource )); // try with  this one only as it seems that you are playing the meditate animation. I don't remember if it works with all kinds of weapons

 

 

However, I don't remember what TRUE/FALSE do and I don't have a copy of nwscript.nss to check it out.

 

The mod is here if you want to check it (source code is included): http://www.lucasfiles.com/?s=&action=file&id=1489

 

Off-topic: btw, is it only me or those code boxes are awfully narrow? (It can be fixed) Maybe it's the widescreen that gives me that impression.

Link to comment
Share on other sites

Thank you both for your huge amount of help. Unfortunately, the script is still being...erratic.

 

I've been modifying it to try and get it to work more properly, but now the di_somb item won't equip and the character doesn't perform the meditation either.

 

I appear to only be able to get either the character to meditate or the character to automatically equip the weapon after a set period or immediately.

 

I think in the case of equipping the di_somb weapon, it may be a problem with the ClearAllActions() function, since the meditation function also contains this. But without a ClearAllActions() function, the character will stand up/attack and sit down again, or not meditate at all, or any number of other things. I also tried using an EffectStunned() instead, but that won't work either...

 

I'm sorry to keep asking about this script, but I just don't seem to be getting anywhere, and I'm pushing the limits of both my scripting knowledge and my imagination when it comes to what could be wrong...

 

#include "k_inc_force"

void DrawGroundBeams(float fRadius, float fDur) 
{
float 	fAngleInc 	= 360.0 / 6.0;
float 	fAngle 		= 0.0;	
int 	i;
vector 	vPos;	
effect eBeam;
       effect eBeam3;
       object oTarget = OBJECT_SELF;

object oNode1, oNode2, oNode3, oNode4, oNode5, oNode6;

for (i = 0; i < 6; i++) {
	vPos = GetPosition(oTarget);
	vPos.x += cos(fAngle) * fRadius; 
	vPos.y += sin(fAngle) * fRadius; 
	vPos.z += 0.22;


	object oInv = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisible", Location(vPos, (fAngle - 180.0)));
	AssignCommand(oInv, DestroyObject(oInv, fDur, TRUE));


	if (!GetIsObjectValid(oNode1))
		oNode1 = oInv;
	else if (!GetIsObjectValid(oNode2))
		oNode2 = oInv;
	else if (!GetIsObjectValid(oNode3))
		oNode3 = oInv;	
	else if (!GetIsObjectValid(oNode4))
		oNode4 = oInv;
	else if (!GetIsObjectValid(oNode5))
		oNode5 = oInv;
	else if (!GetIsObjectValid(oNode6))
		oNode6 = oInv;					

	fAngle += fAngleInc;
	if (fAngle > 360.0)
		fAngle = fAngle - 360.0;
}

       int eBeam1 = (2068);
       int eBeam2 = (2068);

eBeam = EffectBeam(eBeam1, oNode1, BODY_NODE_CHEST);
eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur));
DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur));
DelayCommand(0.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur));
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur));
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode1, fDur));

eBeam = EffectBeam(eBeam1, oNode2, BODY_NODE_CHEST);
eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
DelayCommand(0.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
DelayCommand(0.8, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
DelayCommand(0.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
DelayCommand(1.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
DelayCommand(1.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode2, fDur-0.8));

eBeam = EffectBeam(eBeam1, oNode3, BODY_NODE_CHEST);
eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
DelayCommand(1.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
DelayCommand(1.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
DelayCommand(1.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
DelayCommand(1.6, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur-0.4));
DelayCommand(1.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));	
DelayCommand(1.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode3, fDur-0.8));

eBeam = EffectBeam(eBeam1, oNode4, BODY_NODE_CHEST);
eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
DelayCommand(1.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
DelayCommand(2.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur-0.2));
DelayCommand(2.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
DelayCommand(2.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
DelayCommand(2.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode4, fDur-0.8));

eBeam = EffectBeam(eBeam1, oNode5, BODY_NODE_CHEST);
eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
DelayCommand(2.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
DelayCommand(2.6, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur-0.1));
DelayCommand(2.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
DelayCommand(2.8, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
DelayCommand(2.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
DelayCommand(2.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode5, fDur-0.8));

eBeam = EffectBeam(eBeam1, oNode6, BODY_NODE_CHEST);
eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
DelayCommand(3.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur));
DelayCommand(3.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
DelayCommand(3.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
DelayCommand(3.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
DelayCommand(3.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
DelayCommand(3.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode6, fDur-0.8));
}

void DoEquipSomb(object oSource, object oItem)
{
ActionEquipItem(oItem, INVENTORY_SLOT_RIGHTWEAPON, FALSE );
SetFakeCombatState(oSource, TRUE ); 
CreatureFlourishWeapon( oSource );
SetFakeCombatState(oSource, FALSE );
}

void Meditate(object oSource, float fDuration) 
{

   AssignCommand(oSource, ClearAllActions());

   if (oSource == GetFirstPC())
       NoClicksFor(fDuration);

   AssignCommand(oSource, PlayAnimation( ANIMATION_LOOPING_MEDITATE, 1.0, fDuration ));

   SetCommandable(FALSE, oSource);
   DelayCommand(fDuration, SetCommandable(TRUE, oSource));
}


void main()
{ 

   object oSource = OBJECT_SELF; 
   object oTarget = GetSpellTargetObject();
   object oSomb   = CreateItemOnObject("di_somb", oSource, 1, TRUE);
   object oWeapLeft = GetItemInSlot( INVENTORY_SLOT_LEFTWEAPON, GetFirstPC() );
   object oWeapRight = GetItemInSlot( INVENTORY_SLOT_RIGHTWEAPON, GetFirstPC() );

   effect eVFX1 = EffectVisualEffect(9014);
   effect eVFX2 = EffectVisualEffect(9012);
   effect eVFX3 = EffectVisualEffect(3018);

ActionUnequipItem(oWeapLeft, TRUE);
ActionUnequipItem(oWeapRight, TRUE);

DelayCommand(0.0, Meditate(oSource, 5.5));

DelayCommand(0.2, DrawGroundBeams(2.0, 6.0));


DelayCommand(6.0, ApplyEffectToObject(1, eVFX1, oSource, 1.0f));
DelayCommand(6.0, ApplyEffectToObject(1, eVFX2, oSource, 1.0f));
DelayCommand(6.0, ApplyEffectToObject(1, eVFX3, oSource, 1.0f));
DelayCommand(6.1, DoEquipSomb(OBJECT_SELF, GetObjectByTag("di_somb")));


DelayCommand(12.0, ActionUnequipItem(oSomb));
DelayCommand(12.0, DestroyObject(oSomb));

DelayCommand(12.0, ActionEquipItem(oWeapLeft, INVENTORY_SLOT_LEFTWEAPON));
DelayCommand(12.0, ActionEquipItem(oWeapRight, INVENTORY_SLOT_RIGHTWEAPON));

}

Thank you so much for your help so far, and if you can help me solve this, I would be very grateful. Thank you again.

 

off-topic: I think the box is a little narrow...

Link to comment
Share on other sites

Thank you both for your huge amount of help. Unfortunately, the script is still being...erratic.

 

I've been modifying it to try and get it to work more properly, but now the di_somb item won't equip and the character doesn't perform the meditation either.

 

Erratic is a good word for describing NWScript as a whole. Getting a scripted sequence to perform exactly as you want it 100% of the time is a nightmare in this game. Which I'd guess is the reason Obsidian has a lot of in-game cutscenes as pre-rendered bink movies instead. :)

 

Try this variant and see if it makes any difference. Trying to run more of what's happening through the action queue to ensure it's done in sequence:


void DrawGroundBeams(float fRadius, float fDur);
void DoEquipSomb(object oSource, object oItem);
void Meditate(object oSource, float fDuration);

void main() { 
   object oSource = OBJECT_SELF; 
   object oSomb   = CreateItemOnObject("di_somb", oSource, 1, TRUE);
   object oWeapLeft = GetItemInSlot( INVENTORY_SLOT_LEFTWEAPON, GetFirstPC() );
   object oWeapRight = GetItemInSlot( INVENTORY_SLOT_RIGHTWEAPON, GetFirstPC() );

   effect eVFX1 = EffectVisualEffect(9014);
   effect eVFX2 = EffectVisualEffect(9012);
   effect eVFX3 = EffectVisualEffect(3018);

   ActionUnequipItem(oWeapLeft, TRUE);
   ActionUnequipItem(oWeapRight, TRUE);

   ActionDoCommand(Meditate(oSource, 5.5));

   DelayCommand(0.2, DrawGroundBeams(2.0, 6.0));
   DelayCommand(6.0, ApplyEffectToObject(1, eVFX1, oSource, 1.0f));
   DelayCommand(6.0, ApplyEffectToObject(1, eVFX2, oSource, 1.0f));
   DelayCommand(6.0, ApplyEffectToObject(1, eVFX3, oSource, 1.0f));

   DelayCommand(6.1, DoEquipSomb(OBJECT_SELF, oSomb));
   DelayCommand(12.0, ActionUnequipItem(oSomb));
   DelayCommand(12.0, DestroyObject(oSomb));
   DelayCommand(12.2, ActionEquipItem(oWeapLeft, INVENTORY_SLOT_LEFTWEAPON));
   DelayCommand(12.2, ActionEquipItem(oWeapRight, INVENTORY_SLOT_RIGHTWEAPON));
}


void DrawGroundBeams(float fRadius, float fDur)  {
   float   fAngleInc   = 360.0 / 6.0;
   float   fAngle      = 0.0;  
   int     i;
   vector  vPos;   
   effect eBeam;
       effect eBeam3;
       object oTarget = OBJECT_SELF;

   object oNode1, oNode2, oNode3, oNode4, oNode5, oNode6;

   for (i = 0; i < 6; i++) {
       vPos = GetPosition(oTarget);
       vPos.x += cos(fAngle) * fRadius; 
       vPos.y += sin(fAngle) * fRadius; 
       vPos.z += 0.22;


       object oInv = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisible", Location(vPos, (fAngle - 180.0)));
       AssignCommand(oInv, DestroyObject(oInv, fDur, TRUE));


       if (!GetIsObjectValid(oNode1))
           oNode1 = oInv;
       else if (!GetIsObjectValid(oNode2))
           oNode2 = oInv;
       else if (!GetIsObjectValid(oNode3))
           oNode3 = oInv;  
       else if (!GetIsObjectValid(oNode4))
           oNode4 = oInv;
       else if (!GetIsObjectValid(oNode5))
           oNode5 = oInv;
       else if (!GetIsObjectValid(oNode6))
           oNode6 = oInv;                  

       fAngle += fAngleInc;
       if (fAngle > 360.0)
           fAngle = fAngle - 360.0;
   }

   int eBeam1 = 2068;
   int eBeam2 = 2068;

   eBeam = EffectBeam(eBeam1, oNode1, BODY_NODE_CHEST);
   eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
   DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
   DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur));
   DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur));
   DelayCommand(0.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur));
   DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur));
   DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode1, fDur));

   eBeam = EffectBeam(eBeam1, oNode2, BODY_NODE_CHEST);
   eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
   DelayCommand(0.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
   DelayCommand(0.8, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
   DelayCommand(0.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
   DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
   DelayCommand(1.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
   DelayCommand(1.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode2, fDur-0.8));

   eBeam = EffectBeam(eBeam1, oNode3, BODY_NODE_CHEST);
   eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
   DelayCommand(1.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
   DelayCommand(1.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
   DelayCommand(1.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
   DelayCommand(1.6, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur-0.4));
   DelayCommand(1.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));   
   DelayCommand(1.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode3, fDur-0.8));

   eBeam = EffectBeam(eBeam1, oNode4, BODY_NODE_CHEST);
   eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
   DelayCommand(1.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
   DelayCommand(2.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
   DelayCommand(2.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur-0.2));
   DelayCommand(2.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
   DelayCommand(2.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
   DelayCommand(2.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode4, fDur-0.8));

   eBeam = EffectBeam(eBeam1, oNode5, BODY_NODE_CHEST);
   eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
   DelayCommand(2.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDur));
   DelayCommand(2.6, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur-0.1));
   DelayCommand(2.7, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
   DelayCommand(2.8, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
   DelayCommand(2.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
   DelayCommand(2.9, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode5, fDur-0.8));

   eBeam = EffectBeam(eBeam1, oNode6, BODY_NODE_CHEST);
   eBeam3 = EffectBeam(eBeam2, oTarget, BODY_NODE_CHEST);
   DelayCommand(3.1, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDur));
   DelayCommand(3.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDur-0.1));
   DelayCommand(3.3, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDur-0.2));
   DelayCommand(3.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDur-0.4));
   DelayCommand(3.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode1, fDur-0.6));
   DelayCommand(3.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam3, oNode6, fDur-0.8));
}

void DoEquipSomb(object oSource, object oItem) {
   ActionEquipItem(oItem, INVENTORY_SLOT_RIGHTWEAPON, FALSE );
   ActionDoCommand(SetFakeCombatState(oSource, TRUE )); 
   ActionDoCommand(CreatureFlourishWeapon( oSource ));
   ActionDoCommand(SetFakeCombatState(oSource, FALSE ));
}

void Meditate(object oSource, float fDuration) {
   AssignCommand(oSource, ClearAllActions());
   AssignCommand(oSource, PlayAnimation( ANIMATION_LOOPING_MEDITATE, 1.0, fDuration ));
   AssignCommand(oSource, SetCommandable(FALSE, oSource));
   DelayCommand(fDuration, SetCommandable(TRUE, oSource));
}

Link to comment
Share on other sites

Erratic is a good word for describing NWScript as a whole. Getting a scripted sequence to perform exactly as you want it 100% of the time is a nightmare in this game. Which I'd guess is the reason Obsidian has a lot of in-game cutscenes as pre-rendered bink movies instead. :)

Indeed. :(

 

It does seem a bit strange, though, given that its for RPGs...You would think greater precision was important...

Try this variant and see if it makes any difference. Trying to run more of what's happening through the action queue to ensure it's done in sequence:

Thanks for this. I tried this one, too, but no luck. :(

 

I think I'll have to go with a "Thought Bomb" FP instead...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...