diff --git a/scripts/commands/lfg.py b/scripts/commands/lfg.py new file mode 100644 index 00000000..3477098f --- /dev/null +++ b/scripts/commands/lfg.py @@ -0,0 +1,11 @@ +from resources.common import PlayerFlags +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + ghost = actor.getSlottedObject('ghost') + print ('Command recieved!') + ghost.toggleFlag(PlayerFlags.LFG) + return \ No newline at end of file diff --git a/scripts/commands/newbiehelper.py b/scripts/commands/newbiehelper.py new file mode 100644 index 00000000..cce8079c --- /dev/null +++ b/scripts/commands/newbiehelper.py @@ -0,0 +1,10 @@ +from resources.common import PlayerFlags +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + ghost = actor.getSlottedObject('ghost') + ghost.toggleFlag(PlayerFlags.HELPER) + return \ No newline at end of file diff --git a/scripts/commands/roleplay.py b/scripts/commands/roleplay.py new file mode 100644 index 00000000..a862303d --- /dev/null +++ b/scripts/commands/roleplay.py @@ -0,0 +1,11 @@ +from java.lang import Integer +from resources.common import PlayerFlags +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + ghost = actor.getSlottedObject('ghost') + ghost.toggleFlag(PlayerFlags.ROLEPLAYER) + return \ No newline at end of file diff --git a/scripts/commands/setcurrentskilltitle.py b/scripts/commands/setcurrentskilltitle.py index 45a49f14..43e9e5f4 100644 --- a/scripts/commands/setcurrentskilltitle.py +++ b/scripts/commands/setcurrentskilltitle.py @@ -6,8 +6,8 @@ def setup(): def run(core, actor, target, commandString): playerObject = actor.getSlottedObject('ghost') - print ("Title set to: " + commandString) - print ("List of Titles: " + playerObject.getTitleList().toString()) + #print ("Title set to: " + commandString) + #print ("List of Titles: " + playerObject.getTitleList().toString()) if playerObject is None: return diff --git a/scripts/commands/toggleawayfromkeyboard.py b/scripts/commands/toggleawayfromkeyboard.py new file mode 100644 index 00000000..18dece5b --- /dev/null +++ b/scripts/commands/toggleawayfromkeyboard.py @@ -0,0 +1,10 @@ +from resources.common import PlayerFlags +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + ghost = actor.getSlottedObject('ghost') + ghost.toggleFlag(PlayerFlags.AFK) + return \ No newline at end of file diff --git a/src/resources/common/PlayerFlags.java b/src/resources/common/PlayerFlags.java new file mode 100644 index 00000000..897659d7 --- /dev/null +++ b/src/resources/common/PlayerFlags.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.common; + +public class PlayerFlags { + public static final int LFG = 0x01; + public static final int HELPER = 0x02; + public static final int ROLEPLAYER = 0x04; + public static final int AFK = 0x80; + public static final int LD = 0x0100; + public static final int FACTIONRANK = 0x0200; + +} diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index 52ee9080..7689f90d 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -598,6 +598,21 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { return buffer; } + public IoBuffer buildFlagBitmask(int bitmask) { + IoBuffer buffer = bufferPool.allocate(30, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(4); + buffer.putInt(bitmask); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + + int size = buffer.position(); + buffer.flip(); + + buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 5, buffer, size + 4); + return buffer; + } + @Override public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { // TODO Auto-generated method stub diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index db033e93..ecdc69bf 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -56,6 +56,7 @@ public class PlayerObject extends IntangibleObject { private int totalPlayTime = 0; private byte[] collections = new byte[] { }; private int highestSetBit = 0; + private int flagBitmask = 0; // PLAY 6 @@ -658,4 +659,38 @@ public class PlayerObject extends IntangibleObject { } } + public int getFlagBitmask() { + synchronized(objectMutex) { + return flagBitmask; + } + } + + public void setFlagBitmask(int flagBitmask) { + synchronized(objectMutex) { + this.flagBitmask |= flagBitmask; + } + + if (getContainer() != null) { + getContainer().notifyObservers(messageBuilder.buildFlagBitmask(this.flagBitmask), true); + } + } + public void clearFlagBitmask(int flagBitmask) { + synchronized(objectMutex) { + // set flag bitmask to 0 + this.flagBitmask &= ~flagBitmask; + } + + if (getContainer() != null) { + getContainer().notifyObservers(messageBuilder.buildFlagBitmask(this.flagBitmask), true); + } + } + + public void toggleFlag(int flag) { + if ((this.flagBitmask & flag) == flag) { + clearFlagBitmask(flag); + } else { + setFlagBitmask(flag); + } + } + }