40 lines
1.1 KiB
GDScript
40 lines
1.1 KiB
GDScript
extends NpcScript
|
|
|
|
# Quest ID
|
|
const questID : int = ProgressCommons.Quest.SANDSTORM_MINE_ABANDONED_TREASURE
|
|
|
|
# Required items
|
|
var chestMineKeyID : int = DB.GetCellHash("Chest Mine Key")
|
|
|
|
# Reward items
|
|
var shortSwordID : int = DB.GetCellHash("Short Sword")
|
|
|
|
#
|
|
func OnStart():
|
|
match GetQuest(questID):
|
|
ProgressCommons.SANDSTORM_MINE_ABANDONED_TREASURE.KEY_FOUND: OnTryOpen()
|
|
ProgressCommons.SANDSTORM_MINE_ABANDONED_TREASURE.REWARDS_WITHDREW: OnEmpty()
|
|
_: OnLocked()
|
|
|
|
func OnTryOpen():
|
|
if not HasItem(chestMineKeyID):
|
|
OnLocked()
|
|
return
|
|
|
|
if not IsTriggering():
|
|
Trigger()
|
|
|
|
if HasSpace(1):
|
|
Mes("钥匙插进锁孔后,锈住的机关咔哒一声松开。箱子里还躺着一把矿工留下的短剑。")
|
|
RemoveItem(chestMineKeyID, 1)
|
|
SetQuest(questID, ProgressCommons.SANDSTORM_MINE_ABANDONED_TREASURE.REWARDS_WITHDREW)
|
|
AddItem(shortSwordID, 1)
|
|
else:
|
|
Mes("你找到了能打开箱子的钥匙,但背包已经装不下新的武器。")
|
|
|
|
func OnEmpty():
|
|
Chat("箱子已经空了,只剩下矿砂和木屑。")
|
|
|
|
func OnLocked():
|
|
Chat("矿工留下的旧箱子锁着,需要对应的矿洞钥匙。")
|