Minor script fixes

=============
ChocoboRideCommand - Fixed the mount speed to be retail accurate.
TeleportCommand            - Added anima costs, mount check, and placeholder for Favoured destinations
nudge/spawn/warpid        - Plus 1 to GetPos() arrays
This commit is contained in:
CuriousJorge 2022-01-28 02:29:45 -05:00
parent 26fd79bea5
commit bad51717c2
5 changed files with 253 additions and 174 deletions

View File

@ -8,42 +8,42 @@ Handles mounting and dismounting the Chocobo and Goobbue
function onEventStarted(player, actor, triggerName, isGoobbue) function onEventStarted(player, actor, triggerName, isGoobbue)
if (player:GetState() == 0) then if (player:GetState() == 0) then
worldMaster = GetWorldMaster(); worldMaster = GetWorldMaster();
if (isGoobbue ~= true) then if (isGoobbue ~= true) then
player:ChangeMusic(83); player:ChangeMusic(83);
player:SendGameMessage(player, worldMaster, 26001, 0x20); player:SendGameMessage(player, worldMaster, 26001, 0x20);
player:SetMountState(1); player:SetMountState(1);
else else
player:ChangeMusic(98); player:ChangeMusic(98);
player:SendGameMessage(player, worldMaster, 26019, 0x20); player:SendGameMessage(player, worldMaster, 26019, 0x20);
player:SetMountState(2); player:SetMountState(2);
end end
player:ChangeSpeed(0.0, 5.0, 10.0, 10.0); player:ChangeSpeed(0.0, 3.6, 9.0, 9.0);
player:ChangeState(15); player:ChangeState(15);
else else
player:ChangeMusic(player:GetZone().bgmDay); player:ChangeMusic(player:GetZone().bgmDay);
worldMaster = GetWorldMaster(); worldMaster = GetWorldMaster();
if (player.rentalExpireTime != 0) then if (player.rentalExpireTime != 0) then
player:SendGameMessage(player, worldMaster, 26004, 0x20); --You dismount. player:SendGameMessage(player, worldMaster, 26004, 0x20); --You dismount.
else else
if (player:GetMountState() == 1) then if (player:GetMountState() == 1) then
player:SendGameMessage(player, worldMaster, 26003, 0x20); --You dismount X. player:SendGameMessage(player, worldMaster, 26003, 0x20); --You dismount X.
else else
player:SendGameMessage(player, worldMaster, 26021, 0x20); --You dismount your Gobbue. player:SendGameMessage(player, worldMaster, 26021, 0x20); --You dismount your Gobbue.
end end
end end
player:SetMountState(0); player:SetMountState(0);
player:ChangeSpeed(0.0, 2.0, 5.0, 5.0) player:ChangeSpeed(0.0, 2.0, 5.0, 5.0)
player:ChangeState(0); player:ChangeState(0);
end end
player:EndEvent(); player:EndEvent();
end end

View File

