Hi there,
I've been trying to work out how to add the walkType if statements to the ChangeRegions.java (that might not be where I should be looking), as I didn't want my NPC direction to be detirmined in process() of NPCHandler.java.
I tried this:
[spoiler]
Code:
if (packetType == 210) {
for (int i = 0; i < maxNPCs; i++) {
if (npcs[i] != null) {
if (npcs[i].walkingType >= 2) {
switch(npcs[i].walkingType) {
case 5: //west
npcs[i].turnNpc(npcs[i].absX -1, npcs[i].absY);
break;
case 4: //east
npcs[i].turnNpc(npcs[i].absX +1, npcs[i].absY);
break;
case 3: //south
npcs[i].turnNpc(npcs[i].absX, npcs[i].absY -1);
break;
case 2: //north
npcs[i].turnNpc(npcs[i].absX, npcs[i].absY +1);
break;
default: // applies to all npc who are only standing, remove if not needed
if (npcs[i].walkingType >= 0) {
npcs[i].turnNpc(npcs[i].absX, npcs[i].absY); //makes it when npcs move they dont turn back to one direction
}
break;
}
}
}
if(npcs[i].walkingType == 1) {
if(Misc.random(3)== 1 && !npcs[i].walkingHome) {
int MoveX = 0;
int MoveY = 0;
int Rnd = Misc.random(9);
if (Rnd == 1) {
MoveX = 1;
MoveY = 1;
} else if (Rnd == 2) {
MoveX = -1;
} else if (Rnd == 3) {
MoveY = -1;
} else if (Rnd == 4) {
MoveX = 1;
} else if (Rnd == 5) {
MoveY = 1;
} else if (Rnd == 6) {
MoveX = -1;
MoveY = -1;
} else if (Rnd == 7) {
MoveX = -1;
MoveY = 1;
} else if (Rnd == 8) {
MoveX = 1;
MoveY = -1;
}
if (MoveX == 1) {
if (npcs[i].absX + MoveX < npcs[i].makeX + 1) {
npcs[i].moveX = MoveX;
} else {
npcs[i].moveX = 0;
}
}
if (MoveX == -1) {
if (npcs[i].absX - MoveX > npcs[i].makeX - 1) {
npcs[i].moveX = MoveX;
} else {
npcs[i].moveX = 0;
}
}
if(MoveY == 1) {
if(npcs[i].absY + MoveY < npcs[i].makeY + 1) {
npcs[i].moveY = MoveY;
} else {
npcs[i].moveY = 0;
}
}
if(MoveY == -1) {
if(npcs[i].absY - MoveY > npcs[i].makeY - 1) {
npcs[i].moveY = MoveY;
} else {
npcs[i].moveY = 0;
}
}
}
}
}
}
[/spoiler]
which went horribly wrong, and didn't help at all! How would I link these if statements so that when packet 210 (the one to change regions) is initiated, it calls them and checks the npc direction?
Thanks!
Baylo