Aller au contenu

Photo

Probem with scripting a function commanding a PC


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Krevett

Krevett
  • Members
  • 104 messages
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!

#2
Shadooow

Shadooow
  • Members
  • 4 471 messages
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).


#3
Krevett

Krevett
  • Members
  • 104 messages
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!!!

#4
Shadooow

Shadooow
  • Members
  • 4 471 messages

Krevett wrote...

nLineofSight is set to TRUE in the getFirst/GetNextObjectInShape!

Oh, right, i forget on this paramater, then its fine.