This commit is contained in:
Light2
2013-12-15 02:15:20 +01:00
8 changed files with 126 additions and 2 deletions
+11
View File
@@ -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
+10
View File
@@ -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
+11
View File
@@ -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
+2 -2
View File
@@ -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
@@ -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
+32
View File
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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;
}
@@ -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
@@ -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);
}
}
}