Quests and more Quests

ex0r
Posts: 83
Joined: Wed Aug 29, 2012 10:08 pm

Quests and more Quests

Post by ex0r » Mon Sep 10, 2012 8:13 pm

I did some more quests tonight, here is a synopsis of all the quests i've done so far. (Not sure if it included them in this patch or not so im going to include them anyways)

The Setting Sun (Done and Complete)
Breaking Stones (Done and Complete)
Her Majesty's Garden (Done and Complete)
Stardust (Done and Complete)
Attachments
ex0r.patch
(15.15 KiB) Downloaded 328 times

Flunklesnarkin
Posts: 238
Joined: Wed Sep 05, 2012 10:48 am

Re: Quests and more Quests

Post by Flunklesnarkin » Mon Sep 10, 2012 8:34 pm

Awesome work man, quests were one of my favorite parts of FFXI

keep them coming :)


Image

ex0r
Posts: 83
Joined: Wed Aug 29, 2012 10:08 pm

Re: Quests and more Quests

Post by ex0r » Mon Sep 10, 2012 10:34 pm

Over the next week or so I plan on getting quite a bit of them done, been going through the list seeing which ones are done and which ones aren't. I'm still new to scripting so some of the advanced quests I won't be attempting yet, but alot of the other ones I will do for sure.

User avatar
diatanato
Developer
Posts: 112
Joined: Thu Aug 30, 2012 9:59 pm

Re: Quests and more Quests

Post by diatanato » Thu Sep 13, 2012 4:53 am

Code: Select all

function alreadyCheckedNPC(player,number)
	
	local wildcatSandy = player:getVar("wildcatSandy_var");
	local bit = {};
	
	for i = 19,0,-1 do 
		twop = 2^i;
		if(wildcatSandy >= twop) then
			bit[i+1] = 1;
			wildcatSandy = wildcatSandy - twop;
		else
			bit[i+1] = 0;
		end;
	end;
		
	if(bit[number] == 0) then
		return false;
	else
		return true;
	end
	
end;
can be change to (where 0x80000 is your 20 bit)

Code: Select all

if (player:getVar("wildcatSandy_var") % 2 * 0x80000 >= 0x80000) then;
-- TODO
end
(value % 2 * bit) >= bit -- there is a bit
(value % 2 * bit) < bit -- there isn't a bit

how it work:
1100101001010111b = 51799
1000000b = 64
let's find this bit
1100101001010111b % 2 * 1000000b >= 1000000b (51799 % 2 * 64 >= 64)
2 * 1000000b == 10000000b
% will remove all bits at the beginning (we have 7 bit in 10000000b then will remove 8,9,10,11,12,13,14,15 and 16 bit)
1100101001010111b % 10000000b = 1010111b (01010111b)
now
1010111b >= 1000000b = true
but it work for one bit only

P.S. I hope that I could explain this principle ^^

Ezekyel
Developer
Posts: 62
Joined: Sat Jul 21, 2012 11:42 pm

Re: Quests and more Quests

Post by Ezekyel » Thu Sep 13, 2012 2:16 pm

you can delete this part, this quest is not implemented because it's aht urhgan, and now we have new lua function for that

int32 setMaskBit(lua_State*); // Sets a single bit in a character variable
int32 getMaskBit(lua_State*); // Retrieves a single bit in a character variable
int32 isMaskFull(lua_State*); // Checks if a bitmask stored in a character varable of a specified size contains all set bits
New Gilgamesh Server --> http://gilgamesh.servegame.com

ex0r
Posts: 83
Joined: Wed Aug 29, 2012 10:08 pm

Re: Quests and more Quests

Post by ex0r » Thu Sep 13, 2012 7:15 pm

I'm sorry, what is this in reference to? I don't remember using any of that stuff in my quest scripts. There was some stuff already in the NPC files, so it's possible somebody else worked on some incomplete stuff.

ex0r
Posts: 83
Joined: Wed Aug 29, 2012 10:08 pm

Re: Quests and more Quests

Post by ex0r » Tue Sep 18, 2012 7:34 pm

BUMP metal

User avatar
diatanato
Developer
Posts: 112
Joined: Thu Aug 30, 2012 9:59 pm

Re: Quests and more Quests

Post by diatanato » Wed Sep 19, 2012 12:39 am

Ezekyel wrote:you can delete this part, this quest is not implemented because it's aht urhgan, and now we have new lua function for that

int32 setMaskBit(lua_State*); // Sets a single bit in a character variable
int32 getMaskBit(lua_State*); // Retrieves a single bit in a character variable
int32 isMaskFull(lua_State*); // Checks if a bitmask stored in a character varable of a specified size contains all set bits
это не очень хорошее решение в большинстве случаев

check Norg/npcs/Mamaulabion.lua

Code: Select all

if(player:getQuestStatus(OUTLANDS,MAMA_MIA) == QUEST_ACCEPTED) then
		if(trade:hasItemQty(1202,1) and trade:getItemCount() == 1) then -- Trade Bubbly water
			wasSet = player:getMaskBit("tradesMamaMia",0)
			player:setMaskBit("tradesMamaMia",0,true)
			if(player:isMaskFull("tradesMamaMia",7) == true) then
				player:startEvent(0x00C3); -- Traded all seven items
			elseif(wasSet) then
				player:startEvent(0x00C2); -- Traded an item you already gave
			else
				player:startEvent(0x00C1); -- Traded an item
			end
wasSet = player:getMaskBit("tradesMamaMia",0) - 1 query to db
player:setMaskBit("tradesMamaMia",0,true) - 2 queries to db
player:isMaskFull("tradesMamaMia",7) == true - 1 query to db
итог: 5 queries

если заменить все это на формулу
(value % 2 * bit) >= bit
то к базе в итоге уйдет лишь 2 queries

2 queries VS 5 queries

bluekirby0
Developer
Posts: 707
Joined: Sun Jul 22, 2012 12:11 am

Re: Quests and more Quests

Post by bluekirby0 » Wed Sep 19, 2012 1:53 am

The number of queries can be cut down by caching the variable first (it would add an extra step to the scripting and an extra argument to the functions, but it would bring it down to 2 queries). Those functions do provide a way of using the efficient storage of bitmasks without having to actually understand them, which is a great benefit to the scripters.

User avatar
diatanato
Developer
Posts: 112
Joined: Thu Aug 30, 2012 9:59 pm

Re: Quests and more Quests

Post by diatanato » Wed Sep 19, 2012 2:29 am

bluekirby0 wrote:Those functions do provide a way of using the efficient storage of bitmasks without having to actually understand them, which is a great benefit to the scripters.
идея хорошая, но реализация плохая

Post Reply