Skip to content
This repository
tree: e443c9aba6
Fetching contributors…

Cannot retrieve contributors at this time

file 332 lines (290 sloc) 11.921 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
------------------------------------------------------------------------------[[
-- Filename: items.lua
--
-- Description: This file contains the definitions of all items.
-- Each item has a unique integer identifier that is used
-- as its key in the items table below. Item IDs are unique not only among
-- each other, but among other inventory game objects as well (weapons, armor,
-- etc).
--
-- Object IDs 1 through 10,000 are reserved for items. Do not break this
-- limit, because other value ranges correspond to other types of inventory objects.
--
-- Item IDs do -not- need to be sequential. When you make a new item, keep it
-- grouped with similar item types (potions, scrolls, etc.) and keep a buffer of
-- space between group types. This way we won't get a mess of random items all over
-- this file.
--
-- All item entries needs the following data to be defined:
-- {name}: Text that defines the name of the item.
-- {description}: A brief description about the item.
-- {icon}: The filepath to the image icon representing this icon.
-- {target_type}: The type of target the item affects, which may be an attack point, actor, or party.
-- {standard_price}: The standard asking price of this weapon from merchants.
-- {warmup_time}: The time needed before using that item in battles.
-- {cooldown_time}: The time needed after using that item in battles.
--
-- Each item entry requires a function called {BattleUse} to be defined. This function implements the
-- use of item in battle, healing damage, causing status changes, playing sounds, and animating
-- sprites.
--
-- If an item is to be permitted for use outside of battle, an additional function {FieldUse} should
-- be defined. Defintion of this function is optional, but required for any items which are intended
-- to be used in the field. Their implementations will be similar to but more simple than their BattleUse
-- cousins as they do not need to be concerned with certain things such as sprite animations.
------------------------------------------------------------------------------]]

-- All item definitions are stored in this table
if (items == nil) then
items = {}
end


--------------------------------------------------------------------------------
-- IDs 1 - 1,000 are reserved for healing potions
--------------------------------------------------------------------------------

function battle_healing_potion(target, hit_points)
if (target:IsAlive() and target:GetHitPoints() < target:GetMaxHitPoints()) then
target:RegisterHealing(hit_points, true);
AudioManager:PlaySound("snd/potion_drink.wav");
return true;
else
target:RegisterMiss(false);
return false;
end
end

-- The return value tells the inventory whether the item was used successfully,
-- and then whether it can be removed from it.
function field_healing_potion(target, hit_points)
if (target:IsAlive() and target:GetHitPoints() < target:GetMaxHitPoints()) then
target:AddHitPoints(hit_points);
AudioManager:PlaySound("snd/potion_drink.wav");
return true;
else
AudioManager:PlaySound("snd/cancel.wav");
return false;
end
end

items[1] = {
name = hoa_system.Translate("Minor Healing Potion"),
description = hoa_system.Translate("Restores a small amount of hit points to an ally."),
icon = "img/icons/items/potion_green_small.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 60,
warmup_time = 1000,
cooldown_time = 700,

BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_healing_potion(target_actor, 40);
end,

FieldUse = function(target)
return field_healing_potion(target, 45);
end
}

items[2] = {
name = hoa_system.Translate("Medium Healing Potion"),
description = hoa_system.Translate("Restores a reasonable amount of hit points to an ally."),
icon = "img/icons/items/potion_green_medium.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 300,
warmup_time = 1200,
cooldown_time = 900,

BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_healing_potion(target_actor, 150);
end,

FieldUse = function(target)
return field_healing_potion(target, 200);
end
}

items[3] = {
name = hoa_system.Translate("Healing Potion"),
description = hoa_system.Translate("Restores a large amount of hit points to an ally."),
icon = "img/icons/items/potion_green_large.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 1000,
warmup_time = 1200,
cooldown_time = 900,

BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_healing_potion(target_actor, 500);
end,

FieldUse = function(target)
return field_healing_potion(target, 620);
end
}

items[4] = {
name = hoa_system.Translate("Mega Healing Potion"),
description = hoa_system.Translate("Restores a very high amount of hit points to an ally."),
icon = "img/icons/items/potion_green_large.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 5000,
warmup_time = 1200,
cooldown_time = 1200,

BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_healing_potion(target_actor, 9000);
end,

FieldUse = function(target)
return field_healing_potion(target, 12000);
end
}

-- Moon juices : Skill points
function battle_skill_potion(target, skill_points)
if (target:IsAlive() and target:GetSkillPoints() < target:GetMaxSkillPoints()) then
target:RegisterHealing(skill_points, false);
AudioManager:PlaySound("snd/potion_drink.wav");
return true;
else
target:RegisterMiss(false);
return false;
end
end

