diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-04-15 21:24:55 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2013-04-15 21:24:55 +0200 |
commit | ef4175cdfae6a6981738e15cb0009d8e47ed7c80 (patch) | |
tree | 5237140b62274b63b9a98ef65aec92df804eb1f6 /example/scripts/maps | |
parent | 0f1449567d5a2ccab9ff6fdc9975150299482834 (diff) | |
download | manaserv-ef4175cdfae6a6981738e15cb0009d8e47ed7c80.tar.gz manaserv-ef4175cdfae6a6981738e15cb0009d8e47ed7c80.tar.bz2 manaserv-ef4175cdfae6a6981738e15cb0009d8e47ed7c80.tar.xz manaserv-ef4175cdfae6a6981738e15cb0009d8e47ed7c80.zip |
Moved functions to entity members where appropriate
Some functions were skipped for now because they may need a new name
or change of behavior. Changes:
chr_warp entity:warp
chr_get_inventory entity:inventory
chr_inv_change entity:inv_change
chr_inv_count entity:inv_count
chr_get_equipment entity:equipment
chr_equip_slot entity:equip_slot
chr_equip_item entity:equip_item
chr_unequip_slot entity:unequip_slot
chr_unequip_item entity:unequip_item
chr_get_level entity:level
chr_get_exp entity:xp
chr_give_exp entity:give_xp
chr_get_rights entity:rights
chr_set_hair_style entity:set_hair_style
chr_get_hair_style entity:hair_style
chr_set_hair_color entity:set_hair_color
chr_get_hair_color entity:hair_color
chr_get_kill_count entity:kill_count
chr_give_special entity:give_special
chr_has_special entity:has_special
chr_take_special entity:take_special
chr_set_special_recharge_speed entity:set_special_recharge_speed
chr_get_special_recharge_speed entity:special_recharge_speed
chr_set_special_mana entity:set_special_mana
chr_get_special_mana entity:special_mana
chr_kick entity:kick
exp_for_level xp_for_level
monster_get_id entity:monster_id
monster_change_anger entity:change_anger
monster_drop_anger entity:drop_anger
monster_get_angerlist entity:angerlist
being_apply_status entity:apply_status
being_remove_status entity:remove_status
being_has_status entity:has_status
being_set_status_time entity:set_status_time
being_get_status_time entity:status_time
being_get_gender entity:gender
being_set_gender entity:set_gender
being_type entity:type
being_walk entity:walk
being_say entity:say
being_damage entity:damage
being_heal entity:heal
being_get_name entity:name
being_get_action entity:action
being_set_action entity:set_action
being_get_direction entity:direction
being_set_direction entity:set_direction
being_apply_attribute_modifier entity:apply_attribute_modifier
being_remove_attribute_modifier entity:remove_attribute_modifier
being_set_base_attribute entity:set_base_attribute
being_get_modified_attribute entity:modified_attribute
being_get_base_attribute entity:base_attribute
being_set_walkmask entity:set_walkmask
being_get_walkmask entity:walkmask
being_get_mapid entity:mapid
chat_message entity:message
being_register entity:register
chr_shake_screen entity:shake_screen
chr_create_text_particle entity:show_text_particle
- entity:position
posX entity:x
posY entity:y
monster_get_name monsterclass:name
item_get_name itemclass:name
Diffstat (limited to 'example/scripts/maps')
-rw-r--r-- | example/scripts/maps/desert.lua | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/example/scripts/maps/desert.lua b/example/scripts/maps/desert.lua index 86f5c814..759dbb51 100644 --- a/example/scripts/maps/desert.lua +++ b/example/scripts/maps/desert.lua @@ -37,7 +37,7 @@ atinit(function() end) function Smith(npc, ch, list) - local sword_count = chr_inv_count(ch, true, true, "Sword") + local sword_count = ch:inv_count(true, true, "Sword") if sword_count > 0 then say("Ah! I can see you already have a sword.") end @@ -48,7 +48,7 @@ function possessions_table(npc, ch) local item_message = "Inventory:".. "\nSlot id, item id, item name, amount:".. "\n----------------------" - local inventory_table = chr_get_inventory(ch) + local inventory_table = ch:inventory() for i = 1, #inventory_table do item_message = item_message.."\n"..inventory_table[i].slot..", " ..inventory_table[i].id..", "..inventory_table[i].name..", " @@ -59,7 +59,7 @@ function possessions_table(npc, ch) item_message = "Equipment:".. "\nSlot id, item id, item name:".. "\n----------------------" - local equipment_table = chr_get_equipment(ch) + local equipment_table = ch:equipment() for i = 1, #equipment_table do item_message = item_message.."\n"..equipment_table[i].slot..", " ..equipment_table[i].id..", "..equipment_table[i].name @@ -71,7 +71,7 @@ end -- Global variable used to know whether Harmony talked to someone. harmony_have_talked_to_someone = false function Harmony(npc, ch, list) - being_apply_status(ch, 1, 99999) + ch:apply_status(1, 99999) -- Say all the messages in the messages list. for i = 1, #list do say(list[i]) @@ -82,7 +82,7 @@ function Harmony(npc, ch, list) chr_money_change(ch, 100) say(string.format("You now have %d shiny coins!", chr_money(ch))) harmony_have_talked_to_someone = true - say(string.format("Try to come back with a better level than %i.", chr_get_level(ch))) + say(string.format("Try to come back with a better level than %i.", ch:level())) else say("Let me see what you've got so far... Don't be afraid!") effect_create(EMOTE_WINK, npc) @@ -91,8 +91,7 @@ function Harmony(npc, ch, list) say("Have fun!") effect_create(EMOTE_HAPPY, npc) -- Make Harmony disappear for a while... with a small earthquake effect! - local shakeX = posX(npc) - local shakeY = posY(npc) + local shakeX, shakeY = npc:position() npc_disable(npc) tremor(shakeX, shakeY, 300) @@ -109,35 +108,35 @@ function Harmony_update(npc) harmony_tick_count = harmony_tick_count + 1 if harmony_tick_count > 100 then harmony_tick_count = 0 - being_say(npc, "Hey! You're new! Come here...") + npc:say("Hey! You're new! Come here...") end end end function Tamer(npc, ch, list) - being_say(npc, string.format("You have %s Sword(s).", - chr_inv_count(ch, true, true, "Sword"))) - being_say(npc, string.format("You are %s pixel away.", - get_distance(npc, ch))) - being_say(npc, "I will now spawn a monster for your training session.") + npc:say(string.format("You have %s Sword(s).", + ch:inv_count(true, true, "Sword"))) + npc:say(string.format("You are %s pixel away.", + get_distance(npc, ch))) + npc:say("I will now spawn a monster for your training session.") -- Remove monsters in the area - for i, b in ipairs(get_beings_in_rectangle(posX(npc) - 3 * TILESIZE, - posY(npc) - 3 * TILESIZE, - 6 * TILESIZE, 6 * TILESIZE)) do - if being_type(b) == TYPE_MONSTER then + for i, b in ipairs(get_beings_in_rectangle(npc:x() - 3 * TILESIZE, + npc:y() - 3 * TILESIZE, + 6 * TILESIZE, 6 * TILESIZE)) do + if b:type() == TYPE_MONSTER then b:remove() end end - local m1 = monster_create("Maggot", posX(ch), posY(ch)) - monster_change_anger(m1, ch, 100) + local m1 = monster_create("Maggot", ch:position()) + m1:change_anger(ch, 100) -- (The following is not safe, since the being might have been removed by -- the time this function gets executed (especially with the above code)) -- --schedule_in(0.5, function() - -- being_say(m1, "Roaaarrrr!!!") - -- monster_change_anger(m1, ch, 100) + -- m1:say("Roaaarrrr!!!") + -- m1:change_anger(ch, 100) -- end) end |