GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ScriptParser/umpscript.js at master · DRRP-Team/ScriptParser Expand file tree/ Copy pathumpscript.jsMore file actions 105 lines (81 loc) · 3.35 KB / Copy pathumpscript.jsFile metadata and controls105 lines (81 loc) · 3.35 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 // [#maindev] <PROPHESSOR> 05.11.2018 // Новая версия UMP скрипта по линковке скриптов (добавил присваивание ID триггерам): const prompt = require('prompt-sync')(); const Thing = require('../../structures/Thing'); const UDMFBlock = require('../../lib/oop/UDMFBlock'); const getX = x => (x * 64) + 32; const getY = y => (32 * 64) - (y * 64) - 32; const convertToDoomGrid = (x, y) => [getX(x), getY(y)]; const getDX = x => (x - 32) / 64; const getDY = y => (32 * 64 - y) / 64; module.exports = function (udmfarray) { console.info('# == DRRP Script Assigner == #'); let map = null; do { try { const tmp = prompt('Enter DRRP UMP Script map (intro.bsp): ', 'intro.bsp'); if (!tmp) { console.log('Skipped by User'); return udmfarray; } map = require('./maps/' + tmp + '.json'); } catch (e) { console.error('Can\'t open this map! Try again'); } } while (!map); console.log('Locating the local player start...'); let localplayerstart = null; for (const block of udmfarray) { const [btype, bdata] = block; if (btype === 'thing' && bdata.type === 1) { const x = Number(bdata.x); const y = Number(bdata.y); console.log(`Located the local player start at: (${x};${y})!`); localplayerstart = [x, y]; break; } } if (!localplayerstart) throw new Error('Does this map contain playerstart?'); console.log(`Original player start is at: (${map.playerstart[0]};${map.playerstart[1]})`); const origpstolocps = [getX(map.playerstart[0]), getY(map.playerstart[1])]; console.log(`Calculating offset between ${origpstolocps} and ${localplayerstart}...`); const coordoffset = [origpstolocps[0] - localplayerstart[0], origpstolocps[1] - localplayerstart[1]]; console.log(`Coordinate offset is: ${coordoffset}`); const thingsToAdd = []; { for(let i = 0; i < map.scripts.length; i++) { const [x, y] = map.scripts[i]; const script = i + 1; let found = false; for(const block of udmfarray) { const [btype, bdata] = block; if(btype === 'thing') { const {x:tx, y:ty} = bdata; if(getX(x) === tx && getY(x) === ty) { bdata.special = 80; bdata.arg0 = script; console.log(`script ${i + 1}: `, x, y, tx, ty, '[ASSIGNED]'); found = true; } } } if(!found) { thingsToAdd.push(new Thing(convertToDoomGrid(x, y), 10554, [script])); console.log(`script ${i + 1}: `, x, y, convertToDoomGrid(x, y), 'not found => [CREATED]'); } } for(const thing of thingsToAdd) { const tmp = new UDMFBlock(thing.toArray()); tmp[1].special = 80; udmfarray.push(tmp); } for(const block of udmfarray) { const [btype, bdata] = block; if(btype === 'thing') { const {x:tx, y:ty} = bdata; bdata.id = (getDX(tx) << 5) | getDY(ty); } } } return udmfarray; }; |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |