Author Topic: Switches making me twitch.  (Read 382 times)

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Switches making me twitch.
« on: November 09, 2010, 11:06:15 am »


               I'm back for more sagely council. I'm starting to play with switches, and am having some problems. I'm trying to use each case to generate a randomly determined encounter (an gladitorial arena battle, specifically.)

I'll post the script, but each random case currently identical. Ignore that. I just haven't gotten far enough into making the various encounters yet.

Not only does this not compile, but NOTHING happens when it runs. I don't understand.

Here's the script...

#include "nw_i0_2q4luskan"
void main()
{
if (GetLocalInt(OBJECT_SELF, "Spectate Colosseum Go")== 0)
   return;
if (GetLocalInt(OBJECT_SELF, "Gladiators In Game")!= 0)
   return;
object oTarget;
oTarget = GetObjectByTag("NorthGameEntrance");
SetLocked(oTarget, FALSE);
AssignCommand(oTarget, ActionOpenDoor(oTarget));
oTarget = GetObjectByTag("SouthGameEntrance");
SetLocked(oTarget, FALSE);
AssignCommand(oTarget, ActionOpenDoor(oTarget));
  switch( Random( 4 ))
  { case 0: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
    case 1: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "Sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
    case 2: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "Sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
    case 3: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "Sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
  }
}
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Switches making me twitch.
« Reply #1 on: November 09, 2010, 11:23:35 am »


                
#include "nw_i0_2q4luskan"
void main()
{
if (GetLocalInt(OBJECT_SELF, "Spectate Colosseum Go")== 0)
   return;
if (GetLocalInt(OBJECT_SELF, "Gladiators In Game")!= 0)
   return;
object oTarget;
location lTarget;
oTarget = GetObjectByTag("NorthGameEntrance");
SetLocked(oTarget, FALSE);
AssignCommand(oTarget, ActionOpenDoor(oTarget));
oTarget = GetObjectByTag("SouthGameEntrance");
SetLocked(oTarget, FALSE);
AssignCommand(oTarget, ActionOpenDoor(oTarget));
  switch( Random( 4 ))
  { case 0: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            //location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
    case 1: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            //location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "Sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
    case 2: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            //location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "Sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
    case 3: SetLocalInt(OBJECT_SELF, "Gladiators In Game", 4);
            //location lTarget;
            oTarget = GetWaypointByTag("NorthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "carpathian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "carpathian", lTarget));
            oTarget = GetWaypointByTag("SouthColosseumSpawn");
            lTarget = GetLocation(oTarget);
            CreateObject(OBJECT_TYPE_CREATURE, "Sacrentian", lTarget);
            DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "sacrentian", lTarget));
            break;
  }
}
 
               
               

               


                     Modifié par Lightfoot8, 09 novembre 2010 - 11:25 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Switches making me twitch.
« Reply #2 on: November 09, 2010, 05:40:13 pm »


               Just to clarify, the problem that lightfoot is suggesting you fix is that you're attempting to declare a variable in a case - something the bioware compiler doesn't allow. You can get around this restriction by either declaring everything up top, as his fix has you doing, or by putting brackets around any case you want to declare in.



Funky
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Switches making me twitch.
« Reply #3 on: November 09, 2010, 07:42:35 pm »


               Here is a link that better discribes the problem you are having with the switch/case.

http://social.biowar...5019199#5026795
               
               

               
            

Legacy_One Thousand Talons Mao Ra

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Switches making me twitch.
« Reply #4 on: November 09, 2010, 07:50:02 pm »


               Ahhh. Simple enough. I would have never figured that out! Excellent. Thank you. =D