diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-07 15:45:47 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-07 15:51:49 +0200 |
commit | 203d42e75a02c68d7cda9ff85023910bd1a0a6f4 (patch) | |
tree | 5567957f8576b55a8fc6ba4b9c7e99786397f7f7 | |
parent | a01f15e08da3b2e0e326b2a94100e17962136741 (diff) |
Lua: Refactor Lua-based powers into C
-rw-r--r-- | lib/mods/theme/scpt/init.lua | 3 | ||||
-rw-r--r-- | lib/mods/theme/scpt/powers.lua | 59 | ||||
-rw-r--r-- | lib/scpt/init.lua | 3 | ||||
-rw-r--r-- | lib/scpt/powers.lua | 59 | ||||
-rw-r--r-- | src/defines.h | 5 | ||||
-rw-r--r-- | src/externs.h | 3 | ||||
-rw-r--r-- | src/player.pkg | 6 | ||||
-rw-r--r-- | src/powers.c | 25 | ||||
-rw-r--r-- | src/spells.pkg | 14 | ||||
-rw-r--r-- | src/tables.c | 21 | ||||
-rw-r--r-- | src/variable.c | 8 |
11 files changed, 53 insertions, 153 deletions
diff --git a/lib/mods/theme/scpt/init.lua b/lib/mods/theme/scpt/init.lua index b70fb773..7a229abd 100644 --- a/lib/mods/theme/scpt/init.lua +++ b/lib/mods/theme/scpt/init.lua @@ -11,9 +11,6 @@ tome_dofile("help.lua") -- let the store specific stuff happen! tome_dofile("stores.lua") --- Add various 'U' powers -tome_dofile("powers.lua") - -- Add the mimic shapes tome_dofile("mimic.lua") diff --git a/lib/mods/theme/scpt/powers.lua b/lib/mods/theme/scpt/powers.lua deleted file mode 100644 index 90d69ac7..00000000 --- a/lib/mods/theme/scpt/powers.lua +++ /dev/null @@ -1,59 +0,0 @@ --- Various 'U' powers - --- Invisibility power, for the mouse mimic shape -POWER_INVISIBILITY = add_power -{ - ["name"] = "invisibility", - ["desc"] = "You are able melt into the shadows to become invisible.", - ["desc_get"] = "You suddenly become able to melt into the shadows.", - ["desc_lose"] = "You lose your shadow-melting ability.", - ["level"] = 30, - ["cost"] = 10, - ["stat"] = A_DEX, - ["fail"] = 20, - ["power"] = function() - set_invis(20 + randint(30), 30) - end, -} - --- Web power, for the spider mimic shape -POWER_WEB = add_power -{ - ["name"] = "web", - ["desc"] = "You are able throw a thick and very resistant spider web.", - ["desc_get"] = "You suddenly become able to weave webs.", - ["desc_lose"] = "You lose your web-weaving capability.", - ["level"] = 25, - ["cost"] = 30, - ["stat"] = A_DEX, - ["fail"] = 20, - ["power"] = function() - -- Warning, beware of f_info changes .. I hate to do that .. - grow_things(16, 1 + (player.lev / 10)) - end, -} - --- Activating/stopping space-continuum --- When stopped it will induce constant mana loss -POWER_COR_SPACE_TIME = add_power -{ - ["name"] = "control space/time continuum", - ["desc"] = "You are able to control the space/time continuum.", - ["desc_get"] = "You become able to control the space/time continuum.", - ["desc_lose"] = "You are no more able to control the space/time continuum.", - ["level"] = 1, - ["cost"] = 10, - ["stat"] = A_WIS, - ["fail"] = 10, - ["power"] = function() - if player.corrupt_anti_teleport_stopped == TRUE then - player.corrupt_anti_teleport_stopped = FALSE - msg_print("You stop controlling your corruption.") - player.update = bor(player.update, PU_BONUS) - else - player.corrupt_anti_teleport_stopped = TRUE - msg_print("You start controlling your corruption, teleportation works once more.") - player.update = bor(player.update, PU_BONUS) - end - end, -} diff --git a/lib/scpt/init.lua b/lib/scpt/init.lua index ea42f927..d0512c76 100644 --- a/lib/scpt/init.lua +++ b/lib/scpt/init.lua @@ -11,9 +11,6 @@ tome_dofile("help.lua") -- let the store specific stuff happen! tome_dofile("stores.lua") --- Add various 'U' powers -tome_dofile("powers.lua") - -- Add the mimic shapes tome_dofile("mimic.lua") diff --git a/lib/scpt/powers.lua b/lib/scpt/powers.lua deleted file mode 100644 index 90d69ac7..00000000 --- a/lib/scpt/powers.lua +++ /dev/null @@ -1,59 +0,0 @@ --- Various 'U' powers - --- Invisibility power, for the mouse mimic shape -POWER_INVISIBILITY = add_power -{ - ["name"] = "invisibility", - ["desc"] = "You are able melt into the shadows to become invisible.", - ["desc_get"] = "You suddenly become able to melt into the shadows.", - ["desc_lose"] = "You lose your shadow-melting ability.", - ["level"] = 30, - ["cost"] = 10, - ["stat"] = A_DEX, - ["fail"] = 20, - ["power"] = function() - set_invis(20 + randint(30), 30) - end, -} - --- Web power, for the spider mimic shape -POWER_WEB = add_power -{ - ["name"] = "web", - ["desc"] = "You are able throw a thick and very resistant spider web.", - ["desc_get"] = "You suddenly become able to weave webs.", - ["desc_lose"] = "You lose your web-weaving capability.", - ["level"] = 25, - ["cost"] = 30, - ["stat"] = A_DEX, - ["fail"] = 20, - ["power"] = function() - -- Warning, beware of f_info changes .. I hate to do that .. - grow_things(16, 1 + (player.lev / 10)) - end, -} - --- Activating/stopping space-continuum --- When stopped it will induce constant mana loss -POWER_COR_SPACE_TIME = add_power -{ - ["name"] = "control space/time continuum", - ["desc"] = "You are able to control the space/time continuum.", - ["desc_get"] = "You become able to control the space/time continuum.", - ["desc_lose"] = "You are no more able to control the space/time continuum.", - ["level"] = 1, - ["cost"] = 10, - ["stat"] = A_WIS, - ["fail"] = 10, - ["power"] = function() - if player.corrupt_anti_teleport_stopped == TRUE then - player.corrupt_anti_teleport_stopped = FALSE - msg_print("You stop controlling your corruption.") - player.update = bor(player.update, PU_BONUS) - else - player.corrupt_anti_teleport_stopped = TRUE - msg_print("You start controlling your corruption, teleportation works once more.") - player.update = bor(player.update, PU_BONUS) - end - end, -} diff --git a/src/defines.h b/src/defines.h index b590edc5..95c8eff5 100644 --- a/src/defines.h +++ b/src/defines.h @@ -4301,7 +4301,7 @@ /* * Powers (mutation, activations, ...) */ -#define POWER_MAX_INIT 62 +#define POWER_MAX_INIT 65 #define PWR_SPIT_ACID 0 #define PWR_BR_FIRE 1 @@ -4366,6 +4366,9 @@ #define PWR_BEAR 59 #define PWR_DODGE 60 #define PWR_BALROG 61 +#define POWER_INVISIBILITY 62 +#define POWER_WEB 63 +#define POWER_COR_SPACE_TIME 64 #define ADD_POWER(pow, p) ((pow)[(p)] = TRUE) diff --git a/src/externs.h b/src/externs.h index c82eee41..c400d76f 100644 --- a/src/externs.h +++ b/src/externs.h @@ -603,9 +603,6 @@ extern s32b max_gods; extern timer_type *gl_timers; extern s16b tim_precognition; extern const char *get_version_string(); -extern s16b POWER_INVISIBILITY; -extern s16b POWER_WEB; -extern s16b POWER_COR_SPACE_TIME; /* plots.c */ extern FILE *hook_file; diff --git a/src/player.pkg b/src/player.pkg index fd7754fc..e5d64cbc 100644 --- a/src/player.pkg +++ b/src/player.pkg @@ -3427,9 +3427,9 @@ extern void desc_god(int g_idx, int d, char *desc); #define PWR_BALROG 61 /** @} */ -extern s16b POWER_INVISIBILITY; -extern s16b POWER_WEB; -extern s16b POWER_COR_SPACE_TIME; +#define POWER_INVISIBILITY 62 +#define POWER_WEB 63 +#define POWER_COR_SPACE_TIME 64 /* Misc */ diff --git a/src/powers.c b/src/powers.c index 12b2c2c0..2f0206aa 100644 --- a/src/powers.c +++ b/src/powers.c @@ -1221,7 +1221,32 @@ static void power_activate(int power) use_ability_blade(); break; + case POWER_INVISIBILITY: + set_invis(20 + randint(30), 30); + break; + + case POWER_WEB: + /* Warning, beware of f_info changes .. I hate to do that .. */ + grow_things(16, 1 + (p_ptr->lev / 10)); + break; + + case POWER_COR_SPACE_TIME: + if (p_ptr->corrupt_anti_teleport_stopped) + { + p_ptr->corrupt_anti_teleport_stopped = FALSE; + msg_print("You stop controlling your corruption."); + p_ptr->update |= PU_BONUS; + } + else + { + p_ptr->corrupt_anti_teleport_stopped = TRUE; + msg_print("You start controlling your corruption, teleportation works once more."); + p_ptr->update |= PU_BONUS; + } + break; + default: + if (!process_hooks(HOOK_ACTIVATE_POWER, "(d)", power)) { msg_format("Warning power_activate() called with invalid power(%d).", power); diff --git a/src/spells.pkg b/src/spells.pkg index 77a1794e..c972a814 100644 --- a/src/spells.pkg +++ b/src/spells.pkg @@ -754,20 +754,6 @@ extern bool project(int who, int rad, int y, int x, int dam, int typ, int flg); */ extern void corrupt_player(void); -/** @fn grow_things(s16b type, int rad) - * @brief Grow "type" things within "rad" distance of the player.\n - * @param type Number \n type of thing to grow (FEAT field). - * @brief Type - * @param rad Number \n rad is the radius of the area where things may grow. - * @brief Radius - * @note - * Grow things\n\n - * Up to (rad * (rad + 11)) things can be grown around the player. The - * grids must support growth. - * @note (see file spells2.c) - */ -extern void grow_things(s16b type, int rad); - /** @fn grow_grass(int rad) * @brief Grow grass within "rad" distance of the player.\n * @param rad Number \n rad is the radius of the area where grass may grow. diff --git a/src/tables.c b/src/tables.c index d0dbb9b7..3df97271 100644 --- a/src/tables.c +++ b/src/tables.c @@ -3571,6 +3571,27 @@ power_type powers_type_init[POWER_MAX_INIT] = "You no longer feel the fire of Udun in you.", 35, 80, A_WIS, 25, }, + { + "invisibility", + "You are able melt into the shadows to become invisible.", + "You suddenly become able to melt into the shadows.", + "You lose your shadow-melting ability.", + 30, 10, A_DEX, 20, + }, + { + "web", + "You are able throw a thick and very resistant spider web.", + "You suddenly become able to weave webs.", + "You lose your web-weaving capability.", + 25, 30, A_DEX, 20, + }, + { + "control space/time continuum", + "You are able to control the space/time continuum.", + "You become able to control the space/time continuum.", + "You are no more able to control the space/time continuum.", + 1, 10, A_WIS, 10, + }, }; /* diff --git a/src/variable.c b/src/variable.c index f775df66..8ad1d14f 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1593,14 +1593,6 @@ timer_type *gl_timers = NULL; s16b tim_precognition = 0; -/* - * Powers - */ -s16b POWER_INVISIBILITY = -1; -s16b POWER_WEB = -1; -s16b POWER_COR_SPACE_TIME = -1; - - /** * Get the version string. */ |