mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Clarify unclear code.
This commit is contained in:
@@ -10,8 +10,8 @@ ORE_SIZE = 1
|
|||||||
class MiningAction < DistancedAction
|
class MiningAction < DistancedAction
|
||||||
attr_reader :position, :ore, :counter, :started
|
attr_reader :position, :ore, :counter, :started
|
||||||
|
|
||||||
def initialize(player, position, ore)
|
def initialize(mob, position, ore)
|
||||||
super 0, true, player, position, ORE_SIZE
|
super 0, true, mob, position, ORE_SIZE
|
||||||
@position = position
|
@position = position
|
||||||
@ore = ore
|
@ore = ore
|
||||||
@started = false
|
@started = false
|
||||||
@@ -20,12 +20,12 @@ class MiningAction < DistancedAction
|
|||||||
|
|
||||||
def find_pickaxe
|
def find_pickaxe
|
||||||
PICKAXE_IDS.each do |id|
|
PICKAXE_IDS.each do |id|
|
||||||
weapon = player.equipment.get EquipmentConstants::WEAPON
|
weapon = mob.equipment.get EquipmentConstants::WEAPON
|
||||||
if weapon.id == id
|
if weapon.id == id
|
||||||
return PICKAXES[id]
|
return PICKAXES[id]
|
||||||
end
|
end
|
||||||
|
|
||||||
if player.inventory.contains id
|
if mob.inventory.contains id
|
||||||
return PICKAXES[id]
|
return PICKAXES[id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -33,31 +33,31 @@ class MiningAction < DistancedAction
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# starts the mining animation, sets counters/flags and turns the player to
|
# starts the mining animation, sets counters/flags and turns the mob to
|
||||||
# the ore
|
# the ore
|
||||||
def start_mine(pickaxe)
|
def start_mine(pickaxe)
|
||||||
@started = true
|
@started = true
|
||||||
player.send_message "You swing your pick at the rock."
|
mob.send_message "You swing your pick at the rock."
|
||||||
player.turn_to @position
|
mob.turn_to @position
|
||||||
player.play_animation pickaxe.animation
|
mob.play_animation pickaxe.animation
|
||||||
@counter = pickaxe.pulses
|
@counter = pickaxe.pulses
|
||||||
end
|
end
|
||||||
|
|
||||||
def executeAction
|
def executeAction
|
||||||
skills = player.skill_set
|
skills = mob.skill_set
|
||||||
level = skills.get_skill(Skill::MINING).current_level
|
level = skills.get_skill(Skill::MINING).current_level
|
||||||
pickaxe = find_pickaxe
|
pickaxe = find_pickaxe
|
||||||
|
|
||||||
# verify the player can mine with their pickaxe
|
# verify the mob can mine with their pickaxe
|
||||||
if not (pickaxe != nil and level >= pickaxe.level)
|
if not (pickaxe != nil and level >= pickaxe.level)
|
||||||
player.send_message "You do not have a pickaxe for which you have the level to use."
|
mob.send_message "You do not have a pickaxe for which you have the level to use."
|
||||||
stop
|
stop
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# verify the player can mine the ore
|
# verify the mob can mine the ore
|
||||||
if ore.level > level
|
if ore.level > level
|
||||||
player.send_message "You do not have the required level to mine this rock."
|
mob.send_message "You do not have the required level to mine this rock."
|
||||||
stop
|
stop
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -68,13 +68,13 @@ class MiningAction < DistancedAction
|
|||||||
else
|
else
|
||||||
# count down and check if we can have a chance at some ore now
|
# count down and check if we can have a chance at some ore now
|
||||||
if @counter == 0
|
if @counter == 0
|
||||||
# TODO: calculate the chance that the player can actually get the rock
|
# TODO: calculate the chance that the mob can actually get the rock
|
||||||
|
|
||||||
if player.inventory.add ore.id
|
if mob.inventory.add ore.id
|
||||||
ore_def = ItemDefinition.lookup @ore.id # TODO: split off into some method
|
ore_def = ItemDefinition.lookup @ore.id # TODO: split off into some method
|
||||||
name = ore_def.name.sub(/ ore$/, "").downcase
|
name = ore_def.name.sub(/ ore$/, "").downcase
|
||||||
|
|
||||||
player.send_message "You manage to mine some #{name}."
|
mob.send_message "You manage to mine some #{name}."
|
||||||
skills.add_experience Skill::MINING, ore.exp
|
skills.add_experience Skill::MINING, ore.exp
|
||||||
# TODO: expire the rock
|
# TODO: expire the rock
|
||||||
end
|
end
|
||||||
@@ -94,12 +94,12 @@ end
|
|||||||
class ExpiredProspectingAction < DistancedAction
|
class ExpiredProspectingAction < DistancedAction
|
||||||
attr_reader :position
|
attr_reader :position
|
||||||
|
|
||||||
def initialize(player, position)
|
def initialize(mob, position)
|
||||||
super 0, true, player, position, ORE_SIZE
|
super 0, true, mob, position, ORE_SIZE
|
||||||
end
|
end
|
||||||
|
|
||||||
def executeAction
|
def executeAction
|
||||||
player.send_message "There is currently no ore available in this rock."
|
mob.send_message "There is currently no ore available in this rock."
|
||||||
stop
|
stop
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ end
|
|||||||
class ProspectingAction < DistancedAction
|
class ProspectingAction < DistancedAction
|
||||||
attr_reader :position, :ore
|
attr_reader :position, :ore
|
||||||
|
|
||||||
def initialize(player, position, ore)
|
def initialize(mob, position, ore)
|
||||||
super PROSPECT_PULSES, true, player, position, ORE_SIZE
|
super PROSPECT_PULSES, true, mob, position, ORE_SIZE
|
||||||
@position = position
|
@position = position
|
||||||
@ore = ore
|
@ore = ore
|
||||||
@started = false
|
@started = false
|
||||||
@@ -123,13 +123,13 @@ class ProspectingAction < DistancedAction
|
|||||||
if not @started
|
if not @started
|
||||||
@started = true
|
@started = true
|
||||||
|
|
||||||
player.send_message "You examine the rock for ores..."
|
mob.send_message "You examine the rock for ores..."
|
||||||
player.turn_to @position
|
mob.turn_to @position
|
||||||
else
|
else
|
||||||
ore_def = ItemDefinition.lookup @ore.id
|
ore_def = ItemDefinition.lookup @ore.id
|
||||||
name = ore_def.name.sub(/ ore$/, "").downcase
|
name = ore_def.name.sub(/ ore$/, "").downcase
|
||||||
|
|
||||||
player.send_message "This rock contains #{name}."
|
mob.send_message "This rock contains #{name}."
|
||||||
|
|
||||||
stop
|
stop
|
||||||
end
|
end
|
||||||
@@ -140,24 +140,22 @@ class ProspectingAction < DistancedAction
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on :event, :object_action do |ctx, player, event|
|
on :event, :object_action do |ctx, mob, event|
|
||||||
if event.option == 1
|
if event.option == 1
|
||||||
ore = ORES[event.id]
|
ore = ORES[event.id]
|
||||||
if ore != nil
|
if ore != nil
|
||||||
player.startAction MiningAction.new(player, event.position, ore)
|
mob.startAction MiningAction.new(mob, event.position, ore)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on :event, :object_action do |ctx, player, event|
|
on :event, :object_action do |ctx, mob, event|
|
||||||
if event.option == 2
|
if event.option == 2
|
||||||
ore = ORES[event.id]
|
ore = ORES[event.id]
|
||||||
if ore != nil
|
if ore != nil
|
||||||
player.startAction ProspectingAction.new(player, event.position, ore)
|
mob.startAction ProspectingAction.new(mob, event.position, ore)
|
||||||
else
|
elsif EXPIRED_ORES[event.id] != nil
|
||||||
if EXPIRED_ORES[event.id] != nil
|
mob.startAction ExpiredProspectingAction.new(mob, event.position)
|
||||||
player.startAction ExpiredProspectingAction.new(player, event.position)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -72,21 +72,21 @@ public final class ItemDefinitionDecoder {
|
|||||||
if (opcode == 0) {
|
if (opcode == 0) {
|
||||||
return definition;
|
return definition;
|
||||||
} else if (opcode == 1) {
|
} else if (opcode == 1) {
|
||||||
buffer.getShort();// & 0xFFFF; // model Id
|
buffer.getShort();
|
||||||
} else if (opcode == 2) {
|
} else if (opcode == 2) {
|
||||||
definition.setName(ByteBufferUtil.readString(buffer));
|
definition.setName(ByteBufferUtil.readString(buffer));
|
||||||
} else if (opcode == 3) {
|
} else if (opcode == 3) {
|
||||||
definition.setDescription(ByteBufferUtil.readString(buffer));
|
definition.setDescription(ByteBufferUtil.readString(buffer));
|
||||||
} else if (opcode == 4) {
|
} else if (opcode == 4) {
|
||||||
buffer.getShort();// & 0xFFFF; // sprite scale
|
buffer.getShort();
|
||||||
} else if (opcode == 5) {
|
} else if (opcode == 5) {
|
||||||
buffer.getShort();// & 0xFFFF; // sprite pitch
|
buffer.getShort();
|
||||||
} else if (opcode == 6) {
|
} else if (opcode == 6) {
|
||||||
buffer.getShort();// & 0xFFFF; //sprite camera roll
|
buffer.getShort();
|
||||||
} else if (opcode == 7) {
|
} else if (opcode == 7) {
|
||||||
buffer.getShort(); // sprite dX
|
buffer.getShort();
|
||||||
} else if (opcode == 8) {
|
} else if (opcode == 8) {
|
||||||
buffer.getShort(); // sprite dY
|
buffer.getShort();
|
||||||
} else if (opcode == 10) {
|
} else if (opcode == 10) {
|
||||||
buffer.getShort();
|
buffer.getShort();
|
||||||
} else if (opcode == 11) {
|
} else if (opcode == 11) {
|
||||||
@@ -96,15 +96,15 @@ public final class ItemDefinitionDecoder {
|
|||||||
} else if (opcode == 16) {
|
} else if (opcode == 16) {
|
||||||
definition.setMembersOnly(true);
|
definition.setMembersOnly(true);
|
||||||
} else if (opcode == 23) {
|
} else if (opcode == 23) {
|
||||||
buffer.getShort(); // & 0xFFFF; //primaryMaleEquipModelId
|
buffer.getShort();
|
||||||
buffer.get(); // maleEquipYTranslation
|
buffer.get();
|
||||||
} else if (opcode == 24) {
|
} else if (opcode == 24) {
|
||||||
buffer.getShort(); // & 0xFFFF; // secondaryMaleEquipModelId
|
buffer.getShort();
|
||||||
} else if (opcode == 25) {
|
} else if (opcode == 25) {
|
||||||
buffer.getShort(); // & 0xFFFF; // primaryFemaleEquipModelId
|
buffer.getShort();
|
||||||
buffer.get(); // femaleEquipYTranslation
|
buffer.get();
|
||||||
} else if (opcode == 26) {
|
} else if (opcode == 26) {
|
||||||
buffer.getShort(); // & 0xFFFF; // secondaryFemaleEquipModelId
|
buffer.getShort();
|
||||||
} else if (opcode >= 30 && opcode < 35) {
|
} else if (opcode >= 30 && opcode < 35) {
|
||||||
String str = ByteBufferUtil.readString(buffer);
|
String str = ByteBufferUtil.readString(buffer);
|
||||||
if (str.equalsIgnoreCase("hidden")) {
|
if (str.equalsIgnoreCase("hidden")) {
|
||||||
@@ -116,40 +116,40 @@ public final class ItemDefinitionDecoder {
|
|||||||
} else if (opcode == 40) {
|
} else if (opcode == 40) {
|
||||||
int colourCount = buffer.get() & 0xFF;
|
int colourCount = buffer.get() & 0xFF;
|
||||||
for (int i = 0; i < colourCount; i++) {
|
for (int i = 0; i < colourCount; i++) {
|
||||||
buffer.getShort(); // & 0xFFFF; // original colour
|
buffer.getShort();
|
||||||
buffer.getShort(); // & 0xFFFF; // replacement colour
|
buffer.getShort();
|
||||||
}
|
}
|
||||||
} else if (opcode == 78) {
|
} else if (opcode == 78) {
|
||||||
buffer.getShort(); // & 0xFFFF; // tertiaryMaleEquipModelId
|
buffer.getShort();
|
||||||
} else if (opcode == 79) {
|
} else if (opcode == 79) {
|
||||||
buffer.getShort(); // & 0xFFFF; // tertiaryFemaleEquipModelId
|
buffer.getShort();
|
||||||
} else if (opcode == 90) {
|
} else if (opcode == 90) {
|
||||||
buffer.getShort(); // & 0xFFFF; // primaryMaleHeadPiece
|
buffer.getShort();
|
||||||
} else if (opcode == 91) {
|
} else if (opcode == 91) {
|
||||||
buffer.getShort(); // & 0xFFFF; // primaryFemaleHeadPiece
|
buffer.getShort();
|
||||||
} else if (opcode == 92) {
|
} else if (opcode == 92) {
|
||||||
buffer.getShort(); // & 0xFFFF; // secondaryMaleHeadPiece
|
buffer.getShort();
|
||||||
} else if (opcode == 93) {
|
} else if (opcode == 93) {
|
||||||
buffer.getShort(); // & 0xFFFF; // secondaryFemaleHeadPiece
|
buffer.getShort();
|
||||||
} else if (opcode == 95) {
|
} else if (opcode == 95) {
|
||||||
buffer.getShort(); // & 0xFFFF; // spriteCameraYaw
|
buffer.getShort();
|
||||||
} else if (opcode == 97) {
|
} else if (opcode == 97) {
|
||||||
definition.setNoteInfoId(buffer.getShort() & 0xFFFF);
|
definition.setNoteInfoId(buffer.getShort() & 0xFFFF);
|
||||||
} else if (opcode == 98) {
|
} else if (opcode == 98) {
|
||||||
definition.setNoteGraphicId(buffer.getShort() & 0xFFFF);
|
definition.setNoteGraphicId(buffer.getShort() & 0xFFFF);
|
||||||
} else if (opcode >= 100 && opcode < 110) {
|
} else if (opcode >= 100 && opcode < 110) {
|
||||||
buffer.getShort(); // & 0xFFFF; // stack id
|
buffer.getShort();
|
||||||
buffer.getShort(); // & 0xFFFF; // stack size
|
buffer.getShort();
|
||||||
} else if (opcode == 110) {
|
} else if (opcode == 110) {
|
||||||
buffer.getShort(); // & 0xFFFF; // groundScaleX
|
buffer.getShort();
|
||||||
} else if (opcode == 111) {
|
} else if (opcode == 111) {
|
||||||
buffer.getShort(); // & 0xFFFF; // groundScaleY
|
buffer.getShort();
|
||||||
} else if (opcode == 112) {
|
} else if (opcode == 112) {
|
||||||
buffer.getShort(); // & 0xFFFF; // groundScaleZ
|
buffer.getShort();
|
||||||
} else if (opcode == 113) {
|
} else if (opcode == 113) {
|
||||||
buffer.get(); // light ambiance
|
buffer.get();
|
||||||
} else if (opcode == 114) {
|
} else if (opcode == 114) {
|
||||||
buffer.getShort(); // * 5; // light diffusion
|
buffer.getShort();
|
||||||
} else if (opcode == 115) {
|
} else if (opcode == 115) {
|
||||||
definition.setTeam(buffer.get() & 0xFF);
|
definition.setTeam(buffer.get() & 0xFF);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user