class RuneRb::Net::ActionSender
Constants
- SIDEBAR_INTERFACES
Attributes
player[R]
Public Class Methods
new(player)
click to toggle source
# File app/net/actionsender.rb, line 10 def initialize(player) @player = player end
Public Instance Methods
send_amount_interface()
click to toggle source
Send amount interface.
# File app/net/actionsender.rb, line 122 def send_amount_interface @player.connection.send_data PacketBuilder.new(27).to_packet self end
send_chat_interface(id)
click to toggle source
Send a chatbox interface.
# File app/net/actionsender.rb, line 101 def send_chat_interface(id) @player.connection.send_data PacketBuilder.new(164).add_leshort(id).to_packet self end
send_clear_screen()
click to toggle source
Clear the screen from all interfaces.
# File app/net/actionsender.rb, line 128 def send_clear_screen @player.connection.send_data PacketBuilder.new(219).to_packet self end
send_config(id, value)
click to toggle source
# File app/net/actionsender.rb, line 286 def send_config(id, value) @player.connection.send_data PacketBuilder.new(36).add_leshort(id).add_byte(value).to_packet self end
send_details()
click to toggle source
Send the initial login details.
# File app/net/actionsender.rb, line 36 def send_details @player.connection.send_data PacketBuilder.new(249).add_byte_a(1).add_leshort_a(player.index).to_packet @player.connection.send_data PacketBuilder.new(107).to_packet self end
send_grounditem_creation(item)
click to toggle source
Create a ground item.
# File app/net/actionsender.rb, line 151 def send_grounditem_creation(item) x = item.location.x - (@player.last_location.get_region_x * 8) y = item.location.y - (@player.last_location.get_region_y * 8) @player.connection.send_data PacketBuilder.new(85).add_byte_c(y).add_byte_c(x).to_packet @player.connection.send_data PacketBuilder.new(44).add_leshort_a(item.item.id).add_short(item.item.count).add_byte(0).to_packet self end
send_grounditem_removal(item)
click to toggle source
Remove a ground item.
# File app/net/actionsender.rb, line 162 def send_grounditem_removal(item) x = item.location.x - (@player.last_location.get_region_x * 8) y = item.location.y - (@player.last_location.get_region_y * 8) @player.connection.send_data PacketBuilder.new(85).add_byte_c(y).add_byte_c(x).to_packet @player.connection.send_data PacketBuilder.new(156).add_byte_s(0).add_short(item.item.id).to_packet self end
send_interaction_option(option, slot, top)
click to toggle source
Add an option for interactions.
# File app/net/actionsender.rb, line 134 def send_interaction_option(option, slot, top) bldr = PacketBuilder.new(104, :VAR) bldr.add_byte_c slot bldr.add_byte_a(top ? 0 : 1) bldr.add_str option @player.connection.send_data bldr.to_packet self end
send_interface(id, walkable = false)
click to toggle source
Open an interface on the client.
# File app/net/actionsender.rb, line 75 def send_interface(id, walkable = false) bldr = PacketBuilder.new(walkable ? 208 : 97) if walkable bldr.add_leshort id else bldr.add_short id end @player.connection.send_data bldr.to_packet self end
send_interface_inventory(interface_id, inv_id)
click to toggle source
Send an interface within the inventory interface.
# File app/net/actionsender.rb, line 89 def send_interface_inventory(interface_id, inv_id) @player.interface_state.interface_opened interface_id @player.connection.send_data PacketBuilder.new(248).add_short_a(interface_id).add_short(inv_id).to_packet end
send_interface_model(id, zoom, model)
click to toggle source
Send a model within an interface.
# File app/net/actionsender.rb, line 95 def send_interface_model(id, zoom, model) @player.connection.send_data PacketBuilder.new(246).add_leshort(id).add_short(zoom).add_short(model).to_packet self end
send_login()
click to toggle source
# File app/net/actionsender.rb, line 14 def send_login send_details # temp send_message("Welcome to RuneRb."); send_map_region send_skills send_interaction_option "Trade", 2, true send_interaction_option "Follow", 3, true self end
send_logout()
click to toggle source
Log the player out.
# File app/net/actionsender.rb, line 30 def send_logout @player.connection.send_data PacketBuilder.new(109).to_packet self end
send_map_region()
click to toggle source
Send map region.
# File app/net/actionsender.rb, line 43 def send_map_region @player.last_location = player.location @player.connection.send_data PacketBuilder.new(73).add_short_a(@player.location.get_region_x + 6).add_short(@player.location.get_region_y + 6).to_packet self end
send_message(message)
click to toggle source
Send player a message in chatbox.
# File app/net/actionsender.rb, line 50 def send_message(message) @player.connection.send_data PacketBuilder.new(253, :VAR).add_str(message).to_packet self end
send_replace_object(loc, rel, new_id, face, type)
click to toggle source
Replace an object within the world.
# File app/net/actionsender.rb, line 251 def send_replace_object(loc, rel, new_id, face, type) # Face: 0 = WEST, -1 = NORTH, -2 = EAST, -3 = SOUTH # Type: 0-3 = Wall Objects, 4-8 = Wall Deco., 9 = Diag. Walls, # 10-11 = World Objects, 12-21 = Roofs, 22 = Floor Deco. bldr = PacketBuilder.new(60, :VARSH) # Location to modify bldr.add_byte (loc.y - (rel.get_region_y * 8)) bldr.add_byte_c (loc.x - (rel.get_region_x * 8)) # Delete object bldr.add_byte 101 bldr.add_byte_c ((type << 2) + (face & 3)) bldr.add_byte 0 # Place object if new_id != -1 bldr.add_byte 151 bldr.add_byte_s 0 bldr.add_leshort new_id bldr.add_byte_s ((type << 2) + (face & 3)) end @player.connection.send_data bldr.to_packet self end
send_skill(skill)
click to toggle source
Send a specific skill update.
# File app/net/actionsender.rb, line 64 def send_skill(skill) bldr = PacketBuilder.new(134) bldr.add_byte RuneRb::Player::Skills::SKILLS.index(skill) bldr.add_int1 @player.skills.exps[skill] bldr.add_byte @player.skills.skills[skill] @player.connection.send_data bldr.to_packet self end
send_skills()
click to toggle source
Update all player skills.
# File app/net/actionsender.rb, line 56 def send_skills RuneRb::Player::Skills::SKILLS.each {|s| send_skill s } self end
send_string(id, string)
click to toggle source
Send a string replacement.
# File app/net/actionsender.rb, line 145 def send_string(id, string) @player.connection.send_data PacketBuilder.new(126, :VARSH).add_str(string).add_short_a(id).to_packet self end
send_system_update(time)
click to toggle source
Start system update countdown.
# File app/net/actionsender.rb, line 281 def send_system_update(time) @player.connection.send_data PacketBuilder.new(114).add_leshort(5 * time / 3).to_packet self end
send_update_item(interface, slot, item)
click to toggle source
Sends an update to a single item.
# File app/net/actionsender.rb, line 227 def send_update_item(interface, slot, item) bldr = PacketBuilder.new(34, :VARSH) bldr.add_short interface bldr.add_smart slot if item != nil bldr.add_short (item.id + 1) count = item.count if count > 254 bldr.add_byte 255 bldr.add_int count else bldr.add_byte count end else bldr.add_short 0 bldr.add_byte 0 end @player.connection.send_data bldr.to_packet self end
send_update_items(interface, items)
click to toggle source
Send updates to a group of items.
# File app/net/actionsender.rb, line 173 def send_update_items(interface, items) bldr = PacketBuilder.new(53, :VARSH) bldr.add_short interface bldr.add_short items.size items.each {|item| if item != nil count = item.count if count > 254 bldr.add_byte 255 bldr.add_int2 count else bldr.add_byte count end bldr.add_leshort_a (item.id + 1) else bldr.add_byte 0 bldr.add_leshort_a 0 end } @player.connection.send_data bldr.to_packet self end
send_update_some_items(interface, slots, items)
click to toggle source
Send an update to mutliple items, but not all.
# File app/net/actionsender.rb, line 200 def send_update_some_items(interface, slots, items) bldr = PacketBuilder.new(34, :VARSH).add_short(interface) slots.each {|slot| item = items[slot] bldr.add_smart slot if item != nil bldr.add_short (item.id + 1) count = item.count if count > 254 bldr.add_byte 255 bldr.add_int count else bldr.add_byte count end else bldr.add_short 0 bldr.add_byte 0 end } @player.connection.send_data bldr.to_packet self end