Author Topic: Polymorph problems  (Read 347 times)

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Polymorph problems
« on: August 17, 2013, 03:44:10 am »


               Help ! Had what I thought was a great idea. Silly, but fun. I am trying to script a storyline in which a PC and a henchman put on a cow costume and attempt to sneak up on a dragon. I modified the x2_mod_def_equ , and saved it under a new name.

    } // ED modifications to  script 8-15-13
    if(oItem == oOwner)
    {
     SetLocalInt(oPc,"Dragon",8);
     DelayCommand(1.0,ExecuteScript(sScript,oPc));
    }
The executed script is this.

void main()
{
 object oPC = GetFirstPC();
 object oHench = GetHenchman(oPC);
 effect eMorph = EffectPolymorph(POLYMORPH_TYPE_COW,TRUE);
 int nVol = TALKVOLUME_TALK;
 int nSlot = INVENTORY_SLOT_CHEST;
 if(GetIsObjectValid(GetHenchman(oPC)))
 {
  SetLocalInt(oPC,"Dragon",8);
  AssignCommand(oHench,SetIsDestroyable(TRUE,TRUE,TRUE));
  DestroyObject(oHench,1.0);
  DelayCommand(2.0,ApplyEffectToObject(DURATION_TYPE_INSTANT,eMorph,oPC));
  DelayCommand(4.0,AssignCommand(oPC,ActionSpeakString("Moooo!",nVol)));
 }
 else
 {
  AssignCommand(oPC,ActionUnequipItem(GetItemInSlot(nSlot,oPC)));
  SendMessageToPC(oPC,"You need a henchman to equip this item.");
 }
}
This works just fine. When the PC equips the item, the hench is destroyed and the PC morphs to cow.
I set some triggers along thier path. Tripping, talking,ect. They all work fine. It's the last trigger that is giving me the problem.

#include "x0_i0_position"
void main()
{
 object oPC = GetFirstPC();
 object oEnt = GetEnteringObject();
 object oTrig = GetObjectByTag("LifeAsACow4");
 object oPerv = GetObjectByTag("Farmer");
 string sName = GetName(oPC,FALSE);
 string sTemp = "farmer";
 int nVol = TALKVOLUME_TALK;
 int nVolb = TALKVOLUME_SHOUT;
 int nType = OBJECT_TYPE_CREATURE;
 int bUse = FALSE;
 location lLoc = GetLocation(GetWaypointByTag("WpSpFarmer"));
 location lAss = GetBehindLocation(oPC);
 if(GetLocalInt(oPC,"MeetBoss") == 3)
 {
  DelayCommand(1.0,AssignCommand(oPerv,ActionMoveToObject(oPC,TRUE)));
  DelayCommand(6.0,AssignCommand(oPerv,
   ActionSpeakString("Oh Petunia! Where have you been?",nVol)));
  DelayCommand(10.0,AssignCommand(oPerv,
   ActionSpeakString("I've been looking all over for you.",nVol)));
  DelayCommand(14.0,AssignCommand(oPerv,ActionMoveToLocation(lAss,FALSE)));
  DelayCommand(17.0,AssignCommand(oPerv,ActionForceFollowObject(oPC,0.1)));
  DelayCommand(20.0,AssignCommand(oPerv,ClearAllActions()));
  DelayCommand(21.0,AssignCommand(oPerv,
   ActionSpeakString("Hold still. I want to make love to you.",nVol)));
  DelayCommand(25.0,AssignCommand(oPC,
   ActionSpeakString("[Kreg]Huh? Oh no you don't!",nVolb)));
  DelayCommand(28.0,AssignCommand(oPerv,
   ActionSpeakString("A talking cow?.",nVol)));
  DelayCommand(31.0,AssignCommand(oPerv,
   ActionSpeakString("AHHHHHHHHHH!",nVolb)));
  DelayCommand(34.0,AssignCommand(oPerv,ClearAllActions()));
  DelayCommand(35.0,AssignCommand(oPerv,
  ActionMoveAwayFromObject(oPC,TRUE,30.0)));
  DelayCommand(38.0,AssignCommand(oPC,
  ActionSpeakString("[Kreg] That was close!",nVol)));
   DelayCommand(41.0,AssignCommand(oPC,
   ActionSpeakString("["+sName+"]" + "Maybe for you.",nVolb)));
  DestroyObject(oPerv,40.0);
  DestroyObject(oTrig,42.0);
 }
 else
 {
  if(GetIsPC(oEnt))
  {
   if(GetLocalInt(oPC,"MeetBoss") == 2)
   {
   CreateObject(nType,sTemp,lLoc,bUse);
   DelayCommand(3.0,SetLocalInt(oPC,"MeetBoss",3));
   DelayCommand(5.0,ExecuteScript("cow_fun4",oPC));
   }
  }
 }
}
It is a little longer but otherwise the same as the others. On testing it repeats and skips actions randomly. I commented out the include and command it uses. It made no difference. It's close, but not right.

The second problem I'm having is ending the polymorph. I set a trigger around the dragon and put the following script on enter.