@ -6,7 +6,7 @@ Functions:
eventRegion(numAnima) eventRegion(numAnima)
eventAetheryte(region, animaCost1, animaCost2, animaCost3, animaCost4, animaCost5, animaCost6) eventAetheryte(region, animaCost1, animaCost2, animaCost3, animaCost4, animaCost5, animaCost6)
eventConfirm(isReturn, isInBattle, cityReturnNum, 138821, forceAskReturnOnly) eventConfirm(isReturn, isInBattle, HomePointInn, HomePoint, forceAskReturnOnly)
--]] --]]
@ -15,112 +15,190 @@ require ("aetheryte")
require ("utils") require ("utils")
teleportMenuToAetheryte = { teleportMenuToAetheryte = {
[1] = { [1] = {
[1] = 1280001, [1] = 1280001,
[2] = 1280002, [2] = 1280002,
[3] = 1280003, [3] = 1280003,
[4] = 1280004, [4] = 1280004,
[5] = 1280005, [5] = 1280005,
[6] = 1280006 [6] = 1280006
}, },
[2] = { [2] = {
[1] = 1280092, [1] = 1280092,
[2] = 1280093, [2] = 1280093,
[3] = 1280094, [3] = 1280094,
[4] = 1280095, [4] = 1280095,
[5] = 1280096 [5] = 1280096
}, },
[3] = { [3] = {
[1] = 1280061, [1] = 1280061,
[2] = 1280062, [2] = 1280062,
[3] = 1280063, [3] = 1280063,
[4] = 1280064, [4] = 1280064,
[5] = 1280065, [5] = 1280065,
[6] = 1280066 [6] = 1280066
}, },
[4] = { [4] = {
[1] = 1280031, [1] = 1280031,
[2] = 1280032, [2] = 1280032,
[3] = 1280033, [3] = 1280033,
[4] = 1280034, [4] = 1280034,
[5] = 1280035, [5] = 1280035,
[6] = 1280036 [6] = 1280036
}, },
[5] = { [5] = {
[1] = 1280121, [1] = 1280121,
[2] = 1280122 [2] = 1280122
} },
} }
zoneIdToRegionChoice =
{
[128] = 1, [129] = 1, [130] = 1, [131] = 1, [132] = 1, [133] = 1, [134] = 1, [135] = 1, [230] = 1,
[143] = 2, [144] = 2, [145] = 2, [147] = 2, [148] = 2,
[150] = 3, [151] = 3, [152] = 3, [153] = 3, [154] = 3, [155] = 3, [157] = 3, [158] = 3, [159] = 3, [160] = 3, [206] = 3,
[170] = 4, [171] = 4, [172] = 4, [173] = 4, [174] = 4, [175] = 4, [176] = 4, [178] = 4, [180] = 4, [181] = 4, [209] = 4,
[190] = 5
}
function onEventStarted(player, actor, eventType, eventName, isTeleport) function onEventStarted(player, actor, eventType, eventName, isTeleport)
local worldMaster = GetWorldMaster(); local worldMaster = GetWorldMaster();
local playerState = player:GetState();
local currentAnima = 100;
local baseAnimaCost = 6;
local animaCost = 0;
local favoredLocation = {1280003, 1280005, 1280062};
local currentRegion = zoneIdToRegionChoice[player:GetPos()[5]] or 0;
local isCity = {[1280001] = true, [1280061] = true, [1280031] = true};
local isRegion = true;
local destination = 0;
if (isTeleport == 0) then
while (true) do
regionChoice = callClientFunction(player, "delegateCommand", actor, "eventRegion", 100);
if (regionChoice == nil) then break end if (isTeleport == 0) then -- Teleport hit
while (true) do
regionChoice = callClientFunction(player, "delegateCommand", actor, "eventRegion", currentAnima);
while (true) do if (regionChoice == nil) then break end
aetheryteChoice = callClientFunction(player, "delegateCommand", actor, "eventAetheryte", regionChoice, 2, 2, 2, 4, 4, 4);
if (aetheryteChoice == nil) then break end while (true) do
if (regionChoice > 0 and regionChoice < 6) then -- If Region selected
player:PlayAnimation(0x4000FFA); if (regionChoice == currentRegion) then -- Check if selected region matches player's region, reduce cost if so.
player:SendGameMessage(worldMaster, 34101, 0x20, 2, teleportMenuToAetheryte[regionChoice][aetheryteChoice], 100, 100); baseAnimaCost = baseAnimaCost - 2;
confirmChoice = callClientFunction(player, "delegateCommand", actor, "eventConfirm", false, false, 1, 138824, false); else
if (confirmChoice == 1) then baseAnimaCost = 6;
player:PlayAnimation(0x4000FFB); end
player:SendGameMessage(worldMaster, 34105, 0x20);
--Do teleport
destination = aetheryteTeleportPositions[teleportMenuToAetheryte[regionChoice][aetheryteChoice]];
if (destination ~= nil) then
randoPos = getRandomPointInBand(destination[2], destination[4], 3, 5);
rotation = getAngleFacing(randoPos.x, randoPos.y, destination[2], destination[4]);
GetWorldManager():DoZoneChange(player, destination[1], nil, 0, 2, randoPos.x, destination[3], randoPos.y, rotation);
end
end
player:endEvent();
return;
end
end -- Assign anima cost to the six possible slots after factoring in same region or not.
else animaCost = {baseAnimaCost, baseAnimaCost, baseAnimaCost, baseAnimaCost, baseAnimaCost, baseAnimaCost};
player:PlayAnimation(0x4000FFA);
local choice, isInn = callClientFunction(player, "delegateCommand", actor, "eventConfirm", true, false, player:GetHomePointInn(), player:GetHomePoint(), false);
if (choice == 1) then
player:PlayAnimation(0x4000FFB);
player:SendGameMessage(worldMaster, 34104, 0x20);
--bandaid fix for returning while dead, missing things like weakness and the heal number if (isCity[teleportMenuToAetheryte[regionChoice][1]] == true) then
if (player:GetHP() == 0) then -- Halve the cost of applicable city aetheryte
player:SetHP(player.GetMaxHP()); animaCost[1] = animaCost[1] / 2;
player:ChangeState(0); end
player:PlayAnimation(0x01000066);
end
if (isInn) then elseif (regionChoice == 6) then -- Favored Destinations selected.
--Return to Inn -- Dummy info. Favored would be half price after factoring in same region cost or not.
if (player:GetHomePointInn() == 1) then animaCost = {2, 3, 3, favoredLocation[1], favoredLocation[2], favoredLocation[3]};
GetWorldManager():DoZoneChange(player, 244, nil, 0, 15, -160.048, 0, -165.737, 0); isRegion = false;
elseif (player:GetHomePointInn() == 2) then end
GetWorldManager():DoZoneChange(player, 244, nil, 0, 15, 160.048, 0, 154.263, 0);
elseif (player:GetHomePointInn() == 3) then
GetWorldManager():DoZoneChange(player, 244, nil, 0, 15, 0.048, 0, -5.737, 0);
end
elseif (choice == 1 and isInn == nil) then
--Return to Homepoint
destination = aetheryteTeleportPositions[player:GetHomePoint()];
if (destination ~= nil) then
randoPos = getRandomPointInBand(destination[2], destination[4], 3, 5);
rotation = getAngleFacing(randoPos.x, randoPos.y, destination[2], destination[4]);
GetWorldManager():DoZoneChange(player, destination[1], nil, 0, 2, randoPos.x, destination[3], randoPos.y, rotation);
end
end
end
end
player:endEvent(); aetheryteChoice = callClientFunction(
player,
"delegateCommand",
actor,
"eventAetheryte",
regionChoice,
animaCost[1],
animaCost[2],
animaCost[3],
animaCost[4],
animaCost[5],
animaCost[6]
);
if (aetheryteChoice == nil) then break end
player:PlayAnimation(0x4000FFA);
if (isRegion == true) then
destination = aetheryteTeleportPositions[teleportMenuToAetheryte[regionChoice][aetheryteChoice]];
player:SendGameMessage(worldMaster, 34101, 0x20, 2, teleportMenuToAetheryte[regionChoice][aetheryteChoice], animaCost[aetheryteChoice], currentAnima);
else
destination = aetheryteTeleportPositions[favoredLocation[aetheryteChoice]];
player:SendGameMessage(worldMaster, 34101, 0x20, 2, favoredLocation[aetheryteChoice], animaCost[aetheryteChoice], currentAnima);
end
confirmChoice = callClientFunction(player, "delegateCommand", actor, "eventConfirm", false, false, 1, 138824, false);
if (confirmChoice == 1) then
player:PlayAnimation(0x4000FFB);
player:SendGameMessage(worldMaster, 34105, 0x20);
if (destination ~= 0) then
randoPos = getRandomPointInBand(destination[2], destination[4], 3, 5);
rotation = getAngleFacing(randoPos.x, randoPos.y, destination[2], destination[4]);
if (playerState == ACTORSTATE_MOUNTED) then
player:SetMountState(0);
player:ChangeSpeed(0.0, 2.0, 5.0, 5.0)
player:ChangeState(ACTORSTATE_PASSIVE);
end
GetWorldManager():DoZoneChange(player, destination[1], nil, 0, 2, randoPos.x, destination[3], randoPos.y, rotation);
end
end
player:endEvent();
return;
end
end
else -- Return hit
player:PlayAnimation(0x4000FFA);
local choice, isInn = callClientFunction(player, "delegateCommand", actor, "eventConfirm", true, false, player:GetHomePointInn(), player:GetHomePoint(), false);
if (choice == 1) then
player:PlayAnimation(0x4000FFB);
player:SendGameMessage(worldMaster, 34104, 0x20);
--bandaid fix for returning while dead, missing things like weakness and the heal number
if (player:GetHP() == 0) then
player:SetHP(player.GetMaxHP());
player:ChangeState(0);
player:PlayAnimation(0x01000066);
end
if (isInn) then
--Return to Inn
if (player:GetHomePointInn() == 1) then
GetWorldManager():DoZoneChange(player, 244, nil, 0, 15, -160.048, 0, -165.737, 0);
elseif (player:GetHomePointInn() == 2) then
GetWorldManager():DoZoneChange(player, 244, nil, 0, 15, 160.048, 0, 154.263, 0);
elseif (player:GetHomePointInn() == 3) then
GetWorldManager():DoZoneChange(player, 244, nil, 0, 15, 0.048, 0, -5.737, 0);
end
elseif (choice == 1 and isInn == nil) then
--Return to Homepoint
destination = aetheryteTeleportPositions[player:GetHomePoint()];
if (destination ~= nil) then
randoPos = getRandomPointInBand(destination[2], destination[4], 3, 5);
rotation = getAngleFacing(randoPos.x, randoPos.y, destination[2], destination[4]);
if (playerState == ACTORSTATE_MOUNTED) then
player:SetMountState(0);
player:ChangeSpeed(0.0, 2.0, 5.0, 5.0)
player:ChangeState(ACTORSTATE_PASSIVE);
end
GetWorldManager():DoZoneChange(player, destination[1], nil, 0, 2, randoPos.x, destination[3], randoPos.y, rotation);
end
end
end
end
player:endEvent();
end end

