本文整理汇总了C#中RunescapeServer.player.Player.setTarget方法的典型用法代码示例。如果您正苦于以下问题:C# Player.setTarget方法的具体用法?C# Player.setTarget怎么用?C# Player.setTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RunescapeServer.player.Player
的用法示例。
在下文中一共展示了Player.setTarget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handlePacket
public void handlePacket(Player player, Packet packet) {
int size = packet.getLength();
if(packet.getPacketId() == PacketHandlers.PacketId.WALK_2) {
size -= 14;
}
player.getWalkingQueue().resetWalkingQueue();
int steps = (size - 5) / 2;
if (steps > WalkingQueue.MAX_WALKING_WAYPOINTS)
{
misc.WriteError("Warning: Walk command contains too many steps (" + steps + ") currently set to 50 [maybe need increase?]");
return;
}
player.getWalkingQueue().setIsRunning(packet.readByteA() == 1);
bool following = false;
if (!canWalk(player, packet, following))
{
player.getPackets().clearMapFlag();
player.getWalkingQueue().resetWalkingQueue();
return;
}
int firstX = packet.readUShort() - (player.getLocation().getRegionX() - 6) * 8;
int firstY = packet.readShortA() - (player.getLocation().getRegionY() - 6) * 8;
player.getWalkingQueue().addToWalkingQueue(firstX, firstY);
for (int i = 0; i < steps; i++) //all the waypoints.
player.getWalkingQueue().addToWalkingQueue((packet.readByteA() + firstX), (packet.readByteS() + firstY));
if (player.getTeleportTo() != null) //is teleporting?
player.getWalkingQueue().resetWalkingQueue();
if (player.getTemporaryAttribute("homeTeleporting") != null) {
player.removeTemporaryAttribute("homeTeleporting");
}
SkillHandler.resetAllSkills(player);
if (player.getTrade() != null)
player.getTrade().decline();
if (player.getDuel() != null) {
if (player.getDuel().getStatus() < 4)
player.getDuel().declineDuel();
else if (player.getDuel().getStatus() == 8)
player.getDuel().recieveWinnings(player);
}
if (player.getTarget() != null) {
if (!following && player.getTarget().getAttacker() != null && player.getTarget().getAttacker().Equals(player))
player.getTarget().setAttacker(null);
}
if (!following) {
player.getFollow().setFollowing(null);
player.setTarget(null);
player.removeTemporaryAttribute("autoCasting");
if (player.getEntityFocus() != 65535)
player.setEntityFocus(65535);
}
player.getPackets().closeInterfaces();
}
示例2: resetVariables
private void resetVariables(Player p) {
p.setSkullCycles(0);
p.getSpecialAttack().resetSpecial();
p.setLastkiller(null);
p.setDead(false);
p.setEntityFocus(65535);
p.setPoisonAmount(0);
p.clearKillersHits();
p.setLastVengeanceTime(0);
p.setVengeance(false);
p.removeTemporaryAttribute("willDie");
p.setFrozen(false);
p.removeTemporaryAttribute("unmovable");
p.setAntifireCycles(0);
p.setSuperAntipoisonCycles(0);
p.setTeleblockTime(0);
p.removeTemporaryAttribute("teleblocked");
p.setTarget(null);
p.setAttacker(null);
foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
p.getSkills().setCurLevel(skill, p.getSkills().getMaxLevel(skill));
p.getPackets().sendSkillLevels();
Prayer.deactivateAllPrayers(p);
if (p.getTemporaryAttribute("cantDoAnything") != null) {
p.getAppearance().setInvisible(false);
p.getUpdateFlags().setAppearanceUpdateRequired(true);
p.removeTemporaryAttribute("cantDoAnything");
p.removeTemporaryAttribute("unmovable");
teleportToWaitingRoom(p, false);
p.getPackets().closeInterfaces();
p.getPackets().setMinimapStatus(0);
p.getPackets().clearMapFlag();
}
}
示例3: teleport
public static bool teleport(Player p, int opt, JewellerySlot js) {
if (js == null) {
return false;
}
if (js.index == -1 || js.index > 3 || opt > 6) {
return false;
}
if (!canTeleport(p, js)) {
p.getPackets().closeInterfaces();
return true;
}
if ((js.index == 2 && opt == 4) || (js.index != 2 && opt == 6)) {
p.getPackets().sendMessage("You stay where you are.");
p.getPackets().closeInterfaces();
return true;
}
opt -= 2; // Used to get the 'index' from the button id.
p.setLastGraphics(new Graphics(1684));
p.setLastAnimation(new Animation(9603));
p.getWalkingQueue().resetWalkingQueue();
p.getPackets().clearMapFlag();
p.setTemporaryAttribute("teleporting", true);
p.setTemporaryAttribute("unmovable", true);
p.removeTemporaryAttribute("autoCasting");
p.removeTemporaryAttribute("lootedBarrowChest");
p.setTarget(null);
changeJewellery(p, js);
int option = opt;
p.getPackets().closeInterfaces();
Event teleportEvent = new Event(2000);
teleportEvent.setAction(() => {
teleportEvent.stop();
p.teleport(new Location(TELEPORT_COORDINATES[js.index][option][0], TELEPORT_COORDINATES[js.index][option][1], 0));
p.setLastAnimation(new Animation(65535));
Teleport.resetTeleport(p);
p.removeTemporaryAttribute("unmovable");
});
Server.registerEvent(teleportEvent);
return true;
}
示例4: handleMagicOnNPC
private void handleMagicOnNPC(Player player, Packet packet) {
int childId = packet.readLEShort();
int interfaceId = packet.readLEShort();
int junk = packet.readShortA();
int npcIndex = packet.readLEShortA();
if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
Npc npc = Server.getNpcList()[npcIndex];
if (npc == null || npc.isDestroyed()) {
return;
}
SkillHandler.resetAllSkills(player);
player.setTarget(npc);
MagicCombat.newMagicAttack(player, npc, childId, interfaceId == 193);
Console.WriteLine(childId);
}
示例5: drinkPotion
private static void drinkPotion(Player p, int i, int j, int slot) {
//TODO antipoisons/antifire
int lastPotion = -1;
int delay = 500;
long lastDrink = 0;
if (p.isDead() || p.getTemporaryAttribute("willDie") != null) {
return;
}
if (p.getDuel() != null) {
if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_DRINKS)) {
p.getPackets().sendMessage("Drinks have been disabled for this duel!");
return;
}
}
if (p.getTemporaryAttribute("lastDrankPotion") != null) {
lastPotion = (int) p.getTemporaryAttribute("lastDrankPotion");
}
if (p.getTemporaryAttribute("drinkPotionTimer") != null) {
lastDrink = (int) p.getTemporaryAttribute("drinkPotionTimer");
}
int time = (j == lastPotion) ? 1000 : 500;
if (Environment.TickCount - lastDrink < time) {
return;
}
p.getPackets().closeInterfaces();
p.setTemporaryAttribute("drinkPotionTimer", Environment.TickCount);
p.setTemporaryAttribute("lastDrankPotion", j);
p.setTarget(null);
p.resetCombatTurns();
p.setEntityFocus(65535);
p.removeTemporaryAttribute("autoCasting");
Event drinkPotionEvent = new Event(delay);
drinkPotionEvent.setAction(() => {
drinkPotionEvent.stop();
if (p.isDead() || p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) <= 0) {
return;
}
int item = i != 0 && POTIONS[i - 1][j] != -1 ? POTIONS[i - 1][j] : 229;
if (!p.getInventory().replaceItemSlot(POTIONS[i][j], item, slot)) {
return;
}
string drinkPotion = ItemData.forId(POTIONS[0][j]).getName().Replace("(", "").Replace(")", "").Replace("3", "").Replace("2", "").Replace("1", "").ToLower();
p.getPackets().sendMessage("You drink some of your " + drinkPotion + ".");
p.getPackets().sendMessage("You have " + (i == 0 ? "no" : i.ToString()) + " doses of potion left.");
switch(j) {
case 0: //Attack potion [+3 and 10% of max attack]
statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
break;
case 1: //Antipoison potion
p.setPoisonAmount(0);
break;
case 2: //Strength potion [+3 and 10% of max strength]
statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
break;
case 3: //Restore potion [restores randomly between 10-39 points]
restorePotion(p, Skills.SKILL.DEFENCE, 10, 39);
restorePotion(p, Skills.SKILL.ATTACK, 10, 39);
restorePotion(p, Skills.SKILL.STRENGTH, 10, 39);
restorePotion(p, Skills.SKILL.RANGE, 10, 39);
restorePotion(p, Skills.SKILL.HITPOINTS, 10, 39);
break;
case 4: //Energy potion [restores 20% energy]
double newEnergy = p.getRunEnergy() * 0.20;
p.setRunEnergy(((p.getRunEnergy() + (int)newEnergy >= 100) ? 100 : (p.getRunEnergy() + (int)newEnergy)));
break;
case 5: //Defence potion [Should be +3 and 10% of max defence]
statBoost(p, Skills.SKILL.DEFENCE, 0.10, 3, false);
break;
case 6: //Agility potion [restores 2 or 3 agility points]
int newAgility = misc.random(2, 3) + p.getSkills().getCurLevel(Skills.SKILL.AGILITY);
if (newAgility < p.getSkills().getMaxLevel(Skills.SKILL.AGILITY))
p.getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility);
break;
case 7: //Combat potion [Should be 10% of attack+strength and +3 to each].
statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
break;
case 8: //Prayer potion, [heals 7-31, formula = 7+floor(prayerlevel/4)]
int newPrayer = 7 + (int)Math.Floor((double)(p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) / 4)) + p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
if (newPrayer < p.getSkills().getCurLevel(Skills.SKILL.PRAYER))
p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayer);
checkOverdose(p, Skills.SKILL.PRAYER);
break;
case 9: //Summoning potion [25% of players summoning + 7]
int newSummoning = (7 + (int)((double)p.getSkills().getMaxLevel(Skills.SKILL.SUMMONING) * 0.25)) + p.getSkills().getCurLevel(Skills.SKILL.SUMMONING);
if (newSummoning < p.getSkills().getCurLevel(Skills.SKILL.SUMMONING))
p.getSkills().setCurLevel(Skills.SKILL.SUMMONING, newSummoning);
statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
break;
//.........这里部分代码省略.........
示例6: eatFood
private static void eatFood(Player p, int i, int j, int slot) {
//delay at which you eat food 0.5 seconds (half a second per eat).
int delay = 500;
//If you are dead or yourHp is zero (this should be enough), also if variable is set to die from next attack
if (p.isDead() || p.getHp() <= 0 || p.getTemporaryAttribute("willDie") != null)
return;
//Last time you ate timer was previously set.
if (p.getTemporaryAttribute("eatFoodTimer") != null) {
//Check if the timer has passed the time of 1.2 seconds
if (Environment.TickCount - (int) p.getTemporaryAttribute("eatFoodTimer") < 1200) {
return;
}
}
//if you are in a duel
if (p.getDuel() != null) {
//dueling with No Food rule enabled
if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_FOOD)) {
p.getPackets().sendMessage("Food has been disabled for this duel!");
return;
}
}
//Set timer right now because you are eating some food.
p.setTemporaryAttribute("eatFoodTimer", Environment.TickCount);
//while you are eating the target you are attacking gets reset.
p.setTarget(null);
p.resetCombatTurns();
p.setEntityFocus(65535);
p.getPackets().closeInterfaces();
p.removeTemporaryAttribute("autoCasting");
//start eating the food at delay which is 0.5 of a second / half a second.
Event eatFoodEvent = new Event(delay);
eatFoodEvent.setAction(() => {
//make the food eating event stop after this time.
eatFoodEvent.stop();
//if you are dead or your hp is zero aka dead.
if (p.isDead() || p.getHp() <= 0) {
return;
}
int newHealth = p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) + FOOD_HEAL[j];
int item = i != 2 && FOOD[i + 1][j] != -1 ? FOOD[i + 1][j] : -1;
if (!p.getInventory().replaceItemSlot(FOOD[i][j], item, slot))
{
return;
}
p.getPackets().sendMessage("You eat the " + ItemData.forId(FOOD[i][j]).getName().ToLower() + ".");
p.getSkills().setCurLevel(Skills.SKILL.HITPOINTS, newHealth > p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) ? p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) : newHealth);
p.setLastAnimation(new Animation(829));
p.getPackets().sendSkillLevel(Skills.SKILL.HITPOINTS);
});
Server.registerEvent(eatFoodEvent);
}
示例7: handleMagicOnPlayer
private void handleMagicOnPlayer(Player player, Packet packet) {
int junk = packet.readShortA();
int id = packet.readLEShort();
int interfaceId = packet.readLEShort();
int index = packet.readLEShortA();
if(index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
SkillHandler.resetAllSkills(player);
Player p2 = Server.getPlayerList()[index];
if (p2 == null) {
return;
}
player.getPackets().closeInterfaces();
player.setTarget(p2);
MagicCombat.newMagicAttack(player, p2, id, interfaceId == 193);
}