Aller au contenu

Photo

Switches making me twitch.


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

#1
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
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;
  }
}

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
 
#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 .


#3
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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

#4
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Here is a link that better discribes the problem you are having with the switch/case.

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

#5
One Thousand Talons Mao Ra

One Thousand Talons Mao Ra
  • Members
  • 40 messages
Ahhh. Simple enough. I would have never figured that out! Excellent. Thank you. =D