本文整理汇总了C#中WorldServer.player.Player.getAttacker方法的典型用法代码示例。如果您正苦于以下问题:C# Player.getAttacker方法的具体用法?C# Player.getAttacker怎么用?C# Player.getAttacker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldServer.player.Player
的用法示例。
在下文中一共展示了Player.getAttacker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: canCastSpell
private static bool canCastSpell(Player p, Entity target, int i, bool fakeNPC)
{
// fakeNPC is used to keep location when autocasting.
if (fakeNPC) {
return !p.isDead();
}
if (target.isDead() || p.isDead() || target.isDestroyed() || p.isDestroyed()) {
return false;
}
if (target is Npc) {
if (((Npc) target).getHp() <= 0) {
return false;
}
if (i == 47) {
p.getPackets().sendMessage("You cannot cast Teleblock upon an NPC.");
return false;
}
}
if ((target is Player) && (p is Player)) {
if (Location.inFightPits(target.getLocation()) && Location.inFightPits(target.getLocation()))
{
if (!Server.getMinigames().getFightPits().hasGameStarted()) {
return false;
}
return true;
}
if (p.getDuel() != null) {
if (((Player)target).getDuel() != null) {
if (p.getDuel().getPlayer2().Equals(((Player) target)) && ((Player) target).getDuel().getPlayer2().Equals(p)) {
if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_MAGIC)) {
p.getPackets().sendMessage("Magical combat has been disabled in this duel!");
return false;
}
if (p.getDuel().getStatus() == 6 && ((Player) target).getDuel().getStatus() == 6) {
return true;
}
}
}
p.getPackets().sendMessage("That isn't your opponent.");
return false;
}
if (i == 47) {
if (((Player)target).getTemporaryAttribute("teleblocked") != null) {
p.getPackets().sendMessage("That player already has a teleportation block upon them.");
return false;
}
}
if (!Location.inWilderness(target.getLocation())) {
p.getPackets().sendMessage("That player isn't in the wilderness.");
return false;
}
if (!Location.inWilderness(p.getLocation()))
{
p.getPackets().sendMessage("You aren't in the wilderness.");
return false;
}
int killerWildLevel = p.getLocation().wildernessLevel();
int targetWildLevel = ((Player)target).getLocation().wildernessLevel();
int killerCombatLevel = p.getSkills().getCombatLevel();
int targetCombatLevel = ((Player)target).getSkills().getCombatLevel();
int highest = killerCombatLevel > targetCombatLevel ? killerCombatLevel : targetCombatLevel;
int lowest = highest == killerCombatLevel ? targetCombatLevel : killerCombatLevel;
int difference = (highest - lowest);
if (difference > killerWildLevel || difference > targetWildLevel) {
((Player) p).getPackets().sendMessage("You must move deeper into the wilderness to attack that player.");
return false;
}
}
if (!Location.inMultiCombat(target.getLocation())) {
if (p.getAttacker() != null && !p.getAttacker().Equals(target)) {
p.getPackets().sendMessage("You are already in combat!");
return false;
}
if (target.getAttacker() != null && !target.getAttacker().Equals(p)) {
string type = target is Player ? "player" : "npc";
p.getPackets().sendMessage("That " + type + " is already in combat.");
return false;
}
}
if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < SPELL_LEVEL[i]) {
p.getPackets().sendMessage("You need a Magic level of " + SPELL_LEVEL[i] + " to cast that spell.");
return false;
}
if (!hasRunes(p, RUNES[i], RUNE_AMOUNTS[i])) {
p.getPackets().sendMessage("You do not have enough runes to cast that spell.");
return false;
}
if (NEEDS_STAFF[i]) {
if ((i != 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]) || (i == 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != 8841 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]))
{
p.getPackets().sendMessage("You need to wield " + STAFF_NAME[i] + " to cast this spell.");
return false;
}
}
if (i == 37) {
if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2412)
{
p.getPackets().sendMessage("You need to wear the Cape of Saradomin to be able to cast Saradomin Strike.");
return false;
}
//.........这里部分代码省略.........