Author Topic: Why do I need to redefine mtype (or zom)?  (Read 466 times)

Offline pisskop

  • Survivor
  • ***
  • Posts: 3616
  • Excitebike
    • View Profile
Why do I need to redefine mtype (or zom)?
« on: October 17, 2016, 12:54:41 AM »
bit of a crosspost

Is this the proper thread to cry tears into?

I have a chunk of c++ here.  The former

(click to show/hide)



(click to show/hide)

Throws errors about zom not being defined.  I dont know.  If I add a mtype_id before zom they read (and then the line add_spawn(zom, 1, zx, zy); fails to read 'zom'), but I shouldnt have to?  zom is simply shorthand for a specific group of monsters.  I am sure Ive otherwise defined the specific critters.

all Im doing is extending the concept of spawning a specified set of critters based upon a dice-roll, correct?

in case you wanna know where I got this

Offline Profugo Barbatus

  • NPC
  • **
  • Posts: 163
  • Is that a Minefield?
    • View Profile
Re: Why do I need to redefine mtype (or zom)?
« Reply #1 on: October 17, 2016, 01:51:35 AM »
I've not actually done any cata work, but there seems to be a logic error in your code.

In the base code, you got:

if(condition for corpse){stuff}
else{defines zom, then rolls to see if its a special}

Whereas your code has:

if(condition for corpse){stuff}
else{defines zom}
if{then we change what might be in zom}

Its throwing up because its possible to have zom not be defined by never entering the else part of the statement, so the code wouldn't work half the time. Either move the if statements into the else statement, or define zom beforehand.
a - || Hip Flask of Coffee (Hot)

Offline Coolthulhu

  • Contributor
  • Survivor
  • ****
  • Posts: 3839
    • View Profile
Re: Why do I need to redefine mtype (or zom)?
« Reply #2 on: October 17, 2016, 02:52:20 AM »
Do not add zombies directly to hardcoded mapgen, this is outdated and horrible to maintain. Not to mention that it ignores zombie spawn density.

Wrap them in a group and add a group spawn, like this:
Code: [Select]
place_spawns(  mongroup_id( "GROUP_ID_HERE" ), chance, x1, y1, x2, y2, density );Where x1, y1 are both 0, and x2 and y2 are both 23. This should be invoked outside the loop that places corpses. No need to check for walls.

And the error you committed (just for info, you shouldn't fix it using your old method) is that you closed the brace after defining "zom".
Code: [Select]
} else {
    mtype_id zom = mon_zombie;
} if (one_in(50)) {
If you removed the '}' before "if", it would probably work.