diff options
-rw-r--r-- | lib/mods/theme/scpt/player.lua | 177 | ||||
-rw-r--r-- | lib/scpt/player.lua | 61 | ||||
-rw-r--r-- | src/birth.c | 169 | ||||
-rw-r--r-- | src/cmd5.c | 2 | ||||
-rw-r--r-- | src/defines.h | 2 | ||||
-rw-r--r-- | src/externs.h | 2 |
6 files changed, 160 insertions, 253 deletions
diff --git a/lib/mods/theme/scpt/player.lua b/lib/mods/theme/scpt/player.lua index fd11ed9d..de04052d 100644 --- a/lib/mods/theme/scpt/player.lua +++ b/lib/mods/theme/scpt/player.lua @@ -6,88 +6,6 @@ function __birth_hook_objects() -- Grace delay for adding piety GRACE_DELAY = 0 - -- Provide a book of Geyser to Geomancers - if get_class_name() == "Geomancer" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Geyser") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Provide a book of prayer to priests - if get_class_name() == "Priest(Eru)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("See the Music") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Priest(Manwe)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Manwe's Blessing") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Druid" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Charm Animal") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Dark-Priest" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Curse") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Paladin" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Divine Aim") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Stonewright" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Firebrand") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Priest(Varda)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Light of Valinor") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Priest(Ulmo)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Song of Belegaer") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Priest(Mandos)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Tears of Luthien") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - if get_class_name() == "Mimic" then - local obj = create_object(TV_CLOAK, 100); - obj.pval2 = resolve_mimic_name("Mouse") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - -- Start the undeads, as undeads with the corruptions if get_subrace_name() == "Vampire" then player.corruption(CORRUPT_VAMPIRE_TEETH, TRUE) @@ -95,101 +13,6 @@ function __birth_hook_objects() player.corruption(CORRUPT_VAMPIRE_VAMPIRE, TRUE) end - -- Start the Red (Fire) dragons with a book of Light (Theme) - if get_subrace_name() == "Red" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Globe of Light") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Black (Water) dragons with a book of Geyser (Theme) - if get_subrace_name() == "Black" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Geyser") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Green (Air) dragons with a book of Noxious Cloud (Theme) - if get_subrace_name() == "Green" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Noxious Cloud") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Blue (Earth) dragons with a book of Stone Skin (Theme) - if get_subrace_name() == "Blue" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Stone Skin") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the White dragons with a book of Sense Monsters (Theme) - if get_subrace_name() == "White" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Sense Monsters") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Ethereal dragons with a book of Recharge (Theme) - if get_subrace_name() == "Ethereal" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Recharge") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Aewroeg with a book of Charm (Theme) - if get_subrace_name() == "(Aewrog)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Charm") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Narroeg with a book of blink (Theme) - if get_subrace_name() == "(Narrog)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Phase Door") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Peace-mages with a book of blink (Theme) - if get_class_name() == "Peace-mage" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Phase Door") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Start the Wainriders with a book of Curse (Theme) - if get_class_name() == "Wainrider" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Curse") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Provide everyone with a scroll of WoR (Theme) - local obj = create_object(TV_SCROLL, SV_SCROLL_WORD_OF_RECALL); - inven_carry(obj, FALSE) - end_object(obj) - identify_pack_fully() end -- Register in the hook list diff --git a/lib/scpt/player.lua b/lib/scpt/player.lua index 2a617608..e8fb7e25 100644 --- a/lib/scpt/player.lua +++ b/lib/scpt/player.lua @@ -2,67 +2,6 @@ ----------------------- Hook to create birth objects ------------------------- ------------------------------------------------------------------------------ function __birth_hook_objects() - -- Provide a book of blink to rangers - if get_class_name() == "Ranger" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Phase Door") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Provide a book of Geyser to Geomancers - if get_class_name() == "Geomancer" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Geyser") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - - -- Provide a book of prayer to priests - if get_class_name() == "Priest(Eru)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("See the Music") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Priest(Manwe)" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Manwe's Blessing") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Druid" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Charm Animal") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Dark-Priest" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Curse") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Paladin" then - local obj = create_object(TV_BOOK, 255); - obj.pval = find_spell("Divine Aim") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end - if get_class_name() == "Mimic" then - local obj = create_object(TV_CLOAK, 100); - obj.pval2 = resolve_mimic_name("Mouse") - obj.ident = bor(obj.ident, IDENT_MENTAL, IDENT_KNOWN) - inven_carry(obj, FALSE) - end_object(obj) - end -- Start the undeads, as undeads with the corruptions if get_subrace_name() == "Vampire" then diff --git a/src/birth.c b/src/birth.c index cbe87512..263877fe 100644 --- a/src/birth.c +++ b/src/birth.c @@ -1083,6 +1083,35 @@ void outfit_obj(int tv, int sv, int pval, int dd, int ds) /* + * Give the player an object. + */ +static void player_outfit_object(int qty, int tval, int sval) +{ + object_type forge; + object_type *q_ptr = &forge; + object_prep(q_ptr, lookup_kind(tval, sval)); + q_ptr->number = qty; + object_aware(q_ptr); + object_known(q_ptr); + (void)inven_carry(q_ptr, FALSE); +} + + +/* + * Give player a spell book. + */ +static void player_outfit_spellbook(cptr spell_name) +{ + object_type forge; + object_type *q_ptr = &forge; + object_prep(q_ptr, lookup_kind(TV_BOOK, 255)); + q_ptr->pval = find_spell(spell_name); + q_ptr->ident |= IDENT_MENTAL | IDENT_KNOWN; + inven_carry(q_ptr, FALSE); +} + + +/* * Init players with some belongings * * Having an item makes the player "aware" of its purpose. @@ -1090,33 +1119,147 @@ void outfit_obj(int tv, int sv, int pval, int dd, int ds) static void player_outfit(void) { int i; + cptr class_name = spp_ptr->title + c_name; + cptr subrace_name = rmp_ptr->title + rmp_name; /* * Get an adventurer guide describing a bit of the * wilderness. */ { - object_type forge; - object_type *q_ptr = &forge; /* Hack -- Give the player an adventurer guide */ - object_prep(q_ptr, lookup_kind(TV_PARCHMENT, 20)); - q_ptr->number = 1; - object_aware(q_ptr); - object_known(q_ptr); - (void)inven_carry(q_ptr, FALSE); + player_outfit_object(1, TV_PARCHMENT, 20); } - process_hooks(HOOK_BIRTH_OBJECTS, "()"); + /* + * Provide spell books + */ + if (game_module_idx == MODULE_TOME) + { + if (streq(class_name, "Ranger")) + { + player_outfit_spellbook("Phase Door"); + } + } + if (streq(class_name, "Geomancer")) + { + player_outfit_spellbook("Geyser"); + } + if (streq(class_name, "Priest(Eru)")) + { + player_outfit_spellbook("See the Music"); + } + if (streq(class_name, "Priest(Manwe)")) + { + player_outfit_spellbook("Manwe's Blessing"); + } + if (streq(class_name, "Druid")) + { + player_outfit_spellbook("Charm Animal"); + } + if (streq(class_name, "Dark-Priest")) + { + player_outfit_spellbook("Curse"); + } + if (streq(class_name, "Paladin")) + { + player_outfit_spellbook("Divine Aim"); + } + if (game_module_idx == MODULE_THEME) + { + /* Priests */ + if (streq(class_name, "Stonewright")) + { + player_outfit_spellbook("Firebrand"); + } + if (streq(class_name, "Priest(Varda)")) + { + player_outfit_spellbook("Light of Valinor"); + } + if (streq(class_name, "Priest(Ulmo)")) + { + player_outfit_spellbook("Song of Belegaer"); + } + if (streq(class_name, "Priest(Mandos)")) + { + player_outfit_spellbook("Tears of Luthien"); + } + + /* Dragons */ + if (streq(subrace_name, "Red")) + { + player_outfit_spellbook("Globe of Light"); + } + if (streq(subrace_name, "Black")) + { + player_outfit_spellbook("Geyser"); + } + if (streq(subrace_name, "Green")) + { + player_outfit_spellbook("Noxious Cloud"); + } + if (streq(subrace_name, "Blue")) + { + player_outfit_spellbook("Stone Skin"); + } + if (streq(subrace_name, "White")) + { + player_outfit_spellbook("Sense Monsters"); + } + if (streq(subrace_name, "Ethereal")) + { + player_outfit_spellbook("Recharge"); + } + + /* Demons */ + if (streq(subrace_name, "(Aewrog)")) + { + player_outfit_spellbook("Charm"); + } + if (streq(subrace_name, "(Narrog)")) + { + player_outfit_spellbook("Phase Door"); + } + + /* Peace-mages */ + if (streq(class_name, "Peace-mage")) + { + player_outfit_spellbook("Phase Door"); + } + /* Wainriders */ + if (streq(class_name, "Wainrider")) + { + player_outfit_spellbook("Curse"); + } + } + + if (streq(class_name, "Mimic")) { object_type forge; object_type *q_ptr = &forge; + + object_prep(q_ptr, lookup_kind(TV_CLOAK, SV_MIMIC_CLOAK)); + q_ptr->pval2 = resolve_mimic_name("Mouse"); + q_ptr->ident |= IDENT_MENTAL | IDENT_KNOWN; + inven_carry(q_ptr, FALSE); + } + + if (game_module_idx == MODULE_THEME) + { + /* Give everyone a scroll of WoR. */ + player_outfit_object(1, TV_SCROLL, SV_SCROLL_WORD_OF_RECALL); + + /* Identify everything in pack. */ + identify_pack_fully(); + } + + process_hooks(HOOK_BIRTH_OBJECTS, "()"); + + { /* Hack -- Give the player some food */ - object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION)); - q_ptr->number = (byte)rand_range(3, 7); - object_aware(q_ptr); - object_known(q_ptr); - (void)inven_carry(q_ptr, FALSE); + int qty = (byte)rand_range(3, 7); + player_outfit_object(qty, TV_FOOD, SV_FOOD_RATION); } { @@ -2538,7 +2538,7 @@ void do_cmd_copy_spell() /* * Finds a spell by name, optimized for speed */ -int find_spell(char *name) +int find_spell(const char *name) { int oldtop, spell; oldtop = lua_gettop(L); diff --git a/src/defines.h b/src/defines.h index 344a171e..a75df305 100644 --- a/src/defines.h +++ b/src/defines.h @@ -4420,6 +4420,8 @@ /* * Modules */ +#define MODULE_TOME 0 +#define MODULE_THEME 1 #define MAX_MODULES 2 /* diff --git a/src/externs.h b/src/externs.h index c671693d..a9baa853 100644 --- a/src/externs.h +++ b/src/externs.h @@ -811,7 +811,7 @@ extern s32b get_school_spell(cptr do_what, cptr check_fct, s16b force_book); extern void do_cmd_copy_spell(void); extern void cast_school_spell(void); extern void browse_school_spell(int book, int pval, object_type *o_ptr); -extern int find_spell(char *name); +extern int find_spell(const char *name); extern bool_ is_school_book(object_type *o_ptr); /* cmd6.c */ |