Username: Password:

Author Topic: Scripting Documentation  (Read 15541 times)

Offline =Mindee=

  • Commander Shepard
  • BOT Developer Administrator
  • Dragon
  • *****
  • Posts: 2,788
  • Cookies 9020
  • We'll bang, OKAY?
    • View Profile
    • http://mindee-bot.com
Scripting Documentation
« on: January 17, 2020, 03:52:58 PM »
Events

onScriptActivation()
Executed: after activating the script

onScriptDeactivation()
Executed: before deactivating the script

onReceiveItemOnGround(x, y, z, itemId)
Executed: when item appears on ground (dropped for example)

onChangeLocation(x, y, z)
Executed: when x,  y or z is changed.

onReceivePlatinumUpdate(platinum)
Executed: when platinum count is received

onReceiveCurrentHp(hp)
Executed: when current HP is changed

onReceiveCurrentMp(mp)
Executed: when current MP is changed

onReceiveEnemyHp(uid, hp_percent, name)
Executed: when enemy HP percentage is received

onReceiveRemoveItemFromGround(x, y, z)
Executed: when item on ground is removed (taken for example)

onReceiveClearBackpack(slot, itemId)
Executed: when backpack slot is erased (dropped item, used potion, etc)

onReceiveAddItemToDepot(slot, itemId)
Executed: when item is stored to a slot in depot

onReceiveAddItemToBackpack(slot, itemId)
Executed: when item appears in backpack slot (taken, retrieved from depot, bought, etc)

