Question?

Post Reply
HackGoDz
Posts: 37
Joined: Thu Aug 16, 2012 12:12 pm

Question?

Post by HackGoDz » Thu Aug 23, 2012 9:48 pm

How could i make it so new characters automatically get all key items and maps?
Can i possibly make it so once i trade the adventure coupon to the npc it'll give all the maps and key items?

PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

Re: Question?

Post by PrBlahBlahtson » Fri Aug 24, 2012 12:12 am

Hope you don't mind a little light programming. I swear, it's pretty easy.

You may want to consider whether or not to do all key items, since it could cause strange behavior from certain quests (i.e. unflagable, get stuck, etc.) If you're okay with that, then by all means.

This is the script I use for Jack of Spades in Windurst Woods, which is an Adventurer's Coupon NPC. You'd have to copy-paste the relevant code into whichever NPCs you wanted to behave this way. As an aside, I got the code from someone else either in this forum, or the old forum. All this one does is add maps, but it shouldn't be too hard to puzzle out how to make it all key items, all spells, etc.

It also happens pretty much instantaneously, so no worries about the server lagging when people use it. At least, the maps go okay.

The relevant code is the player:addKeyItem() bits.

Code: Select all

-----------------------------------
--	Area: Windurst Woods
--	NPC: Jack of Spades
--	Adventurer's Assistant
--	Working 100%
-------------------------------------

require("scripts/globals/settings");
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
require("scripts/zones/Windurst_Woods/TextIDs");

----------------------------------- 
-- onTrade Action 
----------------------------------- 

function onTrade(player,npc,trade)

count = trade:getItemCount();
AdventurerCoupon = trade:hasItemQty(536,1);

	if (AdventurerCoupon == true and count == 1) then
		player:startEvent(0x271a,GIL_RATE*50);
		-- ADD ALL MAPS
		-- MAIN NATIONS SANDY BASTOK WINDURST JEUNO
		player:addKeyItem(385);
		player:addKeyItem(386);
		player:addKeyItem(387);
		player:addKeyItem(388);
		-- ITEMS 389 to 447
		z = 389;
		while z <= 447 do
			player:addKeyItem(z);
			z = z + 1;
		end
		-- KEY ITEMS 1856 to 1893
		z = 1856;
			while z <= 1893 do
			player:addKeyItem(z);
			z = z + 1;
		end
	end
end;

----------------------------------- 
-- onTrigger Action 
-----------------------------------
 
function onTrigger(player,npc) 
	player:startEvent(0x2719,0,4);
end; 

-----------------------------------
-- onEventUpdate
-----------------------------------

function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;

-----------------------------------
-- onEventFinish
-----------------------------------

function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
	if (csid == 0x271a) then
		player:tradeComplete();
		player:addGil(GIL_RATE*50);
	end 
end;

Post Reply