Devilution
Diablo devolved - magic behind the 1996 computer game
portal.cpp
Go to the documentation of this file.
1 #include "all.h"
2 
4 
9 
11 int WarpDropX[MAXPORTAL] = { 57, 59, 61, 63 };
13 int WarpDropY[MAXPORTAL] = { 40, 40, 40, 40 };
14 
16 {
17  int i;
18 
19  for (i = 0; i < MAXPORTAL; i++) {
20  if (delta_portal_inited(i))
21  portal[i].open = FALSE;
22  }
23 }
24 
25 void SetPortalStats(int i, BOOL o, int x, int y, int lvl, int lvltype)
26 {
27  portal[i].open = o;
28  portal[i].x = x;
29  portal[i].y = y;
30  portal[i].level = lvl;
31  portal[i].ltype = lvltype;
32  portal[i].setlvl = FALSE;
33 }
34 
35 void AddWarpMissile(int i, int x, int y)
36 {
37  int mi;
38 
40  dMissile[x][y] = 0;
41  mi = AddMissile(0, 0, x, y, 0, MIS_TOWN, 0, i, 0, 0);
42 
43  if (mi != -1) {
44  SetMissDir(mi, 1);
45 
46  if (currlevel != 0)
47  missile[mi]._mlid = AddLight(missile[mi]._mix, missile[mi]._miy, 15);
48 
50  }
51 }
52 
54 {
55  int i;
56 
57  for (i = 0; i < MAXPORTAL; i++) {
58  if (!portal[i].open)
59  continue;
60  if (currlevel == 0)
62  else {
63  int lvl = currlevel;
64  if (setlevel)
65  lvl = setlvlnum;
66  if (portal[i].level == lvl)
67  AddWarpMissile(i, portal[i].x, portal[i].y);
68  }
69  }
70 }
71 
72 void AddInTownPortal(int i)
73 {
75 }
76 
77 void ActivatePortal(int i, int x, int y, int lvl, int lvltype, BOOL sp)
78 {
79  portal[i].open = TRUE;
80 
81  if (lvl != 0) {
82  portal[i].x = x;
83  portal[i].y = y;
84  portal[i].level = lvl;
85  portal[i].ltype = lvltype;
86  portal[i].setlvl = sp;
87  }
88 }
89 
90 void DeactivatePortal(int i)
91 {
92  portal[i].open = FALSE;
93 }
94 
95 BOOL PortalOnLevel(int i)
96 {
97  if (portal[i].level == currlevel)
98  return TRUE;
99  else
100  return currlevel == 0;
101 }
102 
104 {
105  int i;
106  int mi;
107 
108  for (i = 0; i < nummissiles; i++) {
109  mi = missileactive[i];
110  if (missile[mi]._mitype == MIS_TOWN && missile[mi]._misource == id) {
112  dMissile[missile[mi]._mix][missile[mi]._miy] = 0;
113 
114  if (portal[id].level)
115  AddUnLight(missile[mi]._mlid);
116 
117  DeleteMissile(mi, i);
118  }
119  }
120 }
121 
122 void SetCurrentPortal(int p)
123 {
124  portalindex = p;
125 }
126 
128 {
129  if (currlevel) {
130  setlevel = FALSE;
131  currlevel = 0;
132  plr[myplr].plrlevel = 0;
134  } else {
135  if (portal[portalindex].setlvl) {
136  setlevel = TRUE;
141  } else {
142  setlevel = FALSE;
146  }
147  if (portalindex == myplr) {
150  }
151  }
152 }
153 
155 {
156  if (currlevel == 0) {
157  ViewX = WarpDropX[portalindex] + 1;
158  ViewY = WarpDropY[portalindex] + 1;
159  } else {
162 
163  if (portalindex != myplr) {
164  ViewX++;
165  ViewY++;
166  }
167  }
168 }
169 
170 BOOL PosOkPortal(int lvl, int x, int y)
171 {
172  int i;
173 
174  for (i = 0; i < MAXPORTAL; i++) {
175  if (portal[i].open && portal[i].level == lvl && ((portal[i].x == x && portal[i].y == y) || (portal[i].x == x - 1 && portal[i].y == y - 1)))
176  return TRUE;
177  }
178  return FALSE;
179 }
180 
AddLight
int AddLight(int x, int y, int r)
Definition: lighting.cpp:1021
SyncPortals
void SyncPortals()
Definition: portal.cpp:53
currlevel
BYTE currlevel
Definition: gendung.cpp:40
MAXPORTAL
#define MAXPORTAL
Definition: defs.h:34
MIS_TOWN
@ MIS_TOWN
Definition: enums.h:1204
delta_portal_inited
BOOL delta_portal_inited(int i)
Definition: msg.cpp:401
ViewX
int ViewX
Definition: gendung.cpp:73
missile
MissileStruct missile[MAXMISSILES]
Definition: missiles.cpp:12
portal
DEVILUTION_BEGIN_NAMESPACE PortalStruct portal[MAXPORTAL]
In-game state of portals.
Definition: portal.cpp:6
SetMissDir
void SetMissDir(int mi, int dir)
Definition: missiles.cpp:1092
MissileData::mlSFX
int mlSFX
Definition: structs.h:385
all.h
ViewY
int ViewY
Definition: gendung.cpp:74
portalindex
int portalindex
Current portal number (a portal array index).
Definition: portal.cpp:8
PortalStruct::y
int y
Definition: structs.h:697
MissileStruct::_miy
int _miy
Definition: structs.h:410
PortalStruct::ltype
int ltype
Definition: structs.h:699
AddMissile
int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micaster, int id, int midam, int spllvl)
Definition: missiles.cpp:2455
PortalStruct
Definition: structs.h:694
PortalStruct::setlvl
BOOL setlvl
Definition: structs.h:700
DeactivatePortal
void DeactivatePortal(int i)
Definition: portal.cpp:90
DEVILUTION_END_NAMESPACE
#define DEVILUTION_END_NAMESPACE
Definition: types.h:10
AddUnLight
void AddUnLight(int i)
Definition: lighting.cpp:1046
WarpDropY
int WarpDropY[MAXPORTAL]
Y-coordinate of each players portal in town.
Definition: portal.cpp:13
MissileStruct::_mlid
int _mlid
Definition: structs.h:442
dMissile
char dMissile[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:76
DeleteMissile
void DeleteMissile(int mi, int i)
Definition: missiles.cpp:355
PortalOnLevel
BOOL PortalOnLevel(int i)
Definition: portal.cpp:95
missileactive
DEVILUTION_BEGIN_NAMESPACE int missileactive[MAXMISSILES]
Definition: missiles.cpp:10
AddInTownPortal
void AddInTownPortal(int i)
Definition: portal.cpp:72
MissileStruct::_mix
int _mix
Definition: structs.h:409
PortalStruct::level
int level
Definition: structs.h:698
setlevel
BOOLEAN setlevel
Definition: gendung.cpp:65
SetPortalStats
void SetPortalStats(int i, BOOL o, int x, int y, int lvl, int lvltype)
Definition: portal.cpp:25
DTYPE_TOWN
@ DTYPE_TOWN
Definition: enums.h:1868
WarpDropX
int WarpDropX[MAXPORTAL]
X-coordinate of each players portal in town.
Definition: portal.cpp:11
NetSendCmd
void NetSendCmd(BOOL bHiPri, BYTE bCmd)
Definition: msg.cpp:615
PortalStruct::open
BOOL open
Definition: structs.h:695
InitPortals
void InitPortals()
Definition: portal.cpp:15
PortalStruct::x
int x
Definition: structs.h:696
setlvlnum
BYTE setlvlnum
Definition: gendung.cpp:58
myplr
int myplr
Definition: player.cpp:9
nummissiles
int nummissiles
Definition: missiles.cpp:13
PlayerStruct::plrlevel
int plrlevel
Definition: structs.h:187
GetPortalLevel
void GetPortalLevel()
Definition: portal.cpp:127
GetPortalLvlPos
void GetPortalLvlPos()
Definition: portal.cpp:154
RemovePortalMissile
void RemovePortalMissile(int id)
Definition: portal.cpp:103
DEVILUTION_BEGIN_NAMESPACE
Definition: sha.cpp:10
ActivatePortal
void ActivatePortal(int i, int x, int y, int lvl, int lvltype, BOOL sp)
Definition: portal.cpp:77
BFLAG_MISSILE
@ BFLAG_MISSILE
Definition: enums.h:1877
missiledata
DEVILUTION_BEGIN_NAMESPACE MissileData missiledata[]
Data related to each missile ID.
Definition: misdat.cpp:11
dFlags
char dFlags[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:56
PosOkPortal
BOOL PosOkPortal(int lvl, int x, int y)
Definition: portal.cpp:170
leveltype
BYTE leveltype
Definition: gendung.cpp:39
CMD_DEACTIVATEPORTAL
@ CMD_DEACTIVATEPORTAL
Definition: enums.h:2228
SetCurrentPortal
void SetCurrentPortal(int p)
Definition: portal.cpp:122
plr
PlayerStruct plr[MAX_PLRS]
Definition: player.cpp:10
LS_SENTINEL
@ LS_SENTINEL
Definition: enums.h:412
AddWarpMissile
void AddWarpMissile(int i, int x, int y)
Definition: portal.cpp:35