* 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:
parent
6928c2f898
commit
a22ae10d3b
|
@ -59,3 +59,11 @@ VHT_QST_3_0 =
|
||||||
VHT_QST_3_1 =
|
VHT_QST_3_1 =
|
||||||
"there doesn't seem to be anything here\n"
|
"there doesn't seem to be anything here\n"
|
||||||
"for @= right now.";
|
"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.";
|
||||||
|
|
|
@ -21,40 +21,22 @@ class VhtEvents : StaticEventHandler {
|
||||||
override void playerDisconnected(PlayerEvent e) {
|
override void playerDisconnected(PlayerEvent e) {
|
||||||
let p = players[e.playerNumber].mo;
|
let p = players[e.playerNumber].mo;
|
||||||
if(p) {
|
if(p) {
|
||||||
let qh_r = VhtQuestHolder(p.findInventory("VhtQuestHolder"));
|
let qh_ply = VhtQuestHolder(p.findInventory("VhtQuestHolder"));
|
||||||
if(qh_r) {
|
let qh_cur = vhtGetQuests();
|
||||||
p.removeInventory(qh_r);
|
if(qh_cur == qh_ply) {
|
||||||
let qh_l = vhtGetQuests();
|
p.removeInventory(qh_ply);
|
||||||
if(qh_l) {
|
qh_cur = vhtGetQuests();
|
||||||
qh_r.m_quests.move(qh_l.m_quests);
|
qh_ply.m_quests.move(qh_cur.m_quests);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override void worldTick() {
|
override void worldTick() {
|
||||||
m_useQuestLog = vht_player_questlog;
|
m_useQuestLog = vht_player_questlog;
|
||||||
let qh = vhtGetQuests();
|
let qh = vhtGetQuests();
|
||||||
if(!qh) {
|
if(qh) {
|
||||||
return;
|
qh.vhtTick();
|
||||||
}
|
|
||||||
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) {
|
if(m_useQuestLog) {
|
||||||
m_questLog = "";
|
m_questLog = qh.vhtDescribe();
|
||||||
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()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
int m_player;
|
||||||
virtual bool vhtCall(PlayerInfo p) {return false;}
|
virtual bool vhtCall(PlayerInfo p) {return false;}
|
||||||
bool vhtRun() {
|
override bool vhtRun() {
|
||||||
for(int i = 0; i < MAXPLAYERS; ++i) {
|
for(int i = 0; i < MAXPLAYERS; ++i) {
|
||||||
if(playerInGame[i] && vhtCall(players[i])) {
|
if(playerInGame[i] && vhtCall(players[i])) {
|
||||||
m_player = i;
|
m_player = i;
|
|
@ -1,5 +1,5 @@
|
||||||
class VhtQuest abstract play {
|
class VhtQuest abstract play {
|
||||||
int m_mapNum, m_step, m_flags;
|
int m_mapNum, m_step;
|
||||||
VhtHubQuest m_hubQuest;
|
VhtHubQuest m_hubQuest;
|
||||||
virtual VhtQuest vhtInit(VhtHubQuest hubQuest) {
|
virtual VhtQuest vhtInit(VhtHubQuest hubQuest) {
|
||||||
m_mapNum = level.levelNum;
|
m_mapNum = level.levelNum;
|
||||||
|
@ -19,6 +19,19 @@ class VhtQuest abstract play {
|
||||||
LevelInfo vhtLevelInfo() const {
|
LevelInfo vhtLevelInfo() const {
|
||||||
return LevelInfo.findLevelByNum(m_mapNum);
|
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 {
|
class VhtHubQuest : VhtQuest abstract {
|
||||||
|
@ -34,11 +47,9 @@ class VhtHubQuest : VhtQuest abstract {
|
||||||
class VhtQuest1 : VhtHubQuest {
|
class VhtQuest1 : VhtHubQuest {
|
||||||
VhtFnPlayer m_fStep0; // quest 1 step 0: walk into courtyard
|
VhtFnPlayer m_fStep0; // quest 1 step 0: walk into courtyard
|
||||||
VhtFnPlayer m_fStep1; // quest 1 step 1: pick up silver key
|
VhtFnPlayer m_fStep1; // quest 1 step 1: pick up silver key
|
||||||
Line m_lStep2; // quest 1 step 2: ring the bell
|
|
||||||
override void vhtInitHub() {
|
override void vhtInitHub() {
|
||||||
m_fStep0 = new("VhtFnPlayerInSector") .vhtInit(115);
|
m_fStep0 = new("VhtFnPlayerInSector") .vhtInit(115);
|
||||||
m_fStep1 = new("VhtFnPlayerInvAmount").vhtInit("KeySilver", 1);
|
m_fStep1 = new("VhtFnPlayerInvAmount").vhtInit("KeySilver", 1);
|
||||||
m_lStep2 = level.lines[level.createLineIdIterator(2).next()];
|
|
||||||
}
|
}
|
||||||
// same hub, but cannot return
|
// same hub, but cannot return
|
||||||
override void vhtTravelled() {
|
override void vhtTravelled() {
|
||||||
|
@ -46,9 +57,17 @@ class VhtQuest1 : VhtHubQuest {
|
||||||
}
|
}
|
||||||
override void vhtTick() {
|
override void vhtTick() {
|
||||||
switch(m_step) {
|
switch(m_step) {
|
||||||
case 0: if(m_fStep0.vhtRun()) {m_step = 1;} break;
|
case 0:
|
||||||
case 1: if(m_fStep1.vhtRun()) {m_step = 2;} // -->
|
if(m_fStep0.vhtRun()) {m_step = 1;}
|
||||||
case 2: if(!(m_lStep2.flags & Line.ML_BLOCKING)) {m_step = 3;} break;
|
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 {
|
class VhtQuest2 : VhtHubQuest {
|
||||||
// quest 2 step 1: 3 switches pulled in first puzzle
|
// quest 2 step 1: 3 switches pulled in first puzzle
|
||||||
int m_guardianOfFire, m_guardianOfSteel;
|
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() {
|
override void vhtTravelled() {
|
||||||
// quest 2 step 0: return from guardian of ice
|
// quest 2 step 0: return from guardian of ice
|
||||||
if(m_step == 0 && level.levelNum == m_mapNum) {
|
if(m_step == 0 && level.levelNum == m_mapNum) {
|
||||||
++m_step;
|
m_step = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override string vhtDescribe() {
|
override string vhtDescribe() {
|
||||||
|
@ -77,13 +104,38 @@ class VhtQuest3 : VhtQuest {
|
||||||
override void vhtPreTravelled() {
|
override void vhtPreTravelled() {
|
||||||
// quest 3 step 0: exit to hub
|
// quest 3 step 0: exit to hub
|
||||||
if(m_step == 0) {
|
if(m_step == 0) {
|
||||||
++m_step;
|
m_step = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// quest 4: guardian of fire
|
// 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
|
// quest 5: guardian of steel
|
||||||
class VhtQuest5 : VhtQuest {}
|
class VhtQuest5 : VhtQuest {}
|
||||||
|
@ -144,12 +196,39 @@ class VhtQuestHolder : Inventory {
|
||||||
}
|
}
|
||||||
override void preTravelled() {
|
override void preTravelled() {
|
||||||
for(int i = 0, j = m_quests.size(); i < j; ++i) {
|
for(int i = 0, j = m_quests.size(); i < j; ++i) {
|
||||||
|
if(m_quests[i]) {
|
||||||
m_quests[i].vhtPreTravelled();
|
m_quests[i].vhtPreTravelled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
override void travelled() {
|
override void travelled() {
|
||||||
for(int i = 0, j = m_quests.size(); i < j; ++i) {
|
for(int i = 0, j = m_quests.size(); i < j; ++i) {
|
||||||
|
if(m_quests[i]) {
|
||||||
m_quests[i].vhtTravelled();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
version "4.8"
|
version "4.8"
|
||||||
|
|
||||||
#include "vhtzs/fnplayer.zsc"
|
#include "vhtzs/fn.zsc"
|
||||||
#include "vhtzs/fx.zsc"
|
#include "vhtzs/fx.zsc"
|
||||||
#include "vhtzs/projectiles.zsc"
|
#include "vhtzs/projectiles.zsc"
|
||||||
#include "vhtzs/weapons.zsc"
|
#include "vhtzs/weapons.zsc"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user