![]() |
#1 |
Knight
Join Date: Oct 2019
Posts: 964
![]() |
Vanilla Code Questions
I'm hacking around with vanilla at the moment. I'm going to post some questions as they come up.
My background: I don't have a lot of experience with C but I have 15+ years experience as a professional software developer. I'm more familiar with Perl than any other language. Last edited by DavidMedley; March 16, 2020 at 02:31. |
![]() |
![]() |
![]() |
#2 |
Knight
Join Date: Oct 2019
Posts: 964
![]() |
Where do things like PLAYER_LEVEL from class.txt get interpreted? I only find that string in text files and player-spell.c.
Code:
expression_base_value_f spell_value_base_by_name(const char *name) { static const struct value_base_s { const char *name; expression_base_value_f function; } value_bases[] = { { "SPELL_POWER", spell_value_base_spell_power }, { "PLAYER_LEVEL", spell_value_base_player_level }, { "DUNGEON_LEVEL", spell_value_base_dungeon_level }, { "MAX_SIGHT", spell_value_base_max_sight }, { "WEAPON_DAMAGE", spell_value_base_weapon_damage }, { "PLAYER_HP", spell_value_base_player_hp }, { "MONSTER_PERCENT_HP_GONE", spell_value_base_monster_percent_hp_gone }, { NULL, NULL }, }; const struct value_base_s *current = value_bases; while (current->name != NULL && current->function != NULL) { if (my_stricmp(name, current->name) == 0) return current->function; current++; } return NULL; } So where are these codes, such as PLAYER_LEVEL and MONSTER_PERCENT_HP_GONE interpretted? |
![]() |
![]() |
![]() |
#3 |
Knight
Join Date: Oct 2019
Posts: 964
![]() |
Confirming: "s32b" means "signed 32 bit integer"? Example:
Code:
s32b new_mana, new_mana_frac; Last edited by DavidMedley; March 16, 2020 at 02:56. |
![]() |
![]() |
![]() |
#4 | |
Veteran
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,461
![]() |
Quote:
|
|
![]() |
![]() |
![]() |
#5 |
Adept
Join Date: Aug 2019
Posts: 136
![]() |
Yes, it means a 32-bit signed integer. If one uses long, you don't have a guarantee about the size. For instance, when compiling 64-bit applications on Linux or Mac OS, a long is a 64-bit signed integer. There's a standard way of referring to integers with a known number of bits (int32_t, uint32_t, ....), and you'll see that used in h-basic.h to define what s32b is. But those types were introduced after Angband was originally written, and it's understandable that Angband adopted its own convention.
|
![]() |
![]() |
![]() |
#6 | |
Veteran
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,461
![]() |
Quote:
Code:
spell:Magic Missile:1:1:22:4 effect:BOLT_OR_BEAM:MISSILE:0:-10 dice:$Dd4 expr:D:PLAYER_LEVEL:- 1 / 5 + 3 desc:Fires a magic missile that always hits its target and does desc: unresistable damage. desc: Sometimes a beam is fired instead that hurts each monster desc: in its path. desc: The chance to get a beam goes up with your character level. Code:
spell:Magic Missile:1:1:22:4 effect:BOLT_OR_BEAM:MISSILE:0:-10 dice:$Dd4 expr:D:WEAPON_DAMAGE:- 1 / 5 + 3 desc:Fires a magic missile that always hits its target and does desc: unresistable damage. desc: Sometimes a beam is fired instead that hurts each monster desc: in its path. desc: The chance to get a beam goes up with your character level. What parser error are you getting? |
|
![]() |
![]() |
![]() |
#7 |
Knight
Join Date: Oct 2019
Posts: 964
![]() |
|
![]() |
![]() |
![]() |
#8 |
Knight
Join Date: Oct 2019
Posts: 964
![]() |
|
![]() |
![]() |
![]() |
#9 |
Knight
Join Date: Oct 2019
Posts: 964
![]() |
|
![]() |
![]() |
![]() |
#10 |
Knight
Join Date: Oct 2019
Posts: 964
![]() |
OK, this is a pretty big ask, but I'll put it out into the universe and see what happens.
I want to create a spell that includes a melee blow as one of its effects. I've looked at Code:
static bool py_attack_real(struct player *p, struct loc grid, bool *fear) /**Attack the monster at the given location with a single blow.*/ But when I look at Code:
bool spell_cast(int spell_index, int dir) { ... effect_do(spell->effect, source_player(), NULL, ident, true, dir, beam, 0) ... } So can anyone provide me with hints or examples of how to do this? |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
is there a code? | jozmon | Development | 19 | August 4, 2014 00:38 |
Questions regarding vanilla inscriptions | Avenger | Vanilla | 8 | December 13, 2013 21:15 |
Questions regarding vanilla dungeon design | Cazliostro | Vanilla | 23 | October 11, 2010 12:05 |
code help please | will_asher | Variants | 22 | March 15, 2010 19:00 |
Looking through the code | K.I.L.E.R | Vanilla | 5 | July 11, 2007 08:01 |