Scripts for running the various commands/npcs (done so far) are pushed.

This commit is contained in:
Filip Maj 2016-03-12 02:54:03 -05:00
parent e851c767df
commit e409d3792c
67 changed files with 1447 additions and 0 deletions

View file

@ -0,0 +1,22 @@
--[[
ActivateCommand Script
Switches between active and passive mode states
--]]
function onEventStarted(player, actor)
if (player:getState() == 0) then
player:changeState(2);
elseif (player:getState() == 2) then
player:changeState(0);
end
player:endEvent();
end
function onEventUpdate(player, npc)
end

View file

@ -0,0 +1,24 @@
--[[
AttackWeaponSkill Script
Finds the correct weaponskill subscript to fire when a weaponskill actor is activated.
--]]
function onEventStarted(player, actor)
worldMaster = getWorldMaster();
if (player:getState() != 2) then
player:sendGameMessage(worldMaster, 32503, 0x20);
end
player:endEvent();
end
function onEventUpdate(player, npc)
end

View file

@ -0,0 +1,23 @@
--[[
BonusPointCommand Script
Functions:
operateUI(pointsAvailable, pointsLimit, str, vit, dex, int, min, pie)
--]]
function onEventStarted(player, actor)
--local points = player:getAttributePoints();
--player:runEventFunction("delegateCommand", actor, "operateUI", points.available, points.limit, points.inSTR, points.inVIT, points.inDEX, points.inINT, points.inMIN, points.inPIT);
player:runEventFunction("delegateCommand", actor, "operateUI", 10, 10, 10, 10, 10, 10, 10, 10);
end
function onEventUpdate(player, actor, step, arg1)
--Submit
player:endEvent();
end

View file

@ -0,0 +1,19 @@
--[[
CheckCommand Script
Handles player examining someone
--]]
function onEventStarted(player, commandactor, arg1, arg2, arg3, arg4, checkedActorId)
actor = player:getActorInInstance(checkedActorId);
if (actor ~= nil) then
player:examinePlayer(actor);
end
player:endEvent();
end

View file

@ -0,0 +1,50 @@
--[[
ChocoboRideCommand Script
Handles mounting and dismounting the Chocobo and Goobbue
--]]
function onEventStarted(player, actor, isGoobbue)
if (player:getState() == 0) then
worldMaster = getWorldMaster();
if (isGoobbue ~= true) then
player:changeMusic(83);
player:sendChocoboAppearance();
player:sendGameMessage(player, worldMaster, 26001, 0x20);
player:setMountState(1);
else
player:changeMusic(98);
player:sendGoobbueAppearance();
player:sendGameMessage(player, worldMaster, 26019, 0x20);
player:setMountState(2);
end
player:changeSpeed(0.0, 5.0, 10.0);
player:changeState(15);
else
player:changeMusic(player:getZone().bgmDay);
worldMaster = getWorldMaster();
if (player:getMountState() == 1) then
player:sendGameMessage(player, worldMaster, 26003, 0x20);
else
player:sendGameMessage(player, worldMaster, 26021, 0x20);
end
player:setMountState(0);
player:changeSpeed(0.0, 2.0, 5.0)
player:changeState(0);
end
player:endEvent();
end
function onEventUpdate(player, npc)
end

View file

@ -0,0 +1,23 @@
--[[
DiceCommand Script
--]]
function onEventStarted(player, actor, maxNumber)
if (maxNumber == nil) then
maxNumber = 999;
end
result = math.random(0, maxNumber);
worldMaster = getWorldMaster();
player:sendGameMessage(player, worldMaster, 25342, 0x20, result, maxNumber);
player:endEvent();
end
function onEventUpdate(player, npc)
end

View file

@ -0,0 +1,24 @@
--[[
EmoteSitCommand Script
--]]
function onEventStarted(player, actor, emoteId)
if (player:getState() == 0) then
if (emoteId == 0x2712) then
player:changeState(11);
else
player:changeState(13);
end
else
player:changeState(0);
end
player:endEvent();
end
function onEventUpdate(player, npc)
end

View file

@ -0,0 +1,23 @@
--[[
EmoteStandardCommand Script
--]]
emoteTable = {
{},
};
function onEventStarted(player, actor, emoteId)
if (player:getState() == 0) then
player:doEmote(emoteId);
end
player:endEvent();
end
function onEventUpdate(player, npc)
end

View file

