Doing Multiple Cases

09/09/2013 00:46 hacksaw#1
Is there a way to select a case range from the NPC.cs rather than writing each number individualy? and if so how?

Example if my Npc UID's from 1 to 100 all did the same thing rather than doing:

Case1:
Case2:
Case3:
Case4: ect ect ect

Is there Something like:

Case1 < Case100:

That could be used instead.
09/09/2013 02:13 Aceking#2
Quote:
Originally Posted by hacksaw View Post
Is there a way to select a case range from the NPC.cs rather than writing each number individualy? and if so how?

Example if my Npc UID's from 1 to 100 all did the same thing rather than doing:

Case1:
Case2:
Case3:
Case4: ect ect ect

Is there Something like:

Case1 < Case100:

That could be used instead.
Code:
If (NPC.UID >= 1 && NPC.UID <=100)
{
//Enter code here
}
09/09/2013 02:32 { Angelius }#3
Use the default keyword.

switch(npcid)
{
case 0:
case 1:
case etc:
default:
if(npcid = to whatever you want it to be) { do something; }
break;
}
09/09/2013 03:50 Super Aids#4
I know VB can do something case-ranging ex. from 1 - 100. C# can do something similar, but a case scope has to be done for every single case inbetween.

You could write your own middleman "compiler" that would translate your sort of code into proper C# code, thus parsing something like:
Code:
case 1 < case 100:
break;
to something like:
Code:
case 1
case 2
...
case 99:
break;
09/09/2013 17:26 hacksaw#5
Thanks for the ideas guys, Few for me to ponder over there.