Gamestudio Links
Zorro Links
Newest Posts
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (basik85278), 777 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trouble about to create $$m file. #391968
01/17/12 19:33
01/17/12 19:33
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline OP
User
Emre  Offline OP
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
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.
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.

Re: Trouble about to create $$m file. [Re: Emre] #391975
01/17/12 20:17
01/17/12 20:17
Joined: Aug 2002
Posts: 2,183
Germany, BaW�
Rondidon Offline
Expert
Rondidon  Offline
Expert

Joined: Aug 2002
Posts: 2,183
Germany, BaW�
A7 is unsupported and old. Upgrade to A8. laugh

Re: Trouble about to create $$m file. [Re: Rondidon] #391977
01/17/12 20:32
01/17/12 20:32
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline OP
User
Emre  Offline OP
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
Hello Rondidon, thanks for your kindly suggestion. laugh
is A8 have a "save_wmb" function? or "get_action_name" function? Or is there huge difference between A7&A8 $$m files? if is not, it doesn't matter A7 or A8, i am still waiting for an answer.

Re: Trouble about to create $$m file. [Re: Emre] #391980
01/17/12 21:23
01/17/12 21:23
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
there is engine_getscriptinfo wink


Visit my site: www.masterq32.de
Re: Trouble about to create $$m file. [Re: MasterQ32] #391981
01/17/12 21:50
01/17/12 21:50
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline OP
User
Emre  Offline OP
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
Thank you, MasterQ32. A7 supports engine_getscriptinfo. But;
Originally Posted By: Manual

engine_getscriptinfo (void* address,char** name)

function foo() { beep(); }
...
char* funcname;
engine_getscriptinfo(foo,&funcname);



So i need a void/function address. My question is how can i find that as "your.action".
i need something like "get_action(ENTITY* ent,char* name)" and i don't know how can i do that.

Re: Trouble about to create $$m file. [Re: Emre] #391982
01/17/12 22:15
01/17/12 22:15
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
you can use engine_taskinfo:
Code:
var num = 0;
ENTITY* ent;
char* funcname;
for(num = 0; engine_gettaskinfo(num,&funcname,&ent); num++)
{
   if(ent == you)
   { 
      funcname now is your action name
      return here or search for another action which is running [Thanks to Sid!]
   }
}


code is untested but should work)

EDIT:
The code above finds all functions and actions for you, not only the first action!

Last edited by MasterQ32; 01/17/12 23:11. Reason: Changed suggested things by sid

Visit my site: www.masterq32.de
Re: Trouble about to create $$m file. [Re: MasterQ32] #391984
01/17/12 22:35
01/17/12 22:35
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
The 0 should be num in your loop wink
And you should add a break and somehow save the function pointer as this is probably a slow function.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Trouble about to create $$m file. [Re: WretchedSid] #391987
01/17/12 23:13
01/17/12 23:13
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
thanks, changed the things
you should notice that the function finds all funcs and actions running with this ent, not only the basic action. but it should be a workaround first.

@Sid: Thanks wink


Visit my site: www.masterq32.de
Re: Trouble about to create $$m file. [Re: MasterQ32] #391993
01/18/12 00:14
01/18/12 00:14
Joined: Jul 2007
Posts: 619
Turkey, Izmir
Emre Offline OP
User
Emre  Offline OP
User

Joined: Jul 2007
Posts: 619
Turkey, Izmir
Okay. I will try it. Thanks to both of you.


Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1