-
Content Count
363 -
Joined
-
Days Won
46
Content Type
Profiles
Forums
Downloads
Staff Applications
Calendar
Everything posted by meko
-
You could also emulate it in your scripts by adding some zeros to your numbers, ie .@percent = rand(10000); if (.@percent == 4273) { // 42.73% }
-
well I assumed it was more than one because your percentage exceeds 100%, which implies you want to give 1~2 (154% ➜ 1.54) items
-
you could make it use doevent() to call an external script and in that script do the check for enchant poison, and call itself with addtimer() with a short delay like 500ms, so it will keep checking
-
You want the player to get only one item? Your percents make a total of 154% ... list of items,qty / Chance 607,5 50% 608,6 52% 678,4 50% 672,1 2% Try this: .@rnd = rand(154); if (.@rnd < 50) { getitem(607, 5); } else if (.@rnd < 102) { getitem(608, 6); } else if (.@rnd < 152) { getitem(678, 4); } else { getitem(672, 1); }
-
Very hard to understand what you're saying... Try to just say it in Spanish and I'll use Google Translate on my side. Also why did you remove all the parentheses? o_o Not using them is the legacy syntax and is deprecated. And if you do remove them you can't omit the space and do things like input.@input; And you can't just turn a mesf() into a mes(), there's extra parameters Do you happen to be using rAthena and not using the right forums? I can't think of any other reason why you would turn a properly formatted script back to a horror show otherwise. If what you want is to prevent the quest from being done again I had already added in the script a method to prevent it, just uncomment the line: .quest_tratoa = 2; If what you're saying is you can't get it to work at all, well in your modified version there is a ton of malformed lines, so fix that first.
-
That was... the most horribly formatted script I've ever seen. Here, try this instead skull.txt
-
It seems there's been no changelog since quite a while so here's one highlighting the most recent changes related to scripting. Sorry if that's not the right category, please move accordingly. New script commands: chr ord gettimer getunits getvariableofpc can_use_command has_permission addchannelhandler removechannelhandler setunitdata getunitdata getunitname setunitname getequipisenableopt getequippedoptioninfo getequipoptioninfo setequipoption navigateto Modified script commands (extra parameters): strcharinfo strnpcinfo addtimer deltimer addtimercount checkoption checkoption1 checkoption2 setoption warpparty warpguild classchange New params: BankVault Big projects currently in development: Implementation of the official Clan system Implementation of the official RoDEX system Implementation of the official Achievements system Complete rewrite of the map cache system
-
You can implement your own wrapper functions around atcommands by using bindatcmd()
-
Just add more Apple in the Drops{} section of the Poring. You can have a maximum of 10 drops per monster, so you will have to remove some existing drops if you want 8 apples.
-
Script that runs a custom monster for testing.
meko replied to Like it~*'s question in Script Requests
first you might want to change this setunitdata(.@unitID, UDT_MODE, getunitdata(.@mobGID, UDT_MODE) &~ 1); to this (mobGID is unused here) setunitdata(.@unitID, UDT_MODE, getunitdata(.@unitID, UDT_MODE) &~ 1); to set the AI to zero you don't need to do any bitwise operation, you can just do this: setunitdata(.@unitID, UDT_AI, 0); to prevent skill use I'm not sure, you could try setting UDT_ATKMAX and UDT_MATKMAX to 0, or setting UDT_CANMOVETICK to 2147483647 (but that's just an ugly workaround, if it works at all) -
Script that runs a custom monster for testing.
meko replied to Like it~*'s question in Script Requests
First of all, I would encourage you to read the whole documentation to understand how the herc language works. If you still have problems then, here's something that could help you get started: <map>,<x>,<y>,<dir> script <name> <sprite>,{ // YOUR INPUT FUNCTIONS GO HERE function input_mob_id { do { mes("Please enter the desired mob ID."); input(.@id, 1001, 10000); } while(getmonsterinfo(.@id, MOB_LV) < 0); // ^ the above will keep asking the player over and over until // they enter the ID of a monster that exists next(); return .@id; } function input_mob_agi { mes("Please enter the desired AGI."); input(.@agi, 1, 99); // ^ the above will ask the player once, but cap the value next(); return .@agi; } // YOUR MAIN SCRIPT GOES HERE do { mes("Hi there, please enter the desired values."); // print a message next(); // require the player to click "next" .@mobID = input_mob_id(); // call the mob id menu, store the value .@mobAGI = input_mob_agi(); // call the mob AGI menu, store the value // ^ HERE ADD MORE CALLS AS NEEDED mes("Do you wish to proceed?"); // print a message select("Start over.", "Proceed."); // ask the player if they wish to continue } while (@menu != 2); mes("Please close the dialog to continue."); close2(); // require the player to close the dialog // HERE SPAWN YOUR MONSTER .@unitID = monster("<map name>", <x>, <y>, getmonsterinfo(.@mobID, MOB_NAME), .@mobID, 1); // MAKE SURE TO CHANGE THE map, x and y // NOW MANIPULATE THE MONSTER WITH THE DATA YOU GATHERED setunitdata(.@unitID, UDT_AGI, .@mobAGI); end; // terminate the script } -
Script that runs a custom monster for testing.
meko replied to Like it~*'s question in Script Requests
for inputs just use the aptly-named input() command. if you want to restrict to only a few choices you could use select() in combination with switch() -
here, I made this for you: <map>,<x>,<y>,<dir> script <name> <sprite>,{ mes("Hi there."); mes("Can I help you?"); next(); select("claim reward"); mes("..."); next(); for (.@i = 0; .@i < .reward_len; .@i += 3) { if (rand(100) < .reward[.@i + 2]) { getitem(.reward[.@i], .reward[.@i + 1]); mesf("You obtained %i %s.", .reward[.@i + 1], getitemname(.reward[.@i])); .@reward = true; // got at least one reward next(); } } if (.@reward != true) { mes("It seems you're out of luck."); next(); } mes("Come back anytime!"); close; OnInit: setarray(.reward[0], //ID,QTY,% 607, 5, 50, 608, 6, 52, 678, 4, 50, 672, 1, 2); .reward_len = getarraysize(.reward); } hope it helps UPDATE: added reward_len (sorry, forgot that)
-
I believe you wish the npc to spawn in random locations on the map? For this you would first define your npc, then disable it in OnInit, and when the event starts you would enable it and move it to the desired location. If this does not work for you then please attach your full script here
-
// 1 / 20 chance => 5% if (rand(20) == 0) { getitem(...); // give the item } else { // do something else }
-
not sure clone() is a good idea, because it requires the cloned player to be online, but if that's intended then try this: .@mobGID = clone("prontera", 157, 167, "HALL::OnMobDead", 150005, 0, 0x0); // make the clone setunitdata(.@mobGID, UDT_MODE, getunitdata(.@mobGID, UDT_MODE) &~ (1 | 128)); // prevent from attacking & moving this makes it unable to move or attack, but doesn't (and can't) prevent the player from attacking it An alternative could be to use a NPC instead and change its appearance by manipulating UDT_SEX, UDT_HAIRSTYLE, UDT_HAIRCOLOR, UDT_HEADBOTTOM, UDT_HEADMIDDLE, UDT_HEADTOP, UDT_CLOTHCOLOR, UDT_SHIELD, and UDT_WEAPON, but I don't know if the Gravity client supports dynamic NPCs
-
I think the only way to selectively hide a npc would be to make map instances but that adds a layer of complexity for nothing imho. You could just make your merchant say stuff like "I'm busy, don't bother me" if the criteria is unmet, and else call the shop menu
-
Actually it's pretty useful, it allows to pass custom variables instead of having the functions register hardcoded variables, and it avoids having to use getd. So if your function needs to return more than one value it can just ask for a variable as an argument, and fill it with the return data. The alternative would be to implode() the values, return, and then explode() after the function call, which is much dirtier.
-
It's impossible to have perfect RNG without natural entropy. You'd need a hardware generator for that, and even then they're not always perfect
-
if all you want to do is drop an item, this can be done directly in the mob db about rand() you cannot use a custom seed; Hercules generates its own With killedrid you could get the mob id with getunitdats(UDT_CLASS, killedrid) and then you can get further information with getmonsterinfo()
-
setarray() does not create the structure of the array; it sets multiple elements of the array at the same time. this means every time setarray() is called it will overwrite the values. arrays do not need to be declared. every variable is always implicitly an array Also, there's another problem: variable$[2] = 1; You are setting an integer as value of a string variable If what you need is an array of integers then remove the "$" in the variable name
-
it's not possible to make it persist after logout, but you can emulate this behaviour by setting a char variable, then in OnPCLoginEvent checking if the variable exists and calling atcommand()
-
I do see your problem though: if (.@mapa$ != "pvp_n_1-5,guild_vs2,pvp_n_1-3") Here you are checking for a map called "pvp_n_1-5,guild_vs2,pvp_n_1-3", not for 3 different maps. Try replacing by: if (.@mapa$ != "pvp_n_1-5" && .@mapa$ != "guild_vs2" && .@mapa$ != "pvp_n_1-3")
-
first, remove the existing drop: delmonsterdrop(<mob id or name>, <item id>) then add it back, with a different drop rate: addmonsterdrop(<mob id or name>, <item id>, <rate>) This will only change one monster at a time, so you must hard-code all the mob ids in your script. An alternative could be to iterate over ALL monsters in a loop starting from id 1001 and checking with getmonsterinfo() if the race is RC_Fish, but the loop would be insanely long and block the thread (so requires freeloop), which would make the server completely unresponsive while processing the loop. If you only plan to do it in OnInit or when a custom atcommand is called it would probably be fine though.
-
When a function is invoked, the arguments are pushed to the stack, but if an argument is a scope variable its reference is also pushed. This means you can access variables of the parent scope from within a function. function do_something { setarray(getarg(0), 69, 42, 1337); return; } debugmes(.@var[0]); // <= 0 debugmes(.@var[1]); // <= 0 debugmes(.@var[2]); // <= 0 do_something(.@var[0]); debugmes(.@var[0]); // <= 69 debugmes(.@var[1]); // <= 42 debugmes(.@var[2]); // <= 1337