t9540513

楓之谷腳本開發常見用法

發表於 2024-5-4 12:00:01
t9540513 發表於 2024-5-4 12:00:01 | 顯示全部樓層 |閱讀模式
image.png

最近在研究冒險島的腳本開發,網上沒找到啥資料,今天大佬給了個網站學習,做個筆記。
1)兩種不同的NPC


//第一種,沒有其他狀態的NPC
function start() {
 cm.sendOk("I am an NPC without a status.");
 cm.dispose();
}
//沒有其他狀態NPC的另一種寫法
function start() {
  cm.sendOk("Here is another example of an NPC without status.");
}

function action(mode, type, selection) {
 cm.warp(100000000, 0);
 cm.gainItem(4001126, 1);
 cm.sendOk("See? Here, I warped you and gave you an item without using status.");
 cm.dispose();
}
//第二種,帶有狀態的NPC
var status;

function start() {
 status = -1;
 action(1, 0, 0);
}

function action(mode, type, selection) {
if (mode == 1) {
 status++;
}else{
 status--;
}
if (status == 0) {
 cm.sendNext("Go ahead and press Next so I can proceed to the next status.");
} else if (status == 1) {
 cm.sendSimple("Would you like to see how I use status again? \r\n #L0# Yes. #l \r\n #L1# No. #l");
} else if (status == 2) {
  if (selection == 0) {
   cm.sendOk("Here I am, in another status. As you can see from the script, this window is in status 2.");
   cm.dispose();
  } else if (selection == 1) {
   cm.sendOk("Well, sucks to be you, don't it? This window is also in status 2 :) ");
   cm.dispose();
  }
 }
}
2)NPC Color codes/Item pictures/etcnpc 文字顏色和物品圖片等等

#b = Blue text. //藍色文本
#c[itemid]# Shows how many [itemid] the player has in their inventory.//顯示玩家揹包中有多少個itemid的物品
#d = Purple text.//紫色文本
#e = Bold text.//血色文本
#f[imagelocation]# - Shows an image inside the .wz files.//顯示wz文件中的圖片
#g = Green text.//綠色文本
#h # - Shows the name of the player.//顯示玩家名字
#i[itemid]# - Shows a picture of the item.//顯示物品圖片
#k = Black text.//黑色文本
#l - Selection close. //選項關閉,
#m[mapid]# - Shows the name of the map.//顯示地圖名字
#n = Normal text (removes bold).//正常文本
#o[mobid]# - Shows the name of the mob.//顯示怪物名稱
#p[npcid]# - Shows the name of the NPC.//顯示NPC名字
#q[skillid]# - Shows the name of the skill.//顯示技能名字
#r = Red text.//紅色文本
#s[skillid]# - Shows the image of the skill.//顯示技能圖片
#t[itemid]# - Shows the name of the item.//顯示物品名稱
#v[itemid]# - Shows a picture of the item.//顯示物品圖片
#x - Returns "0%" (need more information on this).//這個不知道是啥
#z[itemid]# - Shows the name of the item.//顯示物品名稱
#B[%]# - Shows a 'progress' bar.//顯示進度條
#F[imagelocation]# - Shows an image inside the .wz files.//顯示wz中的圖片
#L[number]# Selection open. //開始一個number的選擇
\r\n - Moves down a line. //換行
\r = Return Carriage //
\n = New Line//新的一行
\t = Tab (4 spaces)
\b = Backwards //向後一格

2)NPC Color codes/Item pictures/etcnpc 文字顏色和物品圖片等等

#b = Blue text. //藍色文本
#c[itemid]# Shows how many [itemid] the player has in their inventory.//顯示玩家揹包中有多少個itemid的物品
#d = Purple text.//紫色文本
#e = Bold text.//血色文本
#f[imagelocation]# - Shows an image inside the .wz files.//顯示wz文件中的圖片
#g = Green text.//綠色文本
#h # - Shows the name of the player.//顯示玩家名字
#i[itemid]# - Shows a picture of the item.//顯示物品圖片
#k = Black text.//黑色文本
#l - Selection close. //選項關閉,
#m[mapid]# - Shows the name of the map.//顯示地圖名字
#n = Normal text (removes bold).//正常文本
#o[mobid]# - Shows the name of the mob.//顯示怪物名稱
#p[npcid]# - Shows the name of the NPC.//顯示NPC名字
#q[skillid]# - Shows the name of the skill.//顯示技能名字
#r = Red text.//紅色文本
#s[skillid]# - Shows the image of the skill.//顯示技能圖片
#t[itemid]# - Shows the name of the item.//顯示物品名稱
#v[itemid]# - Shows a picture of the item.//顯示物品圖片
#x - Returns "0%" (need more information on this).//這個不知道是啥
#z[itemid]# - Shows the name of the item.//顯示物品名稱
#B[%]# - Shows a 'progress' bar.//顯示進度條
#F[imagelocation]# - Shows an image inside the .wz files.//顯示wz中的圖片
#L[number]# Selection open. //開始一個number的選擇
\r\n - Moves down a line. //換行
\r = Return Carriage //
\n = New Line//新的一行
\t = Tab (4 spaces)
\b = Backwards //向後一格

