attempt to add tutorial fight

- added tempvars which are reset on spawning/zoning
This commit is contained in:
Tahir Akhlaq 2017-09-16 02:50:32 +01:00
parent da621dfc0e
commit ba8184db89
30 changed files with 552 additions and 154 deletions

78
data/scripts/ally.lua Normal file
View file

@ -0,0 +1,78 @@
require ("global")
require ("magic")
require ("weaponskill")
allyGlobal =
{
};
function allyGlobal.onSpawn(ally, target)
end;
function allyGlobal.onEngage(ally, target)
end;
function allyGlobal.onAttack(ally, target, damage)
end;
function allyGlobal.onDamageTaken(ally, attacker, damage)
end;
function allyGlobal.onCombatTick(ally, target, tick, contentGroupCharas)
allyGlobal.HelpPlayers(ally, contentGroupCharas);
end;
function allyGlobal.onDeath(ally, player, lastAttacker)
end;
function allyGlobal.onDespawn(ally)
end;
function allyGlobal.HelpPlayers(ally, contentGroupCharas, pickRandomTarget)
if contentGroupCharas then
for _, chara in pairs(contentGroupCharas) do
if chara then
-- probably a player, or another ally
-- todo: queue support actions, heal, try pull hate off player etc
if chara.IsPlayer() then
-- do stuff
if not ally.IsEngaged() then
if chara.IsEngaged() then
allyGlobal.EngageTarget(ally, target, nil);
end;
end;
elseif chara.IsMonster() and chara.IsEngaged() then
end;
end;
end;
end;
end;
function allyGlobal.HealPlayer(ally, player)
end;
function allyGlobal.SupportAction(ally, player)
end;
function allyGlobal.EngageTarget(ally, target, contentGroupCharas)
if contentGroupCharas then
for _, chara in pairs(contentGroupCharas) do
if chara.IsMonster() then
if chara.allegiance ~= ally.allegiance then
ally.Engage(chara);
end;
end;
end;
elseif target then
ally.Engage(target);
end;
end;

View file

@ -0,0 +1,27 @@
require("global");
require("weaponskill");
function onSkillPrepare(caster, target, spell)
return 0;
end;
function onSkillStart(caster, target, spell)
return 0;
end;
function onSkillFinish(caster, target, spell, action)
local damage = math.random(10, 100);
-- todo: populate a global script with statuses and modifiers
action.worldMasterTextId = 0x765D;
-- todo: populate a global script with statuses and modifiers
-- magic.HandleAttackSkill(caster, target, spell, action)
-- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636);
action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636);
if target.hateContainer then
target.hateContainer.UpdateHate(caster, damage);
end;
return damage;
end;

View file

@ -28,7 +28,7 @@ function onUpdate()
end
function onTalkEvent(player, npc)
;
if (player:HasQuest(110001) == true) then
man0l0Quest = player:GetQuest("man0l0");

View file

@ -1,5 +1,6 @@
require ("global")
require ("tutorial")
require ("modifiers")
require ("quests/man/man0g0")
--processTtrBtl001: Active Mode Tutorial
@ -9,6 +10,37 @@ function init()
return "/Director/Quest/QuestDirectorMan0g001";
end
function onCreateContentArea(players, director, contentArea, contentGroup)
local worldManager = GetWorldManager();
yshtola = GetWorldManager():SpawnBattleNpcById(6, contentArea);
stahlmann = GetWorldManager():SpawnBattleNpcById(7, contentArea);
mob1 = GetWorldManager():SpawnBattleNpcById(3, contentArea);
mob2 = GetWorldManager():SpawnBattleNpcById(4, contentArea);
mob3 = GetWorldManager():SpawnBattleNpcById(5, contentArea);
local added = false;
for _, player in pairs(players) do
if player.currentParty and not added then
player.currentParty.AddMember(yshtola);
player.currentParty.AddMember(stahlmann);
added = true;
end;
-- dont let player die
player.SetModifier(modifiersGlobal.MinimumHpLock, 1);
contentGroup:AddMember(player);
end;
contentGroup:AddMember(director);
contentGroup:AddMember(yshtola);
contentGroup:AddMember(stahlmann);
contentGroup:AddMember(mob1);
contentGroup:AddMember(mob2);
contentGroup:AddMember(mob3);
end
function onEventStarted(player, actor, triggerName)
man0g0Quest = player:GetQuest("Man0g0");
@ -16,30 +48,20 @@ function onEventStarted(player, actor, triggerName)
callClientFunction(player, "delegateEvent", player, man0g0Quest, "processTtrBtl001", nil, nil, nil);
player:EndEvent();
waitForSignal("playerActive");
wait(1); --If this isn't here, the scripts bugs out. TODO: Find a better alternative.
wait(2); --If this isn't here, the scripts bugs out. TODO: Find a better alternative.
kickEventContinue(player, actor, "noticeEvent", "noticeEvent");
callClientFunction(player, "delegateEvent", player, man0g0Quest, "processTtrBtl002", nil, nil, nil);
player:EndEvent();
wait(4);
closeTutorialWidget(player);
showTutorialSuccessWidget(player, 9055); --Open TutorialSuccessWidget for attacking enemy
wait(3);
man0g0Quest:NextPhase(5);
openTutorialWidget(player, CONTROLLER_KEYBOARD, TUTORIAL_TP);
wait(5);
closeTutorialWidget(player);
openTutorialWidget(player, CONTROLLER_KEYBOARD, TUTORIAL_WEAPONSKILLS);
wait(4); --Should be wait for weaponskillUsed signal
closeTutorialWidget(player);
showTutorialSuccessWidget(player, 9065); --Open TutorialSuccessWidget for weapon skill
wait(5);
wait(6); --Should be wait for mobkill
worldMaster = GetWorldMaster();
player:SendDataPacket("attention", worldMaster, "", 51073, 2);
wait(7);
player:ChangeMusic(7);
player:ChangeState(0);
kickEventContinue(player, actor, "noticeEvent", "noticeEvent");
callClientFunction(player, "delegateEvent", player, man0g0Quest, "processEvent020_1", nil, nil, nil);
man0g0Quest:NextPhase(6);
closeTutorialWidget(player);
--[[
IF DoW:
@ -54,10 +76,10 @@ function onEventStarted(player, actor, triggerName)
OpenWidget (DEFEAT ENEMY)
]]
man0g0Quest:NextPhase(10);
player:EndEvent();
--man0g0Quest:NextPhase(10);
--player:EndEvent();
GetWorldManager():DoZoneChange(player, 155, "PrivateAreaMasterPast", 1, 15, 175.38, -1.21, -1156.51, -2.1);
--GetWorldManager():DoZoneChange(player, 155, "PrivateAreaMasterPast", 1, 15, 175.38, -1.21, -1156.51, -2.1);
end

