MathsNightmare ScarScripts?

Discussion in 'Code Snippets and Tutorials' started by II_warlord_II, Sep 16, 2008.

Thread Status:
Not open for further replies.
  1. II_warlord_II

    II_warlord_II Level III

    Joined:
    Aug 13, 2008
    Messages:
    532
    Likes Received:
    31
    Can anyone help me out, i'm not sure what i did wrong?
    it's not working.

    program MathsNightmare;

    type
    arraytype = array[0..9] of Integer;

    var
    imgMain, imgRandom, imgGame: Integer;
    x, y: Integer;
    numImageArray: arraytype;
    add, sub, mult, divide: Integer;
    oldTop, oldBtm: Integer;

    procedure loadPics;
    begin
    sub := BitmapFromString(6, 3, '7BA2CE738ABD7386BD6B82BD73' +
    '82BD7B9ACE5A599C4220734220734220734220735A559C8CC3E78' +
    '4B2DE84B6DE84B2DE84AEDE84BAE7');
    mult := BitmapFromString(7, 7, 'z78DA6590490EC5200C43AFD492' +
    '01B2CCC4FD8FF403A895BEBA798BD83236E20973CA663749CFA27' +
    'ACA73EF9BF3F11C92D22DBE89AFE75519F8561AA819CCD6C5A8C3' +
    '608B81C6915CD010F47AF024606B57872FA9E13DBC9BB6E0933CD' +
    'C21272A5C03515B69DFB6E5B1E5596A35118DEA404627B35AF15F' +
    '5A7540A915BB8F6058AD6BEB727E433C6AFB0F1AA04513');
    add := BitmapFromString(9, 9, 'z78DA95514B0E432108BC522B0A' +
    '650988F73F520974619F4D5EBA994C9C0FA26CAE6BB1F94A0C4EF' +
    '0429DBDB547305377DA553EFC85A85BAAAB4C97F1E539F9CA5972' +
    'CCFAE9A9FEC221E3C9BD5208C8324E4FA9FF62DD7CC7E89FF2692' +
    '3E06618E718AA293A056FD36FF792DC8B5285C4E097F739DFB09A' +
    '2F29BEFB2FCC146CA9C0378AAB73D5');
    divide := BitmapFromString(6, 16, 'z78DA75915D12C3200884AFD' +
    '42A823EF2E7FD8F548CD531CDF4656707C8FA419A7AEEBD2DA5E5' +
    'AB0A9A53AE2CD6FECC142EEFA653A322A36EFD980985945E94230' +
    '7AF1C3A66228184D170CE5410767ABE8242450A707E55F821D95A' +
    '12943A488CCB4FC250D0EE8B449AABDF39878F3AAB7F4954C96F0' +
    'CD363C6C61624F520A13B09705292C9FCBC5B24E7455281D9F049' +
    '12DF5AEC7BCD3C19F6E5CB71F9B33BFE0298745A976F49918BF7D' +
    'DD5E1E375DF975FFBEEEEF4638BD8378D8DCEFA99F6016BEB8BDF' +
    '');
    numImageArray[0] := BitmapFromString(10, 15, 'z78DA8D53DB92C52008FBA53D' +
    '8A228F02FAFF9FB469AD1D7B99B3FBC2309D90C440C59AF62EE4B' +
    'D73D692D553A0548C42F8E1B8D6425A1B8B3506DE80476DA8C0CB' +
    'C46765D1049EA08E891B5BA15A3D632AF68EBE793EA66296EAE3F' +
    'BA5927367AAC15807CF5087CAA7FAC169163757871F5E187664F6' +
    '8914B2DEE0367D8406E78A7C3280BBDAE1107D9B7DAA60B017B7C' +
    'B6C3108B713EF352DB374F379ABC8392CB39BDBD9A745F7E9991F' +
    'BAC07FD15D19E646DE7467F2FF7CEFD8E6AAFEFDBDC816D772E68' +
    'CCCB15FD774BD99BFF78B4BE0D65937FCC53979EC97BB3D132EB8' +
    'AB9A44368CEE9CA863BF330712A171C97095E06ABF9CA9883FE22' +
    '58D03F9F88346AA7098AF2FFA05A177D1F9');
    numImageArray[1] := BitmapFromString(6, 16, 'z78DAD5914B1203210844AF3451' +
    '545802E2FD8F14662833C62407C886A2E857CD8FD4C618A42657D' +
    'C7254E16E6B9DCB9DB74C492BA4747836995B154E6AA1BE98D319' +
    'BA8B551A4959D588D111381F0851A9B9162E2501D1AC0856E9CE2' +
    '0421332B57076EC3119EF92EDCB46A7156930EB2E2B7931B0EDB5' +
    '329BCFAFFBBCCDF3719FFF9D277E17533D017CED8A7D');
    numImageArray[2] := BitmapFromString(10, 15, 'z78DA7D525B12032108BB52EB0' +
    '3F41350EE7FA4B2B23A6BBBDD9F0C93811083553AAB2213354814' +
    '4B49298417C65FCC946B959A5A54ACD251D56A544C1404D911B80' +
    '46E180B0CB4DAA61A6557008646CD66A32AC4A376DE3ABB80F31B' +
    '0E7D537857393B9960F87C4D9FA713693AA6F0A26075115BD9D71' +
    '673654CEF58D2C15F3B7F154C1BA44FE7C75B8CF71EFEF2B9E91C' +
    '75A654EBE9D07685B18B2F3D78A7E05B56DAF6EAD579FB3A47E4D' +
    'AA74F4FA626D175A3DDED528088EF997F0E2917319FD4F12B0DDD' +
    '6FE1175C0EEDB2CEDF26C9EB8243FF4C32421D7F00EF336C3C156' +
    'C6A65387F4E7BC8C1672D43D8324CFF7FC86052E389FF7EFE33AE' +
    '7F6EF732CC036DEF621E78BB1D49FF002514D36D');
    numImageArray[3] := BitmapFromString(10, 15, 'z78DA8D524BB2C3200CBB524' +
    'BC086A53F70FF233D0703216D5FA71B4FC6918524BB483D5A4326' +
    '508874E41C63080F3C6EB5F773E4A0B574FCA8516CD4FE3E6CAA5' +
    '760544E786460F59A422C6570E648A4E0B37040A2E47DE4427232' +
    'E3C9AC6DF267E15AD131062E451C63B3CF397BD3332BCEEFA5DFB' +
    '4FD87F950A362C3DDFBC2E32BC3508B7D8ABB36255DBEAAACC436' +
    'A4BB8B54B5BEA7ED197EE0DF143AB365F22CD1AAA12DE79465BCD' +
    'B93FFD1EFEAEF0C6BD7DFFC6E7DDFECD0DFB7E3EE7C835F785E72' +
    '70477B1A8671246F75752C0790EB5D4B7EBF0D9B0E02EF0C5904E' +
    'DAE2808F2F24BA75A93DBC63D4F4E93043CEE99586F7FE7A62E6D' +
    'D17CA1F50B9F1A16FF70D713B6B7402BA54BD51F7370D379');
    numImageArray[4] := BitmapFromString(11, 15, 'z78DA8D534912032108FC52A2' +
    '287A04C4FF3F2918667166AC542E5D164BDB3648497BEF5594BF3' +
    '89FE3C066118C452543082F8C99B171B22CEED965AFA3D51491A8' +
    '1D2808B233185BE6B6F33BCFBAD76B528054C47B0F863031C4878' +
    '6BE33F85D87F2CAE9AAA11D9594EE1A8AB02A6EBD11DFD40A7068' +
    'FA970F6011048AA5400A518A58CDE09C187EFB30AB75255E79637' +
    '8FAD0AFCA9F2F35867CD770664D39F7D16BF372E7E75978E56F1F' +
    '2C625EEDBEE54ACD751E68377ADC6B1225EBF7387225518FCC13F' +
    'F1F1341AB605BC73A7C204557EBAF2E406A28E38CB18673AB73B3' +
    'F97EE3DE75DBC3C981F3A50B1F867B7DC3C56FBA20AEF7619B457' +
    'CFC055CF1F8ACCDB17705776F9EE607472CEBB9');
    numImageArray[5] := BitmapFromString(10, 15, 'z78DA8D534BB2042108BBD28C' +
    '22E85240EF7FA48732DACEB7DE86B2834048EC228D7B27AE55114' +
    '2B851FC4F2CD2A8778BDD6A634656C753855220D5749F311599E7' +
    '2B1A625571D6DADC89C0A32708B7BEB31EA9BF2271CD851A6F195' +
    '28892ADA7F6B7FBF3ECF89105E54E3E1123969A9E6F7E98BBB3D9' +
    '08B6476D0A90B2F8F4777D9051AB5A15AF3EA74A4BAB27658662B' +
    '3E7CEEAE2663CEDD371EFF36DDF934F86E1A9EBFC7BAFC5B0A0B4' +
    '6BFA74AA7FD1FFC5175306B59D7B6518882BF6C3C7510B1CAE5AD' +
    '0F51EDCDF8F6C6945E2120497E6943839F3AD5513FCE02F28D91B' +
    'A811326CADDA602BD4EC5D0521DE2FE45E13720EAC0F078FAC216' +
    '17871309C9D9DC979736F9433D8BF86C3976B973F2F83D21B');
    numImageArray[6] := BitmapFromString(10, 15, 'z78DA75524DBA032108BB52EB1' +
    'FB214D4FB1FE965446778EDD70D8B984008B28E3827A74E938A50' +
    '969C5A509214C28BA2AFB9E5372B1BFF549A132A86CA38216A554' +
    '328D622DDBF1629BD75D356551A73F75F130DB19EAC7D9E29A9C5' +
    '5493316B92D087F53184849B0EEFC73BACA9B55ECC8969F776AB7' +
    'EF37FF5D94E4E0E79E5000E7A042D259637C0855B053E2E577B0B' +
    '3ADA2BE1D6C1410ADF09FB0A6697ECB527E194EBD35F6E87EB82C' +
    '8EA7567A5320679AD25F06B53BC07D9A962233E095BFDCF7FF6B2' +
    '8A5905D9BA7C3EB4F439F1B92F6E349CF6CD09954F07786ECBB36' +
    'D3A5D95957FD1B27F42BC6E4182D30E9F159201D1AB0C41568AAC' +
    'EC27380E66B693C3FD9FFBFACFC0D193399D8917727B93C7D5F5E' +
    'BD0BF9E5BF8EDEC762D3F7EFE00FB7DD0F9');
    numImageArray[7] := BitmapFromString(10, 15, 'z78DA95534172042108FCD2A' +
    'EA0E85141FEFFA418C755D42455B97459A34D370D83CEBD08F09F' +
    'E8B37F276CE83BA6C4FDCCE6FB731E88195E1127571A856B519D4' +
    '81D61C788C5491DBA1962C484424AED56FB1B5D5C59679456D32A' +
    '4666A8ABB2D585BD4228E4B33CAC00F4CE72D4D78BFB8DC8AA64F' +
    '369EFAFFA5BA7B3DFE6CE95A9185257842B0DBD52A21F7AA48F4F' +
    'D14B1796620A5CED1CEFCA47BF93FB4CF6E1524999EBE1D372A76' +
    'EE4522B6D73FC65E233B7995573EB388C7C4A10930F9D28C72EF5' +
    '3CFD874B52FCAEDB7DF66D19683C8FBD1DD936E1BF3A855DD7FE0' +
    'B7363AF7ED78CBE00460DD71D');
    numImageArray[8] := BitmapFromString(10, 15, 'z78DA75534996C42008BD52B' +
    '7A2C85206EF7FA4C6A81552D5B5213E44FE0021311EA389661BD0' +
    '736B0029FD60FE8CA5172221311C8344C78CE6B124A026BB26656' +
    '95219890BE69658FDB69CDB95F757790CE49EC4763E57EABAF231' +
    '366133042F445E954D3C35FCDB597706B8AABDF860E8E067E7EC7' +
    '8B1123325A92B834C5DEC4DD1AB83BB01C78DC58440711C3E576C' +
    'D0BBD6FDEABA7544EDE5E8AD1A745D3E4BB659F34B5F7D7697CA7' +
    '1E9F83055472DC76D5082959F53383D9D6F65DD0EA41B6B76763E' +
    'A079E09BEA77BDC0492D62114C0ED1DBC8D09DB433CDE8C09AFE6' +
    '7FD435DC02A7D2A7AE22AFF379D758EB8355FB861872BCF0DFC36' +
    'DFE5DE718CAA98FB8CF32FB8F7CDF9B8ABABCF72F5D1FFB9B78F1' +
    'D784E6AC7EBEDD9BA9BCF1F2BA6CEF0');
    numImageArray[9] := BitmapFromString(10, 15, 'z78DA7D524B92C52008BCD28B' +
    '3F6429A0F73FD21050C7BC4CCD864A99A6699A46EE710CA056A4A' +
    '416182885F081F8A8F65ED38D41C3CF9A585B538B9F9A1C590890' +
    'B256A10CB116921C12E2FCAB0C6D31945872CBBB2B37D177B8996' +
    '52CFECA4C7D28A69A2AAD8E99134D152681015B156C6D732FECDC' +
    'F7F47B47FBD6D117A637FEAC355190BE14D640327B6DA3E7C4A91' +
    '956AD4C65F5EAAC8CAC5D57E5A9C4F6FAB3D79C81ABC9A9F3DC42' +
    '79726565887D9C1A94B573396F61BD3C390FFDFFDFF7E9CFAFB67' +
    'D4DC1E41BF9ADEF0CDC4A84C6383370DEF1CBE7AF2B43C4B2B6D3' +
    '4D1B77CF8F4F518C23E9A8FB453188D3554D829269AE64B9E7BEB' +
    'D194E3F1DDFB2612C4B2B5D77F594EAEE8D44BFAF95D81CA2DE60' +
    '676F33DB5DC0DD7BFBBC1C53AF604EB4AE1F7B13D0F8');

    imgMain := BitmapFromString(14, 7, 'z78DA7D914B0E80200C44C' +
    'FA4524A97FD71FF2359533544829B0921C39B76680589C1BBF58E' +
    '541AB3595571CC9B54D8614399958158EC76E2A579434ABBDC4CA' +
    'DE2E6A9AF53BCAF987854A332A6A7B661CEEB4C1ADE8D3473D5F5' +
    '305F31EB01D66EE787690F938D77ADE1A456A2811E6EB7F0450A9' +
    '0AEC8918BCF5EF96A4C19DF4633FE74953BAE982361EE2DE7CC9E' +
    '5333F77FCECF4F05676E63560176F51FE6BB51EA09FCAD8C3D');
    imgRandom := BitmapFromString(20, 13, 'z78DAB5934992C3200C45AF14' +
    '9BC92C41C0FD8FD4328FB89538E95DB370B984863F8831CE93251' +
    '789D265F4340323BA184A709B7B1CBE84A277ADB7DA4772692B6D' +
    'A4E1C6E0967C8D68A5CB4E0E21403E39EB6B6E39871CBDB61A6A6' +
    'C71CDAD319736F3855BC5D625FAE2F56F4D99B7E42B6AD73A11F0' +
    'D36DCFBBCCB9FE106EFBE875A46B6EA96D71994739EED2A952EE5' +
    'B092DB6D493623E0E814BF6394A241EF610B290AF736B4FDC3291' +
    '383953AB5755A70EE0811DFA583CE8906A5275604DA6D1C7C3B7B' +
    '452A45F3AEBF455753FD335BA514B15EE93A23AE7FC12513D77E5' +
    '6CDCA4D628BFFC5D7CFF3EC6C1E5FB33A2C8FDEEB7A7B3377D96B' +
    'F2A602EC1FA0B12FA58A6F86287C3CEEA0366E23653B75237DE32' +
    'A2CAFA7B39D54A5B2E4C675183EDB51AF28EE0C53EDFF5579D95F' +
    '9C9F1B9ED56079BA913F61A2C2ABA592E6C14738958841F5E2B9B' +
    'A9FB3DD23703E9FFE6C263F6540CD7AE2A4E902FBEEA6CF6365F7' +
    '7CAF574E74BC4BA4987553BDF231DEC2B0315EF9AF77BF78B2F71' +
    '72C8E7BBDEFE7493FD21C76AFBF6FF1B4155ABED2DF372FCDCF38' +
    '9F6DEE763FCDBDC7F8DFF00738F6DF1');
    imgGame := BitmapFromString(18, 17, 'z78DADD92D10AC02008453F6A' +
    '8CE8B1A2FBFF9FB42787A58B6A0A632F22665E8ED7742203B1200' +
    '089E5B154B098FB88A3ED5FCDDB8AA2024D85FF1AD7E52BF5482D' +
    '4B963B068D656FFE5897265B12C91D6A5C3DD19E53335C561B7B6' +
    '2242E7B8F342EFDB69DFC7AE9CB925FAE7BF3BB811946EFDCCA97' +
    'AFB1FCC9AF0B54DFD451');
    end;

    function getNumbers(below, above: Integer): Integer;
    var
    fX, fY, minVal, minX, i, sX: Integer;
    temp: string;
    begin
    temp := '';
    sX := 8;

    //find numbers on first line
    repeat
    minVal := -1;
    minX := 1000;

    for i := 0 to 9 do
    if (findBitmapToleranceIn(numImageArray, fX, fY, sX, below, 77, above,
    150)) and (fX < minX) then
    begin
    minVal := i;
    minX := fX;
    end;

    if (minVal > -1) then
    begin
    temp := temp + inttostr(minVal);
    //writeln(temp);
    sX := minX + 10;
    end;

    until (minVal = -1);

    if (temp = '') then
    Result := -1
    else
    Result := strtoint(temp);
    end;

    function solve: Boolean;
    var
    top, btm, ans: Integer;
    begin
    //find numbers
    top := getNumbers(499, 525);
    btm := getNumbers(530, 557);

    //get sign
    if (top > -1) and (btm > -1) then
    begin
    ans := -1;
    if (findbitmaptolerancein(divide, x, y, 18, 535, 73, 559, 150)) then
    ans := top / btm
    else if (findbitmaptolerancein(mult, x, y, 18, 535, 73, 559, 150)) then
    ans := top * btm
    else if (findbitmaptolerancein(add, x, y, 18, 535, 73, 559, 150)) then
    ans := top + btm
    else if (findbitmaptolerancein(sub, x, y, 18, 535, 73, 559, 150)) then
    ans := top - btm;
    if (top <> oldTop) and (btm <> oldBtm) then
    begin
    writeln('Sending ' + inttostr(ans) + ' for ' + inttostr(top) + ' ' +
    inttostr(btm));
    SendKeys(inttostr(ans));
    wait(10);
    SendKeysVb('{ENTER}', True);
    oldTop := top;
    oldBtm := btm;
    Result := True;
    end else
    Result := False;
    end;
    end;

    procedure solveMouse;
    var
    i, j, sheepX, sheepY: Integer;
    begin
    //sheep width: 93
    //sheep height: 98
    //startX: 15, endX: 286
    //startY: 0, endY: 445
    //search for sheep color in blocks
    for i := 0 to 3 do //y
    begin
    for j := 0 to 2 do //x
    begin
    //7566707
    if (FindColor(sheepX, sheepY, 7566707, 15 + j * 93, i * 98, 15 + j * 93 +
    93, i * 98 + 98)) then
    begin
    ClickMouse(sheepX, sheepY, True);
    wait(100);
    solve;
    wait(100);
    end;
    end;
    end;
    end;

    procedure solveKey;
    var
    counter: Integer;
    begin
    oldTop := -1;
    oldBtm := -1;
    SendKeysVB('{LEFT}', True);
    SendKeysVB('{LEFT}', True);
    SendKeysVB('{LEFT}', True);
    SendKeysVB('{LEFT}', True);
    SendKeysVB('{LEFT}', True);
    SendKeysVB('{LEFT}', True);
    writeln('done reseting pointer');
    wait(10);
    counter := 0;
    while (solve) and (counter < 4) do
    begin
    SendKeysVB('{RIGHT}', True);
    wait(100);
    counter := counter + 1;
    end;
    end;

    begin
    ActivateClient;
    oldTop := -1;
    oldBtm := -1;
    //load number, symbol, and screen pics
    loadPics;

    repeat
    //check if on main screen
    if (FindBitmaptoleranceIn(imgMain, x, y, 135, 495, 170, 512, 100)) then
    ClickMouse(x, y, True)
    //check if on problem select screen
    else if (FindBitmaptoleranceIn(imgRandom, x, y, 56, 444, 157, 523, 100))
    then
    ClickMouse(x, y, True)
    //check if in game
    else if (FindBitmapToleranceIn(imgGame, x, y, 3, 566, 41, 592, 100)) then
    repeat
    //solveMouse;
    //wait(3000);
    writeln('starting solve run');
    solveKey;
    writeln('finished solve run');
    wait(3000);
    until (False);
    wait(500);
    until (False);
    end.
     
    vic_loon46 likes this.
  2. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    What exactly isn't working?
    Its not detecting the numbers correctly or something?

    I'm not a SCAR programmer, but I can somewhat understand the code and could possibly find the error. Plus I'm sure it would help the SCAR programmers look through the code, since its not exactly a short script ;)
     
  3. II_warlord_II

    II_warlord_II Level III

    Joined:
    Aug 13, 2008
    Messages:
    532
    Likes Received:
    31
    its not detecting the text box.
    cit should be like:
    click on textbox, hit run and solve and execute.
     
  4. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    Ok, I knew I had seen this script before (copied for Here)

    I won't be able to fix this script for one simple reason : posted in 2006.
    The game changed in 2008. This is the second version of maths nightmare and it's TOTALLY different from the first one.

    Sorry, you'll have to learn how to code scar script and create a new one.
     
  5. II_warlord_II

    II_warlord_II Level III

    Joined:
    Aug 13, 2008
    Messages:
    532
    Likes Received:
    31
    EKKK....
    dam it, that suck

    alrighty, thanks guy...

    some please close this then
     
Thread Status:
Not open for further replies.