/* Copyright (c) 1998-2010, Enno Rehling Katja Zedel Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ #include #include #include "xerewards.h" /* kernel includes */ #include #include #include #include #include #include #include #include #include /* util includes */ #include /* libc includes */ #include #include #include static int use_skillpotion(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { /* the problem with making this a lua function is that there's no way * to get the list of skills for a unit. and with the way skills are * currently saved, it doesn't look likely (can't make eressea::list * from them) */ int n; for (n = 0; n != amount; ++n) { skill *sv = u->skills; while (sv != u->skills + u->skill_size) { int i; for (i = 0; i != 3; ++i) learn_skill(u, (skill_t)sv->id, 1.0); ++sv; } } ADDMSG(&u->faction->msgs, msg_message("skillpotion_use", "unit", u)); change_resource(u, itype->rtype, -amount); return 0; } static int use_manacrystal(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { int i, sp = 0; if (!is_mage(u)) { cmistake(u, u->thisorder, 295, MSG_EVENT); return -1; } for (i = 0; i != amount; ++i) { sp += MAX(25, max_spellpoints(u->region, u) / 2); change_spellpoints(u, sp); } ADDMSG(&u->faction->msgs, msg_message("manacrystal_use", "unit aura", u, sp)); change_resource(u, itype->rtype, -amount); return 0; } void register_xerewards(void) { register_item_use(use_skillpotion, "use_skillpotion"); register_item_use(use_manacrystal, "use_manacrystal"); }