Posted By: Emre
Trouble about to create $$m file. - 01/17/12 19:33
Hello all,
i wanted while engine is open to create .wmb file. i had to create .$$m file before. Then i had to build this file with "wwmp2wmb.exe." . So i succeed. Now i have a few questions about this.
here is a sample from .$$m.
as far as i understand
and there is my code;
You can use this with copy&paste. it works mostly. But, sometimes doesn't work correctly. So here are my questions;
1-I think i have a problem about flags. I want to know which flags are used for this. And i need to know which order. There is no explanation for this in SDK.
2-)to use "watch_str" is a hard way in order to find action's name. AND if i don't use "wait", it doesn't work. is there any easy way to find name of Enttity's action? i have checked "engine_gettaskinfo" but it hasn't helped me.
I use A7 btw
P.S: This code works with only models&terrains. Doesn't work with blocks,paths,lights,sound etc. (i don't use them. i don't need for now.)
Thanks for answers.
i wanted while engine is open to create .wmb file. i had to create .$$m file before. Then i had to build this file with "wwmp2wmb.exe." . So i succeed. Now i have a few questions about this.
here is a sample from .$$m.
Code:
{ //model 7 -124.403564 -252.974167 13.000001 0 0 0 1 1 1 cube.mdl cube_mdl_016 ndef 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000 0 50 0 0 ndef asdadasdasd qweqeqweqw }
as far as i understand
Code:
{ //model model id xyz pan tilt roll scale file name ent name action skills flags ambient albedo i don't know what is that i don't know what is that material string1 string2 }
and there is my code;
Code:
//save wmb #include <stdio.h> STRING* temp_str ="#25"; STRING* temp_str2 ="#25"; STRING* temp_str3 ="#25"; var wmb_handle; #define skipline file_asc_write (wmb_handle, 13);file_asc_write (wmb_handle, 10) #define cbrackets file_str_write (wmb_handle,"}") #define obrackets file_str_write (wmb_handle,"{") void set_flags() { str_cpy(temp_str,""); if(is(you,POLYGON)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,CAST)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,METAL)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,DECAL)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,BRIGHT)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,NOFOG)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,LIGHT)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,SHADOW)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,UNLIT)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,NOFILTER)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,ZNEAR)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,SPOTLIGHT)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,OVERLAY)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,TRANSLUCENT)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,PASSABLE)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,INVISIBLE)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG8)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG7)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG6)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG5)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG4)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG3)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG2)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} if(is(you,FLAG1)){str_cat(temp_str,"1");} else{str_cat(temp_str,"0");} file_str_write (wmb_handle,temp_str); skipline; } //for $$w file char buffer[12] = {0x57, 0x41, 0x44, 0x37, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00}; void save_wmb() { remove("export.$$M"); remove("export.$$w"); wait(-0.5); //create $$w file FILE *myfile = fopen("export.$$w", "wb"); int i=0; for(i=0;i<12;i++) { putc(buffer[i], myfile); } fclose(myfile); wmb_handle = file_open_append("export.$$M"); file_str_write (wmb_handle,"version 711"); skipline; //level obrackets;file_str_write (wmb_handle," //level"); skipline; file_var_write (wmb_handle,0);skipline; file_str_write (wmb_handle,"export.$$w"); skipline; file_str_write (wmb_handle,"palette.pcx"); skipline; cbrackets;skipline; //sun obrackets;file_str_write (wmb_handle," //sun"); skipline; file_var_write (wmb_handle,5);skipline; file_var_write (wmb_handle,sun_angle.tilt);skipline; file_var_write (wmb_handle,sun_angle.pan);skipline; cbrackets;skipline; var yourtype; //entities you = ent_next(NULL); // retrieve first entity var startact; var startmtl; var cut; while (you) // repeat until there are no more entities { yourtype=0;//for ent id //parantez ac obrackets;file_str_write (wmb_handle," //model"); skipline; #ifndef entid #define entid /* from sdk: 'wmpio_ModelEntity * model; // id == 3 (7, for model-ex)' SO CHECK IF EX OR NOT (if has a material or string1-2 it's 7) */ //materyalin varsa tipi arttir if(your.material!=mat_model&&your.material!=NULL&&your.material!=mat_terrain) { yourtype+=1; } if(str_len(your.string1)>0||str_len(your.string2)>0) { yourtype+=1; } if(yourtype>0){file_var_write (wmb_handle,7);skipline;}else{file_var_write (wmb_handle,3);skipline;} #endif //xyz file_var_write (wmb_handle,you.x); file_var_write (wmb_handle,you.y); file_var_write (wmb_handle,you.z);skipline; //pan-tilt-roll file_var_write (wmb_handle,you.pan); file_var_write (wmb_handle,you.tilt); file_var_write (wmb_handle,you.roll);skipline; //scale file_var_write (wmb_handle,you.scale_x); file_var_write (wmb_handle,you.scale_y); file_var_write (wmb_handle,you.scale_z);skipline; str_for_entfile(temp_str,you); file_str_write (wmb_handle,temp_str); skipline; str_for_entname(temp_str,you); file_str_write (wmb_handle,temp_str); skipline; //find funcname from watch_str watched = you; wait(10); if(str_stri(watch_str,"Act ")) { //error(watch_str); startact = str_stri(watch_str,"Act "); str_cpy(temp_str,watch_str); str_clip(temp_str,startact+3); str_cpy(temp_str2,temp_str); startmtl = str_stri(temp_str2,"Mtl "); str_clip(temp_str2,startmtl+3); cut=str_len(temp_str2); str_trunc(temp_str,cut+4); file_str_write (wmb_handle,temp_str); skipline; } else { file_str_write (wmb_handle,"ndef"); skipline; } //skills file_var_write (wmb_handle,you.skill1); file_var_write (wmb_handle,you.skill2); file_var_write (wmb_handle,you.skill3); file_var_write (wmb_handle,you.skill4); file_var_write (wmb_handle,you.skill5); file_var_write (wmb_handle,you.skill6); file_var_write (wmb_handle,you.skill7); file_var_write (wmb_handle,you.skill8); if(yourtype>0)//type==7 { file_var_write (wmb_handle,you.skill9); file_var_write (wmb_handle,you.skill10); file_var_write (wmb_handle,you.skill11); file_var_write (wmb_handle,you.skill12); file_var_write (wmb_handle,you.skill13); file_var_write (wmb_handle,you.skill14); file_var_write (wmb_handle,you.skill15); file_var_write (wmb_handle,you.skill16); file_var_write (wmb_handle,you.skill17); file_var_write (wmb_handle,you.skill18); file_var_write (wmb_handle,you.skill19); file_var_write (wmb_handle,you.skill20); }skipline; //flags set_flags(); //bu illaki olacak file_var_write (wmb_handle,your.ambient);skipline; //material if(your.material!=mat_model&&your.material!=NULL&&your.material!=mat_terrain) { file_var_write (wmb_handle,your.albedo);skipline; file_var_write (wmb_handle,0);skipline; file_var_write (wmb_handle,0);skipline; str_cpy(temp_str,_chr(your.material.link.name)); file_str_write (wmb_handle,temp_str); skipline; } else { if(yourtype>0) { file_var_write (wmb_handle,your.albedo);skipline; file_var_write (wmb_handle,0);skipline; file_var_write (wmb_handle,0);skipline; file_str_write (wmb_handle,"ndef"); skipline; } } //string1 string2 if(str_len(your.string1)>0) { str_cpy(temp_str,_chr(your.string1)); file_str_write (wmb_handle,temp_str); skipline; } if(str_len(your.string2)>0) { str_cpy(temp_str,_chr(your.string2)); file_str_write (wmb_handle,temp_str); skipline; } cbrackets;skipline; //wait(1); you = ent_next(you); wait(1); } file_close(wmb_handle); watched=NULL; wait(-1); exec("%EXE_DIR%\\wwmp2wmb.exe","export.$$M -pal palette.pcx -close"); } void on_enter_event() { save_wmb(); }
You can use this with copy&paste. it works mostly. But, sometimes doesn't work correctly. So here are my questions;
1-I think i have a problem about flags. I want to know which flags are used for this. And i need to know which order. There is no explanation for this in SDK.
2-)to use "watch_str" is a hard way in order to find action's name. AND if i don't use "wait", it doesn't work. is there any easy way to find name of Enttity's action? i have checked "engine_gettaskinfo" but it hasn't helped me.
I use A7 btw
P.S: This code works with only models&terrains. Doesn't work with blocks,paths,lights,sound etc. (i don't use them. i don't need for now.)
Thanks for answers.