--- reserved for documentation--
This table is for the 1.1 language, for 1.0 language drop the words "npc", "map", "skill" and "monster".
amount of item ItemName | Used as a part of an expression, it returns the number of a certain item in the inventory. |
attack self with skill SkillName | Casts a spell on yourself by the spell name like Cure for example. |
attack monster MonsterName with skill SkillName | Casts a spell on a monster by the spell name. |
change map MapName | [Yet to be implemented] Figures out how to reach a given map name and goes there. |
choose option Integer | Selects an object from the windows that opens when you click an NPC. |
# Comments | A marker used to making comments in the code. |
delay Integer | Same as sleep & wait, delays the script thread for the given amount of time in milliseconds. |
do ActionName | Performs an action. (like dance1, dance2, ..., sit, knell, bow, etc.) (Only other people can see it, not yourself.) |
go to <<Label>> | Jumps execution to a given label in the script. |
goto <<Label>> | Jumps execution to a given label in the script. |
go to X,Y | Uses pathfinder to go to the given (X,Y) coordinates. (Straight line path atm, except for in version 1.1, it uses real pathfinder) |
goto X,Y | Uses pathfinder to go to the given (X,Y) coordinates. (Straight line path atm, except for in version 1.1, it uses real pathfinder) |
mine | Starts mining |
drop item ItemName | Drops an item |
buy item ItemName from npc NpcName | Buys an item from an npc |
sell item ItemName to npc NpcName | Sells an item to an npc |
deposit item ItemName into npc NpcName | Deposits an item into an npc |
deposit item ItemName | Deposits an item into the nearest warehouse |
use item ItemName | Uses an item |
loot item ItemName | Loots an item |
if Expression Actions [elseif/elif Expression Actions [else Actions]] end | Standard if statement |
while Expression Actions | Standard while statement |
when Expression Actions | An event triggered function |
talk to npc NpcName | Talks to an npc |
stop | Stops the execution |
sleep Integer | Delays for the given number of milliseconds |
wait Integer | Delays for the given number of milliseconds |
revive | Revives your character |
revive here | Revives your character here. |
status Expression | Puts text or a value up into status |
msgbox Expression | Produces a message box containing text or a value. |
<<Label>> | Standard label. |
var Identifier [= Expression], Identifier [= Expression], ... | Defines a heap of variables |
all listed here
Bugs discovered in version 1.0
- item panacea <-- refers to the bundle of panacea and not the individual panacea itself, this is from multiple strings with the same itemId in itemtype.dat, must fix this soon.
- do Actions <-- these do work, but you can not see it on your own client, only other clients can see you do the action, because its pure proxy based (the client does not know your doing the action)
- else-statement <-- "if false {code1} else {code2} end", {code2} is skipped.
- scroll bar stuck when too many lines
TODO list for version 1.1
- buy ItemName from NpcName (completed for next version)
- sell ItemName to NpcName (completed for next version)
- deposit ItemName into NpcName (completed for next version)
- mine (completed for next version)
- Relative paths (.\conquer.exe ..\conquer.exe) (completed for next version)
- Fix DCs (simplify code)
- Drop Item (1/2 working for next version (Inventory reading not always accurate))
- Random value generator (complete for next version)
- Enter Mine command (regex on question/answers)
- Add disconnect command (complete for next version)
- Document operators
- Map Variables (completed for next version)
- Option declarations (option priority loot = true)
- Multiline comments (#cs #ce or /* */) (completed for next version)
- fix "else" in the if-statement (complete for next version)
- fix autoscroll when many lines (completed for next version)
- boolean expressions for testing if an item or an npc is on the screen (found item ItemName / found npcName) (complete for next version)
- allowed maps/npcs/items/monsters/skills to be assigned to variables and used (completed for next version)
- proper pathfinder used for "goto x,y" (completed for next version)
Grammar for the curious: (The documentation for while I catch up with the documentation.)
Code:
start = Start
value = AstNode
debug =
namespace = cofreedom
ignore-case = true
# Start
Start := S (Program);
Program := (When / Action / MultilineComment / Comment)* `value = DoProgram(results)`
When := "when" S Expression Actions "end" S `value = new WhenNode(results[1].Value, results[2].Value)`
Action := "disconnect" S `value = DoSysCall(null, "disconnect", 0)`
Action := "mine" S `value = DoSysCall(null, "mine", 0)`
Action := "drop" S Value `value = DoSysCall(results[1].Value, "dropitem", 1)`
Action := "buy" S Value "from" S Value `value = new BuyFromNpcNode(results[3].Value, results[1].Value)`
Action := "sell" S Value "to" S Value `value = new SellToNpcNode(results[3].Value, results[1].Value)`
Action := "deposit" S Value "into" S Value `value = new DepositInNpcNode(results[3].Value, results[1].Value)`
Action := "deposit" S Value `value = new DepositInNpcNode(new NpcName("Warehouseman"), results[1].Value)`
Action := "change" S Value `value = DoSysCall(results[1].Value, "changemap", 1)`
Action := "msgbox" S Expression `value = new AsmNode(results[1].Value, new IrCode.Instruction(IrCode.Mnemonic.SysCall, "msgbox"))`
Action := "use" S Value `value = DoSysCall(results[1].Value, "useitem", 1)`
Action := "loot" S Value `value = new LootItemNode(results[1].Value)`
Action := "jump" S "to" S Coordinate `value = new AsmNode(results[2].Value, new IrCode.Instruction(IrCode.Mnemonic.SysCall, "jump", 2))`
Action := "if" S Expression Actions (("elif" / "elseif") S Expression Actions)* ("else" S Actions)? "end" S `value = DoIf(results)`
Action := "while" S Expression Actions "end" S `value = DoWhile(results)`
Action := "go" S "to" S Coordinate `value = DoSysCall(results[2].Value, "goto", 2)`
Action := "goto" S Coordinate `value = DoSysCall(results[1].Value, "goto", 2)`
Action := "go" S "to" S Label `value = new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.Jmp, results[2].Text.Trim()))`
Action := "goto" S Label `value = new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.Jmp, results[1].Text.Trim()))`
Action := "talk" S "to" S Value `value = DoSysCall(results[2].Value, "talktonpc", 1)`
Action := "choose" S "option" S Expression `value = DoSysCall(results[2].Value, "chooseoption", 1)`
Action := "attack" S "self" S "with" S Value `value = DoSysCall(results[3].Value, "castonself", 1)`
Action := "attack" S "at" S Coordinate "with" S Value `value = DoSysCall(new SequenceNode(results[4].Value, results[2].Value), "castonxy", 3)`
Action := "attack" S Value "with" S Value `value = DoSysCall(new SequenceNode(results[3].Value, results[1].Value), "castontarget", 2)`
Action := "attack" S Value `value = DoSysCall(results[1].Value, "melee", 1)`
Action := "trade" S Value `value = DoSysCall(results[1].Value, "trade", 1)`
Action := "ok" S "trade" S `value = DoSysCall(null, "oktrade", 0)`
Action := "accept" S "trade" S `value = DoSysCall(null, "accepttrade", 0)`
Action := "repair" S "all" S `value = DoSysCall(null, "repairall", 0)`
Action := "vip" S "repair" S "all" S `value = DoSysCall(null, "viprepairall", 0)`
Action := "stop" S `value = new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.End))`
Action := "sleep" S Expression `value = DoSysCall(results[1].Value, "sleep", 1)`
Action := "wait" S Expression `value = DoSysCall(results[1].Value, "sleep", 1)`
Action := "delay" S Expression `value = DoSysCall(results[1].Value, "sleep", 1)`
Action := "revive" S ("here" S)? `value = results.Count == 1 ? DoSysCall(null, "revive", 0) : DoSysCall(null, "revivehere", 0)`
Action := "status" S Expression `value = new AsmNode(results[1].Value, new IrCode.Instruction(IrCode.Mnemonic.SysCall, "status"))`
Action := Label `value = results[0].Value`
Action := "do" S Act `value = new AsmNode(results[1].Value, new IrCode.Instruction(IrCode.Mnemonic.SysCall, "action", 1))`
Action := "var" S Identifier ("=" S Expression)? ("," S Identifier ("=" S Expression)?)* `value = DoVariableDeclaration(results)`
Action := "hitspermob" S "=" S Expression `value = DoSysCall(results[2].Value, "sethitspermob", 1)`
Action := Identifier "=" S Expression `value = new AsmNode(results[2].Value, new IrCode.Instruction(IrCode.Mnemonic.Set, results[0].Text.Trim()))`
Action := Identifier "," S Identifier "=" S "direction" S "of" S Value `value = new MobDirectionNode(results[0].Text.Trim(), results[2].Text.Trim(), results[6].Value)`
Actions := (Action / MultilineComment / Comment)* `value = DoSequence(results)`
Label := "<<" (!">>".)* ">>" S `value = new LabelNode(text.Trim())`
Coordinate := Expression "," S Expression `value = new CoordinateNode(results[0].Value, results[2].Value)` `expected = "coordinate"`
Npc := "npc" S Identifier `value = new NpcName(results[1].Text.Trim())`
Item := "item" S Identifier `value = new ItemName(results[1].Text.Trim())`
Monster := "monster" S Identifier `value = new MonsterName(results[1].Text.Trim())`
Skill := "skill" S Identifier `value = DoSkillName(results[1])`
Player := "player" S Identifier `value = new PlayerName(results[1].Text.Trim())`
Map := "map" S Identifier `value = DoMap(results[1])`
Act := "sit" S `value = new IntegerExpression(0xFA)`
Act := "dance"Value S `value = results[1].Value`
# Expressions
Expression := Relation;
Relation := Sum ("<=" / ">=" / "==" / "!=" / "<" / ">") S Sum `value = new BinaryExpression(results[0].Value, results[2].Value, results[1].Text)`
Relation := Sum `value = results[0].Value`
Sum := Product (('+' / '-') S Product)* `value = DoCreateBinary(results)`
Product := Value (('*' / '/') S Value)* `value = DoCreateBinary(results)`
Value := "amount" S "of" S Item `value = DoSysCall(results[2].Value, "itemcount", 1)`
Value := [0-9]+ '.' [0-9]+ ('e'[0-9]+)? S `value = new FloatExpression(text.Trim())` `expected = "number"`
Value := [0-9]+ 'e' [0-9]+ S `value = new FloatExpression(text.Trim())` `expected = "number"`
Value := [0-9]+ S `value = new IntegerExpression(text.Trim())` `expected = "number"`
Value := '(' Expression ')' S `value = results[1].Value` `expected = "parenthesized expression"`
Value := '"'(!'"'.)*'"' S `value = new StringExpression(text.Trim())` `expected = "string"`
Value := "true" S `value = new BooleanExpression(true)`
Value := "false" S `value = new BooleanExpression(false)`
Value := "mapid" S `value = DoSysCall(new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.PushConst, results[0].Text.Trim())), "getsysval", 1)`
Value := "posx" S `value = DoSysCall(new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.PushConst, results[0].Text.Trim())), "getsysval", 1)`
Value := "posy" S `value = DoSysCall(new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.PushConst, results[0].Text.Trim())), "getsysval", 1)`
Value := "hp" S `value = DoSysCall(new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.PushConst, results[0].Text.Trim())), "getsysval", 1)`
Value := "mp" S `value = DoSysCall(new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.PushConst, results[0].Text.Trim())), "getsysval", 1)`
Value := "gold" S `value = DoSysCall(new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.PushConst, results[0].Text.Trim())), "getsysval", 1)`
Value := "silver" S `value = DoSysCall(new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.PushConst, results[0].Text.Trim())), "getsysval", 1)`
Value := "random" S Expression "," S Expression `value = new RandomNode(results[1].Value, results[3].Value)`
Value := "on" S "map" S Map `value = DoSysCall(results[2].Value, "isonmap", 1)`
Value := "found" S Item `value = DoSysCall(results[1].Value, "founditem", 1)`
Value := "found" S Monster `value = DoSysCall(results[1].Value, "foundmonster", 1)`
Value := "found" S Npc `value = DoSysCall(results[1].Value, "foundnpc", 1)`
Value := Npc `value = results[0].Value`
Value := Item `value = results[0].Value`
Value := Map `value = results[0].Value`
Value := Monster `value = results[0].Value`
Value := Skill `value = results[0].Value`
Value := Player `value = results[0].Value`
Value := Identifier `value = new AsmNode(null, new IrCode.Instruction(IrCode.Mnemonic.Get, results[0].Text.Trim()))`
Identifier := [a-zA-Z][a-zA-Z0-9_]* S;
# Scaffolding
S := Space* `text = null` # We use a separate space rule because x* always succeeds.
Space := [ \t\r\n] `;` `expected = "whitespace"`
Comment := '#' [^\n\r]* S;
MultilineComment := "#cs" (!"#ce".)* "#ce" S;
MultilineComment := "/*" (!"*/".)* "*/" S;
Tips and Tricks:
MultiThreading
When statement blocks can be used to create code that simultaneously executes with each other.
Code:
when true
# put code in here for thread 1
end
when true
# put code in here for thread 2
end
while true
# your main thread code here
end
All 3 commented spots execute all at the same time on a continuous loop. This can be handy in some instances.
Xp Skill
Hacked method, better method will come later.
Code:
# 23/06/2010 4:05:39 AM universal time
when true
attack self with superman
sleep 1000
end
while true
attack Macaque
end
Smart Potter
Code:
var maxhp = hp
when hp > maxhp maxhp = hp end
when maxhp - hp >= 70 use item Stancher end
when maxhp - hp >= 100 use item Resolutive end
when maxhp - hp >= 250 use item Painkiller end
when maxhp - hp >= 500 use item Amrita end
when maxhp - hp >= 800 use item Panacea end
when maxhp - hp >= 1200 use item Ginseng end
when maxhp - hp >= 2000 use item Vanilla end
# Insert your code here, the above code will do the smart autopotter
# while true end # Uncomment this while if you just want a smart potter by itself
General Stuff for Version 1.1+
Code:
if on map TwinCity
status "You are on map TwinCity"
else
status "You are not on map TwinCity"
end
sleep 1000
status "Your map id is " + mapId
sleep 1000
status "Your coordinates are (" + posx + "," + posy + ")"
sleep 1000
status "Your HP is " + hp
sleep 1000
if found monster Pheasant
status "There is a pheasant on your screen"
end
if found item Meteor
status "There is a meteor on the ground"
end
if amount of item TwinCityGate > 0
status "You have a tc scroll in your inventory"
end
if found npc Conductress
status "There's a pretty girl on your screen"
end
Random Jumps v1.1+
Code:
if found monster birdman
attack monster birdman
else
jump to posx + random 0,6 - 3, posy + random 0,6 - 3
end
Warning: There will be a small syntax change when upgrading to version 1.1. The following are the changes:
- monsters will start with the keyword "monster" before the monster name
- npcs will start with the keyword "npc" before the npc name
- items will start with the keyword "item" before the item name
- maps will start with the keyword "map" before the map name
- skills will start with the keyword "skill" before the skill name
do things allows for assigning monsters, npcs, items, maps, and skills to variables for use later on in your script.
For Example:
Code:
var mobs = monster birdman
while true
attack mobs
end