Jump to content

plankt

Members
  • Posts

    130
  • Joined

  • Last visited

Everything posted by plankt

  1. It could often help to do a flowchart and then pseudo-code when you do a NPC and then turn it, a step at a time, in to code: 1) What should the NPC do when ... Clicked on? -> Nothing -> Put a close/end at the beginning Spoken near? -> Register item ID or name and check if it matches a previously created pattern. -> We need to make the arrays -> We need to make the patterns (there's two ways to handle this, I'll get to that later on) 2) Pseudo-code NPC header { (We could if we wanted to, present the user with a list of items so he/she dont have to remember it) close; (We do not want the user to click the NPC) OnInit: (What do we need to do before using the NPC?) 1) Arrays for items 2) Regular expressions end; (OnInit done) Labels and code for the RegExp (Here we also want to check for the equipped item since the code starts reading from each label) } The arrays are correct for you, I don't see why you put in those two for-loops since they only iterate through the arrays without changing anything. And if you want to have a loop inside another, you shouldn't use the same iteration variable for both (in this case .@i) Regular Expressions, "defpatterns", works like this: You give a pattern for a string to find, the parts that are inside round brackets will be set as a variable you can use! (We like this) So you can make 1 expression for each item OR pass the name or ID said and check if those are inside the arrays. (More convenient with larger arrays) Example of using names for the patterns: (I'm not showing how to manually make each pattern since everyone likes it dynamic, and also using a bit of lazy coding) for(i=0; i < size(.@lowerid); i++){ //For each item (Both lists should be the same size) defpattern 1, "([^:]+):s"+.@lowerid[ i ], getd("L"+.@lowerid[ i ]); //Make a pattern for the id pointing at the label L<id> defpattern 1, "([^:]+):s"+.@lowername$[ i ], getd("L"+.@lowerid[ i ]); //Make a pattern for the name pointing at the label L<id> } activatepset 1; //Activate the patterns we did end; //This is where the code starts reading for the user when they say a certain string, you want to check their items equipped etc. after the appropriate label. L25200: code for item 25200 end; L25201: code for item 25201 end; ... and so on Example of using general pattern for all: defpattern 1, "([^:]+).*)", "CheckItem"; activatepset 1; end; CheckItem: set .@name$, $@p2$; (If the player said the item name) set .@id, atoi($@p2$); (If the player said the item ID) Now you loop through the arrays looking for any of those two, if you find a result, then you can do what you need to, otherwise just end; I'm not 100% sure that the patterns I used above are correct since I can't test them but they should give enough information for you to find the correct one from trial and error. There are also a lot of examples in https://rathena.svn....le/npc_pcre.txt I hope this all makes sense, otherwise just ask
  2. That would make the chance of getting the numbers: 7 | 1:74 6 | 3:74 5 | 6:74 4 | 9:74 3 | 12:74 2 | 15:74 1 | 28:74 Therefore increasing the chance to get the number 1 for the user but decreasing the probability to get other numbers. The amount of winnings with 1 would therefore increase but the amount of high winnings decrease. Since only one number got it's probability increased, that will also increase the over-all winning chance. I hope I'm making sense
  3. The decrement of .menu was if it was supposed to index an array (since arrays start their indexing at 0, not 1). Using it with switch, which itself can handle whatever order you choose, you don't want to '-1'. set .menu, select(.pkmn_menu$) -1; Would make your first choice 0, then you check for 'case 1' which wants a 1. Solved by not having '-1'. You do not terminate the script with a 'close;'. It will therefore continue after the menu down to the OnInit once again and continue to build the menu. It's always good coding standard to make sure that an 'end' or 'close' is placed at the end of the NPC, but before On<Event> labels, in case you miss to terminate the user somewhere on the way.
  4. The 'slotreel' function decides the odds of a number to appear. If you want to decrease the probability of winning, you could equalize the difference between the numbers to give a greater variety but then they will also have a higher chance of hitting the high numbers. You could also add more numbers to give them less chance of getting a combination of three equal numbers. There's currently 18 numbers the random number generated between 0 and 63 could hit to give a 1, that's what the 18:64 means. I guess you could figure out how to alter the table to your liking. If you want to play with the chances, alter this function: function script slotreel { set @number,rand(64); if(@number == 0) return 7; else if(@number >= 1 && 4 > @number) return 6; else if(@number >= 4 && 10 > @number) return 5; else if(@number >= 10 && 19 > @number) return 4; else if(@number >= 19 && 31 > @number) return 3; else if(@number >= 31 && 46 > @number) return 2; else if(@number >= 46 && 64 > @number) return 1; } If you instead want to decrease the winning multiplier, that will say the amount of zeny they win. Then alter this part: case 1: set @mult,8; break; case 2: set @mult,16; break; case 3: set @mult,32; break; case 4: set @mult,64; break; case 5: set @mult,128; break; case 6: set @mult,256; break;
  5. 'select' returns an index for the selection the user made. 1 for the first alternative, 2 for the second and so on... (or if it begins on 0, can't remember) You can just use that to index the correct pokemon in the .pkmn$ array: (-1 if it starts on 1, since arrays count from 0) if( .pkmn$[.@menu-1] == "Bulbasaur" ) ... Or if you don't want to go for names, use the index directly: switch( .@menu ){ case 1: Bulbasaur code break; case 2: Charmander code break; case 3: Squirtle code break; } You only need one for loop in the OnInit aswell: OnInit: setarray .pkmn$,"Bulbasaur","Charmander","Squirtle"; setarray .pkmntype$,"Grass","Fire","Water"; for ( set .@i, 0; .@i < getarraysize(.pkmntype$); set .@i, .@i +1 ) set .pkmn_menu$, .pkmn_menu$ + (.pkmn$[.@i]) + " - " +...
  6. You could make it read the IP-address from the admins main account so that if their IP-address change, they just have to log in to the main account first to sync the table. As a security addition, it would be nice to have the server do a full backup of all data for the account on a master login. Then the admin could just restore if anyone gained illegal access.
×
×
  • Create New...