void main()
{
 object oPC = GetFirstPC();
 object oEnt = GetEnteringObject();
 object oTrig = GetObjectByTag("AttackDragon");
 object oDragon = GetObjectByTag("Horticus");
 int nVolT = TALKVOLUME_TALK;
 int nVolW = TALKVOLUME_WHISPER;
 int nVolS = TALKVOLUME_SHOUT;
 int nDur = DURATION_TYPE_INSTANT;
 string sName = GetName(oPC,FALSE);
 string sScript = "attack_dragon";
 effect eMorph = EffectPolymorph(POLYMORPH_TYPE_COW,FALSE);
 effect eDispell = EffectDispelMagicAll(20);
 object oBoss = GetObjectByTag("BossRance");
 int nType = OBJECT_TYPE_CREATURE;
 location lLoc = GetLocation(oPC);
 string sTemp = "bossrance";
 int bUse = FALSE;
 if(GetLocalInt(oPC,"MeetBoss") == 5)//Equip weapons and armor, Attack Destroy Trigger
 {
  AssignCommand(oBoss,ActionEquipMostDamagingMelee());
  DelayCommand(2.0,AssignCommand(oBoss,ActionEquipMostEffectiveArmor()));
  DelayCommand(4.0,AssignCommand(oBoss,
   ActionSpeakString("ATTACK!",nVolS)));
  DelayCommand(5.0,AssignCommand(oBoss,ActionAttack(oDragon,FALSE)));
  DelayCommand(5.0,AdjustReputation(oPC,oDragon,-100));
  DelayCommand(7.0,AssignCommand(oDragon,ActionAttack(oPC,FALSE)));
 }
 else
 {
  if(GetLocalInt(oPC,"MeetBoss") == 4)//Spawn Kreg
  {
   CreateObject(nType,sTemp,lLoc,bUse);
   DelayCommand(1.0,SetLocalInt(oPC,"MeetBoss",5));
   DelayCommand(4.0,ExecuteScript(sScript,oPC));
  }
  else
  {
   if(GetIsPC(oEnt))//Clear all act, End Polymorph
   {
    if(GetLocalInt(oPC,"MeetBoss") == 3)
    {
     AssignCommand(oPC,ClearAllActions());
     DelayCommand(1.0,SetLocalInt(oPC,"MeetBoss",4));
     DelayCommand(2.0,AssignCommand(oPC,
      ActionSpeakString("["+sName+"] Ready?",nVolW)));
     DelayCommand(5.0,AssignCommand(oPC,
      ActionSpeakString("[Kreg] Yup.",nVolW)));
     DelayCommand(8.0,AssignCommand(oPC,
      ActionSpeakString("["+sName+"] NOW!",nVolT)));
     //DelayCommand(10.0,ApplyEffectToObject(nDur,eMorph,oPC,2.0));
     DelayCommand(12.0,ApplyEffectToObject(nDur,eDispell,oPC));
     DelayCommand(13.0,ExecuteScript(sScript,oPC));
    }
   }
  }
 }
}
I have tried applying effects, a second polymorph of short duration and dispell all. all the lines fire correctly except, there is no PC. Just the hench and the cow.

Silly I know, but if any of you could give this a read and let an old noob learn some new tricks, I would be most thankful.
Ed Venture
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Polymorph problems
« Reply #1 on: August 17, 2013, 08:21:16 am »


               I think you best bet is to add a small function that specifically removes the polymorph effect:


void RemovePoly(object oPC)
{
effect ePoly = GetFirstEffect(oPC);
while (GetIsEffectValid(ePoly) == TRUE)
   {
   if (GetEffectType(ePoly) == EFFECT_TYPE_POLYMORPH)
      {
      RemoveEffect(oPC, ePoly);
      }
   ePoly = GetNextEffect(oPC);
   }
}

Then just add this where you want it to happen in your script (instead of the dispelling effect):


RemovePoly(oPC);

Doing it as a small function can save TMI error headaches if doing the effects check within some other loop.


As far as the "farmer" skipping some assigned actions, I'm thinking there's a limit on actions you can assign to a creature at any one time.  You may have to find a way to stagger out the assigning of commands.  I ran into the same issue when trying to script out a 2-3 minute cutscene once...parts of it just kept getting skipped.  I may have to revisit that bit of code now that I think of it...I didn't consider limits to Assignee's action queues at the time.
               
               

               


                     Modifié par The Amethyst Dragon, 17 août 2013 - 07:25 .
                     
                  


            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Polymorph problems
« Reply #2 on: August 17, 2013, 02:18:25 pm »


               Once again Amethyst Dragon comes to the rescue. Thank you, again. I will try out your advice as soon as I can. I'll let you know how it works. Thank you, Thank you, Thank you.  Bards should sing praises to you.
ED
               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Polymorph problems
« Reply #3 on: August 18, 2013, 03:42:11 am »


               Amethyst Dragon. Didn't work. Not because of your advice, but because I'm stupid. You would think that with as much time I spend in the Lexicon that some of it would stick to the mud between my ears."Effects applied with DURATION_TYPE_INSTANT, can never be removed." Duh!!! Oh well, as I told my exwifes lawyer as I was pulling the shirt off my back,"I'm learning !" Thank you again. Your input helped me greatly.