diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-04-27 21:09:23 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:46 +0200 |
commit | f31277b327df701361391b1d4b8bd6f89f4e3109 (patch) | |
tree | 0fd2b85c13cb11654ff6cd027e0be7ff6b61c2d6 /src/scripting | |
parent | 960d40d819afb65387469591bdb02e6819d72294 (diff) | |
download | manaserv-f31277b327df701361391b1d4b8bd6f89f4e3109.tar.gz manaserv-f31277b327df701361391b1d4b8bd6f89f4e3109.tar.bz2 manaserv-f31277b327df701361391b1d4b8bd6f89f4e3109.tar.xz manaserv-f31277b327df701361391b1d4b8bd6f89f4e3109.zip |
[Abilities] Removed the old autoattack system
As a side effect i had to remove the monster attack AI for now. I will
readd this as next thing.
Diffstat (limited to 'src/scripting')
-rw-r--r-- | src/scripting/lua.cpp | 504 | ||||
-rw-r--r-- | src/scripting/luautil.h | 8 |
2 files changed, 3 insertions, 509 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 11a3feea..87568087 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -33,7 +33,6 @@ extern "C" { #include "game-server/buysell.h" #include "game-server/character.h" #include "game-server/collisiondetection.h" -#include "game-server/combatcomponent.h" #include "game-server/effect.h" #include "game-server/gamehandler.h" #include "game-server/inventory.h" @@ -1381,144 +1380,6 @@ static int entity_walk(lua_State *s) return 0; } -/** LUA entity:damage (being) - * entity:damage(int damage, int delta, - * int accuracy, int type, int element) - * entity:damage(int damage, int delta, int accuracy, - * int type, int element, handle source) - * entity:damage(int damage, int delta, int accuracy, - * int type, int element, handle source, int skill) - * entity:damage(int damage, int delta, int accuracy, - * int type, int element, handle source, string skillname) - ** - * Valid only for being entities. - * - * Inflicts damage to the being. The severity of the attack is between - * `damage` and (`damage` + `delta`) and is calculated using the normal - * damage calculation rules. The being has a chance to - * dodge the attack with its - * [agility attribute](attributes.xml.html). The `accuracy` decides how hard this is. - * - * If `source` is provided the attack is handled as if the `source` - * triggered the damage. - * - * If `skill` is given the `owner` can also recieve XP for the attack. The - * `skill` should be defined in the [skills.xml](skills.xml.html). If the skill - * is provided as string (`skillname`) you have to use this format: - * <setname>_<skillname>. So for example: "Weapons_Unarmed" - * - * `type` affects which kind of armor and character attributes reduce the - * damage. It can be one of the following values: - * <table class="table table-bordered table-hover"> - * <thead> - * <tr> - * <th>Id</th> - * <th>Name</th> - * </tr> - * </thead> - * <tbody> - * <tr> - * <td>0</td> - * <td>DAMAGE_PHYSICAL</td> - * </tr> - * <tr> - * <td>1</td> - * <td>DAMAGE_MAGICAL</td> - * </tr> - * <tr> - * <td>0</td> - * <td>DAMAGE_OTHER</td> - * </tr> - * </tbody> - * </table> - * - * `element` decides how the element system changes the damage. The - * following values are possible: - * <table class="table table-bordered table-hover"> - * <thead> - * <tr> - * <th>Id</th> - * <th>Name</th> - * </tr> - * </thead> - * <tbody> - * <tr> - * <td>0</td> - * <td>ELEMENT_NEUTRAL</td> - * </tr> - * <tr> - * <td>1</td> - * <td>ELEMENT_FIRE</td> - * </tr> - * <tr> - * <td>2</td> - * <td>ELEMENT_WATER</td> - * </tr> - * <tr> - * <td>3</td> - * <td>ELEMENT_EARTH</td> - * </tr> - * <tr> - * <td>4</td> - * <td>ELEMENT_AIR</td> - * </tr> - * <tr> - * <td>5</td> - * <td>ELEMENT_LIGHTNING</td> - * </tr> - * <tr> - * <td>6</td> - * <td>ELEMENT_METAL</td> - * </tr> - * <tr> - * <td>7</td> - * <td>ELEMENT_WOOD</td> - * </tr> - * <tr> - * <td>8</td> - * <td>ELEMENT_ICE</td> - * </tr> - * </tbody> - * </table> - * - * **Return Value**: Actual HP reduction resulting from the attack. - */ -static int entity_damage(lua_State *s) -{ - Entity *being = checkBeing(s, 1); - - if (!being->canFight()) - { - luaL_error(s, "damage called with victim that cannot fight"); - return 0; - } - - Damage dmg; - dmg.base = luaL_checkint(s, 2); - dmg.delta = luaL_checkint(s, 3); - dmg.cth = luaL_checkint(s, 4); - dmg.type = (DamageType)luaL_checkint(s, 5); - dmg.element = (Element)luaL_checkint(s, 6); - Entity *source = 0; - if (lua_gettop(s) >= 7) - { - source = checkBeing(s, 7); - - if (!source->canFight()) - { - luaL_error(s, "damage called with source that cannot fight"); - return 0; - } - } - if (lua_gettop(s) >= 8) - { - dmg.skill = checkSkill(s, 8); - } - being->getComponent<CombatComponent>()->damage(*being, source, dmg); - - return 0; -} - /** LUA entity:heal (being) * entity:heal([int value]) ** @@ -1587,10 +1448,9 @@ static int entity_get_type(lua_State *s) * * | 0 | ACTION_STAND | * | 1 | ACTION_WALK | - * | 2 | ACTION_ATTACK | - * | 3 | ACTION_SIT | - * | 4 | ACTION_DEAD | - * | 5 | ACTION_HURT | + * | 2 | ACTION_SIT | + * | 3 | ACTION_DEAD | + * | 4 | ACTION_HURT | */ static int entity_get_action(lua_State *s) { @@ -2453,55 +2313,6 @@ static int entity_get_monster_id(lua_State *s) return 1; } -/** LUA entity:change_anger (monster) - * entity:change_anger(handle being, int anger) - ** - * Valid only for monster entities. - * - * Makes the monster more angry about the `being` by adding `anger` to the - * being. - */ -static int entity_change_anger(lua_State *s) -{ - Entity *monster = checkMonster(s, 1); - Entity *being = checkBeing(s, 2); - const int anger = luaL_checkint(s, 3); - monster->getComponent<MonsterComponent>()->changeAnger(being, anger); - return 0; -} - -/** LUA entity:drop_anger (monster) - * entity:drop_anger(handle target) - ** - * Valid only for monster entities. - * - * Will drop all anger against the `target`. - */ -static int entity_drop_anger(lua_State *s) -{ - Entity *monster = checkMonster(s, 1); - Entity *being = checkBeing(s, 2); - monster->getComponent<MonsterComponent>()->forgetTarget(being); - return 0; -} - -/** LUA entity:get_angerlist (monster) - * entity:get_angerlist() - ** - * Valid only for monster entities. - * - * **Return value:** A table with the beings as key and the anger against them - * as values. - */ -static int entity_get_angerlist(lua_State *s) -{ - Entity *monster = checkMonster(s, 1); - MonsterComponent *monsterComponent = - monster->getComponent<MonsterComponent>(); - pushSTLContainer(s, monsterComponent->getAngerList()); - return 1; -} - /** LUA_CATEGORY Status effects (statuseffects) */ @@ -3130,38 +2941,6 @@ static int monster_class_on_update(lua_State *s) return 0; } -/** LUA monsterclass:on_damage (monsterclass) - * monsterclass:on_damage(function callback) - ** - * Assigns the `callback` as callback for the monster damage event. - * This callback will be called every time when a monster takes damage. - * The damage can be either invoked from scripts or from other beings such - * as players. The parameters of the callback are: the attacked monster, - * the being dealing the damage and the hp loss - * - * **Note:** See [get_monster_class](scripting.html#get_monster_class) for getting - * a monsterclass object. - * - * **Example:** - * {% highlight lua %} - * local function damage(mob, aggressor, hploss) - * mob:say("I took damage -.- ".. hploss) - * if aggressor then - * mob:say("Curse you, ".. aggressor:name()) - * end - * end - * local maggot = get_monster_class("maggot") - * maggot:on_damage(damage) - * {% endhighlight %} - */ -static int monster_class_on_damage(lua_State *s) -{ - MonsterClass *monsterClass = LuaMonsterClass::check(s, 1); - luaL_checktype(s, 2, LUA_TFUNCTION); - monsterClass->setDamageCallback(getScript(s)); - return 0; -} - /** LUA monsterclass:name (monsterclass) * monsterclass:name() ** @@ -3174,234 +2953,6 @@ static int monster_class_get_name(lua_State *s) return 1; } -/** LUA monsterclass:attacks (monsterclass) - * monsterclass:attacks() - ** - * **Return value:** This function returns a table with all attacks of the - * monster. See the [Attack Info](scripting.html#attackinfo_class) section. - */ -static int monster_class_attacks(lua_State *s) -{ - MonsterClass *monsterClass = LuaMonsterClass::check(s, 1); - pushSTLContainer(s, monsterClass->getAttackInfos()); - return 1; -} - - -/** LUA_CATEGORY AttackInfo class (attackinfoclass) - * The AttackInfo class reveals info about attacks and provides functions to - * register callbacks on attacks. See the - * [Attack Configuration](attackconfiguration.html) for more info. - * To get an AttackInfo use - * [monsterclass:attacks](scripting.html#monsterclassattacks) or - * [itemclass:attacks](scripting.html#itemclassattacks) - */ - -/** LUA attackinfo:priority (attackinfoclass) - * attackinfo:priority() - ** - * **Return value:** This function returns the priority of the attack. - */ -static int attack_get_priority(lua_State *s) -{ - AttackInfo *attack = LuaAttackInfo::check(s, 1); - lua_pushinteger(s, attack->getPriority()); - return 1; -} - -/** LUA attackinfo:cooldowntime (attackinfoclass) - * attackinfo:cooldowntime() - ** - * **Return value:** This function returns the cooldowntime (time after dealing - * damage after which a new attack can be used) of the attack. - */ -static int attack_get_cooldowntime(lua_State *s) -{ - AttackInfo *attack = LuaAttackInfo::check(s, 1); - lua_pushinteger(s, attack->getCooldownTime()); - return 1; -} - -/** LUA attackinfo:warmuptime (attackinfoclass) - * attackinfo:warmuptime() - ** - * **Return value:** This function returns the warmuptime (time before a attack - * triggers damage after being used) of the attack. - */ -static int attack_get_warmuptime(lua_State *s) -{ - AttackInfo *attack = LuaAttackInfo::check(s, 1); - lua_pushinteger(s, attack->getWarmupTime()); - return 1; -} - -/** LUA attackinfo:reusetime (attackinfoclass) - * attackinfo:reusetime() - ** - * **Return value:** This function returns the reusetime (time after which the - * same attack can be used again) of the attack. - */ -static int attack_get_reusetime(lua_State *s) -{ - AttackInfo *attack = LuaAttackInfo::check(s, 1); - lua_pushinteger(s, attack->getReuseTime()); - return 1; -} - -/** LUA attackinfo:damage (attackinfoclass) - * attackinfo:damage() - ** - * **Return value:** This function returns the damage info of the attack. - * - * **See also:** [Damage Class](scripting.html#damage_class) - */ -static int attack_get_damage(lua_State *s) -{ - AttackInfo *attack = LuaAttackInfo::check(s, 1); - LuaDamage::push(s, &attack->getDamage()); - return 1; -} - -/** LUA attackinfo:on_attack (attackinfoclass) - * attackinfo:on_attack(function callback) - ** - * Assigns a callback to the attack that will be called as soon the attack is - * used. The callback will get called with the following parameters: - * being user, being target, int damage_dealt. - */ -static int attack_on_attack(lua_State *s) -{ - AttackInfo *attack = LuaAttackInfo::check(s, 1); - luaL_checktype(s, 2, LUA_TFUNCTION); - attack->setCallback(getScript(s)); - return 0; -} - - -/** LUA_CATEGORY Damage Class (damageclass) - * The Damage class provides info about the kind of damage attack deals. - */ - -/** LUA damage:id (damageclass) - * damage:id() - ** - * **Return value:** This function returns the id of the attack. - */ -static int damage_get_id(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->id); - return 1; -} - -/** LUA damage:skill (damageclass) - * damage:skill() - ** - * **Return value:** This function returns the skill id of the attack. If the - * damage dealer is a character is a character this skill will recieve exp. - */ -static int damage_get_skill(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->skill); - return 1; -} - -/** LUA damage:base (damageclass) - * damage:base() - ** - * **Return value:** This function returns the base damage of the attack. - * It is the minimum of damage dealt. - */ -static int damage_get_base(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->base); - return 1; -} - -/** LUA damage:delta (damageclass) - * damage:delta() - ** - * **Return value:** This function returns the damage delta of the attack. - * base damage + delta damage is the maximum of damage the attack can cause. - * A number in between will be picked by random. - */ -static int damage_get_delta(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->delta); - return 1; -} - -/** LUA damage:cth (damageclass) - * damage:cth() - ** - * **Return value:** This function returns the chance to hit of the attack. - * This number is not a percent value but some factor. Higher means a better - * chance to hit. FIXME: Add info about the factor. - */ -static int damage_get_cth(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->cth); - return 1; -} - -/** LUA damage:element (damageclass) - * damage:element() - ** - * **Return value:** This function returns the element of the attack. - * - * **See:** [entity:damage](scripting.html#entitydamage) for possible values. - */ -static int damage_get_element(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->element); - return 1; -} - -/** LUA damage:type (damageclass) - * damage:type() - ** - * **Return value:** This function returns the type of the attack. - * - * **See:** [entity:damage](scripting.html#entitydamage) for possible values. - */ -static int damage_get_type(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->type); - return 1; -} - -/** LUA damage:is_truestrike (damageclass) - * damage:is_truestrike() - ** - * **Return value:** This function returns whether the attack is a true strike. - * A true strike is not effected by chance of hit or anything that could - * prevent the hit. - */ -static int damage_is_truestrike(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushboolean(s, damage->trueStrike); - return 1; -} - -/** LUA damage:range (damageclass) - * damage:range() - ** - * **Return value:** This function returns the range of the attack in pixels. - */ -static int damage_get_range(lua_State *s) -{ - Damage *damage = LuaDamage::check(s, 1); - lua_pushinteger(s, damage->range); - return 1; -} - /** LUA_CATEGORY Map object class (mapobjectclass) */ @@ -3570,23 +3121,6 @@ static int item_class_get_name(lua_State *s) return 1; } -/** LUA itemclass:attacks (itemclass) - * itemclass:attacks() - ** - * **Return value:** Returns a list of all attacks the item offers. - * - * **See:** the [AttackInfo class](scripting.html#attackinfo_class) for more info - * about how to use the values in the list. - */ -static int item_class_attacks(lua_State *s) -{ - ItemClass *itemClass = LuaItemClass::check(s, 1); - std::vector<AttackInfo *> attacks = itemClass->getAttackInfos(); - pushSTLContainer<AttackInfo *>(s, attacks); - return 1; -} - - /** * Returns four useless tables for testing the STL container push wrappers. * This function can be removed when there are more useful functions which use @@ -3745,29 +3279,6 @@ LuaScript::LuaScript(): #endif lua_pop(mRootState, 1); // pop the globals table - static luaL_Reg const members_AttackInfo[] = { - { "priority", attack_get_priority }, - { "cooldowntime", attack_get_cooldowntime }, - { "warmuptime", attack_get_warmuptime }, - { "reusetime", attack_get_reusetime }, - { "damage", attack_get_damage }, - { "on_attack", attack_on_attack }, - { nullptr, nullptr } - }; - - static luaL_Reg const members_Damage[] = { - { "id", damage_get_id }, - { "skill", damage_get_skill }, - { "base", damage_get_base }, - { "delta", damage_get_delta }, - { "cth", damage_get_cth }, - { "element", damage_get_element }, - { "type", damage_get_type }, - { "is_truestrike", damage_is_truestrike }, - { "range", damage_get_range }, - { nullptr, nullptr } - }; - static luaL_Reg const members_Entity[] = { { "remove", entity_remove }, { "say", entity_say }, @@ -3784,7 +3295,6 @@ LuaScript::LuaScript(): { "ability_mana", entity_get_ability_mana }, { "cooldown_ability", entity_cooldown_ability }, { "walk", entity_walk }, - { "damage", entity_damage }, { "heal", entity_heal }, { "name", entity_get_name }, { "type", entity_get_type }, @@ -3823,9 +3333,6 @@ LuaScript::LuaScript(): { "has_ability", entity_has_ability }, { "take_ability", entity_take_ability }, { "monster_id", entity_get_monster_id }, - { "change_anger", entity_change_anger }, - { "drop_anger", entity_drop_anger }, - { "angerlist", entity_get_angerlist }, { "apply_status", entity_apply_status }, { "remove_status", entity_remove_status }, { "has_status", entity_has_status }, @@ -3838,7 +3345,6 @@ LuaScript::LuaScript(): static luaL_Reg const members_ItemClass[] = { { "on", item_class_on }, { "name", item_class_get_name }, - { "attacks", item_class_attacks }, { nullptr, nullptr } }; @@ -3852,9 +3358,7 @@ LuaScript::LuaScript(): static luaL_Reg const members_MonsterClass[] = { { "on_update", monster_class_on_update }, - { "on_damage", monster_class_on_damage }, { "name", monster_class_get_name }, - { "attacks", monster_class_attacks }, { nullptr, nullptr } }; @@ -3873,8 +3377,6 @@ LuaScript::LuaScript(): { nullptr, nullptr} }; - LuaAttackInfo::registerType(mRootState, "Attack", members_AttackInfo); - LuaDamage::registerType(mRootState, "Damage", members_Damage); LuaEntity::registerType(mRootState, "Entity", members_Entity); LuaItemClass::registerType(mRootState, "ItemClass", members_ItemClass); LuaMapObject::registerType(mRootState, "MapObject", members_MapObject); diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h index 9ea11c07..e7cbc754 100644 --- a/src/scripting/luautil.h +++ b/src/scripting/luautil.h @@ -34,7 +34,6 @@ extern "C" { #include <set> #include <vector> -#include "game-server/attack.h" #include "game-server/abilitymanager.h" class CharacterComponent; @@ -159,8 +158,6 @@ private: template <typename T> const char * LuaUserData<T>::mTypeName; -typedef LuaUserData<AttackInfo> LuaAttackInfo; -typedef LuaUserData<Damage> LuaDamage; typedef LuaUserData<Entity> LuaEntity; typedef LuaUserData<ItemClass> LuaItemClass; typedef LuaUserData<MapObject> LuaMapObject; @@ -210,11 +207,6 @@ inline void push(lua_State *s, double val) lua_pushnumber(s, val); } -inline void push(lua_State *s, AttackInfo *val) -{ - LuaAttackInfo::push(s, val); -} - inline void push(lua_State *s, MapObject *val) { LuaMapObject::push(s, val); |