// This file is (C) Carlos Sanchez 2014, and is released under the MIT license //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// CONDACTS /////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function ACCdesc() { describe_location_flag = true; ACCbreak(); // Cancel doall loop } function ACCdone() { done_flag = true; } function CNDat(locno) { return (loc_here()==locno); } function CNDnotat(locno) { return (loc_here()!=locno); } function CNDatgt(locno) { return (loc_here()>locno); } function CNDatlt(locno) { return (loc_here() value); } function CNDlt(flagno, value) { return (getFlag(flagno) < value); } function CNDadject1(wordno) { return (getFlag(FLAG_ADJECT1) == wordno); } function CNDadverb(wordno) { return (getFlag(FLAG_ADVERB) == wordno); } function CNDtimeout() { return bittest(getFlag(FLAG_TIMEOUT_SETTINGS),7); } function CNDisat(objno, locno) { return (getObjectLocation(objno) == locno); } function CNDisnotat(objno, locno) { return !CNDisat(objno, locno); } function CNDprep(wordno) { return (getFlag(FLAG_PREP) == wordno); } function CNDnoun2(wordno) { return (getFlag(FLAG_NOUN2) == wordno); } function CNDadject2(wordno) { return (getFlag(FLAG_ADJECT2) == wordno); } function CNDsame(flagno1,flagno2) { return (getFlag(flagno1) == getFlag(flagno2)); } function CNDnotsame(flagno1,flagno2) { return (getFlag(flagno1) != getFlag(flagno2)); } function ACCinven() { var count = 0; writeSysMessage(SYSMESS_YOUARECARRYING); ACCnewline(); var listnpcs_with_objects = !bittest(getFlag(FLAG_PARSER_SETTINGS),3); var i; for (i=0;i 1) writeSysMessage(SYSMESS_TURNS_PLURAL); writeSysMessage(SYSMESS_TURNS_END); } function ACCscore() { var score = getFlag(FLAG_SCORE); writeSysMessage(SYSMESS_SCORE_START); writeText(score + ''); writeSysMessage(SYSMESS_SCORE_END); } function ACCcls() { clearScreen(); } function ACCdropall() { // Done in two different loops cause PAW did it like that, just a question of retro compatibility var i; for (i=0;i= getFlag(FLAG_MAXOBJECTS_CARRIED)) { writeSysMessage(SYSMESS_CANTREMOVE_TOOMANYOBJECTS); ACCnewtext(); ACCdone(); return; } setObjectLocation(objno, LOCATION_CARRIED); writeSysMessage(SYSMESS_YOUREMOVEOBJECT); success = true; break; default: writeSysMessage(SYSMESS_YOUARENOTWEARINGTHAT); ACCnewtext(); ACCdone(); return; break; } } function trytoGet(objno) // auxiliaty function for ACCget { if (getFlag(FLAG_OBJECTS_CARRIED_COUNT) >= getFlag(FLAG_MAXOBJECTS_CARRIED)) { writeSysMessage(SYSMESS_CANTCARRYANYMORE); ACCnewtext(); ACCdone(); doall_flag = false; return; } var weight = 0; weight += getObjectWeight(objno); weight += getLocationObjectsWeight(LOCATION_CARRIED); weight += getLocationObjectsWeight(LOCATION_WORN); if (weight > getFlag(FLAG_MAXWEIGHT_CARRIED)) { writeSysMessage(SYSMESS_WEIGHSTOOMUCH); ACCnewtext(); ACCdone(); return; } setObjectLocation(objno, LOCATION_CARRIED); writeSysMessage(SYSMESS_YOUTAKEOBJECT); success = true; } function ACCget(objno) { success = false; setFlag(FLAG_REFERRED_OBJECT, objno); setReferredObject(objno); var locno = getObjectLocation(objno); switch (locno) { case LOCATION_CARRIED: case LOCATION_WORN: writeSysMessage(SYSMESS_YOUALREADYHAVEOBJECT); ACCnewtext(); ACCdone(); return; break; case loc_here(): trytoGet(objno); break; default: if ((locno<=last_object_number) && (CNDpresent(locno))) // If it's not here, carried or worn but it present, that means that bit 7 of flag 12 is cleared, thus you can get objects from present containers/supporters { trytoGet(objno); } else { writeSysMessage(SYSMESS_CANTSEETHAT); ACCnewtext(); ACCdone(); return; break; } } } function ACCdrop(objno) { success = false; setFlag(FLAG_REFERRED_OBJECT, objno); setReferredObject(objno); var locno = getObjectLocation(objno); switch (locno) { case LOCATION_WORN: writeSysMessage(SYSMESS_YOUAREALREADYWEARINGTHAT); ACCnewtext(); ACCdone(); return; break; case loc_here(): writeSysMessage(SYSMESS_YOUDONTHAVEOBJECT); ACCnewtext(); ACCdone(); return; break; case LOCATION_CARRIED: setObjectLocation(objno, loc_here()); writeSysMessage(SYSMESS_YOUDROPOBJECT); success = true; break; default: writeSysMessage(SYSMESS_YOUDONTHAVETHAT); ACCnewtext(); ACCdone(); return; break; } } function ACCwear(objno) { success = false; setFlag(FLAG_REFERRED_OBJECT, objno); setReferredObject(objno); var locno = getObjectLocation(objno); switch (locno) { case LOCATION_WORN: writeSysMessage(SYSMESS_YOUAREALREADYWAERINGOBJECT); ACCnewtext(); ACCdone(); return; break; case loc_here(): writeSysMessage(SYSMESS_YOUDONTHAVEOBJECT); ACCnewtext(); ACCdone(); return; break; case LOCATION_CARRIED: if (!objectIsWearable(objno)) { writeSysMessage(SYSMESS_YOUCANTWEAROBJECT); ACCnewtext(); ACCdone(); return; } setObjectLocation(objno, LOCATION_WORN); writeSysMessage(SYSMESS_YOUWEAROBJECT); success = true; break; default: writeSysMessage(SYSMESS_YOUDONTHAVETHAT); ACCnewtext(); ACCdone(); return; break; } } function ACCdestroy(objno) { setObjectLocation(objno, LOCATION_NONCREATED); } function ACCcreate(objno) { setObjectLocation(objno, loc_here()); } function ACCswap(objno1,objno2) { var locno1 = getObjectLocation (objno1); var locno2 = getObjectLocation (objno2); ACCplace (objno1,locno2); ACCplace (objno2,locno1); setReferredObject(objno2); } function ACCplace(objno, locno) { setObjectLocation(objno, locno); } function ACCset(flagno) { setFlag(flagno, SET_VALUE); } function ACCclear(flagno) { setFlag(flagno,0); } function ACCplus(flagno,value) { var newval = getFlag(flagno) + value; setFlag(flagno, newval); } function ACCminus(flagno,value) { var newval = getFlag(flagno) - value; if (newval < 0) newval = 0; setFlag(flagno, newval); } function ACClet(flagno,value) { setFlag(flagno,value); } function ACCnewline() { writeText(STR_NEWLINE); } function ACCprint(flagno) { writeText(getFlag(flagno) +''); } function ACCsysmess(sysno) { writeSysMessage(sysno); } function ACCcopyof(objno,flagno) { setFlag(flagno, getObjectLocation(objno)) } function ACCcopyoo(objno1, objno2) { setObjectLocation(objno2,getObjectLocation(objno1)); setReferredObject(objno2); } function ACCcopyfo(flagno,objno) { setObjectLocation(objno, getFlag(flagno)); } function ACCcopyff(flagno1, flagno2) { setFlag(flagno2, getFlag(flagno1)); } function ACCadd(flagno1, flagno2) { var newval = getFlag(flagno1) + getFlag(flagno2); setFlag(flagno2, newval); } function ACCsub(flagno1,flagno2) { var newval = getFlag(flagno2) - getFlag(flagno1); if (newval < 0) newval = 0; setFlag(flagno2, newval); } function CNDparse() { return (!getLogicSentence()); } function ACClistat(locno, container_objno) // objno is a container/suppoter number, used to list contents of objects { var listingContainer = false; if (arguments.length > 1) listingContainer = true; var objscount = getObjectCountAt(locno); var concealed_or_scenery_objcount = getObjectCountAtWithAttr(locno, [ATTR_CONCEALED, ATTR_SCENERY]); objscount = objscount - concealed_or_scenery_objcount; if (!listingContainer) setFlag(FLAG_OBJECT_LIST_FORMAT, bitclear(getFlag(FLAG_OBJECT_LIST_FORMAT),7)); if (!objscount) return; var continouslisting = bittest(getFlag(FLAG_OBJECT_LIST_FORMAT),6); if (listingContainer) { writeText(' ('); if (objectIsAttr(container_objno, ATTR_SUPPORTER)) writeSysMessage(SYSMESS_OVER_YOUCANSEE); else if (objectIsAttr(container_objno, ATTR_CONTAINER)) writeSysMessage(SYSMESS_INSIDE_YOUCANSEE); continouslisting = true; // listing contents of container always continuous } if (!listingContainer) { setFlag(FLAG_OBJECT_LIST_FORMAT, bitset(getFlag(FLAG_OBJECT_LIST_FORMAT),7)); if (!continouslisting) ACCnewline(); } var progresscount = 0; for (var i=0;i 1) writeText(')'); } function ACClistnpc(locno) { var npccount = getNPCCountAt(locno); setFlag(FLAG_OBJECT_LIST_FORMAT, bitclear(getFlag(FLAG_OBJECT_LIST_FORMAT),5)); if (!npccount) return; setFlag(FLAG_OBJECT_LIST_FORMAT, bitset(getFlag(FLAG_OBJECT_LIST_FORMAT),5)); continouslisting = bittest(getFlag(FLAG_OBJECT_LIST_FORMAT),6); writeSysMessage(SYSMESS_NPCLISTSTART); if (!continouslisting) ACCnewline(); if (npccount==1) writeSysMessage(SYSMESS_NPCLISTCONTINUE); else writeSysMessage(SYSMESS_NPCLISTCONTINUE_PLURAL); var progresscount = 0; var i; for (i=0;i last_process) { writeText(STR_WRONG_PROCESS); ACCnewtext(); ACCdone(); } callProcess(procno); if (describe_location_flag) done_flag = true; } function ACCmes(mesno) { writeMessage(mesno); } function ACCmode(mode) { setFlag(FLAG_MODE, mode); } function ACCtime(length, settings) { setFlag(FLAG_TIMEOUT_LENGTH, length); setFlag(FLAG_TIMEOUT_SETTINGS, settings); } function ACCdoall(locno) { doall_flag = true; if (locno == LOCATION_HERE) locno = loc_here(); // Each object will be considered for doall loop if is at locno and it's not the object specified by the NOUN2/ADJECT2 pair and it's not a NPC (or setting to consider NPCs as objects is set) setFlag(FLAG_DOALL_LOC, locno); var doall_obj; doall_loop: for (doall_obj=0;(doall_obj getFlag(FLAG_MAXWEIGHT_CARRIED)) { writeSysMessage(SYSMESS_WEIGHSTOOMUCH); ACCnewtext(); ACCdone(); return; } if (getFlag(FLAG_OBJECTS_CARRIED_COUNT) >= getFlag(FLAG_MAXOBJECTS_CARRIED)) { writeSysMessage(SYSMESS_CANTCARRYANYMORE); ACCnewtext(); ACCdone(); return; } setObjectLocation(objno, LOCATION_CARRIED); writeSysMessage(SYSMESS_YOUTAKEOBJECT); success = true; } function ACCnewtext() { player_order_buffer = ''; } function ACCability(maxObjectsCarried, maxWeightCarried) { setFlag(FLAG_MAXOBJECTS_CARRIED, maxObjectsCarried); setFlag(FLAG_MAXWEIGHT_CARRIED, maxWeightCarried); } function ACCweight(flagno) { var weight_carried = getLocationObjectsWeight(LOCATION_CARRIED); var weight_worn = getLocationObjectsWeight(LOCATION_WORN); var total_weight = weight_worn + weight_carried; setFlag(flagno, total_weight); } function ACCrandom(flagno) { setFlag(flagno, 1 + Math.floor((Math.random()*100))); } function ACCwhato() { var whatofound = getReferredObject(); if (whatofound != EMPTY_OBJECT) setReferredObject(whatofound); } function ACCputo(locno) { setObjectLocation(getFlag(FLAG_REFERRED_OBJECT), locno); } function ACCnotdone() { done_flag = false; } function ACCautop(locno) { var objno =findMatchingObject(LOCATION_CARRIED); if (objno != EMPTY_OBJECT) { ACCputin(objno, locno); return; }; objno =findMatchingObject(LOCATION_WORN); if (objno != EMPTY_OBJECT) { ACCputin(objno, locno); return; }; objno = findMatchingObject(loc_here()); if (objno != EMPTY_OBJECT) { ACCputin(objno, locno); return; }; objno = findMatchingObject(null); // anywhere if (objno != EMPTY_OBJECT) { writeSysMessage(SYSMESS_YOUDONTHAVETHAT); ACCnewtext(); ACCdone(); return; }; success = false; writeSysMessage(SYSMESS_CANTDOTHAT); ACCnewtext(); ACCdone(); } function ACCautot(locno) { var objno =findMatchingObject(locno); if (objno != EMPTY_OBJECT) { ACCtakeout(objno, locno); return; }; objno =findMatchingObject(LOCATION_CARRIED); if (objno != EMPTY_OBJECT) { ACCtakeout(objno, locno); return; }; objno =findMatchingObject(LOCATION_WORN); if (objno != EMPTY_OBJECT) { ACCtakeout(objno, locno); return; }; objno = findMatchingObject(loc_here()); if (objno != EMPTY_OBJECT) { ACCtakeout(objno, locno); return; }; objno = findMatchingObject(null); // anywhere if (objno != EMPTY_OBJECT) { if (objectIsAttr(locno, ATTR_SUPPORTER)) writeSysMessage(SYSMESS_YOUCANTTAKEOBJECTFROM); else writeSysMessage(SYSMESS_YOUCANTTAKEOBJECTOUTOF); writeText(getObjectFixArticles(locno)); writeSysMessage(SYSMESS_PUTINTAKEOUTTERMINATION) ACCnewtext(); ACCdone(); return; }; success = false; writeSysMessage(SYSMESS_CANTDOTHAT); ACCnewtext(); ACCdone(); } function CNDmove(flagno) { var locno = getFlag(flagno); var dirno = getFlag(FLAG_VERB); var destination = getConnection( locno, dirno); if (destination != -1) { setFlag(flagno, destination); return true; } return false; } function ACCextern(writeno) { eval(writemessages[writeno]); } function ACCpicture(picno) { drawPicture(picno); } function ACCgraphic(option) { graphicsON = (option==1); if (!graphicsON) hideGraphicsWindow(); } function ACCbeep(sfxno, channelno, times) { if ((channelno <1) || (channelno >MAX_CHANNELS)) return; //SFX channels from 1 to MAX_CHANNELS, channel 0 is for location music and can't be used here sfxplay(sfxno, channelno, times, 'play'); } function ACCsound(value) { soundsON = (value==1); if (!soundsON) sfxstopall(); } function CNDozero(objno, attrno) { if (attrno > 63) return false; return !objectIsAttr(objno, attrno); } function CNDonotzero(objno, attrno) { return objectIsAttr(objno, attrno); } function ACCoset(objno, attrno) { if (attrno > 63) return; if (attrno <= 31) { attrs = getObjectLowAttributes(objno); var attrs = bitset(attrs, attrno); setObjectLowAttributes(objno, attrs); return; } var attrs = getObjectHighAttributes(objno); attrno = attrno - 32; attrs = bitset(attrs, attrno); setObjectHighAttributes(objno, attrs); } function ACCoclear(objno, attrno) { if (attrno > 63) return; if (attrno <= 31) { var attrs = getObjectLowAttributes(objno); attrs = bitclear(attrs, attrno); setObjectLowAttributes(objno, attrs); return; } var attrs = getObjectHighAttributes(objno); attrno = attrno - 32; attrs = bitclear(attrs, attrno); setObjectHighAttributes(objno, attrs); } function CNDislight() { if (!isDarkHere()) return true; return lightObjectsPresent(); } function CNDisnotlight() { return ! CNDislight(); } function ACCversion() { writeText(filterText(STR_RUNTIME_VERSION)); } function ACCwrite(writeno) { writeWriteMessage(writeno); } function ACCwriteln(writeno) { writeWriteMessage(writeno); ACCnewline(); } function ACCrestart() { process_restart = true; } function ACCtranscript() { $('#transcript_area').html(transcript); $('.transcript_layer').show(); inTranscript = true; } function ACCanykey() { writeSysMessage(SYSMESS_PRESSANYKEY); inAnykey = true; } function ACCgetkey(flagno) { getkey_return_flag = flagno; inGetkey = true; } ////////////////// // LEGACY // ////////////////// // From PAW PC function ACCbell() { // Empty, PAW PC legacy, just does nothing } // From PAW Spectrum function ACCreset() { // Legacy condact, does nothing now } function ACCpaper(color) { // Legacy condact, does nothing now, use CSS styles } function ACCink(color) { // Legacy condact, does nothing now, use CSS styles } function ACCborder(color) { // Legacy condact, does nothing now, use CSS styles } function ACCcharset(value) { // Legacy condact, does nothing now, use CSS styles } function ACCline(lineno) { // Legacy condact, does nothing now, use CSS styles } function ACCinput() { // Legacy condact, does nothing now } function ACCsaveat() { // Legacy condact, does nothing now } function ACCbackat() { // Legacy condact, does nothing now } function ACCprintat() { // Legacy condact, does nothing now } function ACCprotect() { // Legacy condact, does nothing now } // From Superglus function ACCdebug() { // Legacy condact, does nothing now } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// CONDACTS FOR COMPILER ////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function CNDverb(wordno) { return (getFlag(FLAG_VERB) == wordno); } function CNDnoun1(wordno) { return (getFlag(FLAG_NOUN1) == wordno); }