View file

@ -15,7 +15,9 @@ function onCreateContentArea(players, director, contentArea, contentGroup)
mob2 = contentArea:SpawnActor(2205403, "mob2", -3.02, 17.35, 14.24, -2.81);
mob3 = contentArea:SpawnActor(2205403, "mob3", -3.02-3, 17.35, 14.24, -2.81);
contentGroup:AddMember(player);
for _, player in pairs(players) do
contentGroup:AddMember(player);
end;
contentGroup:AddMember(director);
contentGroup:AddMember(yshtola);
contentGroup:AddMember(stahlmann);

View file

@ -108,7 +108,15 @@ STAT_CRAFT_PROCESS_CONTROL = 32;
STAT_HARVEST_POTENCY = 33;
STAT_HARVEST_LIMIT = 34;
STAT_HARVEST_RATE = 35;
-- DAMAGE TAKEN TYPE
DAMAGE_TAKEN_TYPE_NONE = 0;
DAMAGE_TAKEN_TYPE_ATTACK = 1;
DAMAGE_TAKEN_TYPE_MAGIC = 2;
DAMAGE_TAKEN_TYPE_WEAPONSKILL = 3;
DAMAGE_TAKEN_TYPE_ABILITY = 4;
--UTILS

View file

@ -19,7 +19,7 @@ function onBeginLogin(player)
end
--For Opening. Set Director and reset position incase d/c
if (player:HasQuest(110001) == true and player:GetZoneID() == 193) then
if (player:HasQuest(110001) == true and player:GetZoneID() == 193) then
director = player:GetZone():CreateDirector("OpeningDirector", false);
player:AddDirector(director);
director:StartDirector(true);

View file

@ -0,0 +1,58 @@
require ("global")
require ("modifiers")
require ("ally")
function onSpawn(mob)
end;
function onDamageTaken(mob, attacker, damage, damageType)
if attacker.IsPlayer() then
local man0g0Quest = attacker:GetQuest("Man0g0");
if damageType == DAMAGE_TAKEN_TYPE_ATTACK then
if man0g0Quest:GetPhase() == 5 then
closeTutorialWidget(player);
showTutorialSuccessWidget(player, 9055); --Open TutorialSuccessWidget for attacking enemy
man0g0Quest:NextPhase(6);
end;
elseif damageType == DAMAGE_TAKEN_TYPE_WEAPONSKILL or damageType == DAMAGE_TAKEN_TYPE_MAGIC then
if man0g0Quest:GetPhase() == 6 then
closeTutorialWidget(player);
showTutorialSuccessWidget(player, 9065); --Open TutorialSuccessWidget for weapon skill
man0g0Quest:NextPhase(7);
end;
end;
end;
end;
function onDeath(mob, player, lastAttacker)
if player then
local man0g0Quest = player:GetQuest("Man0g0");
if man0g0Quest and man0g0Quest:GetPhase() >= 7 then
man0g0Quest:NextPhase(man0g0Quest:GetPhase() + 1);
mob:SetTempVar("playerId", player.actorId);
if man0g0Quest:GetPhase() == 10 then
local worldMaster = GetWorldMaster();
player:SendDataPacket("attention", worldMaster, "", 51073, 1);
kickEventContinue(player, director, "noticeEvent", "noticeEvent");
callClientFunction(player, "delegateEvent", player, man0g0Quest, "processEvent020_1", nil, nil, nil);
player:ChangeMusic(7);
player:Disengage(0x0000);
mob:SetTempVar("complete", 1);
end;
end;
end;
end;
function onDespawn(mob)
if zone then
local player = zone.FindActorInArea(mob:GetTempVar("playerId"));
if player and mob:GetTempVar("complete") == 1 then
local man0g0Quest = player:GetQuest("Man0g0");
player:GetZone():ContentFinished();
player:EndEvent();
GetWorldManager():DoZoneChange(player, 155, "PrivateAreaMasterPast", 1, 15, 175.38, -1.21, -1156.51, -2.1);
end;
end;
end;

View file

@ -0,0 +1,11 @@
require ("global")
require ("ally")
function onSpawn(ally)
ally.isAutoAttackEnabled = false;
end;
function onCombatTick(ally, target, tick, contentGroupCharas)
allyGlobal.onCombatTick(ally, target, tick, contentGroupCharas);
end;

View file

@ -0,0 +1,11 @@
require ("global")
require ("ally")
function onSpawn(ally)
ally.isAutoAttackEnabled = false;
end;
function onCombatTick(ally, target, tick, contentGroupCharas)
allyGlobal.onCombatTick(ally, target, tick, contentGroupCharas);
end;