Jump to content
×
×
  • Create New...

[ Dead Download Link ] [RELEASE] QC (quest compiler) extensions [ We Need You ]


ionutxp

Recommended Posts

Hey,

Today I was working to extend the qc features. I managed to add:

- Lua defines

- When clause functions

 

Example:

define DOG ""Anne has apples.""
define NAB "red"
define TESTX 323
define PI 3.14
define EXPR "if x == 10 then say(22) end"
define _TRA_ "translate"
quest test begin
    state start begin
        function doStuff(x, y)
            say(DOG);
        end
        function doStuffAgain(www)
            say("Test")
            say(22)
        end
        when 20088.chat.translate."SD2.ENTER" begin
            say(DOG)
            doStuff(TESTX, 12)
        end
        when TESTX.chat."Testx" begin
            EXPR;
            say("Random text ! ");
        end
    end
end
Now, you can translate your quest select fields with ease:
quest test begin
    state start begin
        when 2222.chat.tra."ENTER.TITLE" begin
            say(DOG)
        end
    end
end

Make sure to have a:

function tra(str_key)
   return global_table[get_language()][str_key];
end

when 2222.chat.x.y.z.tra.d."ENTER.TITLE" begin

will convert to: when x(y(z(tra(d("ENTER.TITLE)))))

 

I'll come back with the source code after some tests and, a new description and new examples.

 

Download:

http://ionutmilica.ro/downloads/revs/qc_last.rar

Source code:

Hidden Content

    Give reaction to this post to see the hidden content.

  • Metin2 Dev 3
  • Love 10
  • Angry 1
Link to comment
Share on other sites

Source code: 

Hidden Content

    Give reaction to this post to see the hidden content.

As you can see, i hold a quest folder (project) in the same path as libsql / liblua. Edit it accordingly.

  • Metin2 Dev 2
  • Love 3
  • Love 1
  • Good 1
Link to comment
Share on other sites

Update: Fixed major bugs and translate function.

Now, you can override default tra function name in when-event translation.

define _TRA_ "translate"

and

when 20088.chat.translate."SD2.ENTER" begin
  • Love 2
Link to comment
Share on other sites

Even if I already had an enhancement in my compiler like your translate thing I used your because I didn't have the define thing (don't want to use the pre_qc.py always).

 

Could it be that the compiler has a problem with functions now?

 

e5e8432acf.png

 

locale/germany/quest/object/state/oxevents

oxevents={["start"]=0,open= function ()oxevent open 

oxevent open 




,quiz= function ()oxevent quiz 

oxevent quiz 




,check= function ()gmlist 
i table getn gmlist 
gmlist i pc name 





}

oxevent.quest

quest oxevents begin 
	state start begin 
		function open() 
			if(oxevent.open() == 0) then 
				return 0 
			elseif(oxevent.open() == 1) then 
				return 1 
			else 
				return 2 
			end 
		end
		function quiz() 
			if(oxevent.quiz(1,30) == 0) then 
				return 0 
			elseif(oxevent.quiz(1,30) == 1) then 
				return 1  
			else 
				return 2 
			end 
		end 
		function check() 
			local gmlist = {"[NA]Raysis"}
			for i = 1,table.getn(gmlist),1 do 
				if(gmlist[i] == pc.name) then 
					return true 
				else 
					return false 
				end 
			end 
		end 
		 
		when 20011.chat."Der OX-Wettbewerb" with pc.is_gm() and oxevents.check() == true and game.get_event_flag("automatic_oxevent_status") == 0 begin 
			say_title(mob_name(npc.get_race())..":") 
			say("") 
			say("Möchtest du den Wettbewerb starten? ") 
			say("") 
			local s = select(locale.yes,locale.no) 
			if(s == 2) then return end 
			say_title(mob_name(npc.get_race())..":") 
			say("") 
			say_reward("Info: Uhrzeit: "..os.date("%H")) 
			say("") 
			say("Um wie viel Uhr soll der Wettbewerb starten? ") 
			local times = tonumber(input() )
			if(times == "" or tonumber(times) == nil) then return end 
			say_title(mob_name(npc.get_race())..":") 
			say("") 
			game.set_event_flag("automatic_oxevent_opentime",times) 
			say("Der Wettbewerb wurde gestartet!") 
			say("Wird in "..times.." Stunden geöffnet! ") 
			game.set_event_flag("automatic_oxevent_status",1) 
			server_timer('check',30) 
		end 
		 
		when check.server_timer begin 
			if(os.date("%H") == game.get_event_flag("automatic_oxevent_opentime")) then 
				if(oxevents.open() == 0) then 
					print("Der Wettbewerb wurde bereits Gestartet!") 
				elseif(oxevents.open() == 1) then 
					notice_all("~~~~~~~~~~~     OX-EVENT     ~~~~~~~~~~~")
					notice_all("Das OX-Event beginnt in wenigen Minuten.")
					notice_all("Um daran teilzunehmen, sprecht mit Uriel.")
					notice_all("~~~~~~~~~~~     OX-EVENT     ~~~~~~~~~~~")
					server_timer('countdownone',60) 
				else 
					print("Es ist ein Fehler aufgetreten!") 
				end 
			else 
				server_timer('checktwo',30) 
			end 
		end 
		 
		when checktwo.server_timer begin 
			if(os.date("%H") == game.get_event_flag("automatic_oxevent_opentime")) then 
				if(oxevents.open() == 0) then 
					print("Der Wettbewerb wurde bereits Gestartet!") 
				elseif(oxevents.open() == 1) then 
					notice_all("~~~~~~~~~~~     OX-EVENT     ~~~~~~~~~~~")
					notice_all("Das OX-Event beginnt in wenigen Minuten.")
					notice_all("Um daran teilzunehmen, sprecht mit Uriel.")
					notice_all("~~~~~~~~~~~     OX-EVENT     ~~~~~~~~~~~")
					server_timer('countdownone',60) 
				else 
					print("Es ist ein Fehler aufgetreten!") 
				end 
			else 
				server_timer('check',30) 
			end 
		end	 
		 
		when countdownone.server_timer begin 
			notice_all("<OX> Ihr habt noch 4 Minuten Zeit, um am OX-Event teilzunehmen.") 
			server_timer("countdowntwo",60) 
		end 
		 
		when countdowntwo.server_timer begin 
			notice_all("<OX> Ihr habt noch 3 Minuten Zeit, um am OX-Event teilzunehmen.")
			server_timer("countdownthree",60) 
		end 
		 
		when countdownthree.server_timer begin 
			notice_all("<OX> Ihr habt noch 2 Minuten Zeit, um am OX-Event teilzunehmen.") 
			server_timer("countdownfour",60) 
		end 
		 
		when countdownfour.server_timer begin 
			notice_all("<OX> Ihr habt noch 1 Minuten Zeit, um am OX-Event teilzunehmen.") 
			server_timer("countdownfive",30) 
		end 
		 
		when countdownfive.server_timer begin 
			notice_all("<OX> Die Teilnahme am OX-Event wird in 30 Sekunden geschlossen.")
			server_timer("countdown",30) 
		end 
		 
		when countdown.server_timer begin 
			notice_all("<OX> Die Teilnahmemöglichkeit am OX-Event wurde geschlossen.")
			notice_all("<OX> Es können nur noch Zuschauer beitreten.")
			game.set_event_flag("automatic_oxevent_status",2) 
			server_timer('playercheck',10) 
			game.set_event_flag("automatic_oxevent_opentime",0) 
		end 
		 
		when playercheck.server_timer begin 
			if(pc.get_map_index() == 113) then 
				if(oxevent.get_attender() == 0) then 
					notice_all("<OX> Das OX-Event wurde beendet, da es keine Teilnehmer gab.")
					game.set_event_flag("automatic_oxevent_status",0) 
					game.set_event_flag("automatic_oxevent_opentime",0) 
				else 
					return 
				end 
			else 
				server_timer("oxeventstart",10) 
			end 
		end 
		 
		when oxeventstart.server_timer begin 
			if(pc.get_map_index() == 113) then 
				if(oxevents.quiz() == 0) then 
					print("Der Wettbewerb wurde beendet!") 
				elseif(oxevents.quiz() == 1) then 
					notice_in_map("Frage wurde gestellt...") 
					server_timer("goon",30) 
				else 
					print("Seit ihr bereit für die nächste Frage?") 
				end 
			else 
				return 
			end 
		end 
		 
		when goon.server_timer begin 
			-- Check 
			if(oxevent.get_attender() == 0) then 
				notice_in_map("Das Event wird beendet, da es keine Teilnehmer mehr gibt.")
				game.set_event_flag("automatic_oxevent_status",0) 
				game.set_event_flag("automatic_oxevent_opentime",0) 
				warp_all_to_village() 
			elseif(oxevent.get_attender() == 1) then 
				notice_in_map("Das Event ist vorbei. Der Gewinner erhält sein Item.")
				oxevent.give_item(20, 1)
				game.set_event_flag("automatic_oxevent_status",0) 
				game.set_event_flag("automatic_oxevent_opentime",0) 
				server_timer("over",20) 
			else 
				server_timer("goontwo",30) 
			end 
		end 
		 
		when over.server_timer begin 
			warp_all_to_village() 
		end 
		 
		when goontwo.server_timer begin
			if(oxevent.get_attender() == 0) then 
				notice_in_map("Das Event wird beendet, da es keine Teilnehmer mehr gibt.")
				game.set_event_flag("automatic_oxevent_status",0) 
				game.set_event_flag("automatic_oxevent_opentime",0) 
				warp_all_to_village() 
			elseif(oxevent.get_attender() == 1) then 
				notice_in_map("Das Event ist vorbei. Der Gewinner erhält sein Item.")
				oxevent.give_item(20, 1)
				game.set_event_flag("automatic_oxevent_status",0) 
				game.set_event_flag("automatic_oxevent_opentime",0) 
				server_timer("over",20) 
			else 
				server_timer("goon",30) 
			end 
		end
		when 20011.chat."Der OX-Wettbewerb" begin 
			addimage(25, 25, "oxevent.tga")
			say("[ENTER][ENTER][ENTER][ENTER][ENTER]")
			say_npc_title()
			say("")
			if(game.get_event_flag("automatic_oxevent_status") == 2) then 
				say("Das Event läuft bereits. Du kannst nurnoch als[ENTER]Zuschauer beitreten.") 
				say_reward("Möchtest du als Zuschauer beitreten?")
				local s = select(locale.yes,locale.no) 
				if(s == 2) then return end 
				pc.warp(896300, 28900) 
			elseif(game.get_event_flag("automatic_oxevent_status") == 1) then 
				say("Du kannst am OX-Event teilnehmen.[ENTER]Möchtest du teilnehmen?")
				local s = select(locale.yes,locale.no,"Als Zuschauer") 
				if(s == 1) then 
					pc.warp(896500, 24600) 
				elseif(s == 3) then 
					pc.warp(896300, 28900) 
				end 
			else
				say("Das Event findet derzeit nicht statt.")
				say("")
				return
			end 
		end 
	end 
end

 

You can help?

 

Regards

Link to comment
Share on other sites

Hi, (sorry for my bad english)

 

I have a problem, i try to make a quest in windows environment, also i start the debug of qc in my vs 2008 and i add a loop in my main for read the locale_list like that :

	string line;
	ifstream myfile ("locale_list");
	if (myfile.is_open())
	{
		while ( getline (myfile,line) )
		{
			char* t = strdup(line.c_str());
			g_filename = t;
/* I break here */	parse(g_filename); /* here */
			free(t);
  		}

		myfile.close();
 	}

i add a break point access condition fixed at 27 hit AND every time qc crash at this line (in parse method) :

void parse(char * filename) {
    ifstream inf(filename);
    LoadF lf;
    lf.f = fopen(filename, "r");
    ZIO z;
    luaZ_init(&z, getF, &lf, "quest");
    Mbuffer b;
    struct LexState lexstate;
    pls = &lexstate;
    luaZ_initbuffer(L, &;
    lexstate.buff = &b;
    luaX_setinput(L, &lexstate, &z, luaS_new(L, zname(&z))); /* here */ 
...

My error :

 

2505cmw.jpg

 

 

If i continue to debug, i go to feoferr.c at this line :

int __cdecl feof (
        FILE *stream
        )
{
        _VALIDATE_RETURN((stream != NULL),EINVAL, 0); /* here */
        return( ((stream)->_flag & _IOEOF) );
}

----- Edit -----

 

I have found a solution but i don't think it is a good solution :

void parse(char * filename) {
    ifstream inf(filename);
    LoadF lf;
    lf.f = fopen(filename, "r");
	if(!lf.f) // Check feof here
		return;
    ZIO z;
    luaZ_init(&z, getF, &lf, "quest");
    Mbuffer b;
    struct LexState lexstate;
    pls = &lexstate;
    luaZ_initbuffer(L, &;
    lexstate.buff = &b;
    luaX_setinput(L, &lexstate, &z, luaS_new(L, zname(&z)));

Your opinion ?

 

Best regards,

Quentin.

Link to comment
Share on other sites

I think it's better to simply use a shell script for this kind of job.
For example ./qc is used to compile a single or more files from cmd line not from a specific file.
Like in the standard server files, use a python file that calls qc for each quest found in the list...
Link to comment
Share on other sites

  • 8 months later...
  • 2 months later...
  • 4 years later...
  • 5 months later...
  • 1 month later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.