RuneScape 2 Development > General Server Discussion

Runescript

Pages: (1/5) >>>

sini:

With the recent release of Old Runescape the developers have been posting a ton of photos of their work. I stumbled across the thread by Leanbow and also the archive of Andrew Gowers notes from 2001. In his notes he outlines a very primitive scripting system which wouldn't be very hard to implement to be honest.

Notes:
One server cycle is 0.6 seconds, so 100 cycles = 1 minute
Probabilities range from 0=impossible to 256=certain
Misc commands
thinkbubble();Should only be called if the player has just triggered a 'use' script. Displays a thinkbubble above the players head which contains the object they are currently using. For instance this is used to display the axe above your head when you chop a tree down.ifmale();Test the player's gender, useful for getting gender specific language correct in the scripts.nodefault();Stops the game executing the default action when this script is complete. For example can be used to stop an object from being taken, or a spell being cast.openshop(shop);Displays the specified shop dialog, and allows the player to buy and sell items. Doing so frees the npc, so no npc specific commands can be used after this point.displaybalance();Displays the players current bank balanceControl flow based
Delay(delay);Delays both the script and the player for the specified number ofserver cyclesPause(mindelay, maxdelay);Pauses the script for a random amount of time inbetween the specifiedminimum and maximum. The player is free to do other stuff meanwhile, useful for making trees regrow etc.. Be very careful when using delay orpause, as the player may have logged out meanwhile. Normally this doesn't matter, but don't rely on things after it to do anything permament whichaffects the player (such as setting a player variable) as it may be lost.modpause(mindelay, maxdelay);Similar to the pause command, except the total delay is modified bythe number of players in the game. If more than 60 people are playing, the delay is calculated as: delay=(delay*60)/player-count;ifrandom(probability);Randomly sets the condition flag to true or false. A probability of0=impossible, and 256=certainjump(labelname);Jumps to the script block with the trigger 'Label,labelname' The otherscript will not return to this onefork(labelname);Starts the script block with trigger 'Label,labelname' running at thesame time as this one! Be careful with this command :-) If the target block has no pause, wait, say, or npcsay commands then will behave like agosub command. (due to non-preemptive multitasking)end();Terminates processing of the current script blockChat based
mes(string);Displays the specified message at the bottom of the playerscreensay(string);Makes the players character say the specified string, all nearbypeople will also see this. The command will then automatically delay the script depending on the length of the string.multi2(string, label, string, label);Displays a multiple choice menu with 2 items, depending which theplayers chooses the relevant block of script will be called. Note: The player may decide not to choose either item in which case the scriptterminatesmulti3(string, label, string, label, string, label);Displays a multiple choice menu with 3 itemsmulti4(string, label, string, label, string, label, string, label);Displays a multiple choice menu with 4 itemsMovement based
changelevel(int level);Moves the player to the specified level, without changing the x and yposition. Level-codes: 0=ground floor, 1=1st floor, 2=2nd floor, 3=basementchangelevelup();Moves the player up one level if possible.changeleveldown();Moves the player down one level if possible.Stat based
ifstatrandom(stat, base-probability, top-probability);Like the random command but stat modified, if the stat is 0 thebase-probability is used, if the stat is 100 the top-probability is used. If the stat is inbetween then the 2 values are interpolated.advancestat(stat, base, exp);Permanently increases the specified stat, and sets the new levels asthe current normal. The equation used is: stat+=base+exp*stat;addstat(stat, constant, percent);Temporarily adds constant+(current*percent)/100 to the 2nd playersspecified stat. Where current is the current level of the statsubstat(stat, constant, percent);Like addstat, except it subtracts.healstat(stat, constant, percent);Like addstat, but won't take the players stat above the normallevelifstatup(stat);Sets the condition to true if the players stat is currently above thenormal level, false otherwiseifstatdown(stat);Sets the condition to true if the players stat is currently below thenormal level, false otherwiseifstatabove(stat,value);Sets the condition to true if the players stat is above (but not equalto) the specified value, false otherwiseifstatatleast(stat, variable, value);Sets the condition to true if the players stat is more than or equalto getvar(variable)+value, false otherwisegiveqp(value);Gives the player the specified number of quest pointsifqp(value);Sets the condition to true if the players quest points are more thanor equal to the specified value, false otherwiseVariable based
ifvar(variable, value);Sets the condition flag to true if the variable is equal to thespecified value. Sets false otherwiseifvarmore(variable, value);Sets the condition flag to true if the variable is greater than (butnot equal to) the specifed value. Sets false otherwiseifvarless(variable, value);Sets the condition flag to true if the variable is less than (but notequal to) the specifed value. Sets false otherwisesetvar(variable, value);Sets the variable to the specified value. A variable can only hold thevalue 0-127. Always try to zero variables when they are no longer needed to save memory.addvar(variable, value);Adds the specified amount to the variables value. A variable can onlyhold the value 0-127. subvar(variable, value);Subtracts the specified amount to the variables value. A variable canonly hold the value 0-127. randomvar(value);Sets the variable 'random' to a random integer between 0 andvalue-1addbigvar(variable, value);Add the specified value to the variable. A big-variable can holdvalues between 0-268435455subbigvar(variable, value);Subtracts the specified value from the variable. A big-variable canhold values between 0-268435455ifbigvarmore(variable, value);Same as ifvarmore except for big-variablesCoordinate based
These commands all require a map coordinate to operate. The coordinate used can be set using the setcoord command below. If the setcoord command is not used the system will attempt to use the coordinate of the item the player is currently interacting with.
setcoord(coordinate);Sets the active coordinate to the specified absolute position. Thecoordinate can only be worked out with the aid of the runescape map editor.playercoord();Sets the active coordinate to the players current position.addobject(object, count, time);Adds the specified object at the active coordinate. If the object isstackable - count indicates how many to place in the stack. Time indicates how long in server cycles before the object despawns.addnpc(npc);Spawns the specified npc at the active coordinate.addloc(location);Adds the specified location at the active coordinate.ifblocked();Sets the condition flag to true if the square indicated by theactivate coordinate is currently blocked, sets false otherwiseteleport();Teleports the player to the active coordinate.showeffect(type);Displays a special effect animation of the specified type at theactive coordinate.Inventory based
give(object, count);Gives the specified number of the specified object to playersinventoryremove(object, count);Removes the specified number of the specified object from playersinventory (or as many as possible)ifworn(object);Sets condition flag to true if player is wearing specifiedobjectifheld(object, count);Sets condition flag to true if player is holding specifiedobjectThe commands below may only be used when player isinteracting with an object in their inventory
sellinv(percentage);Removes the active inventory object from the players inventory, andreplaces it with the specified percentage of it's value in gold coinsdelinv();Deletes the active inventory object from the playersinventoryObject based
These commands may only be used when a player isinteracting with an object on the ground
ifobjectvisible();Sets the condition code to true if a line of sight can be tracedbetween the player and the object, false otherwisetakeobject();Removes the object from the ground and places it in the playersinventorydelobject();Removes the object from the worldLocation based
These commands may only be used when a player isinteracting with a location
changeloc(location);Changes the location to the new specified location typeupstairs();Moves the player up a level, and adjusts their position horizontallyto account for the stairsdownstairs();Moves the player down a level, and adjusts their position horizontallyto account for the statisdelloc();Removes the location from the worldBoundary based
These commands may only be used when a player isinteracting with a boundary
changebound(boundary);Changes the boundary to the new specified boundary typeboundaryteleport();Walks the player through the boundary to the opposite side. Useful forlocked doors, and secret pasages.Npc based
ifnearnpc(npc);Attempt to find a nearby npc of the type specified. Sets the conditionflag to true if sucessful. If succesful the player is marked as interacting with the npc so the other npc commands can also be used.ifnearvisnpc(npc);Simliar to ifnearnpc, except the npc must be within 8 squares, andthere must be a line of sight between the player and npc for the command to succeed.The commands below may only be used when player isinteracting with an npc
npcsay(string);Makes the npc say the specified string, all nearby people will alsosee this. The command will then automatically delay the script depending on the length of the string.npcbusy();Sets the npc to busy, and stops it walking around. Not normallynecessary as the system attempts to trigger this automatically.npcunbusy();Sets the npc to unbusy, and allows it to walk around again. Notnormally necessary as the system attempt to trigger this automatically.shootnpc(projectile);Fires a projectile at the npcnpcattack();Causes the npcs to pursue and attack the playerifnpcvisible();Sets the condition code to true if a line of sight can be tracedbetween the player and npcaddnpcstat(stat,constant,percent);Temporarily adds constant+(current*percent)/100 to the npcs specifiedstatsubnpcstat(stat,constant,percent);Like addnpc stat, except it subtractshealnpcstat(stat,constant,percent);Like addnpc stat, but won't take npcs stat above the normal levelifnpcstatup(stat);Sets the condition to true if the npcs specified stat is currentlyabove the normal level, false otherwiseifnpcstatdown(stat);Sets the condition to true if the npcs specified stat is currentlybelow the normal level, false otherwisedelnpc();Removes the npc from the worldchangenpc(npc);Changes the npc into a the new npc type specified!npcretreat(time);Causes the npc to run away from the player for the specified number ofserver cyclesOther player based
These commands may only be used when a player isinteracting with another player.
addplaystat(stat, constant, percent);Temporarily adds constant+(current*percent)/100 to the 2nd playersspecified stat. Where current is the current level of the statsubplaystat(stat, constant, percent);Like addplaystat, except it subtracts.healplaystat(stat, constant, percent);Like addplaystat, but won't take the players stat above the normallevelifplaystatup(stat);Sets the condition to true if the 2nd players stat is currently abovethe normal level, false otherwiseifplaystatdown(stat)Sets the condition to true if the 2nd players stat is currently belowthe normal level, false otherwiseomes(string);Displays a message on the 2nd players screenifplayervisible();Sets the condition code to true if a line of sight can be tracedbetween the 2 players, false otherwiseshootplayer(projectile);Fires a projectile at the 2nd player
Modern Runescript:







A lot different :P, not entirely sure how enumerations are handled. The enum command seems to have two type declarations then two parameters.

% - variable
$ - script variable
~ - gosub
@ - jump
<> - evaluate

The enumerations probably have something to do with how the scripts in the client captured variables (could return string/integer).

Ashi:

And this was meant so Jagex could easily add content? It looks ugly.

sini:

Its based off a legacy system. Btw 'loc' is object, 'obj' is item.

Pure_:

Yeah the legacy aspect definitely shows off, I think it's lacking in some features (perhaps a good alternative to mass if-else would be nice). Some of the syntax is meh too.

asshole_rule:

ugh looks so messy and gross to look at

what does loc actually stand for anyway?

Pages: (1/5) >>>

Go to full version