PDA

View Full Version : [PI] Converting IF to CASE



Network
December 7th, 2010, 01:40
Hello,

This is one of my first tutorials, I have made a few in the past on the old forum but I mostly help other people rather then post threads.

Here is what we are trying to do. In this snippet I am using the chaotic maul int code. If in your itemdef or class8 you are using a case rather than a if, this guide is for you. Many people use ifs, and class8. So if you use need the case method or your using itemdef this is for you.

Eg.
if (1345){
...
}
to:

case 1345:
...
break;


Step 1. You are going to need to take the if method for the chaotic maul.

Step 2. You need to change the "if (####) {" to "case ####:"

Step 3. You need to change the "}" at the bottom to "break;"

Step 4. Every variable e.g. (itemDef.modelRotationX = 498;"), the "modelRotationX" may be a 1 or a 2. In the if statement x = 1, y = 2.

Step 5. For each variable, edit them to what is in your other case methods. If you don't have any other examples to take from I have on here:

case 15039:
itemDef.name = "Chaotic maul";
itemDef.itemActions = new String[5];
itemDef.itemActions[1] = "Wield";
itemDef.modelID = 35088;
itemDef.modelZoom = 1360;
itemDef.modelRotationX = 498;
itemDef.modelRotationY = 354;
itemDef.modelOffset1 = 4;
itemDef.modelOffset2 = 2;
itemDef.anInt188 = -1;
itemDef.anInt164 = -1;
itemDef.description = "A weapon of brute strength.".getBytes();
break;


- Most of the variables will be the same as in the if method, but same may be changed slightly. Look carefully. Your finished method should look like the one above.

Note: Obviously your modelOffset's, modelId etc will NOT be the same as mine. It all depends on the weapon/item's ints that you are modifying.

Hopefully this guide has helped you, if you guys have any questions or errors I will try to help :).

Relapse
December 7th, 2010, 21:51
Strictly following this guide will not work... you don't explain enough

Steve
December 7th, 2010, 21:54
Lol wtf is this, u didn't explain anything, and forgot about that you use a switch statement.

Network
December 7th, 2010, 23:27
I had to leave guys, I am fixing it up as I speak.

Relapse
December 7th, 2010, 23:29
I had to leave guys, I am fixing it up as I speak.

Ahh lol alright that makes more sense, then I'll look back at it once you finish and edit my first post accordingly.

Network
December 7th, 2010, 23:54
Thread updated.

Steve
December 7th, 2010, 23:56
Thread updated.

Your still not covering the fact that they need a switch statement somewhere...

Relapse
December 7th, 2010, 23:57
Your still not covering the fact that they need a switch statement somewhere...

I don't think this is for converting all of the if statements to a switch this is just for if you are given ints for an if statement and your client uses a switch... if that makes more sense.

Lol at this ^ multi-tasking > Relapse

Steve
December 8th, 2010, 00:00
I don't think this is for converting all of the if statements to a switch this is just for if you are given ints for an if statement and your client uses a switch... if that makes more sense.

I had no idea what you just said, you can't just do switch(id) { //ifstatements and no casestatements }

Network
December 8th, 2010, 00:00
Your still not covering the fact that they need a switch statement somewhere...

This is not a tutorial on how to add a case method within your basic itemdef.java with other if methods. This is for people who have another/seperate itemdef file that is for models and uses case.

Relapse
December 8th, 2010, 00:05
I had no idea what you just said, you can't just do switch(id) { //ifstatements and no casestatements }

Alright I'll try again...

If you are given ints for an item and it is in a if statement

And your itemDef uses a switch statement then you could use this guide to convert that single items ints.

//IT IS NOT FOR\\

Not if your client uses a if else statement and you want to convert the whole group to a switch statement.