@ -0,0 +1,205 @@
--[[
EquipCommand Script
Notes:
Gearset activating could be optimized a bit more by doing the item packets in one go.
The param "invActionInfo" has the vars: actorId, unknown, slot, and inventoryType.
The param "itemDBIds" has the vars: item1 and item2.
--]]
EQUIPSLOT_MAINHAND = 0;
EQUIPSLOT_OFFHAND = 1;
EQUIPSLOT_THROWINGWEAPON = 4;
EQUIPSLOT_PACK = 5;
EQUIPSLOT_POUCH = 6;
EQUIPSLOT_HEAD = 8;
EQUIPSLOT_UNDERSHIRT = 9;
EQUIPSLOT_BODY = 10;
EQUIPSLOT_UNDERGARMENT = 11;
EQUIPSLOT_LEGS = 12;
EQUIPSLOT_HANDS = 13;
EQUIPSLOT_FEET = 14;
EQUIPSLOT_WAIST = 15;
EQUIPSLOT_NECK = 16;
EQUIPSLOT_EARS = 17;
EQUIPSLOT_WRIST = 19;
EQUIPSLOT_RFINGER = 21;
EQUIPSLOT_LFINGER = 22;
GRAPHICSLOT_MAINHAND = 5;
GRAPHICSLOT_OFFHAND = 6;
GRAPHICSLOT_SPMAINHAND = 7;
GRAPHICSLOT_SPOFFHAND = 8;
GRAPHICSLOT_THROWING = 9;
GRAPHICSLOT_PACK = 10;
GRAPHICSLOT_POUCH = 11;
GRAPHICSLOT_HEAD = 12;
GRAPHICSLOT_BODY = 13;
GRAPHICSLOT_LEGS = 14;
GRAPHICSLOT_HANDS = 15;
GRAPHICSLOT_FEET = 16;
GRAPHICSLOT_WAIST = 17;
GRAPHICSLOT_NECK = 18;
GRAPHICSLOT_R_EAR = 19;
GRAPHICSLOT_L_EAR = 20;
GRAPHICSLOT_R_WRIST = 21;
GRAPHICSLOT_L_WRIST = 22;
GRAPHICSLOT_R_RINGFINGER = 23;
GRAPHICSLOT_L_RINGFINGER = 24;
GRAPHICSLOT_R_INDEXFINGER = 25;
GRAPHICSLOT_L_INDEXFINGER = 26;
function onEventStarted(player, actor, invActionInfo, param1, param2, param3, param4, param5, param6, param7, equipSlot, itemDBIds)
equipSlot = equipSlot-1;
--Equip Item
if (invActionInfo ~= nil) then
item = player:getInventory(0):getItemBySlot(invActionInfo.slot);
equipItem(player, equipSlot, item);
player:sendAppearance();
--Unequip Item
else
item = player:getEquipment():GetItemAtSlot(equipSlot);
if (unequipItem(player, equipSlot, item) == true) then --Returns true only if something changed (didn't error out)
player:sendAppearance();
end
end
player:endEvent();
end
function loadGearset(player, classId)
player:getEquipment():ToggleDBWrite(false);
gearset = player:getGearset(classId);
if gearset == nil then
return;
end
for slot = 0, 34 do
if (slot ~= EQUIPSLOT_MAINHAND and slot ~= EQUIPSLOT_UNDERSHIRT and slot ~= EQUIPSLOT_UNDERGARMENT) then
itemAtSlot = player:getEquipment():GetItemAtSlot(slot);
itemAtGearsetSlot = gearset[slot];
if (itemAtSlot ~= nil or itemAtGearsetSlot ~= nil) then
if (itemAtSlot ~= nil and itemAtGearsetSlot == nil) then
unequipItem(player, slot, itemAtSlot);
elseif (itemAtSlot == nil and itemAtGearsetSlot ~= nil) then
equipItem(player, slot, itemAtGearsetSlot);
elseif (itemAtGearsetSlot.uniqueId ~= itemAtSlot.uniqueId) then
unequipItem(player, slot, itemAtSlot);
equipItem(player, slot, itemAtGearsetSlot)
end
end
end
end
player:getEquipment():ToggleDBWrite(true);
player:doClassChange(classId);
end
function equipItem(player, equipSlot, item)
if (item ~= nil) then
worldMaster = getWorldMaster();
--Item Equipped message
player:sendGameMessage(player, worldMaster, 30601, 0x20, equipSlot+1, item.itemId, item.quality, 0, 0, 1);
player:getEquipment():Equip(equipSlot, item);
gItem = getItemGamedata(item.itemId);
if (equipSlot == EQUIPSLOT_MAINHAND and gItem:IsNailWeapon() == false and gItem:IsBowWeapon() == false) then graphicSlot = GRAPHICSLOT_MAINHAND;
elseif (equipSlot == EQUIPSLOT_OFFHAND) then graphicSlot = GRAPHICSLOT_OFFHAND;
elseif (equipSlot == EQUIPSLOT_HEAD) then graphicSlot = GRAPHICSLOT_HEAD;
elseif (equipSlot == EQUIPSLOT_BODY) then graphicSlot = GRAPHICSLOT_BODY;
elseif (equipSlot == EQUIPSLOT_LEGS) then graphicSlot = GRAPHICSLOT_LEGS;
elseif (equipSlot == EQUIPSLOT_HANDS) then graphicSlot = GRAPHICSLOT_HANDS;
elseif (equipSlot == EQUIPSLOT_FEET) then graphicSlot = GRAPHICSLOT_FEET;
elseif (equipSlot == EQUIPSLOT_WAIST) then graphicSlot = GRAPHICSLOT_WAIST;
elseif (equipSlot == EQUIPSLOT_RFINGER) then graphicSlot = GRAPHICSLOT_RFINGER;
elseif (equipSlot == EQUIPSLOT_LFINGER) then graphicSlot = GRAPHICSLOT_LFINGER;
end
--Graphic Slot was set, otherwise it's a special case
if (graphicSlot ~= nil) then
player:graphicChange(graphicSlot, item);
if (graphicSlot == GRAPHICSLOT_MAINHAND) then player:graphicChange(GRAPHICSLOT_OFFHAND, nil); end
elseif (gItem:IsNailWeapon()) then
player:graphicChange(GRAPHICSLOT_MAINHAND, item);
player:graphicChange(GRAPHICSLOT_OFFHAND, item);
elseif (gItem:IsBowWeapon()) then
player:graphicChange(GRAPHICSLOT_MAINHAND, item);
--player:graphicChange(GRAPHICSLOT_OFFHAND, item);
elseif (equipSlot == EQUIPSLOT_EARS) then
player:graphicChange(GRAPHICSLOT_R_EAR, item);
player:graphicChange(GRAPHICSLOT_L_EAR, item);
end
--If it's the mainhand, begin class change based on weapon
if (equipSlot == EQUIPSLOT_MAINHAND) then
if (gItem:IsNailWeapon()) then classId = 2;
elseif (gItem:IsSwordWeapon()) then classId = 3;
elseif (gItem:IsAxeWeapon()) then classId = 4;
elseif (gItem:IsBowWeapon()) then classId = 7;
elseif (gItem:IsLanceWeapon()) then classId = 8;
elseif (gItem:IsThaumaturgeWeapon()) then classId = 22;
elseif (gItem:IsConjurerWeapon()) then classId = 23;
elseif (gItem:IsCarpenterWeapon()) then classId = 29;
elseif (gItem:IsBlackSmithWeapon()) then classId = 30;
elseif (gItem:IsArmorerWeapon()) then classId = 31;
elseif (gItem:IsGoldSmithWeapon()) then classId = 32;
elseif (gItem:IsTannerWeapon()) then classId = 33;
elseif (gItem:IsWeaverWeapon()) then classId = 34;
elseif (gItem:IsAlchemistWeapon()) then classId = 35;
elseif (gItem:IsCulinarianWeapon()) then classId = 36;
elseif (gItem:IsMinerWeapon()) then classId = 39;
elseif (gItem:IsBotanistWeapon()) then classId = 40;
elseif (gItem:IsFishingWeapon()) then classId = 41;
end
loadGearset(player, classId);
end
end
end
function unequipItem(player, equipSlot, item)
worldMaster = getWorldMaster();
if (item ~= nil and (equipSlot == EQUIPSLOT_MAINHAND or equipSlot == EQUIPSLOT_UNDERSHIRT or equipSlot == EQUIPSLOT_UNDERGARMENT)) then
player:sendGameMessage(player, worldMaster, 30730, 0x20, equipSlot+1, item.itemId, item.quality, 0, 0, 1); --Unable to unequip
elseif (item ~= nil) then
player:sendGameMessage(player, worldMaster, 30602, 0x20, equipSlot+1, item.itemId, item.quality, 0, 0, 1); --Item Removed
player:getEquipment():Unequip(equipSlot);
if (equipSlot == EQUIPSLOT_BODY) then --Show Undershirt
item = player:getEquipment():GetItemAtSlot(EQUIPSLOT_UNDERSHIRT);
player:graphicChange(GRAPHICSLOT_BODY, item);
elseif (equipSlot == EQUIPSLOT_LEGS) then --Show Undergarment
item = player:getEquipment():GetItemAtSlot(EQUIPSLOT_UNDERGARMENT);
player:graphicChange(GRAPHICSLOT_LEGS, item);
elseif (equipSlot == EQUIPSLOT_HANDS) then player:graphicChange(15, 0, 1, 0, 0);
elseif (equipSlot == EQUIPSLOT_FEET) then player:graphicChange(16, 0, 1, 0, 0);
else
if (equipSlot == EQUIPSLOT_MAINHAND) then player:graphicChange(GRAPHICSLOT_MAINHAND, nil);
elseif (equipSlot == EQUIPSLOT_OFFHAND) then player:graphicChange(GRAPHICSLOT_OFFHAND, nil);
elseif (equipSlot == EQUIPSLOT_HEAD) then player:graphicChange(GRAPHICSLOT_HEAD, nil);
elseif (equipSlot == EQUIPSLOT_WAIST) then player:graphicChange(GRAPHICSLOT_WAIST, nil);
elseif (equipSlot == EQUIPSLOT_EARS) then player:graphicChange(GRAPHICSLOT_L_EAR, nil); player:graphicChange(GRAPHICSLOT_R_EAR, nil);
elseif (equipSlot == EQUIPSLOT_RFINGER) then player:graphicChange(GRAPHICSLOT_RFINGER, nil);
elseif (equipSlot == EQUIPSLOT_LFINGER) then player:graphicChange(GRAPHICSLOT_LFINGER, nil);
end
end
return true;
end
end

View file

@ -0,0 +1,15 @@
--[[
ItemWasteCommand Script
Notes:
The param "invActionInfo" has the vars: actorId, unknown, slot, and inventoryType.
The param "itemDBIds" has the vars: item1 and item2.
--]]
function onEventStarted(player, actor, invActionInfo, param1, param2, param3, param4, param5, param6, param7, param8, itemDBIds)
player:getInventory(0x00):removeItem(invActionInfo.slot);
player:endEvent();
end

View file

@ -0,0 +1,52 @@
--[[
LogoutCommand Script
Functions:
eventConfirm()
eventCountDown()
eventLogoutFade()
Menu Ids:
Menu: 0
Countdown: 1
--]]
function onEventStarted(player, command)
player:setCurrentMenuId(0);
player:runEventFunction("delegateCommand", command, "eventConfirm");
end
function onEventUpdate(player, command, step, arg1, arg2)
currentMenuId = player:getCurrentMenuId();
--Menu Dialog
if (currentMenuId == 0) then
if (arg1 == 1) then --Exit
player:quitGame();
player:endEvent();
elseif (arg1 == 2) then --Character Screen
player:logout();
player:endEvent();
--player:setCurrentMenuId(1);
--player:runEventFunction("delegateCommand", command, "eventCountDown");
elseif (arg1 == 3) then --Cancel
player:endEvent();
end
--Countdown Dialog
elseif (currentMenuId == 1) then
if (arg2 == 1) then --Logout Complete
player:logout();
player:endEvent();
elseif (arg2 == 2) then --Cancel Pressed
player:endEvent();
end
end
end

View file

@ -0,0 +1,51 @@
--[[
TeleportCommand Script
Functions:
eventRegion(numAnima)
eventAetheryte(region, animaCost1, animaCost2, animaCost3, animaCost4, animaCost5, animaCost6)
eventConfirm(isReturn, isInBattle, cityReturnNum, 138821, forceAskReturnOnly)
Menu Ids:
Region Menu: 0
Aetheryte Menu: 1
Confirm Menu: 2
--]]
function onEventStarted(player, actor, isTeleport)
if (isTeleport == 0) then
player:setCurrentMenuId(0);
player:runEventFunction("delegateCommand", actor, "eventRegion", 100);
else
player:setCurrentMenuId(2);
player:runEventFunction("delegateCommand", actor, "eventConfirm", true, false, 1, 0x138824, false);
end
end
function onEventUpdate(player, actor, step, arg1)
menuId = player:getCurrentMenuId();
if (menuId == 0) then --Region
if (arg1 ~= nil and arg1 >= 1) then
player:setCurrentMenuId(1);
player:runEventFunction("delegateCommand", actor, "eventAetheryte", arg1, 2, 2, 2, 4, 4, 4);
else
player:endEvent();
end
elseif (menuId == 1) then --Aetheryte
if (arg1 == nil) then
player:endEvent();
return;
end
player:setCurrentMenuId(2);
player:runEventFunction("delegateCommand", actor, "eventConfirm", false, false, 1, 138824, false);
elseif (menuId == 2) then --Confirm
player:endEvent();
end
end