int16 Op_ReadObject() { int16 returnParam; int member = popVar(); int obj = popVar(); int ovl = popVar(); getSingleObjectParam(ovl, obj, member, &returnParam); return returnParam; }
int16 Op_WriteObject() { int16 returnParam; int16 param1 = popVar(); int16 param2 = popVar(); int16 param3 = popVar(); int16 param4 = popVar(); getSingleObjectParam(param4, param3, param2, &returnParam); setObjectPosition(param4, param3, param2, param1); return returnParam; }
/** * Preliminary command to list the current items in the player's inventory */ bool Debugger::cmd_items(int argc, const char **argv) { for (int i = 1; i < numOfLoadedOverlay; i++) { ovlDataStruct *pOvlData = overlayTable[i].ovlData; if (overlayTable[i].alreadyLoaded) { if (overlayTable[i].ovlData->arrayObject) { for (int j = 0; j < pOvlData->numObj; j++) { if (getObjectClass(i, j) != 3) { int16 returnVar; getSingleObjectParam(i, j, 5, &returnVar); if (returnVar < -1) DebugPrintf("%s\n", getObjectName(j, pOvlData->arrayNameObj)); } } } } } return true; }
void buildInventory(int X, int Y) { menuStruct *pMenu; pMenu = createMenu(X, Y, _vm->langString(ID_INVENTORY)); menuTable[1] = pMenu; if (pMenu == NULL) return; int numObjectInInventory = 0; for (int i = 1; i < numOfLoadedOverlay; i++) { ovlDataStruct *pOvlData = overlayTable[i].ovlData; if (overlayTable[i].alreadyLoaded) { if (overlayTable[i].ovlData->arrayObject) { for (int j = 0; j < pOvlData->numObj; j++) { if (getObjectClass(i, j) != 3) { int16 returnVar; getSingleObjectParam(i, j, 5, &returnVar); if (returnVar < -1) { addSelectableMenuEntry(i, j, pMenu, 1, -1, getObjectName(j, pOvlData->arrayNameObj)); numObjectInInventory++; } } } } } } if (numObjectInInventory == 0) { freeMenu(menuTable[1]); menuTable[1] = NULL; } }
cellStruct *addCell(cellStruct *pHead, int16 overlayIdx, int16 objIdx, int16 type, int16 backgroundPlane, int16 scriptOverlay, int16 scriptNumber, int16 scriptType) { int16 var; cellStruct *newElement; cellStruct *currentHead = pHead; cellStruct *currentHead2; cellStruct *currentHead3; if (getSingleObjectParam(overlayIdx, objIdx, 2, &var) < 0) { return 0; } currentHead3 = currentHead; currentHead2 = currentHead->next; while (currentHead2 && (currentHead2->type != 3)) { if (currentHead2->type != 5) { int16 lvar2; if (getSingleObjectParam(currentHead2->overlay, currentHead2->idx, 2, &lvar2) >= 0 && lvar2 >= var) break; } currentHead3 = currentHead2; currentHead2 = currentHead2->next; } if (currentHead2) { if ((currentHead2->overlay == overlayIdx) && (currentHead2->backgroundPlane == backgroundPlane) && (currentHead2->idx == objIdx) && (currentHead2->type == type)) return NULL; } currentHead = currentHead2; newElement = (cellStruct *) mallocAndZero(sizeof(cellStruct)); if (!newElement) return 0; newElement->next = currentHead3->next; currentHead3->next = newElement; newElement->idx = objIdx; newElement->type = type; newElement->backgroundPlane = backgroundPlane; newElement->overlay = overlayIdx; newElement->freeze = 0; newElement->parent = scriptNumber; newElement->parentOverlay = scriptOverlay; newElement->gfxPtr = NULL; newElement->followObjectIdx = objIdx; newElement->followObjectOverlayIdx = overlayIdx; newElement->parentType = scriptType; newElement->animStart = 0; newElement->animEnd = 0; newElement->animWait = 0; newElement->animSignal = 0; newElement->animCounter = 0; newElement->animType = 0; newElement->animStep = 0; newElement->animLoop = 0; if (currentHead) { newElement->prev = currentHead->prev; currentHead->prev = newElement; } else { newElement->prev = pHead->prev; pHead->prev = newElement; } return newElement; }
void sortCells(int16 ovlIdx, int16 ovjIdx, cellStruct *objPtr) { cellStruct *pl, *pl2, *pl3, *pl4, *plz, *pllast; cellStruct prov; int16 newz, objz, sobjz; pl4 = NULL; getSingleObjectParam(ovlIdx, ovjIdx, 2, &sobjz); pl = objPtr; prov.next = NULL; prov.prev = NULL; pl2 = pl->next; pllast = NULL; plz = objPtr; while (pl2) { pl3 = pl2->next; if ((pl2->overlay == ovlIdx) && (pl2->idx == ovjIdx)) {// found pl->next = pl3; if (pl3) { pl3->prev = pl2->prev; } else { objPtr->prev = pl2->prev; } pl4 = prov.next; if (pl4) { pl4->prev = pl2; } else { prov.prev = pl2; } pl2->prev = NULL; pl2->next = prov.next; prov.next = pl2; if (pllast == NULL) { pllast = pl2; } } else { if (pl2->type == 5) { newz = 32000; } else { getSingleObjectParam(pl2->overlay, pl2->idx, 2, &objz); newz = objz; } if (newz < sobjz) { plz = pl2; } pl = pl->next; } pl2 = pl3; } if (pllast) { pl2 = prov.next; pl4 = plz->next; plz->next = pl2; pllast->next = pl4; if (plz != objPtr) pl2->prev = plz; if (!pl4) objPtr->prev = pllast; else pl4->prev = pllast; } }
bool findRelation(int objOvl, int objIdx, int x, int y) { bool found = false; bool first = true; int testState = -1; int j; int16 objectState; getSingleObjectParam(objOvl, objIdx, 5, &objectState); for (j = 1; j < numOfLoadedOverlay; j++) { if (overlayTable[j].alreadyLoaded) { int idHeader = overlayTable[j].ovlData->numMsgRelHeader; for (int i = 0; i < idHeader; i++) { linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i]; int thisOvl = ptrHead->obj1Overlay; if (!thisOvl) { thisOvl = j; } //const char* pName = getObjectName(ptrHead->obj1Number, overlayTable[thisOvl].ovlData->arrayNameObj); objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number); if ((thisOvl == objOvl) && (objIdx == ptrHead->obj1Number) && pObject && (pObject->_class != THEME)) { int verbeOvl = ptrHead->verbOverlay; int obj1Ovl = ptrHead->obj1Overlay; int obj2Ovl = ptrHead->obj2Overlay; if (!verbeOvl) verbeOvl = j; if (!obj1Ovl) obj1Ovl = j; if (!obj2Ovl) obj2Ovl = j; char verbe_name[80]; char obj1_name[80]; char obj2_name[80]; char r_verbe_name[80]; char r_obj1_name[80]; char r_obj2_name[80]; verbe_name[0] = 0; obj1_name[0] = 0; obj2_name[0] = 0; r_verbe_name[0] = 0; r_obj1_name[0] = 0; r_obj2_name[0] = 0; ovlDataStruct *ovl2 = NULL; ovlDataStruct *ovl3 = NULL; ovlDataStruct *ovl4 = NULL; if (verbeOvl > 0) ovl2 = overlayTable[verbeOvl].ovlData; if (obj1Ovl > 0) ovl3 = overlayTable[obj1Ovl].ovlData; if (obj2Ovl > 0) ovl4 = overlayTable[obj2Ovl].ovlData; if ((ovl3) && (ptrHead->obj1Number >= 0)) { testState = ptrHead->obj1OldState; if ((first) && (ovl3->arrayNameObj) && ((testState == -1) || (testState == objectState))) { const char *ptrName = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj); menuTable[0] = createMenu(x, y, ptrName); first = false; } } if ((ovl2) && (ptrHead->verbNumber >= 0)) { if (ovl2->nameVerbGlob) { const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); strcpy(verbe_name, ptr); if ((!first) && ((testState == -1) || (testState == objectState))) { if (!strlen(verbe_name)) { if (currentScriptPtr) { attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); } else { attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, 0, 0, scriptType_REL); } } else if (ovl2->nameVerbGlob) { found = true; ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); addSelectableMenuEntry(j, i, menuTable[0], 1, -1, ptr); } } } } } } } } return found; }
bool createDialog(int objOvl, int objIdx, int x, int y) { bool found = false; int testState1 = -1; int testState2 = -1; int j; int16 objectState; int16 objectState2; getSingleObjectParam(objOvl, objIdx, 5, &objectState); menuTable[0] = createMenu(x, y, _vm->langString(ID_SPEAK_ABOUT)); for (j = 1; j < numOfLoadedOverlay; j++) { if (overlayTable[j].alreadyLoaded) { int idHeader = overlayTable[j].ovlData->numMsgRelHeader; for (int i = 0; i < idHeader; i++) { linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i]; int thisOvl = ptrHead->obj1Overlay; if (!thisOvl) { thisOvl = j; } objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number); getSingleObjectParam(thisOvl, ptrHead->obj1Number, 5, &objectState2); if (pObject && (pObject->_class == THEME) && (objectState2 < -1)) { thisOvl = ptrHead->obj2Overlay; if (!thisOvl) { thisOvl = j; } if ((thisOvl == objOvl) && (ptrHead->obj2Number == objIdx)) { int verbeOvl = ptrHead->verbOverlay; int obj1Ovl = ptrHead->obj1Overlay; int obj2Ovl = ptrHead->obj2Overlay; if (!verbeOvl) verbeOvl = j; if (!obj1Ovl) obj1Ovl = j; if (!obj2Ovl) obj2Ovl = j; char verbe_name[80]; char obj1_name[80]; char obj2_name[80]; char r_verbe_name[80]; char r_obj1_name[80]; char r_obj2_name[80]; verbe_name[0] = 0; obj1_name[0] = 0; obj2_name[0] = 0; r_verbe_name[0] = 0; r_obj1_name[0] = 0; r_obj2_name[0] = 0; ovlDataStruct *ovl2 = NULL; ovlDataStruct *ovl3 = NULL; ovlDataStruct *ovl4 = NULL; if (verbeOvl > 0) ovl2 = overlayTable[verbeOvl].ovlData; if (obj1Ovl > 0) ovl3 = overlayTable[obj1Ovl].ovlData; if (obj2Ovl > 0) ovl4 = overlayTable[obj2Ovl].ovlData; if ((ovl3) && (ptrHead->obj1Number >= 0)) { testState1 = ptrHead->obj1OldState; } if ((ovl4) && (ptrHead->obj2Number >= 0)) { testState2 = ptrHead->obj2OldState; } if ((ovl4) && (ptrHead->verbNumber >= 0) && ((testState1 == -1) || (testState1 == objectState2)) && ((testState2 == -1) || (testState2 == objectState))) { if (ovl2->nameVerbGlob) { const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); strcpy(verbe_name, ptr); if (!strlen(verbe_name)) attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); else if (ovl2->nameVerbGlob) { found = true; int color; if (objectState2 == -2) color = subColor; else color = -1; ptr = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj); addSelectableMenuEntry(j, i, menuTable[0], 1, color, ptr); } } } } } } } } return found; }