diff options
-rw-r--r-- | lib/mods/theme/scpt/s_air.lua | 65 | ||||
-rw-r--r-- | lib/scpt/s_air.lua | 65 | ||||
-rw-r--r-- | src/externs.h | 21 | ||||
-rw-r--r-- | src/spells.pkg | 23 | ||||
-rw-r--r-- | src/spells3.c | 162 |
5 files changed, 230 insertions, 106 deletions
diff --git a/lib/mods/theme/scpt/s_air.lua b/lib/mods/theme/scpt/s_air.lua index afd1f584..7b585317 100644 --- a/lib/mods/theme/scpt/s_air.lua +++ b/lib/mods/theme/scpt/s_air.lua @@ -18,19 +18,8 @@ NOXIOUSCLOUD = add_spell ["max_level"] = { 25, 50 }, }, }, - ["spell"] = function() - local ret, dir, type - - ret, dir = get_aim_dir() - if ret == FALSE then return end - if get_level(NOXIOUSCLOUD, 50) >= 30 then type = GF_UNBREATH - else type = GF_POIS end - fire_cloud(type, dir, 7 + get_level(NOXIOUSCLOUD, 150), 3, 5 + get_level(NOXIOUSCLOUD, 40)) - return TRUE - end, - ["info"] = function() - return "dam "..(7 + get_level(NOXIOUSCLOUD, 150)).." rad 3 dur "..(5 + get_level(NOXIOUSCLOUD, 40)) - end, + ["spell"] = function() return air_noxious_cloud() end, + ["info"] = function() return air_noxious_cloud_info() end, ["desc"] = { "Creates a cloud of poison", "The cloud will persist for some turns, damaging all monsters passing by", @@ -57,17 +46,8 @@ AIRWINGS = add_spell }, }, ["inertia"] = { 1, 10 }, - ["spell"] = function() - if get_level(AIRWINGS, 50) >= 16 then - if player.tim_fly == 0 then return set_tim_fly(randint(10) + 5 + get_level(AIRWINGS, 25)) end - else - if player.tim_ffall == 0 then return set_tim_ffall(randint(10) + 5 + get_level(AIRWINGS, 25)) end - end - return FALSE - end, - ["info"] = function() - return "dur "..(5 + get_level(AIRWINGS, 25)).."+d10" - end, + ["spell"] = function() return air_wings_of_winds() end, + ["info"] = function() return air_wings_of_winds_info() end, ["desc"] = { "Grants the power of levitation", "At level 16 it grants the power of controlled flight" @@ -83,12 +63,8 @@ INVISIBILITY = add_spell ["mana_max"] = 20, ["fail"] = 50, ["inertia"] = { 1, 30 }, - ["spell"] = function() - if player.tim_invisible == 0 then return set_invis(randint(20) + 15 + get_level(INVISIBILITY, 50), 20 + get_level(INVISIBILITY, 50)) end - end, - ["info"] = function() - return "dur "..(15 + get_level(INVISIBILITY, 50)).."+d20 power "..(20 + get_level(INVISIBILITY, 50)) - end, + ["spell"] = function() return air_invisibility() end, + ["info"] = function() return air_invisibility_info() end, ["desc"] = { "Grants invisibility" } @@ -113,15 +89,8 @@ POISONBLOOD = add_spell }, }, ["inertia"] = { 1, 35 }, - ["spell"] = function() - local obvious = nil - if player.oppose_pois == 0 then obvious = set_oppose_pois(randint(30) + 25 + get_level(POISONBLOOD, 25)) end - if (player.tim_poison == 0) and (get_level(POISONBLOOD, 50) >= 15) then obvious = is_obvious(set_poison(randint(30) + 25 + get_level(POISONBLOOD, 25)), obvious) end - return obvious - end, - ["info"] = function() - return "dur "..(25 + get_level(POISONBLOOD, 25)).."+d30" - end, + ["spell"] = function() return air_poison_blood() end, + ["info"] = function() return air_poison_blood_info() end, ["desc"] = { "Grants resist poison", "At level 15 it provides poison branding to wielded weapon" @@ -147,13 +116,8 @@ THUNDERSTORM = add_spell }, }, ["inertia"] = { 2, 15 }, - ["spell"] = function() - if player.tim_thunder == 0 then return set_tim_thunder(randint(10) + 10 + get_level(THUNDERSTORM, 25), 5 + get_level(THUNDERSTORM, 10), 10 + get_level(THUNDERSTORM, 25)) end - return FALSE - end, - ["info"] = function() - return "dam "..(5 + get_level(THUNDERSTORM, 10)).."d"..(10 + get_level(THUNDERSTORM, 25)).." dur "..(10 + get_level(THUNDERSTORM, 25)).."+d10" - end, + ["spell"] = function() return air_thunderstorm() end, + ["info"] = function() return air_thunderstorm_info() end, ["desc"] = { "Charges up the air around you with electricity", "Each turn it will throw a thunder bolt at a random monster in sight", @@ -180,13 +144,8 @@ STERILIZE = add_spell ["max_level"] = { 20, 50 }, }, }, - ["spell"] = function() - set_no_breeders((30) + 20 + get_level(STERILIZE, 70)) - return TRUE - end, - ["info"] = function() - return "dur "..(20 + get_level(STERILIZE, 70)).."+d30" - end, + ["spell"] = function() return air_sterilize() end, + ["info"] = function() return air_sterilize_info() end, ["desc"] = { "Prevents explosive breeding for a while." } diff --git a/lib/scpt/s_air.lua b/lib/scpt/s_air.lua index afd1f584..7b585317 100644 --- a/lib/scpt/s_air.lua +++ b/lib/scpt/s_air.lua @@ -18,19 +18,8 @@ NOXIOUSCLOUD = add_spell ["max_level"] = { 25, 50 }, }, }, - ["spell"] = function() - local ret, dir, type - - ret, dir = get_aim_dir() - if ret == FALSE then return end - if get_level(NOXIOUSCLOUD, 50) >= 30 then type = GF_UNBREATH - else type = GF_POIS end - fire_cloud(type, dir, 7 + get_level(NOXIOUSCLOUD, 150), 3, 5 + get_level(NOXIOUSCLOUD, 40)) - return TRUE - end, - ["info"] = function() - return "dam "..(7 + get_level(NOXIOUSCLOUD, 150)).." rad 3 dur "..(5 + get_level(NOXIOUSCLOUD, 40)) - end, + ["spell"] = function() return air_noxious_cloud() end, + ["info"] = function() return air_noxious_cloud_info() end, ["desc"] = { "Creates a cloud of poison", "The cloud will persist for some turns, damaging all monsters passing by", @@ -57,17 +46,8 @@ AIRWINGS = add_spell }, }, ["inertia"] = { 1, 10 }, - ["spell"] = function() - if get_level(AIRWINGS, 50) >= 16 then - if player.tim_fly == 0 then return set_tim_fly(randint(10) + 5 + get_level(AIRWINGS, 25)) end - else - if player.tim_ffall == 0 then return set_tim_ffall(randint(10) + 5 + get_level(AIRWINGS, 25)) end - end - return FALSE - end, - ["info"] = function() - return "dur "..(5 + get_level(AIRWINGS, 25)).."+d10" - end, + ["spell"] = function() return air_wings_of_winds() end, + ["info"] = function() return air_wings_of_winds_info() end, ["desc"] = { "Grants the power of levitation", "At level 16 it grants the power of controlled flight" @@ -83,12 +63,8 @@ INVISIBILITY = add_spell ["mana_max"] = 20, ["fail"] = 50, ["inertia"] = { 1, 30 }, - ["spell"] = function() - if player.tim_invisible == 0 then return set_invis(randint(20) + 15 + get_level(INVISIBILITY, 50), 20 + get_level(INVISIBILITY, 50)) end - end, - ["info"] = function() - return "dur "..(15 + get_level(INVISIBILITY, 50)).."+d20 power "..(20 + get_level(INVISIBILITY, 50)) - end, + ["spell"] = function() return air_invisibility() end, + ["info"] = function() return air_invisibility_info() end, ["desc"] = { "Grants invisibility" } @@ -113,15 +89,8 @@ POISONBLOOD = add_spell }, }, ["inertia"] = { 1, 35 }, - ["spell"] = function() - local obvious = nil - if player.oppose_pois == 0 then obvious = set_oppose_pois(randint(30) + 25 + get_level(POISONBLOOD, 25)) end - if (player.tim_poison == 0) and (get_level(POISONBLOOD, 50) >= 15) then obvious = is_obvious(set_poison(randint(30) + 25 + get_level(POISONBLOOD, 25)), obvious) end - return obvious - end, - ["info"] = function() - return "dur "..(25 + get_level(POISONBLOOD, 25)).."+d30" - end, + ["spell"] = function() return air_poison_blood() end, + ["info"] = function() return air_poison_blood_info() end, ["desc"] = { "Grants resist poison", "At level 15 it provides poison branding to wielded weapon" @@ -147,13 +116,8 @@ THUNDERSTORM = add_spell }, }, ["inertia"] = { 2, 15 }, - ["spell"] = function() - if player.tim_thunder == 0 then return set_tim_thunder(randint(10) + 10 + get_level(THUNDERSTORM, 25), 5 + get_level(THUNDERSTORM, 10), 10 + get_level(THUNDERSTORM, 25)) end - return FALSE - end, - ["info"] = function() - return "dam "..(5 + get_level(THUNDERSTORM, 10)).."d"..(10 + get_level(THUNDERSTORM, 25)).." dur "..(10 + get_level(THUNDERSTORM, 25)).."+d10" - end, + ["spell"] = function() return air_thunderstorm() end, + ["info"] = function() return air_thunderstorm_info() end, ["desc"] = { "Charges up the air around you with electricity", "Each turn it will throw a thunder bolt at a random monster in sight", @@ -180,13 +144,8 @@ STERILIZE = add_spell ["max_level"] = { 20, 50 }, }, }, - ["spell"] = function() - set_no_breeders((30) + 20 + get_level(STERILIZE, 70)) - return TRUE - end, - ["info"] = function() - return "dur "..(20 + get_level(STERILIZE, 70)).."+d30" - end, + ["spell"] = function() return air_sterilize() end, + ["info"] = function() return air_sterilize_info() end, ["desc"] = { "Prevents explosive breeding for a while." } diff --git a/src/externs.h b/src/externs.h index 4dd5424f..4fa71a2f 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1400,6 +1400,27 @@ extern void geomancy_random_floor(int y, int x, bool_ kill_wall); extern void geomancy_dig(int oy, int ox, int dir, int length); extern void channel_the_elements(int y, int x, int level); +/* spells3.c */ +extern s32b NOXIOUSCLOUD; +extern s32b AIRWINGS; +extern s32b INVISIBILITY; +extern s32b POISONBLOOD; +extern s32b THUNDERSTORM; +extern s32b STERILIZE; + +bool_ *air_noxious_cloud(); +char *air_noxious_cloud_info(); +bool_ *air_wings_of_winds(); +char *air_wings_of_winds_info(); +bool_ *air_invisibility(); +char *air_invisibility_info(); +bool_ *air_poison_blood(); +char *air_poison_blood_info(); +bool_ *air_thunderstorm(); +char *air_thunderstorm_info(); +bool_ *air_sterilize(); +char *air_sterilize_info(); + /* randart.c */ extern int get_activation_power(void); extern void build_prob(cptr learn); diff --git a/src/spells.pkg b/src/spells.pkg index 6ca95cfc..de5d55bc 100644 --- a/src/spells.pkg +++ b/src/spells.pkg @@ -2421,3 +2421,26 @@ extern void get_pos_player(int dis, int *ny=0, int *nx=0); extern void geomancy_random_floor(int y, int x, bool kill_wall); extern void geomancy_dig(int y, int x, int dir, int length); extern void channel_the_elements(int y, int x, int level); + +/* + * Air + */ +extern s32b NOXIOUSCLOUD; +extern s32b AIRWINGS; +extern s32b INVISIBILITY; +extern s32b POISONBLOOD; +extern s32b THUNDERSTORM; +extern s32b STERILIZE; + +bool_ *air_noxious_cloud(); +char *air_noxious_cloud_info(); +bool_ *air_wings_of_winds(); +char *air_wings_of_winds_info(); +bool_ *air_invisibility(); +char *air_invisibility_info(); +bool_ *air_poison_blood(); +char *air_poison_blood_info(); +bool_ *air_thunderstorm(); +char *air_thunderstorm_info(); +bool_ *air_sterilize(); +char *air_sterilize_info(); diff --git a/src/spells3.c b/src/spells3.c index e1cb08b3..0b5d5443 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -1,2 +1,164 @@ #include "angband.h" +s32b NOXIOUSCLOUD = -1; /* Identifier */ +s32b AIRWINGS = -1; /* Identifier */ +s32b INVISIBILITY; +s32b POISONBLOOD; +s32b THUNDERSTORM; +s32b STERILIZE; + +/* FIXME: Hackish workaround while we're still tied to Lua. This lets + us return Lua's "nil" and a non-nil value (which is all the s_aux.lua + cares about). */ +bool_ *NO_CAST = NULL; +bool_ CAST_VAL = 0xca; /* Any value will do */ +bool_ *CAST = &CAST_VAL; + +static s32b get_level_s(int sp, int max) +{ + return get_level(sp, max, 1); +} + +bool_ *air_noxious_cloud() +{ + int dir, type; + + if (!get_aim_dir(&dir)) + { + return NO_CAST; + } + + if (get_level_s(NOXIOUSCLOUD, 50) >= 30) + { + type = GF_UNBREATH; + } + else + { + type = GF_POIS; + } + + fire_cloud(type, dir, 7 + get_level_s(NOXIOUSCLOUD, 150), 3, 5 + get_level_s(NOXIOUSCLOUD, 40)); + return CAST; +} + +char *air_noxious_cloud_info() +{ + static char buf[128]; + sprintf(buf, + "dam %d rad 3 dur %d", + (7 + get_level_s(NOXIOUSCLOUD, 150)), + (5 + get_level_s(NOXIOUSCLOUD, 40))); + return buf; +} + +bool_ *air_wings_of_winds() +{ + if (get_level_s(AIRWINGS, 50) >= 16) + { + if (p_ptr->tim_fly == 0) + { + set_tim_fly(randint(10) + 5 + get_level_s(AIRWINGS, 25)); + return CAST; + } + else if (p_ptr->tim_ffall == 0) + { + set_tim_ffall(randint(10) + 5 + get_level_s(AIRWINGS, 25)); + return CAST; + } + } + + return NO_CAST; +} + +char *air_wings_of_winds_info() +{ + static char buf[128]; + sprintf(buf, "dur %d+d10", (5 + get_level_s(AIRWINGS, 25))); + return buf; +} + +bool_ *air_invisibility() +{ + if (p_ptr->tim_invisible == 0) + { + set_invis(randint(20) + 15 + get_level_s(INVISIBILITY, 50), 20 + get_level_s(INVISIBILITY, 50)); + return CAST; + } + + return NO_CAST; +} + +char *air_invisibility_info() +{ + static char buf[128]; + sprintf(buf, "dur %d+d20 power %d", + (15 + get_level_s(INVISIBILITY, 50)), + (20 + get_level_s(INVISIBILITY, 50))); + return buf; +} + +bool_ *air_poison_blood() +{ + bool_ *cast = NO_CAST; + + if (p_ptr->oppose_pois == 0) + { + set_oppose_pois(randint(30) + 25 + get_level_s(POISONBLOOD, 25)); + cast = CAST; + } + + if ((p_ptr->tim_poison == 0) && + (get_level_s(POISONBLOOD, 50) >= 15)) + { + set_poison(randint(30) + 25 + get_level_s(POISONBLOOD, 25)); + cast = CAST; + } + + return cast; +} + +char *air_poison_blood_info() +{ + static char buf[128]; + sprintf(buf, + "dur %d+d30", + (25 + get_level_s(POISONBLOOD, 25))); + return buf; +} + +bool_ *air_thunderstorm() +{ + if (p_ptr->tim_thunder == 0) + { + set_tim_thunder(randint(10) + 10 + get_level_s(THUNDERSTORM, 25), 5 + get_level_s(THUNDERSTORM, 10), 10 + get_level_s(THUNDERSTORM, 25)); + return CAST; + } + + return NO_CAST; +} + +char *air_thunderstorm_info() +{ + static char buf[128]; + sprintf(buf, + "dam %dd%d dur %d+d10", + (5 + get_level_s(THUNDERSTORM, 10)), + (10 + get_level_s(THUNDERSTORM, 25)), + (10 + get_level_s(THUNDERSTORM, 25))); + return buf; +} + +bool_ *air_sterilize() +{ + set_no_breeders((30) + 20 + get_level_s(STERILIZE, 70)); + return CAST; +} + +char *air_sterilize_info() +{ + static char buf[128]; + sprintf(buf, + "dur %d+d30", + (20 + get_level_s(STERILIZE, 70))); + return buf; +} |