Chocobo Whistle

Post Reply
doghusky1990
Posts: 56
Joined: Wed Aug 01, 2012 2:26 pm

Chocobo Whistle

Post by doghusky1990 » Tue Aug 07, 2012 12:43 pm

I was messing around with scripting, and decided to script the chocobo whistle.
This is what I have so far.

Code: Select all

-----------------------------------------
-- ID: 15533
-- Item: chocobo whistle
-- Food Effect: 3Min, All Races
-----------------------------------------

require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/keyitems");

-----------------------------------------
-- OnItemCheck
-----------------------------------------

function onItemCheck(target)
	result = 246; -- full from food.
	hasLicense = target:hasKeyItem(CHOCOBO_LICENSE);
	level = target:getMainLvl();
	if (hasLicense and level >= 15) then
		result = 0; -- continue
	end
return result;
end;

-----------------------------------------
-- OnItemUse
-----------------------------------------

function onItemUse(target)
	--if (hasLicense and level >= 15) then
		target:addStatusEffect(EFFECT_CHOCOBO,1,0,1800);
	--end
end;
What works:
- it checks to see if you are above lvl 15 and that you have the CHOCOBO_LICENSE
- if you do, you are put on the chocobo
- if you don't, you don't get a chocobo

What don't work
- if you don't have a CHOCOBO_LICENSE, the chat spits out "you are full" (not sure of the right result number)
- you can get on a chocobo in town (not sure how to check players location.)

User avatar
whasf
Site Admin
Posts: 1294
Joined: Thu Jul 19, 2012 9:11 pm

Re: Chocobo Whistle

Post by whasf » Tue Aug 07, 2012 5:21 pm

You need to put

Code: Select all

hasLicense = target:hasKeyItem(CHOCOBO_LICENSE);
level = target:getMainLvl();
in your onItemUse() function as the definition in onItemCheck() doesn't fall through
-- Whasf

doghusky1990
Posts: 56
Joined: Wed Aug 01, 2012 2:26 pm

Re: Chocobo Whistle

Post by doghusky1990 » Tue Aug 07, 2012 7:05 pm

thanks for the reply.

I hope this is what you ment.
-----------------------------------------
-- ID: 15533
-- Item: chocobo whistle
-- Food Effect: 3Min, All Races
-----------------------------------------

require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/keyitems");

-----------------------------------------
-- OnItemCheck
-----------------------------------------

function onItemCheck(target)
result = 246; -- full from food.
hasLicense = target:hasKeyItem(CHOCOBO_LICENSE);
level = target:getMainLvl();
zone = target:getZone();


if (hasLicense and level >= 15 and zone ~= 241 and zone ~= 240 and zone ~= 239 and zone ~= 238 and zone ~= 230 and zone ~= 231 and zone ~= 232 and zone ~= 234 and zone ~= 235 and zone ~= 236) then -- check for right level and license
result = 0; -- continue
end
return result;
end;

-----------------------------------------
-- OnItemUse
-----------------------------------------

function onItemUse(target)
hasLicense = target:hasKeyItem(CHOCOBO_LICENSE);
level = target:getMainLvl();
if (hasLicense and level >= 15) then
target:addStatusEffect(EFFECT_CHOCOBO,1,0,1800);
end
end;
I also add a check to see if the player is in a town, but is it safe to do it the way I did.
I am just learning lua...

Kyousousha
Posts: 15
Joined: Sat Aug 04, 2012 12:55 am

Re: Chocobo Whistle

Post by Kyousousha » Tue Aug 07, 2012 10:53 pm

There are other areas that have restrictions on chocobo usage other than major and minor cities -- that is, dungeons and many outside areas (e.g. Beaucedine Glacier et al.). This condition could be handled within the script like you have it now, but it would be bulky and quite unnecessary. Instead, it would be better to implement another solution from within the core that uses the zone restrictions stored in the database for whether or not chocobos can be used.

doghusky1990
Posts: 56
Joined: Wed Aug 01, 2012 2:26 pm

Re: Chocobo Whistle

Post by doghusky1990 » Tue Aug 07, 2012 11:04 pm

True, but this is more of a temp fix, so people can use the chocobo whistle.
I know right now that this is not perfect, but it works.

thank you for the feed back.
You wouldn't happen to know where I can view the return values, would you? as of right now, it returns "player is full". Which makes it sound like the player attempted to eat the poor chocobo.

Kyousousha
Posts: 15
Joined: Sat Aug 04, 2012 12:55 am

Re: Chocobo Whistle

Post by Kyousousha » Tue Aug 07, 2012 11:56 pm

Check message.log in trunk\documentation folder -- it should have the messageId that you need.

Post Reply