Welcome to the Builder Academy

Question Directional Directions with wld_make.c

More
17 Dec 2016 03:26 #6410 by Liko
Hello,
I am trying to modify my wld_make.c to work with se, sw, ne, and nw. I am wondering if I am doing my math correctly for their directions. Normal north, south, east, and west work correctly.

PS, is there a way for me to add so that when you run the generator it also opens the index files searches for the $ and adds the latest generated world above it?
Code:
/* Randian World Generator*/ #include <stdio.h> #include <stdlib.h> void main() { int WIDTH = 64, HEIGHT = 64, VNUM_START = 1, VNUM_END = WIDTH*HEIGHT+(VNUM_START-1), ZONE_NUM = 1, vnum, n, e, s, w, ne, nw, se, sw, line_pos; FILE *fp=fopen("1.wld", "w"); /*change per area*/ printf("#*****************************#\n"); printf("# Generating %3d by %3d world #\n", WIDTH, HEIGHT); printf("# Generating %5d rooms #\n", VNUM_END); printf("#*****************************#\n"); for(vnum = VNUM_START; vnum <=VNUM_END; vnum++) { n=vnum-WIDTH; s=vnum+WIDTH; e=vnum+1; w=vnum-1; ne=vnum-WIDTH+1; nw=vnum-WIDTH-1; se=vnum+WIDTH+1; sw=vnum+WIDTH-1; /*Where is it on line 0.*/ line_pos=(vnum-VNUM_START+1)%(WIDTH); if(line_pos==0) line_pos=WIDTH; /*North Border*/ if ( (vnum >= VNUM_START) && (vnum < VNUM_START+WIDTH) ) { n=(VNUM_END-WIDTH)+(line_pos); } /*North East*/ if((vnum >= VNUM_START-WIDTH+1)%(WIDTH)==2) { ne=(VNUM_END-WIDTH+1) + (line_pos); } /*North West*/ if((vnum>= VNUM_START-WIDTH-1)%(WIDTH)==3) { nw=(VNUM_END-WIDTH-1) +(line_pos); } /*South Border*/ if ( (vnum > VNUM_END-WIDTH) && (vnum <= VNUM_END) ) { s=(VNUM_START)+(line_pos-1); } /*SouthEast*/ if((vnum > VNUM_END-WIDTH+1) && (vnum <= VNUM_END)) { se=(VNUM_START+1)+(line_pos-1); } /*South West*/ if((vnum>VNUM_END-WIDTH-1) && (vnum<=VNUM_END)) { sw=(VNUM_START-1)+(line_pos-1); } /*East Border*/ if ( (vnum-VNUM_START+1)%(WIDTH)==0 ) { e=vnum-WIDTH+1; } /*West Border*/ if ( (vnum-VNUM_START+1)%(WIDTH)==1 ) { w=vnum+WIDTH-1; } fprintf(fp, "#%d\n", vnum); /*Rooms Vnum*/ fprintf(fp, "Randian %d~\n", vnum); /*Rooms Name and Vnum*/ fprintf(fp, "You are on Randian.\n~\n"); /*Rooms Desc*/ fprintf(fp, "0 0 0 0 0 1\n"); /*Zone Number, Room Flag, Room Flag, Room Flag, Room Flag, Room Sector*/ fprintf(fp, "D0\n~\n~\n0 0 %d\n", n); /*North Exit*/ fprintf(fp, "D1\n~\n~\n0 0 %d\n", e); /* East Exit */ fprintf(fp, "D2\n~\n~\n0 0 %d\n", s); /* South Exit*/ fprintf(fp, "D3\n~\n~\n0 0 %d\n", w); /* West Exit*/ fprintf(fp, "D6\n~\n~\n0 0 %d\n", nw); /*North West*/ fprintf(fp, "D7\n~\n~\n0 0 %d\n", ne); /*North East*/ fprintf(fp, "D8\n~\n~\n0 0 %d\n", se); /*South East*/ fprintf(fp, "D9\n~\n~\n0 0 %d\n", sw); /*South West*/ fprintf(fp, "S\n"); /*D0 - North, D1 - East, D2 - South, D3 - West, D4 - up, D5 - down, D6 - northwest, D7 - northeast, D8 - southeast, D9 - southwest*/ } fprintf(fp, "$\n"); fclose(fp); /*Generate a .zon file*/ FILE *fp2=fopen("../zon/1.zon", "w"); /*Change for new area*/ fprintf(fp2, "#%d\nLiko~\nRandian~\n%d %d 30 2 g 0 0 0 -1 -1\nS\n$\n",ZONE_NUM, VNUM_START, VNUM_END); fclose(fp2); FILE *fp3=fopen("../mob/1.mob", "w"); /*Change for new area*/ fprintf(fp3, "$\n"); fclose(fp3); FILE *fp4=fopen("../obj/1.obj", "w"); /*Change for new area*/ fprintf(fp4, "$\n"); fclose(fp4); FILE *fp5=fopen("../shp/1.shp", "w"); /*Change these per new area*/ fprintf(fp5, "$~\n"); fclose(fp5); FILE *fp6=fopen("../qst/1.qst", "w"); /*change these per new area*/ fprintf(fp6, "$~\n"); fclose(fp6); FILE *fp7=fopen("../trg/1.trg", "w"); /*change these per new area*/ fprintf(fp7, "$~\n"); fclose(fp7); }

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
23 Dec 2016 05:39 #6446 by Liko
Anyone?

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
23 Dec 2016 20:32 #6448 by WhiskyTest
Sorry I read through it but I think I failed my rand_number(1, 101) <= GET_SKILL(WhiskyTest, SKILL_CODING) roll :(

Please Log in or Create an account to join the conversation.

More
23 Dec 2016 20:38 #6449 by Liko

WhiskyTest wrote: Sorry I read through it but I think I failed my rand_number(1, 101) <= GET_SKILL(WhiskyTest, SKILL_CODING) roll :(


lol. Well it makes the directions, but when you look at the ascii map it's the "?" Sector which is marked strange. I am wondering if I did math wrong for the additional directions.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

Time to create page: 0.312 seconds