From 3eb4eab63e98e349f2b71ea74b2ded792f15e8d8 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 13 May 2012 18:49:33 +0200 Subject: Lua: Move "Music" spell functions to C --- src/defines.h | 30 ------ src/dungeon.c | 4 +- src/externs.h | 61 ++++++++++++ src/spells.pkg | 61 ++++++++++++ src/spells3.c | 310 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 434 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/defines.h b/src/defines.h index 439048e8..57c4c674 100644 --- a/src/defines.h +++ b/src/defines.h @@ -4087,36 +4087,6 @@ #define ALCHEMIST_ENCHANT_PVAL 0x02 #define ALCHEMIST_ENCHANT_AC 0x04 -/* - * Music songs - */ -#define MUSIC_NONE 0 -#define MUSIC_SLOW 1 -#define MUSIC_CONF 2 -#define MUSIC_STUN 3 -#define MUSIC_LIFE 4 -#define MUSIC_MIND 5 -#define MUSIC_LITE 6 -#define MUSIC_FURY 7 -#define MUSIC_AWARE 8 -#define MUSIC_ID 9 -#define MUSIC_ILLUSION 10 -#define MUSIC_WALL 11 -#define MUSIC_RESIST 12 -#define MUSIC_TIME 13 -#define MUSIC_BETWEEN 14 -#define MUSIC_CHARME 15 -#define MUSIC_VIBRA 16 -#define MUSIC_HOLY 17 -#define MUSIC_HIDE 18 -#define MUSIC_LIBERTY 19 -#define MUSIC_RAISE 20 -#define MUSIC_SHADOW 21 -#define MUSIC_STAR_ID 22 - -#define MAX_MUSIC 23 -#define MAX_MUSICS 11 - /* * Fate */ diff --git a/src/dungeon.c b/src/dungeon.c index fd2cc546..b23a4829 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -950,8 +950,8 @@ static void check_music() if (p_ptr->csp < use_mana) { msg_print("You stop your spell."); - p_ptr->music_extra = MUSIC_NONE; - p_ptr->music_extra2 = MUSIC_NONE; + p_ptr->music_extra = 0; + p_ptr->music_extra2 = 0; } else { diff --git a/src/externs.h b/src/externs.h index 5b935baa..e3ec6ba0 100644 --- a/src/externs.h +++ b/src/externs.h @@ -1780,6 +1780,67 @@ char *device_radagast_info(); bool_ *device_valaroma(); char *device_valaroma_info(); +extern s32b MUSIC_STOP; +extern s32b MUSIC_HOLD; +extern s32b MUSIC_CONF; +extern s32b MUSIC_STUN; +extern s32b MUSIC_LITE; +extern s32b MUSIC_HEAL; +extern s32b MUSIC_HERO; +extern s32b MUSIC_TIME; +extern s32b MUSIC_MIND; +extern s32b MUSIC_BLOW; +extern s32b MUSIC_WIND; +extern s32b MUSIC_YLMIR; +extern s32b MUSIC_AMBARKANTA; + +bool_ *music_stop_singing_spell(); +char *music_stop_singing_info(); + +int music_holding_pattern_lasting(); +bool_ *music_holding_pattern_spell(); +char *music_holding_pattern_info(); + +int music_illusion_pattern_lasting(); +bool_ *music_illusion_pattern_spell(); +char *music_illusion_pattern_info(); + +int music_stun_pattern_lasting(); +bool_ *music_stun_pattern_spell(); +char *music_stun_pattern_info(); + +int music_song_of_the_sun_lasting(); +bool_ *music_song_of_the_sun_spell(); +char *music_song_of_the_sun_info(); + +int music_flow_of_life_lasting(); +bool_ *music_flow_of_life_spell(); +char *music_flow_of_life_info(); + +int music_heroic_ballad_lasting(); +bool_ *music_heroic_ballad_spell(); +char *music_heroic_ballad_info(); + +int music_hobbit_melodies_lasting(); +bool_ *music_hobbit_melodies_spell(); +char *music_hobbit_melodies_info(); + +int music_clairaudience_lasting(); +bool_ *music_clairaudience_spell(); +char *music_clairaudience_info(); + +bool_ *music_blow_spell(); +char *music_blow_info(); + +bool_ *music_gush_of_wind_spell(); +char *music_gush_of_wind_info(); + +bool_ *music_horns_of_ylmir_spell(); +char *music_horns_of_ylmir_info(); + +bool_ *music_ambarkanta_spell(); +char *music_ambarkanta_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 b31ff65b..e032b220 100644 --- a/src/spells.pkg +++ b/src/spells.pkg @@ -2783,3 +2783,64 @@ bool_ *device_radagast(); char *device_radagast_info(); bool_ *device_valaroma(); char *device_valaroma_info(); + +extern s32b MUSIC_STOP; +extern s32b MUSIC_HOLD; +extern s32b MUSIC_CONF; +extern s32b MUSIC_STUN; +extern s32b MUSIC_LITE; +extern s32b MUSIC_HEAL; +extern s32b MUSIC_HERO; +extern s32b MUSIC_TIME; +extern s32b MUSIC_MIND; +extern s32b MUSIC_BLOW; +extern s32b MUSIC_WIND; +extern s32b MUSIC_YLMIR; +extern s32b MUSIC_AMBARKANTA; + +bool_ *music_stop_singing_spell(); +char *music_stop_singing_info(); + +int music_holding_pattern_lasting(); +bool_ *music_holding_pattern_spell(); +char *music_holding_pattern_info(); + +int music_illusion_pattern_lasting(); +bool_ *music_illusion_pattern_spell(); +char *music_illusion_pattern_info(); + +int music_stun_pattern_lasting(); +bool_ *music_stun_pattern_spell(); +char *music_stun_pattern_info(); + +int music_song_of_the_sun_lasting(); +bool_ *music_song_of_the_sun_spell(); +char *music_song_of_the_sun_info(); + +int music_flow_of_life_lasting(); +bool_ *music_flow_of_life_spell(); +char *music_flow_of_life_info(); + +int music_heroic_ballad_lasting(); +bool_ *music_heroic_ballad_spell(); +char *music_heroic_ballad_info(); + +int music_hobbit_melodies_lasting(); +bool_ *music_hobbit_melodies_spell(); +char *music_hobbit_melodies_info(); + +int music_clairaudience_lasting(); +bool_ *music_clairaudience_spell(); +char *music_clairaudience_info(); + +bool_ *music_blow_spell(); +char *music_blow_info(); + +bool_ *music_gush_of_wind_spell(); +char *music_gush_of_wind_info(); + +bool_ *music_horns_of_ylmir_spell(); +char *music_horns_of_ylmir_info(); + +bool_ *music_ambarkanta_spell(); +char *music_ambarkanta_info(); diff --git a/src/spells3.c b/src/spells3.c index 6a45a1a3..1cbe0d85 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -133,6 +133,20 @@ s32b DEVICE_THUNDERLORDS; s32b DEVICE_RADAGAST = -1; s32b DEVICE_VALAROMA = -1; +s32b MUSIC_STOP; +s32b MUSIC_HOLD; +s32b MUSIC_CONF; +s32b MUSIC_STUN; +s32b MUSIC_LITE; +s32b MUSIC_HEAL; +s32b MUSIC_HERO; +s32b MUSIC_TIME; +s32b MUSIC_MIND; +s32b MUSIC_BLOW; +s32b MUSIC_WIND; +s32b MUSIC_YLMIR; +s32b MUSIC_AMBARKANTA; + /* 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 @@ -3898,3 +3912,299 @@ char *device_valaroma_info() { return ""; } + +void static start_lasting_spell(int spl) +{ + p_ptr->music_extra = -spl; +} + +bool_ *music_stop_singing_spell() +{ + start_lasting_spell(0); + return CAST; +} + +char *music_stop_singing_info() +{ + return ""; +} + +static int holding_pattern_power() +{ + return 10 + get_level_s(MUSIC_HOLD, 100); +} + +int music_holding_pattern_lasting() +{ + project_hack(GF_OLD_SLOW, holding_pattern_power()); + return get_mana(MUSIC_HOLD); +} + +bool_ *music_holding_pattern_spell() +{ + start_lasting_spell(MUSIC_HOLD); + return CAST; +} + +char *music_holding_pattern_info() +{ + static char buf[128]; + sprintf(buf, + "power %d", + holding_pattern_power()); + return buf; +} + +static int illusion_pattern_power() +{ + return 10 + get_level_s(MUSIC_CONF, 100); +} + +int music_illusion_pattern_lasting() +{ + project_hack(GF_OLD_CONF, illusion_pattern_power()); + return get_mana(MUSIC_CONF); +} + +bool_ *music_illusion_pattern_spell() +{ + start_lasting_spell(MUSIC_CONF); + return CAST; +} + +char *music_illusion_pattern_info() +{ + static char buf[128]; + sprintf(buf, + "power %d", + illusion_pattern_power()); + return buf; +} + +static int stun_pattern_power() +{ + return 10 + get_level_s(MUSIC_STUN, 90); +} + +int music_stun_pattern_lasting() +{ + project_hack(GF_STUN, stun_pattern_power()); + return get_mana(MUSIC_STUN); +} + +bool_ *music_stun_pattern_spell() +{ + start_lasting_spell(MUSIC_STUN); + return CAST; +} + +char *music_stun_pattern_info() +{ + static char buf[128]; + sprintf(buf, + "power %d", + stun_pattern_power()); + return buf; +} + +int music_song_of_the_sun_lasting() +{ + set_lite(5); + return 1; +} + +bool_ *music_song_of_the_sun_spell() +{ + start_lasting_spell(MUSIC_LITE); + return CAST; +} + +char *music_song_of_the_sun_info() +{ + return ""; +} + +int flow_of_life_hp() +{ + return 7 + get_level_s(MUSIC_HEAL, 100); +} + +int music_flow_of_life_lasting() +{ + hp_player(flow_of_life_hp()); + return get_mana(MUSIC_HEAL); +} + +bool_ *music_flow_of_life_spell() +{ + start_lasting_spell(MUSIC_HEAL); + return CAST; +} + +char *music_flow_of_life_info() +{ + static char buf[128]; + sprintf(buf, + "heal %d/turn", + flow_of_life_hp()); + return buf; +} + +int music_heroic_ballad_lasting() +{ + set_hero(5); + if (get_level_s(MUSIC_HERO, 50) >= 10) + { + set_shero(5); + } + if (get_level_s(MUSIC_HERO, 50) >= 20) + { + set_strike(5); + } + if (get_level_s(MUSIC_HERO, 50) >= 25) + { + set_oppose_cc(5); + } + return get_mana(MUSIC_HERO); +} + +bool_ *music_heroic_ballad_spell() +{ + start_lasting_spell(MUSIC_HERO); + return CAST; +} + +char *music_heroic_ballad_info() +{ + return ""; +} + +int music_hobbit_melodies_lasting() +{ + set_shield(5, 10 + get_level_s(MUSIC_TIME, 50), 0, 0, 0); + if (get_level_s(MUSIC_TIME, 50) >= 15) + { + set_fast(5, 7 + get_level_s(MUSIC_TIME, 10)); + } + return get_mana(MUSIC_TIME); +} + +bool_ *music_hobbit_melodies_spell() +{ + start_lasting_spell(MUSIC_TIME); + return CAST; +} + +char *music_hobbit_melodies_info() +{ + static char buf[128]; + if (get_level_s(MUSIC_TIME, 50) >= 15) + { + sprintf(buf, "AC " FMTs32b " speed " FMTs32b, + 10 + get_level_s(MUSIC_TIME, 50), + 7 + get_level_s(MUSIC_TIME, 10)); + } + else + { + sprintf(buf, "AC " FMTs32b, + 10 + get_level_s(MUSIC_TIME, 50)); + } + return buf; +} + +int music_clairaudience_lasting() +{ + set_tim_esp(5); + if (get_level_s(MUSIC_MIND, 50) >= 10) + { + fire_ball(GF_IDENTIFY, 0, 1, 1 + get_level(MUSIC_MIND, 3, 0)); + } + return get_mana(MUSIC_MIND); +} + +bool_ *music_clairaudience_spell() +{ + start_lasting_spell(MUSIC_MIND); + return CAST; +} + +char *music_clairaudience_info() +{ + static char buf[128]; + + if (get_level_s(MUSIC_MIND, 50) >= 10) + { + sprintf(buf, "rad " FMTs32b, + 1 + get_level(MUSIC_MIND, 3, 0)); + return buf; + } + else + { + return ""; + } +} + +bool_ *music_blow_spell() +{ + fire_ball(GF_SOUND, + 0, + damroll(2 + get_level(MUSIC_BLOW, 10, 0), 4 + get_level(MUSIC_BLOW, 40, 0)), + 1 + get_level(MUSIC_BLOW, 12, 0)); + return CAST; +} + +char *music_blow_info() +{ + static char buf[128]; + sprintf(buf, + "dam " FMTs32b "d" FMTs32b " rad " FMTs32b, + 2 + get_level(MUSIC_BLOW, 10, 0), + 4 + get_level(MUSIC_BLOW, 40, 0), + 1 + get_level(MUSIC_BLOW, 12, 0)); + return buf; +} + +bool_ *music_gush_of_wind_spell() +{ + fire_ball(GF_AWAY_ALL, + 0, + 10 + get_level(MUSIC_BLOW, 40, 0), + 1 + get_level(MUSIC_BLOW, 12, 0)); + return CAST; +} + +char *music_gush_of_wind_info() +{ + static char buf[128]; + sprintf(buf, + "dist " FMTs32b " rad " FMTs32b, + 10 + get_level(MUSIC_BLOW, 40, 0), + 1 + get_level(MUSIC_BLOW, 12, 0)); + return buf; +} + +bool_ *music_horns_of_ylmir_spell() +{ + earthquake(p_ptr->py, p_ptr->px, 2 + get_level_s(SHAKE, 10)); + return CAST; +} + +char *music_horns_of_ylmir_info() +{ + static char buf[128]; + sprintf(buf, + "rad " FMTs32b, + 2 + get_level_s(SHAKE, 10)); + return buf; +} + +bool_ *music_ambarkanta_spell() +{ + alter_reality(); + return CAST; +} + +char *music_ambarkanta_info() +{ + return ""; +} -- cgit v1.2.3