View File

@ -26,11 +26,11 @@ vertical = {
function onTrigger(player, argc, arg1, arg2) function onTrigger(player, argc, arg1, arg2)
local pos = player:GetPos(); local pos = player:GetPos();
local x = pos[0]; local x = pos[1];
local y = pos[1]; local y = pos[2];
local z = pos[2]; local z = pos[3];
local rot = pos[3]; local rot = pos[4];
local zone = pos[4]; local zone = pos[5];
local angle = rot + (math.pi/2); local angle = rot + (math.pi/2);
local worldManager = GetWorldManager(); local worldManager = GetWorldManager();

View File

@ -8,36 +8,36 @@ properties = {
function onTrigger(player, argc, actorClassId, width, height) function onTrigger(player, argc, actorClassId, width, height)
if (actorClassId == nil) then if (actorClassId == nil) then
player:SendMessage(0x20, "", "No actor class id provided."); player:SendMessage(0x20, "", "No actor class id provided.");
return; return;
end end
local pos = player:GetPos(); local pos = player:GetPos();
local x = pos[0]; local x = pos[1];
local y = pos[1]; local y = pos[2];
local z = pos[2]; local z = pos[3];
local rot = pos[3]; local rot = pos[4];
local zone = pos[4]; local zone = pos[5];
actorClassId = tonumber(actorClassId); actorClassId = tonumber(actorClassId);
if (actorClassId ~= nil) then if (actorClassId ~= nil) then
zone = player:GetZone(); zone = player:GetZone();
local w = tonumber(width) or 0; local w = tonumber(width) or 0;
local h = tonumber(height) or 0; local h = tonumber(height) or 0;
printf("%f %f %f", x, y, z); printf("%f %f %f", x, y, z);
--local x, y, z = player.GetPos(); --local x, y, z = player.GetPos();
for i = 0, w do for i = 0, w do
for j = 0, h do for j = 0, h do
actor = zone:SpawnActor(actorClassId, "test", pos[0] + (i - (w / 2) * 3), pos[1], pos[2] + (j - (h / 2) * 3), pos[3]); actor = zone:SpawnActor(actorClassId, "test", x + (i - (w / 2) * 3), y, z + (j - (h / 2) * 3), rot);
actor.SetAppearance(1001149) actor.SetAppearance(1001149)
end end
end end
end end
if (actor == nil) then if (actor == nil) then
player:SendMessage(0x20, "", "This actor class id cannot be spawned."); player:SendMessage(0x20, "", "This actor class id cannot be spawned.");
end end
end; end;

View File

@ -18,21 +18,22 @@ function onTrigger(player, argc, uID)
end; end;
actor = GetWorldManager():GetActorInWorldByUniqueId(uID); actor = GetWorldManager():GetActorInWorldByUniqueId(uID);
actorId = actor:GetActorClassId();
if (actor ~= nil) then if (actor ~= nil) then
local actorPos = actor:GetPos(); local actorPos = actor:GetPos();
local playerPos = player:GetPos(); local playerPos = player:GetPos();
if actorPos[4] == playerPos[4] then if actorPos[5] == playerPos[5] then
worldManager:DoPlayerMoveInZone(player, actorPos[0], actorPos[1], actorPos[2], actorPos[3], 0x00); worldManager:DoPlayerMoveInZone(player, actorPos[1], actorPos[2], actorPos[3], actorPos[4], 0x00);
else else
worldManager:DoZoneChange(player, actorPos[4], nil, 0, 0x02, actorPos[0], actorPos[1], actorPos[2], actorPos[3]); worldManager:DoZoneChange(player, actorPos[5], nil, 0, 0x02, actorPos[1], actorPos[2], actorPos[3], actorPos[4]);
end end
message = string.format("Moving to %s 's coordinates @ zone %s, %.3f %.3f %.3f ", uID, actorPos[4], actorPos[0], actorPos[1], actorPos[2]); message = string.format("Moving to %s 's coordinates @ zone %s, %.3f %.3f %.3f ", uID, actorPos[5], actorPos[1], actorPos[2], actorPos[3]);
end ; end ;
player:SendMessage(messageID, sender, message); player:SendMessage(messageID, sender, message);
player:SendMessage(0x20, "", "Actor Class Id: "..actorId);
end end