Angband Forums

Angband Forums (http://angband.oook.cz/forum/index.php)
-   Development (http://angband.oook.cz/forum/forumdisplay.php?f=10)
-   -   Vanilla Code Questions (http://angband.oook.cz/forum/showthread.php?t=9905)

wobbly March 16, 2020 09:25

Well here's a start:

Code:

/**
 * Execute an effect chain.
 *
 * \param effect is the effect chain
 * \param origin is the origin of the effect (player, monster etc.)
 * \param obj    is the object making the effect happen (or NULL)
 * \param ident  will be updated if the effect is identifiable
 *              (NB: no effect ever sets *ident to false)
 * \param aware  indicates whether the player is aware of the effect already
 * \param dir    is the direction the effect will go in
 * \param beam  is the base chance out of 100 that a BOLT_OR_BEAM effect will beam
 * \param boost  is the extent to which skill surpasses difficulty, used as % boost. It
 *              ranges from 0 to 138.
 */
bool effect_do(struct effect *effect,
                struct source origin,
                struct object *obj,
                bool *ident,
                bool aware,
                int dir,
                int beam,
                int boost)


Nick March 16, 2020 10:09

I think you'll have to write an effect handler (see effects.c - there are a whole lot of them) which will need to call py_attack_real() for each monster you want to hit. To do this you'll need to make py_attack_real() callable from other files, which means adding its definition to player-attack.h and including player-attack.h in effects.c.

DavidMedley March 16, 2020 13:12

OK, thanks!

Pete Mack March 16, 2020 15:09

The reason things are so abstract now is that, while the code is somewhat harder to understand, it is much easier to add things. In the old days, you would need to modify:
* the parser
* at least one .h file
* the global spell list
* the config files

Now to add most spells all you need to change is a couple config (.txt) files and possibly a .h file. Your change requires new interpretation in-code, as you need to surface weapon attacks as a magic effect, so you need a new spell effect procedure.

DavidMedley March 16, 2020 22:10

Quote:

Originally Posted by Pete Mack (Post 143680)
while the code is somewhat harder to understand, it is much easier to add things.

Yeah, that's what I figured. Thanks!

DavidMedley March 16, 2020 22:23

Is there a faster way to check my C syntax than to try to make the whole project?

backwardsEric March 16, 2020 23:31

Quote:

Originally Posted by DavidMedley (Post 143689)
Is there a faster way to check my C syntax than to try to make the whole project?

Are you using Visual Studio (or some other IDE)? For that, I can't offer specific advice. If you're using the makefiles, then you could recompile just one or more of the files, say mon-attack.c and mon-blows.c, by running

Code:

make src/mon-attack.o src/mon-blows.o
in the top-level directory (i.e. for the source file you are interested in, replace the .c with .o). For Mac OS X, the equivalent would be running

Code:

make -f Makefile.osx mon-attack.o man-blows.o
in the src directory. The makefiles, however, should only rebuild what's necessary for a change. So, unless you modified a header file that's widely used, you won't be gaining much by specifically recompiling a handful of files.

DavidMedley March 17, 2020 01:45

Oh, OK. I tried cc and that was awful. I'll try this way, or not, since you say it won't help much anyway.

DavidMedley March 17, 2020 07:32

A bit off-topic, but when I was trying to trace incremental changes to HP and SP, I found that SP regenerates every turn, but HP regens only every fourth turn, except when resting and then the ratio is 2 to 1. I don't understand how or why this is happening. Maybe I screwed something up.

I don't want to track it down right now, but I couldn't help but wonder aloud about it.

DavidMedley March 19, 2020 09:39

Can someone explain the difference between power and mult in object_properties.txt?

# power: the value given to the property in object power calculations
# mult: relative value of properties, used in power calculations
# type-mult: extra multiplier used in power for particular properties on
# particular types of object. Assumed 1 if not mentioned


All times are GMT +1. The time now is 10:36.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.