3)cm.[commands] cm的各種調用

dispose
Ends the conversation with an NPC, allows you to talk to NPCs again.
//關閉與NPC的對話,這樣你就能再次跟NPC對話
How to use: cm.dispose();

sendNext
Shows a conversation window with a 'Next' button.
//顯示一段帶有下一項按鈕的對話
How to use: cm.sendNext("[text]");

sendPrev
Shows a conversation window with a 'Prev' (previous) button.
//顯示一段帶有上一項按鈕的對話
How to use: cm.sendPrev("[text]");

sendNextPrev
Shows a conversation window with a 'Next' and 'Prev' button (see above).
//顯示一段帶有上一項和下一項的對話
How to use: cm.sendNextPrev("[text]");

sendOk
Shows a conversation window with an 'Ok' button.
//顯示一段帶有好的按鈕的對話
How to use: cm.sendOk("[text]");

sendYesNo
Shows a conversation window with a 'Yes' and 'No' button, 'No' ends the conversation unless otherwise stated.
//顯示一段帶有是和否按鈕的對話,否按鈕會關閉對話,除非設置了其他的狀態
How to use: cm.sendYesNo("[text]");

sendAcceptDecline
Shows a conversation window with an 'Accept' and 'Decline' button. 'Decline' ends the conversation unless otherwise stated.
//顯示一段帶有接受和關閉按鈕的對話,關閉按鈕會關閉對話框,除非設置了其他狀態
How to use: cm.sendAcceptDecline("[text]");

sendSimple
Shows a conversation window with no buttons.
//顯示一段沒有任何按鈕的簡單對話框
How to use: cm.sendSimple("[text]");

sendStyle
Shows a style-select window.
//顯示一個帶有風格的對話框
How to use: cm.sendStyle("[Text]", [variable]); // You'll need to declare the variable in a Var statement.

warp
Warps the player to a map.
//傳送玩家到一個地圖上。第二個參數不知道是啥
How to use: cm.warp([mapid], [portal]); // Set [portal] as 0 if you want default.

openShop
Opens a shop window.
//打開商店
How to use: cm.openShop([shopid]);

haveItem
Checks if the player has an item (in their inventories or equipped).
//檢查玩家是否有某個物品
How to use: cm.haveItem([itemid]);

gainItem
Gives the player an item/takes an item from a player.
//獲取或者刪除玩家的物品,當數量爲負數的時候就是刪除物品
How to use: cm.gainItem([itemid],[ammount]); // Change [ammount] to -[ammount] to take an item.

changeJob
Changes the job of the player.
//改變玩家的職業
How to use: cm.changeJob([jobid]);

getJob
Finds out what job the player has.
//獲取玩家當前的職業
How to use: cm.getJob();

startQuest
Starts a quest.
//開始一個任務
How to use: cm.startQuest([questid]);

completeQuest
Finishes a quest.
//結束一個任務
How to use: cm.completeQuest([questid]);

forfeitQuest
Forfeits a quest.
//放棄一個任務
How to use: cm.forfeitQuest([questid]);

getMeso
Finds out how many mesos a player has.
//獲取玩家的楓幣數量。就是打怪掉的那個幣。
How to use: cm.getMeso();

gainMeso
Gives a player mesos/takes mesos from a player.
//給與或扣除玩家的楓幣。當數量爲負數時是扣除玩家楓幣。
How to use: cm.gainMeso([ammount]); // use -[ammount] to take mesos.

gainExp
Gives a player exp/takes exp from a player.
//給與或扣除玩家經驗。負數就是扣除經驗。
How to use: cm.gainExp([ammount]); // use -[ammount] to take exp.

getLevel
Finds out the level of the player.
//獲取玩家當前等級
How to use: cm.getLevel();

teachSkill
Teaches a player a skill.
//教玩家技能
How to use: cm.teachSkill([skillid],[skilllevel],[maxskilllevel]);