onReceiveGroundText(x, y, z, type, text)
Executed: when ground text appears ('X EP or anything else like damage values)

onKilledEnemy(name, templateId)
Executed: when character kills an enemy

onReachedLocation(x, y, z)
Executed: when character reaches location after executing GoToNpc or GoToLocation methods

onReachedNpc(uid, name)
Executed: when npc is reached after executing GoToNpc and GoToNpcEx methods

onReceiveTalkWithNpc(name)
Executed: when chat with npc is started

onReceiveLeavedNpc()
Executed: when chat with npc is ended

onReceiveNpcText(name, text, page)
Executed: for each npc chat text
*page is deprecated

onReceiveNpcAnswer(text, id)
Executed: for each npc chat option
Must return True/False. False = stop proceeding all other npc options.

onReceiveNpcAnswers(answers)
Executed: all npc chat options at once as a list

onReceiveQuestLogUpdate(text)
Executed: when quest log is updated

onReceiveDirectionMarker(x, y, z, text)
Executed: when received new direction marker

onWaypointsEnded()
Executed: when reached waypoints end and there are nowhere else to go

onReceiveLeftShop()
Executed: when left the current shop character was in.

onReceiveEnteredMenu(shopPacket, menuId, title)
Executed: when entered menu. <1/0 if entered shop, unique menu id, menu title>

onReceiveMenuRows(rows)
Executed: after receiving all menu rows
Row values: menuId, menu row id, menu row name, templateId (itemId, look, etc)
Row values are textual.

onReceiveMenuRowsEx(rows)
Executed: after receiving all menu rows. Rows contain more information from menu.
Row values: menuId, menu row id, menu row name, templateId (itemId, look, etc), menu row name (again), unused string, price/etc, is row activated or not
Row values are textual.

onReceiveMenuText(menuId, title, text):
Executed: when menu text packet is received.

onReceiveFullBackpack(slot1, slot2, slot3, slot4, slot5.....slot16)
Executed: on full backpack update (log in, etc)

onTalkedWithNpc(uid, result (true/false))
Executed: when used TalkToNpc or used GoToNpc functions. If result = false, you can use this event to try to talk to npc again.

onDisconnect(info)
Executed: when character is being disconnected

onConnect()
Executed: when character connects to the game

onTick()
Executed: every x milliseconds. Use script.EnableTickEvent(interval) function to enable it.

onReceiveAddCreature(uid, spawn, dir, name, obj_type, icon, looktype)
Executed: when new creature appears on screen.

onRemoveCreature(uid, name, looktype, entity_type, x, y, z)
Executed: when creature gets removed from screen. (Death, logout, teleport somewhere, etc)

onReceivePrivateMessage(name, text)
Executed: when someone sends you a private message.

onReceiveGuildChat(name, text)
Executed: when guild member sends a message in guild chat.

onReceivePublicChat(uid, name, text)
Executed: when someone speaks in public chat nearby.

onReceivePingPacket()
Executed: every ~1 minute when cipsoft pings client. (Doesn't work when char is walking)

onReceiveUserData(icon, looktypeId)
Executed: every 3-5 seconds when server updates client outfit. Can be used as a timer or etc.

onReceiveItemDescription(itemId, name)
Executed: when received item in backpack/when looked at item's description.
Return: 1 - if you want bot to drop that item, 0 - keep it.

onReceiveItemDescriptionEx(itemId, name, slot)
Executed: when received item in backpack/when looked at item's description.

onReceiveItemDescriptionBackpack(itemId, name, slot)
Executed: when received item in backpack only.

onReceiveGameMessage(text):
Executed: when server broadcasts message or when you look at tile and etc.

onEraseMonsterHealth():
Executed: when enemy health bar is erased.

onCharacterInactive():
Executed: when character inactive alarm is played.

onReceiveNpcDialogue(name, text, answers):
Executed: when npc text and answers are received.
answers is array
To check if answer is in array use something like that: if 'blabla' in answers:
To get answer id, use script.GetAnswerId('answer', answers) function.

onSkillDeactivated(skill):
Executed: when skill effect is finished and skill enters cooldown phase.
<skill: 1 - left, 2 - right>

onSkillActivated(skill):
Executed: when skill gets activated.
<skill: 1 - left, 2 - right>

onSkillExecuted(skill):
Executed: when skill gets executed (used).
<skill: 1 - left, 2 - right>
Won't work if skill is running out and you're not attacking anyone, because at that condition server only updates it when time is up.

onReachedTileLocation(spriteId, location, inline (True/False - inline or on tile)):
Executed: when script.GoToTile function finishes moving character.

Methods

script.ShowMessage('text', 'title')
- Displays window message

script.StatusMessage('text')
- Displays ingame message

script.SetWay(setId:byte, reverse:byte)
- Sets current waypoints set <set_id, 1 - reverse / 2 - don't reverse / 0 - keep default>

script.GetWay()
- Returns current waypoint set

script.GetX()
- Returns current x position

script.GetY()
- Returns current y position

script.GetZ()
- Returns current z position

script.GetExp()
- Returns current experience

script.GetGold()
- Returns current gold

script.GetPlatinum()
- Returns current platinum

script.SetVar('key', value)
- Sets variable by key.
Key must be a string, value can be any type.

script.GetVar('key')
- Returns variable by key or 0 if variable not set.

script.SetRegVar('key', value)
- Sets variable in script registry by key.
Key must be a string, value can be any type.

script.GetRegVar('key')
- Returns variable from script registry by key or 0 if variable not set.

script.GoToNpc('name', range:int)
- Goes to specified npc nearby <name, range 1-8>
- Returns true if success, false otherwise

script.ForgetNpc()
- Forget npc executed by "GoToNpc"

script.EndNpcChat()
- Send 'Farewell" to npc.

script.ChooseNpcOption(option:byte)
- Choose npc chat option by id <id 0-xx>

script.Alarm('text')
- Play bot alarm with specified text <text>

script.GoToLocation(x, y, z)
- Goes to specified location nearby <x, y, z>

script.LogoutFor(seconds)
- Logs out character for n seconds.

script.Logout()
- Logs out character permanently.

script.LogoutUntil('timeOfDay')
- Logs out character until time of day. Format: HH:MM (Example.: 17:45)

script.LogoutUntilEx('timeOfDay', offset)
- Logs out character until time of day with offset in seconds. Format: HH:MM (Example.: '17:45', -60 -> Will relog at 17:45 - 60 seconds)

script.DisconnectAt('time' )
- Logs out character at specified time of day. Format: HH:MM (Example.: 17:45)

script.DisconnectAtUntil('time' , 'time' )
- Logs out character at specified time of day and relogs at specified time of day. Formats: HH:MM (Example.: 17:45, 21:30)

script.DisconnectAtUntilEx('time' , 'time', offset)
- Logs out character at specified time of day and relogs at specified time of day with offset in seconds. Formats: HH:MM (Example.: '17:45', '21:30',  -60 -> Will relog at 21:30 - 60 seconds)

script.GetCurrentTime()
- Returns current time in seconds.

script.GetItemsCount(itemId, true/false (include inventory/depotmail or not))
- Gets current items count in backpack and inventory/depotmail if set to true.

script.GetItemsCountWithInventory(itemId)
- Gets current items count in backpack and inventory.

script.GetFreeBackpackSlot()
- Returns empty slot id in backpack or 255 if no free slots are available.

script.GetFreeInventorySlot()
- Returns empty slot id in inventory or 255 if no free slots are available.

script.GetFreeDepotMailSlot()
- Returns empty slot id in depotmail or 255 if no free slots are available.

script.IsStorageFull()
- Returns true/false if all containers (backpack, inventory and depotmail) are full.

script.EnterShop()
- Enters nearby shop. Shop must be one step away. Returns true/false if success.

script.LeaveShop()
- Leaves current shop and refreshes depotmail, inventory.

script.LeaveShopEx()
- Leave current shop.

script.GetTabId()
- Returns the id of bot tab in which script is executed.

script.ChooseShopOption(menuId, optionId)
- Chooses shop option like Buy, Sell, etc.

script.ChooseMenuOption(menuId, optionId, listOptionId)
- Chooses menu option id.

script.IgnoreMonsters(1/0 - enable/disable)
- Ignores all monsters if activated.

script.DropItem(slotId, 1/0 - should search for free spot or not)
- Drops item from specified slot 1-16 and 101-102. 101 = left skill, 102 = right skill.
- Returns 'ok' if success, otherwise returns error message.
Messages:
'forbidden_main_weapon', 'no_room', 'item_not_found', 'protection_zone', 'offline', 'forbidden_1', 'forbidden_2', 'forbidden_3', 'forbidden_4', 'forbidden_5', 'forbidden_6', 'in_shop'

script.IsInLoot(itemId)
- Returns 1/0 if item is in autoloot list or not.

script.GoToNpcEx(name)
- Different go to npc function. This one doesn't talk to npc automatically.
(Use onReachedNpc(uid, name) event to talk to npc)

script.TalkToNpc(uid)
- Talks to npc. Npc must be in line with you (one step distance).

script.EnableTickEvent(interval)
- Enables/disables onTick() event in script. Interval < 100 will disable tick event. Anything above will enable it and tick event will run every "interval" milliseconds.
1000 milliseconds = 1 second.

script.Say(text)
- Character says "text" in public chat. Text length can't exceed 40 letters.
- Limit is one message per 6 seconds.

script.SayDelay(text, delay)
- Character says "text" in public chat. Text length can't exceed 40 letters.
- Message is delayed for x seconds.

script.IsInShop()
- Returns 1 / 0 if character is in shop or not.

script.GetItemSlot(itemId)
- Returns first slot with provided itemId or 0 if no items were found.

script.GetItemInSlot(slot)
- Returns itemId from backpack slot.

script.ToggleTargetSwitch(1/0)
- Enable / disable target switching features. (Good for Don Correc quest to avoid killing more monsters)

script.PZChecksForDrop(1/0)
- Enable / disable safe zone checks from DropItem function. Enabled by default to avoid dropping items in town.

script.GetStaminaTime()
- Returns current stamina in minutes. 3360 = 56h.
Just calculate stamina hours by 60 and add minutes. If your stamina is 54:32, then time will be 54*60+32 = 3272

script.GetStaminaText()
- Returns current stamina text like "56:00".

script.UseItemSlot(slot)
- Uses item in slot 1-9 or skill in slot 101-102.
- Returns 1/0 (true/false) if success.

script.UseItemId(itemId)
- Finds item by id in backpack and uses it if available.
- Returns 1/0 (true/false) if success.

script.UseItemSlotEx(slot, delay)
- Uses item in slot 1-9 or skill in slot 101-102 with delay in milliseconds. 1000 = 1 second.
- Returns 1/0 (true/false) if success.

script.UseItemIdEx(itemId, delay)
- Finds item by id in backpack and uses it if available with delay in milliseconds. 1000 = 1 second.
- Returns 1/0 (true/false) if success.

script.ToggleStaminaSystem(type, 1/0 - enable, disable)
- Enable/disable stamina system. Type 1 = new stamina system, 2 = old stamina system.

script.SuspendStaminaSystemOnReconnect(1/0 - true/false)
- Don't enable any stamina system when reconnecting to the game if it's enabled in waypoints file.
(if player uses ToggleStaminaSystem(1, 0) to disable stamina and then relogs after dc, stamina becomes enabled again.
This function prevents that.)
Perfect place for this functions is in onScriptActivation/Deactivation events.

script.ToggleSpell(type, 1/0 - enable/disable)
- Enable/disable spell. Type 1 = range spell, 2 = all direction spell, 3 - new area spell, 4 - buff spell.

script.LookAt('direction')
- Character looks at tile. Takes stuff from chests, etc. Directions: 'up', 'down', 'left', 'right'

script.IsLocationFree(x, y, z)
- Returns 1/0 if location is free for item drop.

script.GetSecondsFromHM('HH:MM')
- Converts time of day to seconds.

script.GetSecondsFromHMS('HH:MM:SS')
- Converts time of day to seconds.

script.IsItTime('HH:MM', offsetInSeconds, 0/1 (compare by seconds too))
- Checks if provided time is current time.

script.LoadFile('path')
- Loads waypoints file with settings and script. It works like "Load" button.
- Returns "success" or error text.
Path must be like "C:/blabla/blabla/blabla/waypoints.bot"

script.IsSkillEnabled(1/2)
- Returns 1/0 if skill option(left - 1, right - 2) is enabled.

script.IsSkillActivated(1/2)
- Returns 1/0 if skill (left - 1, right - 2) is activated.

script.ToggleSkill(skill, 1/0)
- Enable/disable skill. (Left -1, right - 2) (1/0 - enable/disable)

script.ChangePetSlotId(newslot)
- Change pet slot selection to a new slot.

script.IsEntityOnScreen('name', 0-8 (range), 1/0 (should check if can reach entity or not))
- Checks if an entity with specified name is on screen.
- Returns 1/0 (true/false).

script.RunEvent('eventName', delay)
- Runs event/method after delay.
For example if you have function "def doStuff():", you can use this to run it after delay like that: script.RunEvent('doStuff', 1000)
Delay is in milliseconds. 1000 = 1 second.
script.RunEvent('doStuff', 0) is same as just calling doStuff().

script.ActivateSkill('skill name', 1/2 - left/right)
- Activates skill by name, enables skill option if disabled and enables "Activate saved skills" option if not enabled.
- Returns result as string.
Skill names can be found here: https://mindee-bot.com/forum/index.php/topic,1796.0.html
Make sure that your character has a specified skill before using this function!

script.ActivateSkillId(skillId, 1/2 - left/right)
- Activates skill by id, enables skill option if disabled and enables "Activate saved skills" option if not enabled.
- Returns result as string.
Skill ids can be found here: https://mindee-bot.com/forum/index.php/topic,1796.0.html
Make sure that your character has a specified skill before using this function!

script.SetSkillOption(0/1/2 - Other skill settings/Left skill/Right skill, 0-xx - skill option, 0-xxx - skill option value)
- Sets specified skill settings.
If skill option is a checkbox, then skill option value 1 enables it or anything else disables it.
Skill options:
0 - ENABLE
1 - Use only when under attack.
2 - Including Ignored Mobs
3 - Switch target when Enemy HP <= %:
4 - Switch target when Enemy HP <= % value.
5 - Use when Enemy HP > %:
6 - Use when Enemy HP > % value.
7 - Use when Character HP < %:
8 - Use when Character HP < % value.
9 - Use when Character MP < %:
10 - Use when Character MP < % value.
11 - Use when Enemy HP <= % value. (Second value for <= %) (Only for left skill)
(Other Skill Settings)
0 - Use LEFT skill first.
1 - Use RIGHT skill first.
2 - Activate only one skill at the time.
3 - Activate saved skills (if not active).

script.ToggleAutoloot(1/0 - enabled/disabled)
- Enables/disables autoloot feature.

script.ClearItemList(0/1/2/3 - type)
- Clears all or autoloot or inventory/depotmail storage item lists.
0 - all
1 - autoloot
2 - inventory
3 - depotmail

script.SetItemList(0/1/2/3 - type, 'itemid,itemid,itemid...')
- Sets specified items list. (Example: script.SetItemList(0, '5126') - sets list to one item only)
0 - all
1 - autoloot
2 - inventory
3 - depotmail

script.AddItemToList(0/1/2/3 - type, itemId)
- Adds item to specified list.
0 - all
1 - autoloot
2 - inventory
3 - depotmail

script.RemoveItemFromList(0/1/2/3 - type, itemId)
- Removes item from specified list.
0 - all
1 - autoloot
2 - inventory
3 - depotmail

script.IgnoreNextItem(itemId)
- Ignore next dropped item by id (by your character). (Prevents picking same item again if it's in autoloot)

script.GetAnswerId('answer', answers)
- Returns npc dialogue answer id or -1 if not found.

script.ClearScriptChat()
- Clears script chat.

script.SetIgnoredMobsList('list')
- Sets ignored monsters list.

script.ResetIgnoredMobsList()
- Resets ignored monsters list to default saved list in waypoints file.

script.ToggleStorage(1/0 - enable/disable)
- Enables/disables storage feature in bot.

script.PauseMovement(1/0 - pause/resume)
- Pauses/resumes movement.

script.IsStorageRunning()
- Returns True/False if item storage is running at the moment or not.

script.FindSprite(spriteId)
- Finds sprite nearby and returns Location object or None if not found. (In pathfinding range)
Ids can be found here: https://mindee-bot.com/forum/index.php/topic,1834.0.html
Example:
Code: [Select]
pos = script.FindSprite(2600)
if pos == None:
   script.StatusMessage('Not found!')
else:
   script.StatusMessage('X: ' + str(pos.X) + ' Y: ' + str(pos.Y) + ' Z: ' + str(pos.Z))

script.GoToTile(location, spriteId, True/False - should go onto tile or just stay by side)
- Moves character to tile at location (to script.FindSprite return value).
- Returns True/False if function was launched successfully.
Pass spriteId only if you need to know it in onReachedTileLocation() event. Or put 0.

script.GetItemList(1/2/3 - type)
- Returns specified items list as string (text).
1 - autoloot
2 - inventory
3 - depotmail
« Last Edit: December 25, 2023, 06:31:17 AM by =Mindee= »




Mindee-BOT creator, founder and developer.

Offline =Mindee=

  • Commander Shepard
  • BOT Developer Administrator
  • Dragon
  • *****
  • Posts: 2,788
  • Cookies 9020
  • We'll bang, OKAY?
    • View Profile
    • http://mindee-bot.com
Re: Scripting Documentation
« Reply #1 on: June 28, 2020, 01:31:11 PM »
Events Part 2

onUpdateSpellStatus(canuse, cooldown):
Executed: when spell status gets changed.
canuse (True/False)

onReceiveDepotMenu(depot_name, depot_id, depot_type, slots):
Executed: when character enters depot or opens inventory/depotmail.
depot_type 0 = inventory, 1 = depotmail, 2 = depot
slots - available slots.

onEffectChanged(effect):
Executed: when character effect is changed. ('BUFF', 'DEBUFF', 'NONE', 'UNKNOWN')

onDroppedItem(from_slot):
Executed: when bot is dropping item from slot.

onEncryptedScriptLoad(status):
Executed: when encrypted script is loaded or failed to load.

onReceiveGroundAnimation(location, anim):
Executed: when any animation is played on any tile around (attack, spawn, skill, spell, etc)
Example:
Code: [Select]
def onReceiveGroundAnimation(loc, anim):
script.StatusMessage(str(loc) + ' : ' + str(anim))
if anim == 20:
blabla

onReceiveFullItemDescriptionEx(itemId, name, desc1, desc2, slot):
Executed: when received item in backpack/when looked at item's description.

onReceiveSkillCooldown(skillId, cooldownEnd, cooldownTime, state):
Executed: when skill cooldown is updated.
skillId: 1 - left, 2 - right
cooldownEnd: time when skill cooldown ends in seconds
cooldownTime: cooldown time value in seconds
state: 0 - skill is dropped, 1 - cooldown state, 2 - can be used, 4 - activated, but running out, 5 - activated

onSkillCooldownTick(skillId, tick, totalTime, isCooldown):
Executed: every second of cooldown/running out.
skillId: 1 - left, 2 - right
tick: current cooldown tick
totalTime: total cooldown/usage time of skill
isCooldown: True - skill is in cooldown stage, False - skill is in use and running out

onCurrentTime(hh, mm, ss, ms, time):
Executed: every 1 second after script activation.
hh - hours
mm - minutes
ss - seconds
ms - milliseconds since January 1st, 1970
time - time in textual format 'hh:mm'.

onReceiveGuildMemberInfo(uid, name, hp, mp):
Executed: when guild member information is received.
uid - unique id
name - guild member name
hp - current hp in percentage
mp - current mp in percentage

Methods Part 2

script.BroadcastMessage('text')
- Displays ingame message. Same like StatusMessage, but a different packet.

script.ForgetLocation()
- Forgets GoToTile location.
Use this when you want to return to waypoints (if using any).

script.HasTarget()
- Returns True / False if character has target. (GoToNpc, EnterShop, GoToTile, etc)

script.GetSpellStatus()
- Returns True / False if character can use spell at the moment or not. (Cooldown)

script.ChangeBuffSlotId(slot)
- Change buff slot selection to a new slot.

script.ChangeSpellSlotId(slot)
- Change range attack spell slot selection to a new slot.

script.IsCharacterOnline()
- Returns True/False if character is online in game or not.

script.GetCharacterName()
- Returns character name or null if character not found.

script.GetCharacterWorld()
- Returns character world or 1000 if character not found.

script.GetUniqueKey()
- Returns unique key for character. (Can be used in script.SetRegVar())

script.GetBackpackItems()
- Returns list of all backpack items from slot 1 to slot 16.
Code: [Select]
items = script.GetBackpackItems()
script.StatusMessage('My weapon id is: ' + str(items[9])) # 0 is slot 1, 9 is slot 10 (weapon slot) and so on.

script.RetrieveItem(itemId)
- Retrieves item from inventory.
- Returns True/False if success or not.

script.RetrieveItemTo(itemId, slot)
- Retrieves item from inventory to specified slot. If slot contains item, replaces it.
- Returns True/False if success or not.

script.RetrieveSlot(slot)
- Retrieves item from specified inventory slot.
- Returns True/False if success or not.

script.RetrieveSlotTo(slot, to_slot)
- Retrieves item from specified inventory slot to specified backpack slot.  If backpack slot contains item, replaces it.
- Returns True/False if success or not.

script.StoreItem(itemId, to_inventory(True/False))
- Stores first specified item from backpack to inventory/depotmail.
- Returns backpack slot id from which item was stored or -1 if storage failed.

script.StoreItemTo(itemId, to_slot, to_inventory(True/False))
- Stores first specified item from backpack to specified inventory/depotmail slot.
- Returns backpack slot id from which item was stored or -1 if storage failed.

script.StoreSlot(slot, to_inventory(True/False))
- Stores item from specified backpack slot.
- Returns inventory/depotmail slot in which item was stored or -1 if storage failed.

script.StoreSlotTo(slot, to_slot, to_inventory(True/False))
- Stores item from specified backpack slot to specified inventory/depotmail slot.
- Returns True/False if success or not.

script.SwitchToInventory()
- Switches to inventory. Works only when inside depot/inventory/depotmail.

script.SwitchToDepotmail()
- Switches to depotmail. Works only when inside depot/inventory/depotmail.

script.SwitchDepotPage(depotId)
- Switches to specified depot id. Works only when inside depot.

script.ForceCloseInventory()
- Forces bot to close inventory/depotmail.

script.RunEventEx('eventName', variable, delay)
- Runs event/method after delay with variable included.
For example if you have function "def doStuff(itemId):", you can use this to run it after delay like that: script.RunEvent('doStuff', 1234, 1000)
Delay is in milliseconds. 1000 = 1 second.
script.RunEventEx('doStuff', 1234, 0) is same as just calling doStuff(1234).
Variable can be any type.

script.LookAtBackPackSlot(slot)
- Looks at specified backpack slot and then onReceiveItemDescription event is executed.

script.GetEffect()
- Returns current character effect. ('BUFF', 'DEBUFF', 'NONE', 'UNKNOWN')

script.GetStatistics(type)
- Returns received exp and gold, killed monsters.
Types:
0 - received exp
1 - received total exp
2 - received gold
3 - received total gold
4 - killed monsters
5 - killed monsters (total)
6 - experience per hour
7 - gold per hour
8 - experience left for the next level
9 - current monster
10 - curent HP
11 - current HP %
12 - max HP
13 - curent MP
14 - current MP %
15 - max MP
16 - script log
17 - walking status
18 - stamina

script.PauseStorage(True/False)
- Pauses/resumes item storage. Good for dropping unwanted items, etc.

script.ToggleAntiPvp(True/False)
- Enable/disable antitrap pvp feature.

script.ChooseShopOptionEx(menuId, optionId, delay)
- Chooses shop option like Buy, Sell, etc with delay. (ChooseShopOption uses 3000 (3s) delay)
- 1000 = 1s, 0 = no delay.
(Also works with other menus, not just shop)

script.ChooseMenuOptionEx(menuId, optionId, listOptionId, delay)
- Chooses menu option id with delay. (ChooseMenuOption uses 3000 (3s) delay)
- 1000 = 1s, 0 = no delay.

script.SetSpellBelowMobHp(percentage)
- Set percentage for "Use at <=%" in spell settings. 0 = disable.

script.IsTalkingToNpc()
- Returns True/False if currently talking to npc or not (talking via script).

script.PauseMovementEx(resume_delay)
- Pauses movement and resumes after delay (seconds). (If not canceled by running script.PauseMovement(True/False) function)

script.SetCharRegVar('key', value)
- Sets variable in script registry by key for current character.
Key must be a string, value can be any type.

script.GetCharRegVar('key')
- Returns variable (for current character) from script registry by key or 0 if variable not set.

script.TogglePeacefulHunt(True/False)
- Enable / disable peaceful hunt feature.

script.ToggleDisableStaminaInSets(True/False)
- Enable / disable "Disable Stamina In Sets" feature.

script.ToggleDisableStaminaNotInSets(True/False)
- Enable / disable "Disable Stamina Not In Sets" feature.

script.SetDisableStaminaInSetsList(list)
- Sets 'Disable Stamina In Sets" waypoint sets list. Format: id,id,id and so on.

script.SetDisableStaminaNotInSetsList(list)
- Sets 'Disable Stamina Not In Sets" waypoint sets list. Format: id,id,id and so on.

script.AddSetInSets(setId)
- Adds waypoint set id to 'Disable Stamina In Sets" waypoint sets list.

script.AddSetNotInSets(setId)
- Adds waypoint set id to 'Disable Stamina Not In Sets" waypoint sets list.

script.RemoveSetInSets(setId)
- Removes waypoint set id from 'Disable Stamina In Sets" waypoint sets list.

script.RemoveSetNotInSets(setId)
- Removes waypoint set id from 'Disable Stamina Not In Sets" waypoint sets list.

script.GetVocationId()
- Returns player vocation id.
1 = warrior, 2 = wizard, 0 = not set (using mask?)

script.GetStorageRoom(type)
- Returns number of free slots in specified storage.
0 = backpack, 1 = inventory, 2 = depotmail

script.IsUsingMenu()
- Returns True/False if character is using any menu (inventory/depotmail, status, etc)

script.ToggleMovement(True/False)
- Enable/disable movement in "MOVE" settings.

script.ToggleMovementAll(True/False)
- Enable/disable movement for all tabs in "MOVE" settings.

script.SendPM(name, text)
- Sends private message to player.

script.ChooseMenuOptionText(menuId, optionId, text, delay)
- Chooses menu option with input text. Delay = 0 = instant execution.

script.LoadEncryptedScript(path, True/False - ignore script activation event or not)
- Loads encrypted script from file system. (Ex.: 'C:/blabla/script.bin')
- Returns status (success, failed, etc)

script.ResetCounter(type)
- Resets counter(s). 0 = All, 1 = experience, 2 = gold, 3 = monsters, 4 = steps.

script.GetTargetLocation()
- Returns location object of current target.
Example code will display target Y position (use X, Y or Z):
Code: [Select]
loc = script.GetTargetLocation()
script.StatusMessage(str(loc.Y))
str(loc) - will display whole location string.

script.AttackInLine('name')
- Attacks monster by name in line if found (1 range).

script.SetPathfindingRange(range)
- Sets pathfinding range.

script.GetWayName()
- Returns name of current waypoint set.

script.DisplayAnim(x, y, type)
- Plays specified animation on ground at specified x, y position.
Spawn point under char = 119, type = 1->n

script.DisplayText(x, y, type, 'text')
- Plays specified text on ground at specified x, y position.
Spawn point under char = 119, type = 1->n

script.GetMobsAround()
- Returns a string with monster names around.

script.GetPlayersAround()
- Returns a string with player names around.

script.GetNpcsAround()
- Returns a string with npc names around.

script.ReceivedInventory()
- Returns True / False if inventory info was received. (After connection to the game)

script.AttackDirInLine(dir)
- Attacks monster at direction in line.
- Returns True / False if success or not.
- Directions:
  North = 0,
  East = 1
  South = 2
  West = 3

script.GetNextDirection()
- Returns direction to the next step in path.
- Directions:
  North = 0,
  East = 1
  South = 2
  West = 3

script.GetNextStep()
- Returns Location of the next step in path.
Example:
Code: [Select]
def onScriptActivation():
   location = script.GetNextStep()
   script.StatusMessage("location: " + str(location))
   script.StatusMessage("X: " + str(location.X) + " Y: " + str(location.Y) + " Z: " + str(location.Z))

script.GetPrevStep()
- Returns Location of the previous step in path.
Example:
Code: [Select]
def onScriptActivation():
   location = script.GetPrevStep()
   script.StatusMessage("location: " + str(location))
   script.StatusMessage("X: " + str(location.X) + " Y: " + str(location.Y) + " Z: " + str(location.Z))

script.ToggleForcePath(True/False)
- Enables / Disables "FORCE STAY ON PATH" option in bot.

script.GetMobUidAtDir(direction)
- Returns unique id of mob at direction or -1 if there is no mob at direction.
- Directions:
  North = 0,
  East = 1
  South = 2
  West = 3

script.GetSkillTick(skillId)
- Returns current tick of the skill. skillId: 1 - left, 2 - right.

script.DeleteCharRegVar('variable')
- Deletes character variable from registry.

script.DeleteCharRegVars()
- Deletes all registry variables of current character.

script.RetrieveToBackpack(itemid, type)
- Retrieves item by id from current depot to an empty slot of backpack.
- type: 0 - inventory, 1 - depotmail, 2 - depot
- Returns True/False if success or not.

script.RetrieveSlotToBackpack(slot, type)
- Retrieves item from specified current depot slot to an empty backpack slot.
- type: 0 - inventory, 1 - depotmail, 2 - depot
- Returns True/False if success or not.

script.RetrieveToBackpackSlot(itemId, backpackSlot, type)
- Retrieves item by id from current depot to specified slot of backpack.
- type: 0 - inventory, 1 - depotmail, 2 - depot
- Returns True/False if success or not.

script.RetrieveSlotToBackpackSlot(slot, backpackSlot, type)
- Retrieves item from specified current depot slot to specified slot of backpack.
- type: 0 - inventory, 1 - depotmail, 2 - depot
- Returns True/False if success or not.

script.StoreInDepot(itemid)
- Stores item by id from backpack to an empty slot of current depot.
- Returns True/False if success or not.

script.StoreSlotInDepot(slot)
- Stores item from specified backpack slot to an empty current depot page slot.
- Returns True/False if success or not.

script.StoreInDepotSlot(itemId, depotSlot)
- Stores item by id from backpack to specified slot of current depot page.
- Returns True/False if success or not.

script.StoreSlotInDepotSlot(slot, depotSlot)
- Stores item from specified backpack slot to specified slot of current depot page.
- Returns True/False if success or not.

script.GetCurrentDepotItems()
- Returns list of opened depot page items.

script.GetFreeDepotSlot()
- Returns first free slot available in current depot page or 255 if no slots found.

script.GetFreeDepotSlotCount()
- Returns number of free slots in current depot page.

script.GetInventoryItems()
- Returns items list of inventory or None if player is null.

script.GetDepotmailItems()
- Returns items list of depotmail or None if player is null.

script.GetDepotItems()
- Returns items list of current depot page or None if player is null.

script.GoToLocationEx(x, y, z)
- Forces character to go to a specified x, y, z location. Location must be in range 100.
- Returns True / False if execution was successful.

script.IsOnScreen(x, y, z, range)
- Returns True / False if x, y, z coordinates are visible to current location of character.

script.GetTileType(x, y, z)
- Returns tile type at position as string (text).
- Types: 'NONE' (Does not exist), 'WALKABLE', 'BLOCKING', 'STAIRS', 'PORTAL', 'SHOP'.

script.IsTileBlocking(x, y, z, type)
- Returns True / False if tile at location is blocking. if type is set as True, then it will count shops, portals and stairs as blocking too.

script.MoveUp()
script.MoveDown()
script.MoveLeft()
script.MoveRight()
- Forces character to move one step to direction.
- Returns True / False if function was executed.

script.GetEntityNameAt(x, y, z)
- Returns monster/player/pet/npc name at specified location.

script.SetWalkingSpeed(speed)
- Changes walking speed.

script.AttackEntity('name', move (True = move to target, False = don't)
- Tries to attack anything by name (any mob, pet, player, etc)

script.IsGuildMemberBelowHp(hp_percent, range)
- Returns True / False if any guild member in range is below specified hp percentage.

script.GetHP()
- Returns current HP value of character. If character is null -> returns 65535.

script.GetMP()
- Returns current MP value of character. If character is null -> returns 65535.

script.GetHPPercent()
- Returns current HP percentage of character. If character is null -> returns 255.

script.GetMPPercent()
- Returns current MP percentage of character. If character is null -> returns 255.

script.IsPVPArea()
- Returns True / False if current tile is in PVP Area.

script.Login()
- Connects character back to the game.
- Returns '[success]' if successs, otherwise returns an error message.

script.ClearAllChats()
- Clears all chats.

script.ToggleRunMobs(True/False)
- Enables / disables running from ignored monsters.

script.FindSpriteEx(spriteId, range)
- Finds sprite in range and returns Location object or None if not found.
Ids can be found here: https://mindee-bot.com/forum/index.php/topic,1834.0.html
Example:
Code: [Select]
pos = script.FindSpriteEx(2600, 1)
if pos == None:
   script.StatusMessage('Not found!')
else:
   script.StatusMessage('X: ' + str(pos.X) + ' Y: ' + str(pos.Y) + ' Z: ' + str(pos.Z))

script.IsLooting()
- Returns True / False if character is going to loot an item at the moment (going to item, etc).

script.GetPlayersInRange(range)
- Returns a list of player names in specified range. (name,name,name,etc)

script.MoveUpEx(delay)
script.MoveDownEx(delay)
script.MoveLeftEx(delay)
script.MoveRightEx(delay)
- Forces character to move one step to direction with delay (1000 = 1 second). (This function doesn't return anything)

script.GetSkillId(True/False - offensive/defensive)
- Returns skill id.

script.ChangeSpellMP(value)
- Change mp required value for attack spell.

script.ChangeBuffMP(value)
- Change mp required value for buff spell.

script.IsSpriteAtLocation(x, y, z, spriteId)
- Returns True/False if specified tile spriteId is at location.

script.GetNextSteps()
- Returns an array of the next steps of the waypoint. (Step = Location object, so for example to get x, use blabla.X and so on.)

script.IsSpriteInCollision(spriteId)
- Returns True if sprite is in map collision list (Use -> Misc -> Map Collision).
- Returns False if Map Collision is disabled or sprite is not in the list.

script.DisableStorageInfo(True/False)
- Disables/Enables storage/retrieval status messages.

script.GetSkillName(True (left)/False (right))
- Returns currently in use (by bot) skill name of specified skill type.

script.IsSpellEnabled(type)
- Returns True/False if specified spell option is enabled in bot.
Code: [Select]
0 - attack/shoot spell.
1 - four direction spell.
2 - area spell.
3 - healing spell.
4 - buff spell.

script.GetHpPotionsList()
- Returns list of hp potions from Use -> Potions.

script.GetMpPotionsList()
- Returns list of mp potions from Use -> Potions.

script.ToggleRelogAfterTrapPvp(True/False)
- Enable/disable relogging in seconds after trap by pvp option.

script.GetItem(x, y)
- Returns item id of specified location on screen, or 0 if tile has no item.

script.ToggleBuffRange(True/False)
- Enables/disables "Don't when mobs in range" option for BUFF spell.
« Last Edit: Yesterday at 06:08:24 AM by =Mindee= »


Mindee-BOT creator, founder and developer.

Offline =Mindee=

  • Commander Shepard
  • BOT Developer Administrator
  • Dragon
  • *****
  • Posts: 2,788
  • Cookies 9020
  • We'll bang, OKAY?
    • View Profile
    • http://mindee-bot.com
Re: Scripting Documentation
« Reply #2 on: August 01, 2020, 05:10:38 PM »
Events Part 3

onSetCharRegVar(character_name, var_name, var):
Executed: when script.SetCharRegVar is used.

onSetRegVar(var_name, var):
Executed: when script.SetRegVar is used.

onScriptCharacterInactiveEx(lost path(True/False), movement enabled (True/False), movement paused (True/False), waypoint set id, waypoint id):
Executed: When character is inactive (after 5 mins.) (Not related to inactive alarm settings.)

onInitEvent(x, y, z, currentWaySet):
Executed: one time after script.ToggleInitEvent(seconds) (after x seconds) is used anywhere in the script.
Script disabling cancels the event.

onReceiveEnemyHpEx(uid, hp_percent, name, monster_looktype_id)
Executed: when enemy HP percentage is received

Methods Part 3

script.ToggleInitEvent(seconds)
- Runs onInitEvent after specified time in seconds. Script disabling cancels the event. If function is reused, upcoming event is canceled and a new one is queued for execution instead.

script.SetBuffRange(range)
- Sets range for "Don't when mobs in range" option for BUFF spell. Range <1-6>.

script.ToggleBlockingLocations(True/False)
- Enables/Disables (Collision) blocking locations feature.
- Returns True/False if feature is now enabled/disabled.

script.SetBlockingLocations("xxxxx,yyyyy,z;xxxxx,yyyyy,z;......")
- Sets blocking locations. Format: x,y,z;x,y,z;x,y,z...
- Returns True/False if action was successful.

script.ForceCloseMenus()
- Force closes all menus. (Inventory/depotmail as well)

script.ToggleMenuTerminator(True/False)
- Enable/Disable menu terminator in Fun/Other settings.
Menu terminator is used to force close tibiame menus if any menu is open for too long.

script.IsItemInRange(itemId, range <1-8>, canReach <True/False>)
- Returns specified item location if found or None. canReach = check if bot can reach that item.
Code: [Select]
loc = script.IsItemInRange(1337, 8, True)
if loc != None:
     script.StatusMessage("Found item!")

script.DeleteAllVars()
- Deletes all "SetVar" variables.

script.DeleteVar(name)
- Deletes 'SetVar" variable by name.

script.GetCurrentTimeMS()
- Returns current time in milliseconds.

script.OpenCharacterInfo()
- Opens character info menu. Returns True/False if execution was successful.

script.GetLicenceName()
- Returns BOT licence account name.

script.SetRelogAntitrapPvpTime(value)
- Sets relogging time in seconds for Anti Trap PVP.

script.ToggleAttackSpellRange(True/False)
- Enables/disables "Don't when mobs in range" option for Attack spell.

script.SetAttackSpellRange(range)
- Sets range for "Don't when mobs in range" option for Attack spell. Range <1-6>.

script.LoadFileEx('path', waypoints(True/False), script(True/False), settings(True/False))
- Loads waypoints or script or settings or everything from a waypoints file.
- You can load just waypoints, just waypoints and settings, just script, just script and settings and so on.
- Returns "success" or error text.
Example: script.LoadFileEx('C:/blabla/waypoints.bot', True, False, True)
Path must be like "C:/blabla/blabla/blabla/waypoints.bot"

script.GetScriptTimeLeft()
- Returns encrypted script time label information.

script.DisableScript()
- Disables script.

script.TogglePet(True/False)
- Enables/disables pet option.
- Returns "[success]" string or an error string.

script.GetEquipedSkillName(True (left)/False (right))
- Returns currently equiped skill name of specified skill type.

script.GetSpellSlot(type)
- Returns current selected slot for specified spell type.
Types:
0 - range attack spell
1 - four-direction spell
2 - area spell
3 - healing spell
4 - buff spell

script.RunEventAt(tab_id, event_name, delay)
- Runs event by name on specified tab with delay. 0 delay = instant.
- Script on specified tab must contain the event in the script box and script must be enabled on that tab.
- Returns "OK" on execution or an error text.
Example:
Tab1:
Code: [Select]
def onScriptActivation():
   script.RunEventAt(2, 'sayHello', 0)

Tab2:
Code: [Select]
def sayHello():
   script.Say('Hello world!')

script.AddSpotTrigger(location_tuple, 'method_name')
- Adds location trigger. (Don't need to use onChangeLocation event)
Example:
Code: [Select]
spot = (32121, 31957, 15)

def onScriptActivation():
    script.AddSpotTrigger(spot, 'onStepShit')

def onStepShit():
    script.StatusMessage('Stepped in shit')
    script.DeleteSpotTrigger(spot) # removing it, so it won't be executed again (don't remove if you want it to run all the time when character steps on this location)

script.DeleteSpotTrigger(location_tuple)
- Removes location trigger.

script.DeleteSpotTriggers()
- Removes all location triggers.

script.HasSpotTrigger(location_tuple)
- Returns True/False if trigger is added.

script.GetItemsCountEx(itemId, backpack (True/False), inventory (True/False), depotmail (True/False))
- Gets current items count in backpack and/or inventory and/or depotmail. (Ex: script.GetItemsCountEx(1337, True, True, False)

script.ResetDcStatus
- Sets disconnection status to N/A and it forces bot to reconnect the character.

script.IsMovementPaused()
- Returns True/False if movement is paused by script.PauseMovement.

script.GetDummyCharacterName()
- Returns character name from dummy client login field.

script.GetDummyCharacterWorld()
- Returns character world from dummy client login field.

script.GetRawCharacterName()
- Returns character name or null if character not found. (Only if character was already connected to the game at some point.)

script.GetRawCharacterWorld()
- Returns character world or 1000 if character not found. (Only if character was already connected to the game at some point.)

script.PauseStorageEx(True/False (storage), True/False (autoloot))
- Pauses/resumes item storage and/or autoloot.

script.PauseAutoloot(True/False)
- Pauses/resumes item autoloot.

script.GetBotVersion()
- Returns current bot version as string (text) (Ex.: 2.4.92)

script.GetFreeInventorySlotCount()
- Returns number of free slots in inventory.

script.GetFreeDepotmailSlotCount()
- Returns number of free slots in depotmail.

script.ToggleInactiveRelog(True/False)
- Enables / Disables relogging when inactive (Inactive alarm option)

script.IsInactiveRelogEnabled()
- Returns True/False if inactive alarm relogging option is enabled.

script.GetSwitchWeaponsList(monster_name)
- Returns weapon ids (as an array) from weapon switch feature by the monster name.

script.IsSwitchToMainEnabled()
- Returns True/False if weapon switching to main is enabled.

script.GetSwitchMainWeaponId()
- Returns the main weapon id from the weapon switching feature.

script.GetEnabledWeaponListsCount(monster_name)
- Returns enabled weapon switching lists count for a monster.

script.IsWeaponSwitchingActive()
- Returns True/False if any weapon switching option is enabled.

script.DisableWeaponSwitchingFeature()
- Disables all weapon switching options in the bot.

script.LootItem()
- Send item take action to the server. (Tries to take an item to a free backpack slot.)
- Returns string (text) result: [no_room], [offline] or [ok]

script.IsWayOnScreen(waypoint_set_id, range)
- Returns True/False if waypoint set is on screen in range.

script.IsTileWalkable(x, y, z, True/False (consider stairs, shops as blocking))
- Returns True/False if position is walkable (not blocking and no monster on tile)

script.GetLogoutHpPercent()
- Returns logout because of hp value.

script.GetLogoutMpPercent()
- Returns logout because of mp percentage.

script.PauseLogoutUntilPercent(hp_percent, mp_percent, True/False - pause movement too or not)
- Pauses logout because of low hp/mp.
- Returns "[ok]" if success.
Example:
Code: [Select]
def onDisconnect(str):
if str == 'Hp/Mp':
hp = script.GetLogoutHpPercent()
mp = script.GetLogoutHpPercent()
script.PauseLogoutUntilPercent(hp, mp, True)
                script.ResetDcStatus()

script.CancelEvent("eventName")
- Cancels scheduled RunEvent or RunEventEx by name.
- Returns "[not_found]", "[failed]" or "[ok]" result.

script.GetTargetHp()
- Returns current target's hp percent or 255 if target is not found/dead.

script.GetTargetHpEx(onlyMonster - True/False)
- Returns current target's hp percent or 255 if target is not found/dead or if target is not monster and onlyMonster is True.

script.GetTabCharacterName(tab_id)
- Returns character name from specified tab.

script.GetTabCharacterWorld(tab_id)
- Returns character world from specified tab.

script.GetCharacterNameTab(name, world)
- Returns tab id of specified character. Use world -1 for any world.

script.TogglePauseStaminaCheck(True/False)
- Enables/disables stamina checking.

script.GetTargetTemplateId()
- Returns template id of the target or -1 if there is no target.

script.GetEntityTemplateIdAtDir(dir)
- Returns template id of the entity at direction or -1 if there is no entity at direction.
Directions: North = 0, East = 1 South = 2 West = 3

script.GetTargetObjectType()
- Returns object type of the target or -1 if there is no target.

script.GetEntityObjectTypeAtDir(dir)
- Returns object type of the entity at direction or -1 if there is no entity at direction.
Directions: North = 0, East = 1 South = 2 West = 3

Modules / Classes / Etc
Location(x, y, z)
Simple wrapper for locations.
To see if one location equals other location just use == operator.
Example:
Code: [Select]
playerPos = Location(11111, 22222, 7)
enemyPos = Location(77777, 66666, 5)

# examples
myX = playerPos.x
myY = playerPos.y
myZ = playerPos.z

if playerPos == enemyPos:
    do stuff

Weapon(id, enabled(optional), slot(optional))
Wrapper for weapon id and boolean.
Example:
Code: [Select]
Weapons149 = (
    Weapon(1234, True),
    Weapon(3456, False),
    Weapon(4567, False, 3)
)

def getWeapon(place):
    wpns_len = len(Weapons149)
    if place < 1: place = 1
    elif place > wpns_len: place = wpns_len

    return Weapons149[place - 1]

def onScriptActivation():
    weapon = getWeapon(1)
    if weapon is not None:
        id = weapon.id
        enabled = weapon.enabled
        slot = weapon.slot
        script.Alarm('My weapon: ' + str(weapon))


Random bool:
Code: [Select]
from System import Random
rnd = Random()

def onScriptActivation():
    script.StatusMessage(str(GetRandomBool()))

def GetRandomBool():
    return bool(rnd.Next(2))
« Last Edit: February 09, 2024, 03:37:33 PM by =Mindee= »


Mindee-BOT creator, founder and developer.