本文整理汇总了C#中Player.setFaceLocation方法的典型用法代码示例。如果您正苦于以下问题:C# Player.setFaceLocation方法的具体用法?C# Player.setFaceLocation怎么用?C# Player.setFaceLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.setFaceLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fillingVial
// TODO make this use an AreaEvent so itll work from a distance.
/**
* Will fill vials in a continuous motion from a water source.
*/
public static bool fillingVial(Player p, Location loc)
{
if (!p.getInventory().hasItem(VIAL) || !p.getLocation().withinDistance(loc, 2))
{
return true;
}
if (p.getTemporaryAttribute("fillVialTimer") != null)
{
long lastFillTime = (int)p.getTemporaryAttribute("fillVialTimer");
if (Environment.TickCount - lastFillTime < 600)
{
return true;
}
}
p.setTemporaryAttribute("fillingVials", true);
p.setFaceLocation(loc);
Event fillVialEvent = new Event(500);
fillVialEvent.setAction(() =>
{
int amountFilled = 0;
string s = amountFilled == 1 ? "vial" : "vials";
if (p.getTemporaryAttribute("fillingVials") == null || !p.getLocation().withinDistance(loc, 2) || !p.getInventory().hasItem(229))
{
p.setLastAnimation(new Animation(65535));
if (amountFilled > 0)
{
p.getPackets().sendMessage("You fill up the " + s + " with water.");
}
fillVialEvent.stop();
return;
}
if (p.getInventory().replaceSingleItem(VIAL, VIAL_OF_WATER))
{
p.setLastAnimation(new Animation(832));
amountFilled++;
p.setTemporaryAttribute("fillVialTimer", Environment.TickCount);
}
else
{
if (amountFilled > 0)
{
p.setLastAnimation(new Animation(65535));
p.getPackets().sendMessage("You fill up the " + s + " with water.");
}
fillVialEvent.stop();
}
});
Server.registerEvent(fillVialEvent);
return true;
}
示例2: chopTendrils
public static void chopTendrils(Player p, int x, int y)
{
int var = x == 3057 ? x + 2 : x - 1;
AreaEvent chopTendrilsAreaEvent = new AreaEvent(p, var, y, var, y + 2);
chopTendrilsAreaEvent.setAction(() =>
{
if (!Woodcutting.hasAxe(p))
{
p.getPackets().sendMessage("You need an axe to get past this obstacle.");
return;
}
p.getWalkingQueue().resetWalkingQueue();
p.setFaceLocation(new Location(x + 1, y, 0));
p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p)));
p.setTemporaryAttribute("unmovable", true);
Event chopTendrilsEvent = new Event(1900);
chopTendrilsEvent.setAction(() =>
{
int status = 0;
int[] TENDRILS = { 7161, 7162, 7163 };
if (status < 3)
{
p.getPackets().createObject(TENDRILS[status], new Location(x, y, 0), x == 3057 ? 3 : 1, 10);
}
status++;
if (status == 1)
{
p.setLastAnimation(new Animation(Woodcutting.getAxeAnimation(p)));
chopTendrilsEvent.setTick(1300);
}
if (status == 3)
{
p.getPackets().sendMessage("You clear your way through the tendrils.");
p.setLastAnimation(new Animation(65535));
chopTendrilsEvent.setTick(800);
}
if (status == 4)
{
chopTendrilsEvent.stop();
teleportPastObstacle(p);
p.removeTemporaryAttribute("unmovable");
}
});
Server.registerEvent(chopTendrilsEvent);
return;
});
Server.registerCoordinateEvent(chopTendrilsAreaEvent);
}
示例3: wantToFish
public static bool wantToFish(Player p, Npc npc, bool secondOption)
{
for (int i = 0; i < SPOT_IDS.Length; i++) {
if (npc.getId() == SPOT_IDS[i]){
p.setFaceLocation(npc.getLocation());
AreaEvent startFishingAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
startFishingAreaEvent.setAction(() => {
startFishing(p, i, npc, true, secondOption);
});
Server.registerCoordinateEvent(startFishingAreaEvent);
return true;
}
}
return false;
}
示例4: burnBoil
public static void burnBoil(Player p, int x, int y)
{
AreaEvent burnBoilAreaEvent = new AreaEvent(p, x - 1, y - 1, x + 3, y + 2);
burnBoilAreaEvent.setAction(() =>
{
if (!p.getInventory().hasItem(590))
{
p.getPackets().sendMessage("You need a tinderbox to get past this obstacle.");
return;
}
p.setFaceLocation(new Location(x + 1, y, 0));
p.setLastAnimation(new Animation(733));
p.setTemporaryAttribute("unmovable", true);
Event burnBoilEvent = new Event(1900);
burnBoilEvent.setAction(() =>
{
int status = 0;
int[] BOIL = { 7165, 7166, 7167 };
if (status < 3)
{
p.getPackets().createObject(BOIL[status], new Location(x, y, 0), x == 3060 ? 3 : 1, 10);
}
status++;
if (status == 1)
{
burnBoilEvent.setTick(1300);
}
if (status == 3)
{
p.setLastAnimation(new Animation(65535));
burnBoilEvent.setTick(1000);
}
if (status == 4)
{
burnBoilEvent.stop();
teleportPastObstacle(p);
p.removeTemporaryAttribute("unmovable");
}
});
Server.registerEvent(burnBoilEvent);
return;
});
Server.registerCoordinateEvent(burnBoilAreaEvent);
}
示例5: canThieveNpc
private static bool canThieveNpc(Player p, Npc npc, int index)
{
if (p == null || npc == null || npc.isDead() || npc.isHidden() || npc.isDestroyed() || p.isDead() || p.isDestroyed()) {
return false;
}
if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
return false;
}
if (p.getSkills().getGreaterLevel(Skills.SKILL.THIEVING) < NPC_LVL[index]) {
p.getPackets().sendMessage("You need a Thieving level of " + NPC_LVL[index] + " to rob this Npc.");
p.setFaceLocation(npc.getLocation());
return false;
}
if (p.getInventory().findFreeSlot() == -1) {
p.getPackets().sendMessage("You need a free inventory space for any potential loot.");
return false;
}
if (p.getTemporaryAttribute("stunned") != null) {
return false;
}
if (p.getTemporaryAttribute("lastPickPocket") != null) {
if (Environment.TickCount - (int)p.getTemporaryAttribute("lastPickPocket") < 1500) {
return false;
}
}
return true;
}
示例6: thieveNpc
private static void thieveNpc(Player p, Npc npc, int index)
{
AreaEvent thieveNpcAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
thieveNpcAreaEvent.setAction(() => {
if (!canThieveNpc(p, npc, index)) {
return;
}
p.setFaceLocation(npc.getLocation());
p.setLastAnimation(new Animation(881));
p.getPackets().sendMessage("You attempt to pick the " + NPC_NAMES[index] + " pocket...");
p.setTemporaryAttribute("lastPickPocket", Environment.TickCount);
Event thieveNpcEvent = new Event(1000);
thieveNpcEvent.setAction(() => {
thieveNpcEvent.stop();
if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
return;
}
if (successfulThieve(p, index, false)) {
int rewardIndex = misc.random(NPC_REWARD[index].Length - 1);
int reward = NPC_REWARD[index][rewardIndex];
int rewardAmount = NPC_REWARD_AMOUNT[index][rewardIndex];
if (index == 7) { // Master farmer.
if (misc.random(15) == 0) {
reward = HERB_SEEDS[misc.random(HERB_SEEDS.Length - 1)];
}
}
p.getSkills().addXp(Skills.SKILL.THIEVING, NPC_XP[index]);
p.getInventory().addItem(reward, rewardAmount);
p.getPackets().sendMessage("You pick the " + NPC_NAMES[index] + " pocket.");
} else {
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().sendMessage("You fail to pick the " + NPC_NAMES[index] + " pocket.");
p.getPackets().sendMessage("You've been stunned!");
npc.setForceText("What do you think you're doing?");
p.setTemporaryAttribute("unmovable", true);
p.setTemporaryAttribute("stunned", true);
p.setLastGraphics(new Graphics(80, 0, 100));
p.setLastAnimation(new Animation(p.getDefenceAnimation()));
p.hit(1);
npc.setFaceLocation(p.getLocation());
Event removeStunEvent = new Event(5000);
removeStunEvent.setAction(() => {
removeStunEvent.stop();
p.removeTemporaryAttribute("unmovable");
p.removeTemporaryAttribute("stunned");
p.setLastGraphics(new Graphics(65535));
});
Server.registerEvent(removeStunEvent);
}
});
Server.registerEvent(thieveNpcEvent);
});
Server.registerCoordinateEvent(thieveNpcAreaEvent);
}
示例7: thieveChest
private static void thieveChest(Player p, int index, ushort chestId, int x, int y)
{
AreaEvent thieveChestAreaEvent = new AreaEvent(p, x-1, y-1, x+1, y+1);
thieveChestAreaEvent.setAction(() => {
p.setFaceLocation(new Location(x, y, p.getLocation().getZ()));
if (!canThieveChest(p, index, chestId, x, y)) {
return;
}
p.getPackets().sendMessage("You attempt to pick the chest lock..");
p.setLastAnimation(new Animation(833));
Event thieveChestEvent = new Event(1000);
thieveChestEvent.setAction(() => {
thieveChestEvent.stop();
if (misc.random(5) == 0) {
p.hit(p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) / 10);
p.setForceText("Ouch!");
p.getPackets().sendMessage("You activate a trap whilst trying to pick the lock!");
return;
}
if (Server.getGlobalObjects().originalObjectExists(chestId, new Location(x, y, 0))) {
Server.getGlobalObjects().lowerHealth(chestId, new Location(x, y, 0));
for (int i = 0; i < CHEST_REWARD[index].Length; i++) {
p.getInventory().addItem(CHEST_REWARD[index][i], CHEST_REWARD_AMOUNTS[index][i]);
}
p.getSkills().addXp(Skills.SKILL.THIEVING, CHEST_XP[index]);
p.getPackets().sendMessage("You successfully pick the lock and loot the chest!");
}
});
Server.registerEvent(thieveChestEvent);
});
Server.registerCoordinateEvent(thieveChestAreaEvent);
}
示例8: useAgilityTunnel
public static void useAgilityTunnel(Player p, int x, int y)
{
AreaEvent useAgilityTunnelAreaEvent = new AreaEvent(p, x-2, y-2, y+2, y+2);
useAgilityTunnelAreaEvent.setAction(() => {
p.getWalkingQueue().resetWalkingQueue();
p.setLastAnimation(new Animation(844));
p.setTemporaryAttribute("unmovable", true);
p.setFaceLocation(new Location(x, y, 0));
Event useAgilityTunnelEvent = new Event(1000);
useAgilityTunnelEvent.setAction(() => {
p.getPackets().sendMessage("You squeeze through the gap.");
teleportPastObstacle(p);
p.removeTemporaryAttribute("unmovable");
useAgilityTunnelEvent.stop();
});
Server.registerEvent(useAgilityTunnelEvent);
return;
});
Server.registerCoordinateEvent(useAgilityTunnelAreaEvent);
}
示例9: isCooking
public static bool isCooking(Player p, int item, bool fire, int fireX, int fireY)
{
for (int i = 0; i < MEAT_RAW.Length; i++)
{
if (item == MEAT_RAW[i])
{
if (fire)
{
int j = i;
AreaEvent setCookingAreaEvent = new AreaEvent(p, fireX - 1, fireY - 1, fireX + 1, fireY + 1);
setCookingAreaEvent.setAction(() =>
{
p.setFaceLocation(new Location(fireX, fireY, p.getLocation().getZ()));
if (Server.getGlobalObjects().fireExists(new Location(fireX, fireY, 0)))
{
setCookingItem(p, null);
p.setTemporaryAttribute("cookingFireLocation", new Location(fireX, fireY, p.getLocation().getZ()));
displayCookOption(p, j);
}
});
Server.registerCoordinateEvent(setCookingAreaEvent);
return true;
}
setCookingItem(p, null);
displayCookOption(p, i);
return true;
}
}
for (int i = 0; i < MEAT_COOKED.Length; i++)
{
if (item == MEAT_COOKED[i])
{
if (fire)
{
AreaEvent cookMeatAreaEvent = new AreaEvent(p, fireX - 1, fireY - 1, fireX + 1, fireY + 1);
cookMeatAreaEvent.setAction(() =>
{
p.setFaceLocation(new Location(fireX, fireY, p.getLocation().getZ()));
if (Server.getGlobalObjects().fireExists(new Location(fireX, fireY, 0)))
{
p.getInventory().replaceSingleItem(MEAT_COOKED[i], MEAT_BURNT[i]);
p.getPackets().sendMessage("You deliberately burn the " + ItemData.forId(MEAT_COOKED[i]).getName() + ".");
p.setLastAnimation(new Animation(883));
}
});
Server.registerCoordinateEvent(cookMeatAreaEvent);
return true;
}
setCookingItem(p, null);
p.getInventory().replaceSingleItem(MEAT_COOKED[i], MEAT_BURNT[i]);
p.getPackets().sendMessage("You deliberately burn the " + ItemData.forId(MEAT_COOKED[i]).getName() + ".");
p.setLastAnimation(new Animation(883));
return true;
}
}
return false;
}
示例10: talkToMaster
public static bool talkToMaster(Player p, Npc npc)
{
for (int i = 0; i < SLAYER_MASTERS.Length; i++) {
if (npc.getId() == (int)SLAYER_MASTERS[i][0]) {
int j = i;
p.setEntityFocus(npc.getClientIndex());
AreaEvent talkToMasterAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
talkToMasterAreaEvent.setAction(() => {
p.setTemporaryAttribute("slayerMaster", j);
npc.setFaceLocation(p.getLocation());
p.setFaceLocation(npc.getLocation());
p.setEntityFocus(65535);
doDialogue(p, 1000);
});
Server.registerCoordinateEvent(talkToMasterAreaEvent);
return true;
}
}
return false;
}
示例11: cutTree
public static void cutTree(Player p, ushort treeId, Location treeLocation, int i, bool newCut, int distance)
{
if (!newCut && p.getTemporaryAttribute("cuttingTree") == null) {
return;
}
if (newCut) {
if (i == 10 || i == 11) { // Magic or Yew tree.
if (!Server.getGlobalObjects().objectExists(treeId, treeLocation)) {
// misc.WriteError(p.getUsername() + " tried to cut a non existing Magic or Yew tree!");
// return;
}
}
Tree newTree = new Tree(i, treeId, treeLocation, LOGS[i], LEVEL[i], TREE_NAME[i], XP[i], distance);
p.setTemporaryAttribute("cuttingTree", newTree);
}
Tree treeToCut = (Tree) p.getTemporaryAttribute("cuttingTree");
if (!canCut(p, treeToCut, null)) {
resetWoodcutting(p);
return;
}
if (newCut) {
p.setLastAnimation(new Animation(getAxeAnimation(p)));
p.setFaceLocation(treeLocation);
p.getPackets().sendMessage("You begin to swing your axe at the tree..");
}
int delay = getCutTime(p, treeToCut.getTreeIndex());
Event cutTreeEvent = new Event(delay);
cutTreeEvent.setAction(() => {
cutTreeEvent.stop();
if (p.getTemporaryAttribute("cuttingTree") == null) {
resetWoodcutting(p);
return;
}
Tree tree = (Tree) p.getTemporaryAttribute("cuttingTree");
if (!canCut(p, treeToCut, tree)) {
resetWoodcutting(p);
return;
}
Server.getGlobalObjects().lowerHealth(tree.getTreeId(), tree.getTreeLocation());
if (!Server.getGlobalObjects().originalObjectExists(tree.getTreeId(), tree.getTreeLocation())) {
resetWoodcutting(p);
p.setLastAnimation(new Animation(65535));
}
if (p.getInventory().addItem(tree.getLog())) {
p.getPackets().closeInterfaces();
int index = tree.getTreeIndex();
string s = index == 1 || index == 3 || index == 8 ? "an" : "a";
p.getSkills().addXp(Skills.SKILL.WOODCUTTING, tree.getXp());
if (index == 6 ) {
p.getPackets().sendMessage("You retrieve some Hollow bark from the tree.");
} else {
p.getPackets().sendMessage("You cut down " + s + " " + tree.getName() + " log.");
}
if (misc.random(3) == 0) {
int nestId = misc.random(10) == 0 ? 5073 : 5074;
GroundItem g = new GroundItem(nestId, 1, new Location(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ()), p);
Server.getGroundItems().newEntityDrop(g);
p.getPackets().sendMessage("Something falls out of the tree and lands at your feet.");
}
}
cutTree(p, tree.getTreeId(), tree.getTreeLocation(), tree.getTreeIndex(), false, tree.getDistance());
});
Server.registerEvent(cutTreeEvent);
if (delay >= 2550) {
Event treeCuttingAnimationEvent = new Event(2550);
int time = delay;
treeCuttingAnimationEvent.setAction(() => {
time -= 2550;
if (time <= 0) {
treeCuttingAnimationEvent.stop();
}
Tree tree = (Tree) p.getTemporaryAttribute("cuttingTree");
if (!canCut(p, treeToCut, tree)) {
treeCuttingAnimationEvent.stop();
return;
}
p.setFaceLocation(treeLocation);
p.setLastAnimation(new Animation(getAxeAnimation(p)));
});
Server.registerEvent(treeCuttingAnimationEvent);
}
}
示例12: doCourse
public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
{
if (p.getTemporaryAttribute("unmovable") != null)
{
return;
}
int agilityStage = (int)(p.getTemporaryAttribute("agilityStage") == null ? 0 : p.getTemporaryAttribute("agilityStage"));
switch ((int)objectArray[0])
{
case 2295: // Log
CoordinateEvent doLogCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[3], (int)objectArray[4], 0));
doLogCoordinateEvent.setAction(() =>
{
shoutNPCs[0].setForceText(SHOUT_MESSAGES[0]);
p.getPackets().sendMessage("You walk carefully across the slippery log...");
bool running = p.getWalkingQueue().isRunToggled();
p.getWalkingQueue().setRunToggled(false);
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setTemporaryAttribute("unmovable", true);
p.getAppearance().setWalkAnimation(155);
p.getUpdateFlags().setAppearanceUpdateRequired(true);
p.getWalkingQueue().forceWalk(0, -7);
Event doLogEvent = new Event(4300);
doLogEvent.setAction(() =>
{
doLogEvent.stop();
p.getPackets().sendMessage("...and make it safely to the other side.");
p.removeTemporaryAttribute("unmovable");
p.getAppearance().setWalkAnimation(-1);
p.getUpdateFlags().setAppearanceUpdateRequired(true);
p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
p.getWalkingQueue().setRunToggled(running);
});
Server.registerEvent(doLogEvent);
});
Server.registerCoordinateEvent(doLogCoordinateEvent);
break;
case 2285: // Net #1
AreaEvent doNetOneAreaEvent = new AreaEvent(p, 2471, 3426, 2476, 3426);
doNetOneAreaEvent.setAction(() =>
{
shoutNPCs[1].setForceText(SHOUT_MESSAGES[1]);
p.getPackets().sendMessage("You climb the netting...");
p.setLastAnimation(new Animation(828));
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() - 1, 0));
p.setTemporaryAttribute("unmovable", true);
Event doNetOneEvent = new Event(1000);
doNetOneEvent.setAction(() =>
{
doNetOneEvent.stop();
p.removeTemporaryAttribute("unmovable");
p.teleport(new Location(2473, p.getLocation().getY() - 2, 1));
p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
});
Server.registerEvent(doNetOneEvent);
});
Server.registerCoordinateEvent(doNetOneAreaEvent);
break;
case 35970: // Tree climb
AreaEvent treeClimbAreaEvent = new AreaEvent(p, 2472, 3422, 2474, 3423);
treeClimbAreaEvent.setAction(() =>
{
shoutNPCs[2].setForceText(SHOUT_MESSAGES[2]);
p.getPackets().sendMessage("You climb the tree...");
p.setLastAnimation(new Animation(828));
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setFaceLocation(new Location(2473, 3422, 1));
p.setTemporaryAttribute("unmovable", true);
Event treeClimbEvent = new Event(1000);
treeClimbEvent.setAction(() =>
{
treeClimbEvent.stop();
p.getPackets().sendMessage("...to the platform above.");
p.removeTemporaryAttribute("unmovable");
p.teleport(new Location(2473, 3420, 2));
p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
});
Server.registerEvent(treeClimbEvent);
});
Server.registerCoordinateEvent(treeClimbAreaEvent);
break;
case 2312: // Rope balance
CoordinateEvent ropeBalanceCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[3], (int)objectArray[4], 2));
ropeBalanceCoordinateEvent.setAction(() =>
{
shoutNPCs[3].setForceText(SHOUT_MESSAGES[3]);
p.getPackets().sendMessage("You carefully cross the tightrope.");
bool running = p.getWalkingQueue().isRunToggled();
p.getWalkingQueue().setRunToggled(false);
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setTemporaryAttribute("unmovable", true);
p.getAppearance().setWalkAnimation(155);
//.........这里部分代码省略.........
示例13: doCourse
public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
{
if (p.getTemporaryAttribute("unmovable") != null) {
return;
}
switch((int)objectArray[0]) {
case 2309: //Entrance log
CoordinateEvent startEntranceLogCoordinateEvent = new CoordinateEvent(p, new Location((int)objectArray[1], (int)objectArray[2], 0));
startEntranceLogCoordinateEvent.setAction(() => {
bool running = p.getWalkingQueue().isRunToggled();
Event comeToLogEvent = new Event(500);
comeToLogEvent.setAction(() => {
p.getWalkingQueue().setRunToggled(false);
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setTemporaryAttribute("unmovable", true);
p.getWalkingQueue().forceWalk(0, 1); //go past gate, no animation yet.
comeToLogEvent.stop();
});
Server.registerEvent(comeToLogEvent);
int doLogWalkCounter = 0;
Event doLogWalkEvent = new Event(800);
doLogWalkEvent.setAction(() => {
if (doLogWalkCounter == 0) { //start the animation
p.getAppearance().setWalkAnimation(155);
p.getUpdateFlags().setAppearanceUpdateRequired(true);
doLogWalkEvent.setTick(500); //500 milliseconds required to make animations realistic.
} else if(doLogWalkCounter < 16) { //15 steps foward, 1 step is just quickfix TODO: Add gate opener.
p.getWalkingQueue().forceWalk(0, 1);
} else if(doLogWalkCounter == 17) { //stop the animation add the xp.
doLogWalkEvent.stop();
p.getAppearance().setWalkAnimation(-1);
p.getUpdateFlags().setAppearanceUpdateRequired(true);
p.removeTemporaryAttribute("unmovable");
p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
p.getWalkingQueue().setRunToggled(running);
}
doLogWalkCounter++;
});
Server.registerEvent(doLogWalkEvent);
});
Server.registerCoordinateEvent(startEntranceLogCoordinateEvent);
break;
case 2288: // Tunnel
AreaEvent startTunnelAreaEvent = new AreaEvent(p, 3003, 3937, 3005, 3938);
startTunnelAreaEvent.setAction(() => {
int newMove = 0;
int pX = p.getLocation().getX();
int pY = p.getLocation().getY();
if (pX == objectX + 1 && pY == objectY) // right side
newMove = 1;
else if (pX == objectX - 1 && pY == objectY) // left side
newMove = 2;
if (newMove > 0) {
int walkTunnelCounter = 0;
Event walkTunnelEvent = new Event(500);
walkTunnelEvent.setAction(() => {
if (walkTunnelCounter == 0) {
p.getWalkingQueue().forceWalk(0, -1);
} else if (walkTunnelCounter == 1) {
p.getWalkingQueue().forceWalk(newMove == 1 ? -1 : +1, 0);
} else {
doCourse(p, objectX, objectY, objectArray);
walkTunnelEvent.stop();
}
walkTunnelCounter++;
});
Server.registerEvent(walkTunnelEvent);
return;
}
Event squeezeIntoPipeEvent = new Event(0);
squeezeIntoPipeEvent.setAction(() => {
squeezeIntoPipeEvent.stop();
p.getPackets().sendMessage("You squeeze into the pipe...");
int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
p.setForceMovement(new ForceMovement(lX, lY, lX, lY + 3, 10, 60, 0));
p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() + 1, 0));
p.setLastAnimation(new Animation(10578));
bool running = p.getWalkingQueue().isRunToggled();
p.getWalkingQueue().setRunToggled(false);
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setTemporaryAttribute("unmovable", true);
Event squeezeOutOfPipeEvent = new Event(1000);
int squeezeOutOfPipeCounter = 0;
squeezeOutOfPipeEvent.setAction(() => {
if (squeezeOutOfPipeCounter == 0) {
p.teleport(new Location(p.getLocation().getX(), p.getLocation().getY() + 9, 0));
squeezeOutOfPipeEvent.setTick(850);
} else if (squeezeOutOfPipeCounter == 1) {
ForceMovement movement = new ForceMovement(lX, lY + 9, lX, lY + 12, 10, 90, 0);
p.setForceMovement(movement);
squeezeOutOfPipeEvent.setTick(1100);
} else if (squeezeOutOfPipeCounter == 2) {
squeezeOutOfPipeEvent.setTick(500);
p.setLastAnimation(new Animation(10579));
p.setForceMovement(new ForceMovement(lX, lY + 12, lX, lY + 13, 10, 40, 0));
//.........这里部分代码省略.........
示例14: mineRock
public static void mineRock(Player p, ushort rockId, Location rockLocation, int i, bool newMine)
{
if (!newMine && p.getTemporaryAttribute("miningRock") == null)
{
return;
}
if (newMine)
{
if (!Server.getGlobalObjects().objectExists(rockId, rockLocation))
{
//misc.WriteError(p.getUsername() + " tried to mine a non existing rock!");
//return;
}
Rock newRock = new Rock(i, rockId, rockLocation, ORES[i], ROCK_LEVEL[i], NAME[i], ROCK_XP[i]);
p.setTemporaryAttribute("miningRock", newRock);
}
Rock rockToMine = (Rock)p.getTemporaryAttribute("miningRock");
bool essRock = rockToMine.getRockIndex() == 0;
if (!canMine(p, rockToMine, null))
{
resetMining(p);
return;
}
if (newMine)
{
string s = essRock ? "You begin to mine Essence.." : "You swing your pick at the rock..";
p.getPackets().sendMessage(s);
}
p.getPackets().closeInterfaces();
p.setLastAnimation(new Animation(getPickaxeAnimation(p)));
p.setFaceLocation(rockLocation);
int delay = getMineTime(p, rockToMine.getRockIndex());
Event mineRockEvent = new Event(delay);
mineRockEvent.setAction(() =>
{
mineRockEvent.stop(); // Stop the event no matter what
if (p.getTemporaryAttribute("miningRock") == null)
{
return;
}
Rock rock = (Rock)p.getTemporaryAttribute("miningRock");
if (!canMine(p, rockToMine, rock))
{
return;
}
if (!essRock)
{
Server.getGlobalObjects().lowerHealth(rock.getRockId(), rock.getRockLocation());
if (!Server.getGlobalObjects().originalObjectExists(rock.getRockId(), rock.getRockLocation()))
{
resetMining(p);
stopAllOtherMiners(p, rock);
p.setLastAnimation(new Animation(65535));
mineRockEvent.stop();
}
}
bool addGem = (!essRock && Misc.random(getGemChance(p)) == 0) ? true : false;
if (p.getInventory().addItem(addGem ? randomGem() : rock.getOre()))
{
p.getSkills().addXp(Skills.SKILL.MINING, rock.getXp());
if (addGem)
{
p.getPackets().sendMessage("You manage to mine a sparkling gem!");
}
else
{
if (!essRock)
{
p.getPackets().sendMessage("You manage to mine some " + rock.getName() + ".");
}
}
}
if (rock.isContinueMine())
{
mineRock(p, rock.getRockId(), rock.getRockLocation(), rock.getRockIndex(), false);
}
});
Server.registerEvent(mineRockEvent);
if (delay >= 9000 && !rockToMine.isContinueMine())
{
Event mineMoreRockEvent = new Event(9000);
mineMoreRockEvent.setAction(() =>
{
mineMoreRockEvent.stop();
Rock rock = (Rock)p.getTemporaryAttribute("miningRock");
if (!canMine(p, rockToMine, rock))
{
return;
}
p.setFaceLocation(rock.getRockLocation());
p.setLastAnimation(new Animation(getPickaxeAnimation(p)));
});
Server.registerEvent(mineMoreRockEvent);
}
}
示例15: doCourse
public static void doCourse(Player p, int objectX, int objectY, object[] objectArray)
{
if (p.getTemporaryAttribute("unmovable") != null)
return;
switch ((int)objectArray[0])
{
case 20210: // Entrance tunnel
AreaEvent entranceTunnelAreaEvent = new AreaEvent(p, 2551, 3558, 2553, 3561);
entranceTunnelAreaEvent.setAction(() =>
{
entranceTunnelAreaEvent.stop();
int newMove = 0;
int pX = p.getLocation().getX();
int pY = p.getLocation().getY();
if (pX == objectX + 1 && pY == objectY)
newMove = 1;
else if (pX == objectX - 1 && pY == objectY)
newMove = 2;
else if (pX == objectX - 1 && pY == objectY + 1)
newMove = 3;
else if (pX == objectX + 1 && pY == objectY + 1)
newMove = 4;
if (newMove > 0)
{
int path = newMove;
int doCourseCounter = 0;
Event doCourseEvent = new Event(500);
doCourseEvent.setAction(() =>
{
if (doCourseCounter == 0)
{
p.getWalkingQueue().forceWalk(0, (path == 1 || path == 2) ? -1 : (path == 3 || path == 4) ? +1 : 0);
}
else if (doCourseCounter == 1)
{
p.getWalkingQueue().forceWalk((path == 1 || path == 4) ? -1 : (path == 2 || path == 3) ? +1 : 0, 0);
}
else
{
doCourse(p, objectX, objectY, objectArray);
doCourseEvent.stop();
}
doCourseCounter++;
});
Server.registerEvent(doCourseEvent);
return;
}
int startEnterTunnelCounter = 0;
Event startEnterTunnelEvent = new Event(0);
startEnterTunnelEvent.setAction(() =>
{
if (startEnterTunnelCounter == 0)
{
p.setFaceLocation(new Location(p.getLocation().getX(), p.getLocation().getY() <= 3558 ? 3561 : 3558, 0));
startEnterTunnelEvent.setTick(500);
startEnterTunnelCounter++;
}
else
{
startEnterTunnelEvent.stop();
bool running = p.getWalkingQueue().isRunToggled();
int regionX = p.getUpdateFlags().getLastRegion().getRegionX();
int regionY = p.getUpdateFlags().getLastRegion().getRegionY();
int lX = (p.getLocation().getX() - ((regionX - 6) * 8));
int lY = (p.getLocation().getY() - ((regionY - 6) * 8));
int newLocalY = p.getLocation().getY() == 3558 ? lY + 3 : lY - 3;
int newY = newLocalY > lY ? p.getLocation().getY() + 3 : p.getLocation().getY() - 3;
int dir = newLocalY > lY ? 0 : 4;
p.setForceMovement(new ForceMovement(lX, lY, lX, newLocalY, 10, 60, dir));
p.setLastAnimation(new Animation(10580));
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setTemporaryAttribute("unmovable", true);
Event enterTunnelEvent = new Event(1500);
enterTunnelEvent.setAction(() =>
{
enterTunnelEvent.stop();
p.removeTemporaryAttribute("unmovable");
p.teleport(new Location(p.getLocation().getX(), newY, 0));
p.getSkills().addXp(Skills.SKILL.AGILITY, (double)objectArray[7]);
p.getWalkingQueue().setRunToggled(running);
});
Server.registerEvent(enterTunnelEvent);
}
});
Server.registerEvent(startEnterTunnelEvent);
});
Server.registerCoordinateEvent(entranceTunnelAreaEvent);
break;
case 2282: // Swing
AreaEvent swingAreaEvent = new AreaEvent(p, 2550, 3554, 2552, 3555);
swingAreaEvent.setAction(() =>
{
int newMove = 0;
int pX = p.getLocation().getX();
int pY = p.getLocation().getY();
if (pX == objectX - 1 && pY == objectY + 4) // front left
newMove = 1;
//.........这里部分代码省略.........