get[Stat]
Finds out the [Stat] of the player. [Stat] being: HP, MP, STR, DEX, INT, LUK.
//獲取玩家的屬性:血量,魔法,力量,敏捷,智力,幸運。
How to use: cm.get[Stat]();

modifyNX
Gives/Takes the player nx
//給與或刪除玩家的點券,對就是拿RMB買的那個點券。
How to use: cm.gainNX([amount]);
Make it negative to make it take away.

4)檢查楓幣,捐贈者,物品,管理員,和性別Checking for mesos, items, donator, gm, and gender

if (cm.getPlayer().isGM()) { //檢查gm

if (cm.getChar().isDonator() == true) { // checks for donator

if (cm.getJob().equals(net.sf.odinms.client.MapleJob.BOWMAN)) { // checks for Bowman job (list of jobs in below spoiler)

if (cm.getLevel() >= 30) { // checks if level is more than or equal to 30.

if (cm.getChar().getGender() == 0) { // 0 = male, 1 = female
if (cm.getPlayer().getGender() == 0) { // 0 = male, 1 = female

if (cm.getMeso() >= amount) { // >= greater than or equal to, <= less than or equal to, == is equal to 檢查玩家是否有足夠的楓幣

if (cm.haveItem(itemid, amount)) { // checks if the player has a certain amount of an item 檢查玩家是否有一定數量的某物品

if (cm.getPlayer().getitemQuantity(itemid)); // gets a count of how much a player has of an item 獲得玩家有多少個某個物品。

5)職業代碼 job terms and Ids

//這個太難翻譯了 只翻譯我看的懂得
BEGINNER - 0 //新手
WARRIOR - 100 //戰士
FIGHTER - 110 //劍客
CRUSADER - 111 //勇士
HERO - 112 //英雄
PAGE - 120 //準騎士
WHITEKNIGHT - 121 //騎士
PALADIN - 122 //聖騎士
SPEARMAN - 130 //槍戰士
DRAGONKNIGHT - 131 //龍騎士
DARKKNIGHT - 132 //黑騎士
MAGICIAN - 200 //法師
FP_WIZARD - 210 //火毒法師
FP_MAGE - 211 //火毒巫師
FP_ARCHMAGE - 212 //火毒魔導師
IL_WIZARD - 220 //冰雷法師
IL_MAGE - 221 //冰雷巫師
IL_ARCHMAGE - 222 //冰雷魔導師
CLERIC - 230 //牧師
PRIEST - 231 //祭司
BISHOP - 232 //主教
BOWMAN - 300 //弓箭手
HUNTER - 310 //獵人
RANGER - 311 //射手
BOWMASTER - 312 //神射手
CROSSBOWMAN - 320 //弩弓手
SNIPER - 321 //遊俠
CROSSBOWMASTER - 322 //箭神
THIEF - 400 //盜賊
ASSASSIN - 410 //刺客
HERMIT - 411 //無影人
NIGHTLORD - 412 //隱士
BANDIT - 420 //俠客
CHIEFBANDIT - 421 //獨行客
SHADOWER - 422 //俠盜
PIRATE - 500 //海盜
BRAWLER - 510 //拳手
MARAUDER - 511 //鬥士
BUCCANEER - 512 //衝鋒隊長
GUNSLINGER - 520 //火槍手
OUTLAW - 521 //大副
CORSAIR - 522 //船長
MAPLELEAF_BRIGADIER - 800
GM - 500(v55) / 900(v62+)
SUPERGM 510(v55) / 910(v62+)
DAWNWARRIOR1 - 1000
DAWNWARRIOR2 - 1010
DAWNWARRIOR3 - 1011
DAWNWARRIOR4 - 1012
BLAZEWIZARD1 - 1100
BLAZEWIZARD2 - 1110
BLAZEWIZARD3 - 1111
BLAZEWIZARD4 - 1112
WINDARCHER1 - 1200
WINDARCHER2 - 1210
WINDARCHER3 - 1211
WINDARCHER4 - 1212
NIGHTWALKER1 - 1300 //夜行者?
NIGHTWALKER2 - 1310
NIGHTWALKER3 - 1311
NIGHTWALKER4 - 1312
THUNDERBREAKER1 - 1400
THUNDERBREAKER2 - 1410
THUNDERBREAKER3 - 1411
THUNDERBREAKER4 - 1412
ARAN1 - 2100
ARAN2 - 2110
ARAN3 - 2111
ARAN4 - 2112

6)各種文本框對應的狀態

-----------
sendNext(); & sendOk();
-----------
Type = 0
If end chat - mode = -1
If next/ok - mode = 1

-----------
sendNextPrev();
-----------
Type = 0
If end chat - mode = -1
If next - mode = 1
if back - mode = 0

-----------
sendYesNo();
-----------
Type = 1
If end chat - mode = -1
If yes - mode = 1
If no - mode = 0

-----------
sendAcceptDecline();
-----------
Type = 12
If end chat - mode = -1
If accept - mode = 1
If decline - mode = 0

-----------
sendGetText();
-----------
Nothing o____o its something special <3

-----------
sendGetNumber();
-----------
Type = 3
If end chat - mode = 0
if ok - mode = 1

-----------
sendSimple();
-----------
Type = 4
If end chat - mode = 0
if select - mode = 1

7)一些腳本命令

cm.sendNext("text"); - 顯示一個對話窗口並附帶下一步按鈕。
cm.sendPrev("text"); - 顯示一個對話窗口並附帶上一步按鈕。
cm.sendNextPrev("text"); - 顯示一個對話窗口並附帶下一步和上一步按鈕。
cm.sendOk("text"); - 顯示一個對話窗口並附帶確定按鈕。
cm.sendYesNo("text"); - 顯示一個對話窗口並附帶是和否按鈕。
cm.sendAcceptDecline("text"); - 顯示一個對話窗口並附帶接受和拒絕按鈕。
cm.sendSimple("text"); - 顯示一個對話窗口不含按鈕。
cm.sendGetNumber("text", defammount, minammount, maxammount) - 顯示一個窗口讓玩家選擇一個介於最小和最大數量之間的數字。
cm.sendGetText("text") - 顯示一個輸入對話框讓玩家可以輸入文字。
cm.setGetText("text") - 設定玩家NPC對話框中的文字。
cm.getText() - 獲取在文字框中輸入的文字。
cm.openShop(SHOPID) - 透過商店ID打開一個商店。
cm.openNpc(NPCID) - 透過NPC ID開始一個新的NPC對話。
cm.changeJob(JOBID) - 將玩家的職業改變為指定的JOBID。
cm.getJob() - 獲得玩家的職業。
cm.startQuest(QUESTID) - 開始一個由QUESTID指定的任務。
cm.completeQuest(QUESTID) - 完成一個由QUESTID指定的任務。
cm.forfeitQuest(QUESTID) - 放棄一個由QUESTID指定的任務。
cm.getMeso() - 獲得玩家的楓幣。
cm.gainMeso(NUMBER) - 給予玩家指定數量的楓幣。
cm.gainExp(NUMBER) - 給予玩家指定數量的經驗值。
cm.getNpc() - 獲得當前的NPC。
cm.getFileName() - 可能獲得一個檔案名稱。
cm.getLevel() - 獲得玩家的等級。
cm.unequipEverything() - 使玩家卸下所有裝備。
cm.teachSkill(SKILLID, SKILLLEVEL, MASTERLEVEL) - 教導玩家一個由SKILLID指定的技能。
cm.getSkill() - 獲得玩家的某個技能。
cm.clearSkills() - 清除玩家的所有技能。
cm.getPlayer() - 獲得玩家。
cm.getC() - 獲得客戶端。
cm.rechargeStars() - 為玩家的星星充能。
cm.getEventManager(String event) - 可能獲得一個事件管理器。
cm.showEffect(String effect) - 顯示由ID指定的效果。
cm.playSound(String sound) - 播放由ID指定的聲音。
cm.updateBuddyCapacity(amount) - 更新好友容量至指定數量。
cm.getBuddyCapacity() - 獲得玩家的好友容量。
cm.setHair(ID) - 設定玩家的髮型為指定ID。
cm.setFace(ID) - 設定玩家的臉型為指定ID。
cm.setSkin(ID) - 設定玩家的膚色為指定ID。
cm.warpParty(MAPID) - 傳送隊伍到指定的MAPID(適用於實例)。
cm.warpRandom(MAPID) - 隨機傳送到由MAPID指定的地圖某個傳送門。
cm.spawnMonster(ID, HP, MP, LVL, EXP, Boss?, Undead?, ammount, x, y) - 在X,Y座標處生成指定數量的怪物,ID、HP、MP、LVL、EXP為怪物屬性,若為Boss或Undead則填1。
cm.itemQuantity(itemid) - 獲得指定道具ID的數量。
cm.createMapleSquad(MapleSquadType) - 創建一個由MapleSquadType指定的小隊。
cm.getSquadMember(MapleSquadType, number) - 根據序號獲得MapleSquadType中的小隊成員。
cm.getSquadState(MapleSquadType) - 獲得MapleSquadType的狀態。
cm.setSquadState(MapleSquadType, state) - 設定MapleSquadType的狀態。
cm.checkSquadLeader(MapleSquadType) - 檢查MapleSquadType的隊長。
cm.removeMapleSquad(MapleSquadType) - 移除MapleSquadType指定的小隊。
cm.numSquadMembers(MapleSquadType) - 獲得MapleSquadType中小隊成員的數量。
cm.isSquadMember(MapleSquadType) - 檢查玩家是否為MapleSquadType的小隊成員。
cm.addSquadMember(MapleSquadType) - 向MapleSquadType添加一名小隊成員。
cm.removeSquadMember(MapleSquadType, Char) - 從MapleSquadType移除指定角色。
cm.removeSquadMember(MapleSquadType, Char, ban) - 從MapleSquadType移除指定角色並封禁。
cm.canAddSquadMember(MapleSquadType) - 檢查是否可以向MapleSquadType添加更多小隊成員。
cm.warpSquadMembers(MapleSquadType, mapId) - 將MapleSquadType中的小隊成員傳送至mapId。
cm.searchItem(ItemName) - 搜索指定名稱的道具。
cm.makeRing(partner, ringId) - 為你和你的伴侶創建由ringId指定的戒指。
cm.resetReactors() - 重置反應堆。
cm.displayGuildRanks() - 顯示公會排名。
cm.sendMessage(Player, Message) - 向指定玩家發送訊息。
cm.gainFame(amount) - 給予或從玩家那裡取得名望點數。
cm.maxSkills() - 將玩家的技能提升至最大。
cm.getSkillLevel(skillid) - 獲得玩家指定技能的等級。
cm.giveBuff(skillid) - 給予玩家指定技能的增益效果。
cm.partyMembersInMap() - 檢查地圖中是否有隊伍成員。
cm.modifyNx(amount) - 修改玩家的Nx點數。
cm.getTime(type) - 獲得指定類型的時間,類型可以是小時、分鐘或秒。
cm.addBuddyCapacity(number) - 增加好友容量。
cm.clearKeys() - 將快捷鍵設置重置為默認值。
cm.scheduleWarp(delay, mapid) - 在指定延遲後傳送至mapid。
cm.startClock(limit, endMap) - 啟動倒計時,從limit倒數到0然後傳送至endMap。
cm.getCharByName(name) - 根據名字獲得角色。
cm.warpAllInMap(mapid, portal) - 將地圖中所有人傳送至mapid的指定傳送門。
cm.createMarriage(partner) - 與伴侶建立婚姻。
cm.createEngagement(partner) - 與伴侶訂婚。
cm.divorceMarriage() - 與伴侶離婚。
cm.changeKeyBinding(key, type, action) - 更改快捷鍵綁定。
cm.getEquipById(id) - 根據ID獲得裝備。
cm.getNpcTalkTimes() - 獲得與此NPC交談的次數。
cm.setNpcTalkTimes(amount) - 設定與NPC交談的次數。
cm.makeProItem(ITEMID, NUMBER) - 創造一個每個屬性為NUMBER的專業物品。
cm.isGuest() - 檢查玩家是否為訪客。
cm.broadcastMessage(type, message) - 以指定類型廣播消息。
cm.setClan(ClanName) - 將玩家加入指定的Clan。
cm.getAllOnlineNamesFromClan(ClanName) - 獲得Clan中所有在線成員的名字。
cm.getAllOfflineNamesFromClan(ClanName) - 獲得Clan中所有離線成員的名字。
cm.getOfflineClanCount(ClanName) - 統計Clan中離線成員的數量。
cm.getJobById(id) - 根據ID獲得職業。
cm.getPartyMembers() - 獲得隊伍中的隊員。
cm.getSender() - 獲得發送者。
cm.removeHiredMerchantItem(id) - 從雇傭商人那裡移除指定ID的物品。
cm.getHiredMerchantMesos() - 獲得雇傭商人的楓幣。
cm.setHiredMerchantMesos(Number) - 設定雇傭商人的楓幣數量。
cm.getHiredMerchantItems() - 獲得雇傭商人的物品。
cm.sendKeymap(KEY) - 向快捷鍵地圖發送信息。
cm.removeAll(ItemID) - 移除所有指定ItemID的物品。
cm.removeSlot(inventoryType, deleteSlot, deleteQuantity) - 從指定類型的揹包中移除物品。





瀏覽 3831 回復 1

您需要登錄後才可以回帖 登錄 | 註冊會員

:感谢分享 2024-11-11 15:20回復
返回頂部