vht/vhtzs/events.zsc

66 lines
1.9 KiB
Plaintext
Raw Normal View History

class VhtEvents : StaticEventHandler {
ui bool m_useQuestLog;
ui string m_questLog;
VhtFnPlayerInv m_fGetQuests;
VhtQuestHolder vhtGetQuests() const {
return m_fGetQuests.vhtRun() ? VhtQuestHolder(m_fGetQuests.m_result) : null;
}
override void playerEntered(PlayerEvent e) {
let p = players[e.playerNumber].mo;
if(p && !p.findInventory("VhtQuestHolder")) {
p.giveInventoryType("VhtQuestHolder");
}
if(!m_fGetQuests) {
m_fGetQuests = new("VhtFnPlayerInvExist").vhtInit("VhtQuestHolder");
}
let qh = vhtGetQuests();
if(!e.isReturn && m_fGetQuests.m_player == e.playerNumber) {
qh.vhtAddQuest("VhtQuest" .. level.levelNum);
}
}
override void playerDisconnected(PlayerEvent e) {
let p = players[e.playerNumber].mo;
if(p) {
let qh_ply = VhtQuestHolder(p.findInventory("VhtQuestHolder"));
let qh_cur = vhtGetQuests();
if(qh_cur == qh_ply) {
p.removeInventory(qh_ply);
qh_cur = vhtGetQuests();
qh_ply.m_quests.move(qh_cur.m_quests);
}
}
}
override void uiTick() {
m_useQuestLog = vht_player_questlog;
if(m_useQuestLog) {
let qh = vhtGetQuests();
if(qh) {
m_questLog = qh.vhtDescribe();
}
}
}
override void worldTick() {
let qh = vhtGetQuests();
if(qh) {
qh.vhtTick();
}
}
override void worldLineActivated(WorldEvent e) {
if(vht_player_scruteswitch) {
let which = "VHT_SWI_" .. level.levelNum .. "_" .. e.activatedLine.index();
let loc = StringTable.localize(which, false);
if(loc != which) {
Console.midPrint(null, loc, true);
}
}
}
override void renderUnderlay(RenderEvent e) {
if(automapActive && m_useQuestLog) {
double x = Screen.getWidth() / 320.0;
double y = Screen.getHeight() / 8.0;
Screen.drawText(smallfont, Font.CR_UNTRANSLATED, x+x, y+x, m_questLog, DTA_CLEANNOMOVE_1,true, DTA_ALPHA,0.406, DTA_FILLCOLOR,0);
Screen.drawText(smallfont, Font.CR_UNTRANSLATED, x, y, m_questLog, DTA_CLEANNOMOVE_1,true);
}
}
}