* move fnplayer to fn, making VhtFnPlayer into a VhtFnBool

* remove m_flags from VhtQuest
* add detection for flame mask
* add first step for quest 4
* don't serialize quest 1 step 2 line
* add null check for travelled/pretravelled
* move tick and describe functionality from events to questholder
* fix(?) multiplayer questholder move functionality
This commit is contained in:
alison wright 2022-07-10 08:48:13 -06:00
parent 6928c2f898
commit a22ae10d3b
5 changed files with 130 additions and 42 deletions

View File

@ -59,3 +59,11 @@ VHT_QST_3_0 =
VHT_QST_3_1 =
"there doesn't seem to be anything here\n"
"for @= right now.";
VHT_QST_4_FireMask =
"\n\cfthere should be a fiery artifact here.";
VHT_QST_4_0 =
"there should be a lever somewhere within.";
VHT_QST_4_1 =
"the lever is pulled.";

View File

@ -21,40 +21,22 @@ class VhtEvents : StaticEventHandler {
override void playerDisconnected(PlayerEvent e) {
let p = players[e.playerNumber].mo;
if(p) {
let qh_r = VhtQuestHolder(p.findInventory("VhtQuestHolder"));
if(qh_r) {
p.removeInventory(qh_r);
let qh_l = vhtGetQuests();
if(qh_l) {
qh_r.m_quests.move(qh_l.m_quests);
}
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 worldTick() {
m_useQuestLog = vht_player_questlog;
let qh = vhtGetQuests();
if(!qh) {
return;
}
for(int i = 0, j = qh.m_quests.size(); i < j; ++i) {
if(qh.m_quests[i]) {
qh.m_quests[i].vhtTick();
}
}
if(m_useQuestLog) {
m_questLog = "";
for(int i = 0, j = qh.m_quests.size(); i < j; ++i) {
if(qh.m_quests[i]) {
m_questLog.appendFormat(
"\cu- \cn%s\c-\n%s\n\n",
StringTable.localize(
qh.m_quests[i].vhtLevelInfo().levelName,
false
),
qh.m_quests[i].vhtDescribe()
);
}
if(qh) {
qh.vhtTick();
if(m_useQuestLog) {
m_questLog = qh.vhtDescribe();
}
}
}

View File

@ -1,7 +1,26 @@
class VhtFnPlayer abstract {
class VhtFnBool abstract {
virtual bool vhtRun() {return false;}
}
class VhtFnBoolFuse : VhtFnBool {
bool m_result;
VhtFnBool m_fInner;
VhtFnBoolFuse vhtInit(VhtFnBool fInner) {
m_fInner = fInner;
return self;
}
override bool vhtRun() {
if(!m_result) {
m_result = m_fInner.vhtRun();
}
return m_result;
}
}
class VhtFnPlayer : VhtFnBool abstract {
int m_player;
virtual bool vhtCall(PlayerInfo p) {return false;}
bool vhtRun() {
override bool vhtRun() {
for(int i = 0; i < MAXPLAYERS; ++i) {
if(playerInGame[i] && vhtCall(players[i])) {
m_player = i;

View File

@ -1,5 +1,5 @@
class VhtQuest abstract play {
int m_mapNum, m_step, m_flags;
int m_mapNum, m_step;
VhtHubQuest m_hubQuest;
virtual VhtQuest vhtInit(VhtHubQuest hubQuest) {
m_mapNum = level.levelNum;
@ -19,6 +19,19 @@ class VhtQuest abstract play {
LevelInfo vhtLevelInfo() const {
return LevelInfo.findLevelByNum(m_mapNum);
}
static Line vhtGetLine(int lineId) {
return level.lines[level.createLineIdIterator(lineId).next()];
}
static bool vhtCheckLever(int lineId) {
let ln = vhtGetLine(lineId);
if(ln) {
let sd = ln.sidedef[Line.FRONT];
if(sd && TexMan.getName(sd.getTexture(Side.MID)) ~== "SW_OL5") {
return true;
}
}
return false;
}
}
class VhtHubQuest : VhtQuest abstract {
@ -34,11 +47,9 @@ class VhtHubQuest : VhtQuest abstract {
class VhtQuest1 : VhtHubQuest {
VhtFnPlayer m_fStep0; // quest 1 step 0: walk into courtyard
VhtFnPlayer m_fStep1; // quest 1 step 1: pick up silver key
Line m_lStep2; // quest 1 step 2: ring the bell
override void vhtInitHub() {
m_fStep0 = new("VhtFnPlayerInSector") .vhtInit(115);
m_fStep1 = new("VhtFnPlayerInvAmount").vhtInit("KeySilver", 1);
m_lStep2 = level.lines[level.createLineIdIterator(2).next()];
}
// same hub, but cannot return
override void vhtTravelled() {
@ -46,9 +57,17 @@ class VhtQuest1 : VhtHubQuest {
}
override void vhtTick() {
switch(m_step) {
case 0: if(m_fStep0.vhtRun()) {m_step = 1;} break;
case 1: if(m_fStep1.vhtRun()) {m_step = 2;} // -->
case 2: if(!(m_lStep2.flags & Line.ML_BLOCKING)) {m_step = 3;} break;
case 0:
if(m_fStep0.vhtRun()) {m_step = 1;}
break;
case 1:
if(m_fStep1.vhtRun()) {m_step = 2;}
// fall through
case 2:
// quest 1 step 2: ring the bell
let ln = vhtGetLine(2);
if(ln && !(ln.flags & Line.ML_BLOCKING)) {m_step = 3;}
break;
}
}
}
@ -57,10 +76,18 @@ class VhtQuest1 : VhtHubQuest {
class VhtQuest2 : VhtHubQuest {
// quest 2 step 1: 3 switches pulled in first puzzle
int m_guardianOfFire, m_guardianOfSteel;
// quest 3 puzzle item: flame mask
VhtFnBoolFuse m_fFlameMask;
override void vhtInitHub() {
m_fFlameMask = new("VhtFnBoolFuse").vhtInit(new("VhtFnPlayerInvAmount").vhtInit("PuzzFlameMask", 1));
}
override void vhtTick() {
m_fFlameMask.vhtRun();
}
override void vhtTravelled() {
// quest 2 step 0: return from guardian of ice
if(m_step == 0 && level.levelNum == m_mapNum) {
++m_step;
m_step = 1;
}
}
override string vhtDescribe() {
@ -77,13 +104,38 @@ class VhtQuest3 : VhtQuest {
override void vhtPreTravelled() {
// quest 3 step 0: exit to hub
if(m_step == 0) {
++m_step;
m_step = 1;
}
}
}
// quest 4: guardian of fire
class VhtQuest4 : VhtQuest {}
class VhtQuest4 : VhtQuest {
override VhtQuest vhtInit(VhtHubQuest hubQuest) {
super.vhtInit(hubQuest);
return self;
}
override void vhtTick() {
if(level.levelNum == m_mapNum) {
switch(m_step) {
case 0:
// quest 4 step 0: press the switch
if(vhtCheckLever(2)) {
m_step = 1;
++VhtQuest2(m_hubQuest).m_guardianOfFire;
}
break;
}
}
}
override string vhtDescribe() {
let s = super.vhtDescribe();
if(!VhtQuest2(m_hubQuest).m_fFlameMask.m_result) {
s = s .. StringTable.localize("$VHT_QST_4_FireMask");
}
return s;
}
}
// quest 5: guardian of steel
class VhtQuest5 : VhtQuest {}
@ -144,12 +196,39 @@ class VhtQuestHolder : Inventory {
}
override void preTravelled() {
for(int i = 0, j = m_quests.size(); i < j; ++i) {
m_quests[i].vhtPreTravelled();
if(m_quests[i]) {
m_quests[i].vhtPreTravelled();
}
}
}
override void travelled() {
for(int i = 0, j = m_quests.size(); i < j; ++i) {
m_quests[i].vhtTravelled();
if(m_quests[i]) {
m_quests[i].vhtTravelled();
}
}
}
void vhtTick() {
for(int i = 0, j = m_quests.size(); i < j; ++i) {
if(m_quests[i]) {
m_quests[i].vhtTick();
}
}
}
string vhtDescribe() {
string s = "";
for(int i = 0, j = m_quests.size(); i < j; ++i) {
if(m_quests[i]) {
s.appendFormat(
"\cu- \cn%s\c-\n%s\n\n",
StringTable.localize(
m_quests[i].vhtLevelInfo().levelName,
false
),
m_quests[i].vhtDescribe()
);
}
}
return s;
}
}

View File

@ -1,6 +1,6 @@
version "4.8"
#include "vhtzs/fnplayer.zsc"
#include "vhtzs/fn.zsc"
#include "vhtzs/fx.zsc"
#include "vhtzs/projectiles.zsc"
#include "vhtzs/weapons.zsc"