Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

[K1] Script problem

Page: 1 of 1
 sekan
08-22-2008, 5:43 PM
#1
Hello,

I have added a new force power that freeze an enemy for 25 seconds. But during that progress the hostile shall become neutral so you can't attack him\her during the freezing. Then I want the enemy to return to the faction he\she had before.

The freezing works fine but turning npc to neutral doesn't work for some reason.

Here is the script:




#include "k_inc_force"

void main()
{
object oFollower = GetSpellTargetObject();
object oSource = OBJECT_SELF;

ActionDoCommand(SetCommandable(TRUE,oFollower));
int nFaction = GetStandardFaction(oFollower);
ChangeToStandardFaction((oFollower), 5);


effect eFreeze = EffectSleep();

eFreeze = EffectLinkEffects(eFreeze, EffectVisualEffect(VFX_DUR_HOLD));
eFreeze = SetEffectIcon(eFreeze, 15);

ApplyEffectToObject((DURATION_TYPE_PERMANENT), eFreeze, oFollower);

DelayCommand(25.0, AssignCommand(oFollower, ClearAllEffects()));
ChangeToStandardFaction(oFollower, nFaction);


AssignCommand (oFollower,ActionAttack( oSource));
ActionDoCommand(SetCommandable(FALSE,oFollower));

}


Why is my npcs not becoming neutral?

Thanks and take care
 glovemaster
08-23-2008, 8:06 AM
#2
Your NPC is actually becoming neutral but only for the duration of the script as your line:
ChangeToStandardFaction(oFollower, nFaction);
is not delayed and therefore the NPC is changed to Neutral and then back to hostile.

Here is a more cleaned up script:
void GM_SwitchFaction(float Delay, object NPC, int Faction)
{
int nFaction = GetStandardFaction(NPC);
ChangeToStandardFaction(oFollower, Faction);

DelayCommand(Delay, AssignCommand(NPC, ClearAllEffects()));
DelayCommand(Delay, ChangeToStandardFaction(NPC, nFaction));
DelayCommand(Delay, AssignCommand(NPC, ActionAttack(oSource)));
DelayCommand(Delay, ActionDoCommand(SetCommandable(FALSE, NPC)));
}

void main()
{
object oFollower = GetSpellTargetObject();
object oSource = OBJECT_SELF;
effect eFreeze = EffectSleep();
eFreeze = EffectLinkEffects(eFreeze, EffectVisualEffect(VFX_DUR_HOLD));
eFreeze = SetEffectIcon(eFreeze, 15);

GM_SwitchFaction(25.0, oFollower, STANDARD_FACTION_NEUTRAL);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFreeze, oFollower, 25.0);
ActionDoCommand(SetCommandable(TRUE, oFollower));
}
 sekan
08-23-2008, 8:22 AM
#3
Thanks it works now :)
Page: 1 of 1