MCPcopy Create free account
hub / github.com/NetHack/NetHack / set_mon_data

Function set_mon_data

src/mondata.c:12–38  ·  view source on GitHub ↗

set up an individual monster's base type (initial creation, shapechange) */

Source from the content-addressed store, hash-verified

10
11/* set up an individual monster's base type (initial creation, shapechange) */
12void
13set_mon_data(struct monst *mon, struct permonst *ptr)
14{
15 int new_speed, old_speed = mon->data ? mon->data->mmove : 0;
16 short *movement_p = (mon == &gy.youmonst) ? &u.umovement : &mon->movement;
17
18 mon->data = ptr;
19 mon->mnum = (short) monsndx(ptr);
20
21 if (*movement_p) { /* used to adjust poly'd hero as well as monsters */
22 new_speed = ptr->mmove;
23 /* prorate unused movement if new form is slower so that
24 it doesn't get extra moves leftover from previous form;
25 if new form is faster, leave unused movement as is */
26 if (new_speed < old_speed) {
27 /*
28 * Some static analysis warns that this might divide by 0
29 mon->movement = new_speed * mon->movement / old_speed;
30 * so add a redundant test to suppress that.
31 */
32 *movement_p *= new_speed;
33 if (old_speed > 0) /* old > new and new >= 0, so always True */
34 *movement_p /= old_speed;
35 }
36 }
37 return;
38}
39
40/* does monster-type have any attack for a specific type of damage? */
41struct attack *

Callers 9

create_mplayersFunction · 0.85
enexto_coreFunction · 0.85
new_wereFunction · 0.85
set_uasmonFunction · 0.85
mondeadFunction · 0.85
newchamFunction · 0.85
makemonFunction · 0.85
grow_upFunction · 0.85
create_monsterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected