rwxsu
Computer Engineer
An Uneasy Alliance - RL - TFS: 1.2
Quest Wiki:
An Uneasy Alliance Quest/Spoiler
Add to data/lib/core/quests/uneasy_alliance.lua folder:
Remember to add this in: data/lib/core/core.lua
Add to data/npc/curos.xml
Add to data/npc/scripts/curos.lua
Add to data/creaturescripts/scripts/uneasy_alliance.lua
Remember to add in data/creaturescripts/creaturescripts.xml
Add in data/actions/quests/uneasy_alliance.lua
Remember to add in data/actions/actions.xml
This is the functionality for mission 1 and mission 2 in 'An Uneasy Alliance'.
Hope you enjoy it,
rwxsu
Quest Wiki:
An Uneasy Alliance Quest/Spoiler
Add to data/lib/core/quests/uneasy_alliance.lua folder:
Code:
UneasyAlliance = {
storage = {
[1] = {
onMission = 80770,
complete = 80771,
rewarded = 80772,
},
[2] = {
onMission = 80773,
complete = 80774,
rewarded = 80775,
},
},
item = {
[1] = {
name = "tome of knowledge",
id = 11134,
},
[2] = {
name = "scrying crystal ball",
id = 7493,
},
}
}
UneasyAlliance.__index = UneasyAlliance
function UneasyAlliance:setMission(cid, val, mission)
if mission == 1 then
Player(cid):setStorageValue(UneasyAlliance.storage[mission].onMission, val)
return
elseif mission == 2 then
Player(cid):setStorageValue(UneasyAlliance.storage[mission].onMission, val)
return
end
print("[DEBUG] UneasyAlliance:setMission has failed.")
end
function UneasyAlliance:setCompleted(cid, val, mission)
if mission == 1 then
Player(cid):setStorageValue(UneasyAlliance.storage[mission].complete, val)
return
elseif mission == 2 then
Player(cid):setStorageValue(UneasyAlliance.storage[mission].complete, val)
return
end
print("[DEBUG] UneasyAlliance:setCompleted has failed.")
end
function UneasyAlliance:setRewarded(cid, val, mission)
if mission == 1 then
Player(cid):setStorageValue(UneasyAlliance.storage[mission].rewarded, val)
return
elseif mission == 2 then
Player(cid):setStorageValue(UneasyAlliance.storage[mission].rewarded, val)
return
end
print("[DEBUG] UneasyAlliance:setRewarded has failed.")
end
-- onMission checks if player is already on the mission for the mission provided
function UneasyAlliance:onMission(cid, mission)
if Player(cid):getStorageValue(UneasyAlliance.storage[mission].onMission) == 1 then
return true
end
return false
end
-- isCompleted checks if the required tasks are finished for the mission provided
function UneasyAlliance:isCompleted(cid, mission)
if Player(cid):getStorageValue(UneasyAlliance.storage[mission].complete) == 1 then
return true
end
return false
end
-- isRewarded checks if player has received a reward for the mission provided
function UneasyAlliance:isRewarded(cid, mission)
if Player(cid):getStorageValue(UneasyAlliance.storage[mission].rewarded) == 1 then
return true
end
return false
end
Remember to add this in: data/lib/core/core.lua
Code:
dofile('data/lib/core/quest/uneasy_alliance.lua')
Add to data/npc/curos.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Curos" script="curos.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100" />
<look type="29" corpse="5983" />
<parameters>
<parameter key="message_greet" value="Be greeted blank skin." />
</parameters>
</npc>
Add to data/npc/scripts/curos.lua
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
npcHandler:addModule(FocusModule:new())
function start(cid, mission)
UneasyAlliance:setMission(cid, 1, mission)
end
function reward(cid, mission)
UneasyAlliance:setRewarded(cid, 1, mission)
UneasyAlliance:setMission(cid, 0, mission)
-- Reward 'Tome of Knowledge'
if mission == 2 then
Player(cid):addItem(UneasyAlliance.item[1].id, 1)
Player(cid):sendTextMessage(MESSAGE_EVENT_ORANGE, "You received a " .. UneasyAlliance.item[1].name .."!")
end
end
function creatureSayCallback(cid, type, msg)
if msgcontains(msg, "mission") then
-- If player has started mission 1
if UneasyAlliance:onMission(cid, 1) then
-- If the player has completed mission 1,
-- and hasn't received the reward,
-- give the player a reward
if UneasyAlliance:isCompleted(cid, 1) then
selfSay("With the death of their leader, the rebels return to our camps one by one, deeply humiliated. It might be a wise decision to let a useful tool like you continue to exist.", cid)
reward(cid, 1)
return
end
selfSay("You are already doing your first mission. Kill Renegade Orc!", cid)
return
end
-- If player has started mission 2
if UneasyAlliance:onMission(cid, 2) then
-- If the player has completed mission 2,
-- and hasn't received the reward,
-- give the player a reward
if UneasyAlliance:isCompleted(cid, 2) then
selfSay("Finally, our enemy's vision is obscured. Now we can move in for some more daring raids until they replace their scrying device. You have proven yourself brave and useful so far. With that, you bought your allies some more days to live.", cid)
selfSay("Here is a reward. It's a strange tome that we've found in the lizard ruins. Maybe it is of some value for you or your allies.", cid)
reward(cid, 2)
return
end
selfSay("You are already doing your second mission. Break the stone!", cid)
return
end
-- If player has completed both missions
if UneasyAlliance:isRewarded(cid, 2) then
selfSay("You have already completed both missions", cid)
return
end
-- If player has completed mission 1
-- Then start mission 2
if UneasyAlliance:isRewarded(cid, 1) then
selfSay("We are aware that the lizards use magic to spy on us. In the Dragonblaze Mountains north of here, there is a tower which can only be entered through one of their underground fortresses.", cid)
selfSay("In this tower, there must be some accessory used for magical scrying. Some pond, a crystal ball, or a mirror maybe - it has to be something shiny.", cid)
selfSay("Usually we would send one of our youngsters on such a mission, but we are few and there is little new blood in our ranks.", cid)
selfSay("We can't send a Mooh'Tah master on such a trivial assignment, neither can we use orcs for an infiltration mission.", cid)
selfSay("This is your chance to show us your potential. Infiltrate this tower and destroy their scrying device. Once you have blinded our enemy, we might respect you somewhat more.", cid)
start(cid, 2)
return
end
-- Otherwise start mission 1
selfSay("So you still think you can be of any use for us? Words are cheap and easy. Admittedly, you've passed our first test but even some resilient beast might have accomplished that.", cid)
selfSay("Your actions will tell if you are only yelping for attention like a puppy or if you have the teeth of a wolf.", cid)
selfSay("A first tiny step was taken. You survived the test and ensured the survival of your allies for a while. Now it is time to make the next step.", cid)
selfSay("So listen human: Our rule over the orcs is not unchallenged. Of course now and then someone shows up who thinks he can defeat us. Usually these fights end fast and bloody in the ring.", cid)
selfSay("Right now, some coward from our midst, who is too afraid to face us in single combat, has gathered a group of followers, hoping more will follow and change sides.", cid)
selfSay("With your help, his defeat will not only be deadly but also humiliating and so discourage others to follow his example.", cid)
selfSay("You will seek out this rebel commander in his hideout and kill him. We will show them that not even a Mooh'Tah master is needed to get rid of such wannabe leaders but that a mere human can handle them.", cid)
selfSay("Find him in the mountain north-west of here and kill him. If you find any loot, you can keep it.", cid)
start(cid, 1)
return
end
-- Use only for testing purposes
-- Comment it out when going live
if msgcontains(msg, "reset") then
UneasyAlliance:setMission(cid, 0, 1)
UneasyAlliance:setCompleted(cid, 0, 1)
UneasyAlliance:setRewarded(cid, 0, 1)
UneasyAlliance:setMission(cid, 0, 2)
UneasyAlliance:setCompleted(cid, 0, 2)
UneasyAlliance:setRewarded(cid, 0, 2)
Player(cid):registerEvent("UneasyAlliance")
selfSay("[TESTING]: reseted.", cid)
return
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
Add to data/creaturescripts/scripts/uneasy_alliance.lua
Code:
function onKill(creature, target)
message = "You killed the Renegade Orc! Talk to Curos to claim your reward."
mission = 1
if target:getName() == 'Renegade Orc' then
UneasyAlliance:setCompleted(creature:getId(), 1, mission)
creature:sendTextMessage(MESSAGE_EVENT_ORANGE, message)
-- Unregisters the event to increase server performance
-- And also that you don't get the message when killing
-- 'Renegade Orc' several times
creature:unregisterEvent("UneasyAlliance")
end
return
end
Remember to add in data/creaturescripts/creaturescripts.xml
Code:
<event type="kill" name="UneasyAlliance" script="uneasy_alliance.lua" />
Add in data/actions/quests/uneasy_alliance.lua
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
-- Check if player is on the second mission
if UneasyAlliance:onMission(player:getId(), 2) and not UneasyAlliance:isCompleted(player:getId(), 2) then
player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You destroyed the " .. UneasyAlliance.item[2].name .. "! Report back to Curos to claim your reward.")
UneasyAlliance:setCompleted(player:getId(), 1, 2)
return true
end
return false
end
Remember to add in data/actions/actions.xml
Code:
<action itemid="7493" script="quests/uneasy_alliance.lua" />
This is the functionality for mission 1 and mission 2 in 'An Uneasy Alliance'.
Hope you enjoy it,
rwxsu