AnnieRuru Posted October 29, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted October 29, 2012 yesterday emistry ask me in pm what are they saying in this topic I guess should post this out help those people who wants to abuse that 2040 bit keyworld trying to do <3 I think most of you here already know how to do this prontera,156,181,5 script implode data 100,{ mes "string = "+ $data1$; explode .@data$, $data1$, "#"; .@size = getarraysize( .@data$ ); for ( .@i = 0; .@i < .@size; .@i++ ) mes .@data$[.@i] +""; close; OnInit: setarray .@data, 12,21,13,31,11,7; .@size = getarraysize( .@data ); for ( .@i = 0; .@i < .@size; .@i++ ) .@data$[.@i] = .@data[.@i] +""; // stupid implode ask for string only, need to convert number to string set $data1$, implode( .@data$, "#" ); end; } and this is bit-shifting data prontera,158,181,5 script bitshift data 100,{ mes "value = "+ $data2; for ( .@i = 0; .@i < .size; .@i++ ) mes ( ( $data2 >> .@i * 5 ) % pow( 2, 5 ) )+""; close; OnInit: setarray .@data, 12,21,13,31,11,7; $data2 = 0; .size = getarraysize( .@data ); for ( .@i = 0; .@i < .size; .@i++ ) $data2 = $data2 + ( .@data[.@i] << .@i * 5 ); end; } but this script can only save 31 bit only lol @keyworld, come post your 2040 bit godly script xD I also can't do that myself x.x .... though I know you can do it <3 1 Quote Link to comment Share on other sites More sharing options...
0 AnnieRuru Posted January 9, 2019 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Author Share Posted January 9, 2019 Feeling nostalgic right now the broken link from Keyworld's post, I found it in my old hard-disk setbit.txt Quote Link to comment Share on other sites More sharing options...
-1 Haruka Mayumi Posted January 10, 2019 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 485 Reputation: 271 Joined: 06/13/17 Last Seen: April 14 Share Posted January 10, 2019 What a pain in the eye. Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted October 29, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted October 29, 2012 Old topic Well check this script: http://stockage.robrowser.fr/frathena/boolvar.txt It's an old script, so... Don't be rude if something is wrong lol Just the "how to use" (because it's in French): - script init -1,{ OnPCLoginEvent: // When player log in, unpack all booleans var from "PLAYER_VAR$" into "@_QUEST" callfunc("unpack_var", PLAYER_VAR$, "@_QUEST" ); end; OnPCLogoutEvent: // When log out, save all booleans variables from "@_QUEST" into "PLAYER_VAR$" callfunc("pack_var", VARIABLE_JOUEUR$, "@_QUEST" ); } <map>,<x>,<y>,4 script <nom> <sprite>,{ // Define the quest ID (it will be the 824/2040 boolean var) set .@QUEST_ID, 824; // 1% to init the quest another time if ( rand(100) ) { // Set bit 824 off callfunc("setboolvar_at", "@_QUEST", .@QUEST_ID, 0 ); } // Check if boolean 824 is on in "@_QUEST". if ( callfunc("getboolvar_at", "@_QUEST", .@QUEST_ID ) ) { mes "[NPC]"; mes "I'm sorry you already did this quest."; close; } else { mes "[NPC]"; mes "I have a quest for you, find me 10 ^nItemID^524 !"; if ( countitem(521) > 10 ) { mes "[NPC]"; mes "Oh yeah !"; next; mes "[NPC]"; mes "Thank you !"; // Set on bit 824 callfunc("setboolvar_at", "@_QUEST", .@QUEST_ID, 1 ); } close; } } Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted October 29, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Author Share Posted October 29, 2012 (edited) nonono ... if you look at the example script above, I used 5 bit to save each data, which allows up to 2^5 = 32 only in other words, by using 5 bit to save a data, with rathena crappy script engine limited to int signed 2^31 31 bit limitation / 5 bit = 6 types of data can be save only and I also used rathena bit shifting command << and >> but I don't think using your function can shift above 2^31 isn't it ? as you can do until 2^2040 ... I wonder is there a way to do bit shifting above 2^31 ... EDIT: wait ... don't tell me.... manually set them 1 bit by 1 bit ?? Edited October 29, 2012 by AnnieRuru Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted October 29, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted October 29, 2012 You can store 8 bits in one character. And you can store 255 character in a string. 8*255 = 2040. So yeah you set manually all bits in an array, and pack the array into a string. 1 Quote Link to comment Share on other sites More sharing options...
Variant Posted October 29, 2012 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 52 Reputation: 6 Joined: 01/06/12 Last Seen: December 12, 2017 Share Posted October 29, 2012 (edited) So wait, just to clarify. This is basically saying that you can just use the individual bits in a 255 character string (2040 total bits) to store multiple variables, right? So as to drastically reduce variable usage in scripts (as a result, in large population servers, use significantly less rows in global_reg_value). Well, potentially at least. I had actually taken advantage of something similar to this, but I had used 5 integer variables (that is, 32 bits). It was a script that kept note if a player had collected ~150 different items, and so I just used bitmasking 5 times. Totally forgot that strings held 255 characters... Never need boolean arrays ever! @KeyWorld: Did you ever figure out a good compression method to store a character's skill build? Edit: On another note, does anyone think it'd be viable to support 64-bit integers on rAthena (given a 64-bit system)? I can think of a few uses for 64-bit integers off the top of my head, and I'm sure there are people out there with some crazy projects that they'd like to do given numbers. Edited October 29, 2012 by Variant Quote Link to comment Share on other sites More sharing options...
Euphy Posted October 29, 2012 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Share Posted October 29, 2012 Did you ever figure out a good compression method to store a character's skill build? Multiple people have already done this with new SQL tables - that's probably the best/easiest way. Quote Link to comment Share on other sites More sharing options...
Variant Posted October 29, 2012 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 52 Reputation: 6 Joined: 01/06/12 Last Seen: December 12, 2017 Share Posted October 29, 2012 (edited) Multiple people have already done this with new SQL tables - that's probably the best/easiest way. Oh, I was just interested in if he had found a compression algorithm to do it with only 2040 bits. I'm sure the SQL method proves to be much faster overall (the compression algorithm may significantly increase the number of executed instructions), but it'd be cool to see if it was possible, if not viable, to do it via compression. I'm sure it would have some implications for certain scripts too, but I can't think of any off the top of my head. Edit: Though I finally understood Mytzer's post, took me a few tries. That actually helps a lot. Edited October 29, 2012 by Variant Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted October 30, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Author Share Posted October 30, 2012 (edited) @keyworld I already know how to SET a bit above 2^31 at the time I post in that topic I just didn't know how to SHIFT a group of bits above 2^31 ... (now I know we can abuse SQL to calculate numbers above 2^31 then calculate return values below 2^31 because of script engine limitations) but if the trick you said is to -> uncompress everytime -> calculate -> compress back then it doesn't sound like a trick to me <.< I originally thought we can do something like SQL select unhex( hex( 65 + 26 + 6 ) ); so I guess rathena script engine doesn't support this type of calculation .... oh well maybe I should abuse SQL system from now on !! XD yeah, actually when I released favorite warper and mission board <- look it just 3 weeks apart in March 2010 at that time, I thought explode/implode to save data was the most efficient method ... until toasty released toasty warper <- in Jan 2011 then I only start to aware this 2040-bit system ( yeah his script more optimized and more user friendly compare to mine ) also, his script only do set and unset 1 bit at a time, he didn't shift the bit ( yeah I also noticed in his later version, he already fixed the bug that caused by map index shifted by user change map position in menu, -> print out an error message instead of getting hang at the dialog ) these scripts used these kinds of data compression now I regret I didn't learned this 2040 bit earlier, or my mission board script can save above 5040 missions and able to have player takes more than 4 missions ... mainly due to eathena script engine limitation (string.. int... gotocount... etc) using SQL table is the easiest way, but I don't think its the most efficient a table having too many columns can caused the query time return too long I also did planned to use SQL table to save all the mission data ( yeah ... I was abusing moderator's power create invisible topic ... hahaha ) using my old computer 2 years ago, the result return in 0.4 second now on this new computer pentium 4 - 2.8GHz - quad-core - result return in 0.01 sec at that time. I scrapped out the idea using SQL table to do it ... and I already predicted keyworld's system will fail at that time I post there, with Ragnarok game is always expanding new towns, fields, dungeons, or new jobs, skills ... etc using bit to save the system without future planning will 1 day break your system -> not enough bits actually I read somewhere long time ago in eathena board eathena item database uses bitmask int signed to store all the jobs, which is unique to eathena aegis doesn't do like this if 1 day Gravity develop more than 31 different jobs, we need to expand another equip_job2 lol ... well ... I don't think I can find that topic anymore ... I believe that topic was at 2005 in forum bug report ... before eathena board even has bug tracker system Edited October 30, 2012 by AnnieRuru Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted October 30, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted October 30, 2012 @Annie Be aware with SQL, it's not thread safe for now. About using bits, I don't see the problem you can extend it as you want. Just need to think on a good structure AND maybe add a header to store the compression method and version or anything else to extend the system in future. About job system, int64 will save us Quote Link to comment Share on other sites More sharing options...
Question
AnnieRuru
yesterday emistry ask me in pm what are they saying in this topic
I guess should post this out help those people who wants to abuse that 2040 bit keyworld trying to do <3
I think most of you here already know how to do this
and this is bit-shifting data
but this script can only save 31 bit only lol
@keyworld, come post your 2040 bit godly script xD
I also can't do that myself x.x .... though I know you can do it <3
Link to comment
Share on other sites
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.