Description: Change the face direction from south to anything you want on different npcs.
Difficulty: 2.
Assumed Knowledge: how to declare and read.
Tested Server: cleaned v3 and v4. should work on most
Files/Classes Modified: NPC and NPCHandler.
Step 1:
In your NPC class make sure you have the following methods or something that looks similar, if not just add them.
first declare these
Code:
public int focusPointX, focusPointY;
public boolean turnUpdateRequired;
Code:
public void turnNpc(int i, int j) {
focusPointX = 2 * i + 1;
focusPointY = 2 * j + 1;
updateRequired = true;
turnUpdateRequired = true;
}
Code:
private void appendSetFocusDestination(stream str) {
str.writeWordBigEndian(focusPointX);
str.writeWordBigEndian(focusPointY);
}
Step 2:
go to your
appendNPCUpdateBlock method add the text in green in the exact position.
Code:
public void appendNPCUpdateBlock(stream str) {
if(!updateRequired) return ;
int updateMask = 0;
if(textUpdateRequired) updateMask |= 1;
if(animUpdateRequired) updateMask |= 0x10;
if(hitUpdateRequired) updateMask |= 0x40;
if(dirUpdateRequired) updateMask |= 0x20;
if(faceToUpdateRequired) updateMask |= 0x20;
if(turnUpdateRequired) updateMask |= 4;
str.writeByte(updateMask);
if(textUpdateRequired) {
str.writeString(textUpdate);
}
if (animUpdateRequired) appendAnimUpdate(str);
if (hitUpdateRequired) appendHitUpdate(str);
if (dirUpdateRequired) appendDirUpdate(str);
if (faceToUpdateRequired) appendFaceToUpdate(str);
if(turnUpdateRequired) appendSetFocusDestination(str);
}
under the
clearUpdateFlags method add
Code:
focusPointX = -1;
focusPointY = -1;
turnUpdateRequired = false;
Step 3:
Save and close your NPC class.
Open your NPCHandler and search for
then under
Code:
for (int i = 0; i < maxNPCs; i++) {
if (npcs[i] != null) {
if (npcs[i].actionTimer > 0) {
npcs[i].actionTimer--;
}
add
Code:
if (npcs[i].walkingType == 0) {
switch(npcs[i].npcType) {
case 494: // banker
/**
* absX and absY of a specific npc you want to change face direction,
* if you want all the npcs of the same type to face
* the same direction remove it
**/
if(npcs[i].absX == 3256 && npcs[i].absY == 3418) {
/**
* this turns the npc
* +1 to absX makes the npc face east,
* -1 to absX makes it face west.
* +1 to absY makes it face north and
* -1 to absY makes it face south.
**/
npcs[i].turnNpc(npcs[i].absX, npcs[i].absY+1);
}
break;
default: // applies to all npc who are only standing, remove if not needed
npcs[i].turnNpc(npcs[i].absX, npcs[i].absY+1);
break;
}
}
compile and hopefully it works for you
Picture:
Remember: to change your autospawn to the walking type is set to "0"
Credits: me i guess