MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / OperateBook

Function OperateBook

Source/objects.cpp:1944–2024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1942}
1943
1944void OperateBook(Player &player, Object &book, bool sendmsg)
1945{
1946 if (book._oSelFlag == 0) {
1947 return;
1948 }
1949
1950 if (setlevel && setlvlnum == SL_VILEBETRAYER) {
1951 Point target {};
1952 if (book.position == Point { 26, 45 }) {
1953 target = { 27, 29 };
1954 } else if (book.position == Point { 45, 46 }) {
1955 target = { 43, 29 };
1956 } else {
1957 return;
1958 }
1959
1960 Object &circle = ObjectAtPosition(book.position + Direction::SouthWest);
1961 assert(circle._otype == OBJ_MCIRCLE2);
1962
1963 // Only verfiy that the player stands on the circle when it's the local player (sendmsg), cause for remote players the position could be desynced
1964 if (sendmsg && circle.position != player.position.tile) {
1965 return;
1966 }
1967
1968 circle._oVar6 = 4;
1969 ObjectAtPosition({ 35, 36 })._oVar5++;
1970 AddMissile(player.position.tile, target, Direction::South, MissileID::Phasing, TARGET_BOTH, player.getId(), 0, 0);
1971 }
1972
1973 book._oSelFlag = 0;
1974 book._oAnimFrame++;
1975
1976 if (sendmsg)
1977 NetSendCmdLoc(MyPlayerId, false, CMD_OPERATEOBJ, book.position);
1978
1979 if (!setlevel) {
1980 return;
1981 }
1982
1983 if (setlvlnum == SL_BONECHAMB) {
1984 if (sendmsg) {
1985 uint8_t newSpellLevel = player._pSplLvl[static_cast<int8_t>(SpellID::Guardian)] + 1;
1986 if (newSpellLevel <= MaxSpellLevel) {
1987 player._pSplLvl[static_cast<int8_t>(SpellID::Guardian)] = newSpellLevel;
1988 NetSendCmdParam2(true, CMD_CHANGE_SPELL_LEVEL, static_cast<uint16_t>(SpellID::Guardian), newSpellLevel);
1989 }
1990
1991 if (&player == MyPlayer) {
1992 for (Item &item : InventoryPlayerItemsRange { player }) {
1993 item.updateRequiredStatsCacheForPlayer(player);
1994 }
1995 if (IsStashOpen) {
1996 Stash.RefreshItemStatFlags();
1997 }
1998 }
1999
2000 Quests[Q_SCHAMB]._qactive = QUEST_DONE;
2001 NetSendCmdQuest(true, Quests[Q_SCHAMB]);

Callers 2

OperateObjectFunction · 0.85
SyncOpObjectFunction · 0.85

Calls 11

AddMissileFunction · 0.85
NetSendCmdLocFunction · 0.85
NetSendCmdParam2Function · 0.85
NetSendCmdQuestFunction · 0.85
InitDiabloMsgFunction · 0.85
ObjChangeMapFunction · 0.85
SyncObjectAnimFunction · 0.85
RefreshItemStatFlagsMethod · 0.80
PlaySfxLocFunction · 0.70
getIdMethod · 0.65

Tested by

no test coverage detected