void zrotation(int lay,int dir) { if(lay==1) { rmz(7,1,3,7,dir); rmz(8,4,2,4,dir); rmz(9,7,1,1,dir); if(dir==1) fr(1); else franti(1); } if(lay==2) { rmz(4,2,6,8,dir); rmz(5,5,5,5,dir); rmz(6,8,4,2,dir); } if(lay==3) { rmz(1,3,9,9,dir); rmz(2,6,8,6,dir); rmz(3,9,7,3,dir); if(dir==1) franti(3); else fr(3); } }
int main(int argc, char *argv[]) { int *ids; loginit(NULL); Rng r; int usdargs = rng(&r, argc, argv); argc -= usdargs; argv += usdargs; int n = idargs(argc, argv, &ids); if (argc < 3) fatal("usage: enmgen [-s <seed>] <ID>+ <num>"); long num = strtol(argv[argc-1], NULL, 10); if (num == LLONG_MIN || num == LLONG_MAX) fatal("Invalid number: %s", argv[argc-1]); Zone *zn = zoneread(stdin); if (!zn) die("Failed to read the zone: %s", miderrstr()); Loc ls[zn->lvl->d * zn->lvl->w * zn->lvl->h]; int nls = locs(zn, ls); int i; for (i = 0; i < num && nls > 0; i++) { int idind = rngintincl(&r, 0, n); int lind = rngintincl(&r, 0, nls); Loc l = ls[lind]; if (nls > 1) ls[lind] = ls[nls-1]; nls--; Enemy enm; if (!enemyinit(&enm, ids[idind], l.p.x, l.p.y)) fatal("Failed to initialize enemy with ID: %d", ids[idind]); if (!zoneaddenemy(zn, l.z, enm)) { nls = rmz(ls, nls, l.z); num--; } } if (i < num) fatal("Failed to place all items"); zonewrite(stdout, zn); zonefree(zn); xfree(ids); return 0; }