Bookless spell systems in C: is this a good approach?
Collapse
X
-
I mosltly look into FAangband, and it uses quite old V code, even new versions are based on maybe two yeras old V. Everything seems ok. Some time ago I was trying to tinker with Dungeon Crawl code, and it was much harder to modify then Angband.Comment
-
BTW, can anyone tell me how to invoke the selection-friendly menu system in V? I could do something like what ToME does, i.e. just put up a block of formatted text and wait for character input; but I wanted to do this the right way, not the easy way... Assuming there is a "right way" with this codebase.Comment
-
I'm starting to think you're right. The V sources are prettier than they used to be, but they're still an absolute mess; the stuff required to add another book-user realm is scattered through about a dozen different files. I think it might actually be easier to add bookless caster classes, than to add new spellbooks.
BTW, can anyone tell me how to invoke the selection-friendly menu system in V? I could do something like what ToME does, i.e. just put up a block of formatted text and wait for character input; but I wanted to do this the right way, not the easy way... Assuming there is a "right way" with this codebase.takkaria whispers something about options. -more-Comment
-
Okay, now that the first bookless class is almost done, two questions:
1. What's a reasonable way to refresh the whole screen, so that the casting menu disappears properly once the spell is cast? [Sort of solved]
2. How is command repetition handled?
Once those are taken care of, and with a little more tweaking, my Vanilla mod will be ready to roll for the first time.
Oh, also, two notes:
- I wound up not using the menu system... Sorry, I had a lot of trouble figuring it out.
- The command for using bookless powers is 'p', not 'm'. Partly because I'm too lazy to make bookless powers work with do_cmd_cast(), and partly because I might want casters with both book and bookless options in the future.
Edit: Okay, with (1) you refresh the screen py passing stuff to p_ptr->redraw. Unfortunately I'm having trouble getting mana to redraw properly, even though PR_MANA is definitely getting passed to it (as part of PR_BASIC).Last edited by Therem Harth; January 11, 2013, 22:03.Comment
-
2. How is command repetition handled?takkaria whispers something about options. -more-Comment
-
What version of V are you modifying? It's handled in game-cmd.c in recent versions I think.
Edit: yeah, the problem with scree_save() and screen_load() was doing things in the wrong order. Unfortunately I also have to refresh the mana display *after* casting the spell...
Edit 2: The mana display seems to work now for some reason. OTOH, hitting the Escape key while in the casting menu causes the menu to linger on the screen; and following that, refreshing the screen renders it entirely black.
It looks like the Escape key completely bypasses Angband's key capturing, and allows the user to exit before the saved screen is reloaded. Any way to prevent that?Last edited by Therem Harth; January 12, 2013, 01:29.Comment
-
Ugh. Okay, what I have now is something like
Code:screen_save(); ... while (get_com("Cast which spell? (Esc to exit)", &choice)) { if (!choice) { screen_load(); return; } } ...
Code:if (choice == 27)
Comment
-
Ugh. Okay, what I have now is something like
Code:screen_save(); ... while (get_com("Cast which spell? (Esc to exit)", &choice)) { if (!choice) { screen_load(); return; } } ...
Code:if (choice == 27)
takkaria whispers something about options. -more-Comment
-
Trying to upload the source file as an attachment but the board won't let me, so here's the function.
Code:void do_cmd_pyro() { char choice; screen_save(); print_pyro_menu(); while (get_com("Cast which spell? (Esc to exit)", &choice)) { if (!choice) { screen_load(); return; } if (A2I(choice) < 0 || A2I(choice) >= MAX_PYRO_SPELLS) { msg_print("Invalid spell choice."); continue; } /* Redraw the main window */ screen_load(); cast_pyro_spell(A2I(choice)); break; } return; }
Comment
-
-
Oh, thanks! I hadn't thought of that.
Edit: thank you very much, that worked. Now to figure out why the mana display is still not updating.Last edited by Therem Harth; January 13, 2013, 16:05.Comment
-
-
Yeah, make sure that the screen_load() happens immediately before the final return of the function and you're sorted, really. That's always the best way to do saving/loading - in pairs, not with one _save and multiple _loads. It's too easy to fuck things up otherwise.
Trying to upload the source file as an attachment but the board won't let me, so here's the function.
Code:void do_cmd_pyro() { char choice; screen_save(); print_pyro_menu(); while (get_com("Cast which spell? (Esc to exit)", &choice)) { if (!choice) { screen_load(); return; } if (A2I(choice) < 0 || A2I(choice) >= MAX_PYRO_SPELLS) { msg_print("Invalid spell choice."); continue; } /* Redraw the main window */ screen_load(); cast_pyro_spell(A2I(choice)); break; } return; }
takkaria whispers something about options. -more-Comment
Comment