Well following the subject of cursed items I want to make a sword that can render its wielder berserk here's the function I use but I ran into one issue...Once in "berserk" state the PC never leave cutscene mode anymore even when there's no more creature around!
Here's the function:
void SetBerserk(object oPC, int nChance = 20, float fDelay = 6.0)
{
if (!GetIsCursed(oPC))
{
SetCutsceneMode(oPC, FALSE);
return;
}
SetCommandable(TRUE, oPC);
object oCrea = GetFirstObjectInShape(SHAPE_SPHERE, 15.0, GetLocation(oPC), TRUE, OBJECT_TYPE_CREATURE);
int nRand = d100();
if ((nRand <= nChance || GetLocalInt(oPC, "berserk") == 1) && GetIsObjectValid(oCrea))
{
SetCutsceneMode(oPC, TRUE);
SetPlotFlag(oPC, FALSE);
SetLocalInt(oPC, "berserk", 1);
DelayCommand(0.0, AssignCommand(oPC, ClearAllActions()));
DelayCommand(0.5, AssignCommand(oPC, ActionAttack(oCrea)));
DelayCommand(fDelay, SetBerserk(oPC, nChance, fDelay));
}
else
{
SetCutsceneMode(oPC, FALSE);
DeleteLocalInt(oPC, "berserk");
DelayCommand(fDelay, SetBerserk(oPC, nChance, fDelay));
}
}
I tried the same function without using the cutscene mode (with setcommandable(TRUE/FALSE)) in that case the issue is the same the PC ends up in SetCommandable(FALSE) even when there's no more creature around...
What am I missing here? Thanks!
Probem with scripting a function commanding a PC
Débuté par
Krevett
, janv. 22 2011 10:25
#1
Posté 22 janvier 2011 - 10:25
#2
Posté 22 janvier 2011 - 10:47
There will be every time at least one creature, you. Better would be to use GetNearestCreature and check for perception. Otherwise you can find another issue and thats enemy behind the wall.
Btw: Cutscene is quite unfriendly way to do, commandable is enough, but PC can still cancel an attack (the same problem have confused PC and I have not found any workaround yet).
Btw: Cutscene is quite unfriendly way to do, commandable is enough, but PC can still cancel an attack (the same problem have confused PC and I have not found any workaround yet).
#3
Posté 22 janvier 2011 - 11:19
Just added a test if (oCrea == oPC) oCrea = GetNextObjectInShape and it now works perfectly in the SetCommandable form!! Should be no issue with an ennemy behind a wall because nLineofSight is set to TRUE in the getFirst/GetNextObjectInShape (but i have not tested yet...)
Thanks for your quick answer ShaDoOow!!!
Thanks for your quick answer ShaDoOow!!!
#4
Posté 23 janvier 2011 - 12:18
Oh, right, i forget on this paramater, then its fine.Krevett wrote...
nLineofSight is set to TRUE in the getFirst/GetNextObjectInShape!





Retour en haut