-- The return value tells the inventory whether the item was used successfully,
-- and then whether it can be removed from it.
function field_skill_potion(target, skill_points)
if (target:IsAlive() and target:GetSkillPoints() < target:GetMaxSkillPoints()) then
target:AddSkillPoints(skill_points);
AudioManager:PlaySound("snd/potion_drink.wav");
return true;
else
AudioManager:PlaySound("snd/cancel.wav");
return false;
end
end


items[11] = {
name = hoa_system.Translate("Small Moon Juice Potion"),
description = hoa_system.Translate("Restores a small amount of skill points to an ally."),
icon = "img/icons/items/potion_blue_small.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 90,
use_warmup_time = 1000,
cooldown_time = 1200,

    BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_skill_potion(target_actor, 40);
end,

FieldUse = function(target)
return field_skill_potion(target, 45);
end
}

items[12] = {
name = hoa_system.Translate("Medium Moon Juice Potion"),
description = hoa_system.Translate("Restores a reasonable amount of skill points to an ally."),
icon = "img/icons/items/potion_blue_medium.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 380,
use_warmup_time = 1000,
cooldown_time = 1200,

    BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_skill_potion(target_actor, 150);
end,

FieldUse = function(target)
return field_skill_potion(target, 200);
end
}

items[13] = {
name = hoa_system.Translate("Moon Juice Potion"),
description = hoa_system.Translate("Restores a large amount of skill points to an ally."),
icon = "img/icons/items/potion_blue_large.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 1300,
use_warmup_time = 1000,
cooldown_time = 1200,

    BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_skill_potion(target_actor, 300);
end,

FieldUse = function(target)
return field_skill_potion(target, 420);
end
}

items[13] = {
name = hoa_system.Translate("Mega Moon Juice Potion"),
description = hoa_system.Translate("Restores a very high amount of skill points to an ally."),
icon = "img/icons/items/potion_blue_huge.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 6100,
use_warmup_time = 1200,
cooldown_time = 1300,

    BattleUse = function(user, target)
target_actor = target:GetActor();
return battle_skill_potion(target_actor, 999);
end,

FieldUse = function(target)
return field_skill_potion(target, 1200);
end
}

--------------------------------------------------------------------------------
-- IDs 1,001 - 2,000 are reserved for status potions
--------------------------------------------------------------------------------

decrement_negative_effects = function(target_actor, intensity)
    if (target_actor:IsAlive() == true) then
        -- decrement all the basic negative effects, or put positive effects depending on the intensity
        target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_STRENGTH_RAISE, intensity);
        target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_RAISE, intensity);
        target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_FORTITUDE_RAISE, intensity);
        target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_RAISE, intensity);
        target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_AGILITY_RAISE, intensity);
        target_actor:RegisterStatusChange(hoa_global.GameGlobal.GLOBAL_STATUS_EVADE_RAISE, intensity);
AudioManager:PlaySound("snd/potion_drink.wav");
return true;
    else
        target_actor:RegisterMiss(false);
return false;
    end
end

items[1001] = {
name = hoa_system.Translate("Minor Elixir"),
description = hoa_system.Translate("Improve the character status when it is sane or reduces ailing status effects by a limited degree."),
icon = "img/icons/items/potion_red_small.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY,
standard_price = 160,
use_warmup_time = 1200,
cooldown_time = 1800,

BattleUse = function(user, target)
target_actor = target:GetActor();
-- Decrement all base stats active negative status effects slightly
return decrement_negative_effects(target_actor, hoa_global.GameGlobal.GLOBAL_INTENSITY_POS_LESSER);
end,

FieldUse = function(target)
-- TODO: decrement any active negative status effects when alive, like poison, or paralysis, but not the base stats effects
-- which are valid only in battles.
return false;
end
}

items[1003] = {
name = hoa_system.Translate("Elixir"),
description = hoa_system.Translate("Revive a character, or reduces almost all its ailing status effects if the potion is drunk when alive."),
icon = "img/icons/items/potion_red_large.png",
target_type = hoa_global.GameGlobal.GLOBAL_TARGET_ALLY_EVEN_DEAD,
standard_price = 1600,
use_warmup_time = 1600,
cooldown_time = 2100,

BattleUse = function(user, target)
target_actor = target:GetActor();
if (target_actor:GetHitPoints() > 0) then
-- Decrement any active negative base stats status effects when alive
return decrement_negative_effects(target_actor, hoa_global.GameGlobal.GLOBAL_INTENSITY_POS_MODERATE);
else
-- When dead, revive the character
target_actor:RegisterRevive(1);
end
return true;
end,

FieldUse = function(target)
if (target:GetHitPoints() > 0) then
-- TODO: decrement any active negative status effects when alive, like poison, or paralysis, but not the base stats effects
-- which are valid only in battles.
return false;
else
-- When dead, revive the character
target:SetHitPoints(1);
end
return true;
end
}

--------------------------------------------------------------------------------
-- IDs 2,001 - 3,000 are reserved for elemental potions
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- IDs 3,001 - 4,000 are reserved for attack items
--------------------------------------------------------------------------------
Something went wrong with that request. Please try again.