removeFlag
This commit is contained in:
parent
b0d7ef713b
commit
bcac9e47b5
@ -115,6 +115,10 @@ core.hasFlag('xyz')
|
||||
返回是否存在某个变量且不为0。等价于 core.getFlag('xyz', 0)!=0 。
|
||||
|
||||
|
||||
core.removeFlag('xyz')
|
||||
删除某个flag/变量。
|
||||
|
||||
|
||||
core.insertAction(list, x, y, callback)
|
||||
插入并执行一段自定义事件。在这里你可以写任意的自定义事件列表,有关详细写法请参见文档-事件。
|
||||
x和y如果设置则覆盖"当前事件点"的坐标,callback如果设置则覆盖事件执行完毕后的回调函数。
|
||||
|
||||
@ -1653,7 +1653,7 @@ core.insertAction([
|
||||
// 如果某个flag为真
|
||||
if (core.hasFlag("xxx")) {
|
||||
// 千万别忘了将该flag清空!否则下次仍然会执行这段代码。
|
||||
core.setFlag("xxx", false);
|
||||
core.removeFlag("xxx");
|
||||
// 使用insertAction来插入若干自定义事件执行
|
||||
core.insertAction([
|
||||
{"type":"openDoor", "loc":[0,0], "floorId": "MT0"}
|
||||
@ -1680,7 +1680,7 @@ core.insertAction([
|
||||
// 每层楼的并行事件处理代码样例
|
||||
if (core.getFlag("door",0)==2) {
|
||||
// 将该flag清空
|
||||
core.setFlag("door", 0);
|
||||
core.removeFlag("door");
|
||||
// 开门,如果是当前层则无需写floorId
|
||||
core.insertAction([
|
||||
{"type":"openDoor", "loc":[0,0]}
|
||||
|
||||
@ -335,6 +335,7 @@ function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
var vampireDamage = hero_hp * enemy.value;
|
||||
|
||||
// 如果有神圣盾免疫吸血等可以在这里写
|
||||
// 也可以用hasItem或hasEquip来判断装备
|
||||
if (core.hasFlag("shield5")) vampireDamage = 0; // 存在神圣盾,吸血伤害为0
|
||||
|
||||
vampireDamage = Math.floor(vampireDamage) || 0;
|
||||
@ -348,11 +349,13 @@ function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) {
|
||||
```
|
||||
3. 免疫领域、夹击、阻击效果:在2.4.1之后,可以直接将flag:no_zone设为true来免疫领域效果,其他几个同理。
|
||||
``` js
|
||||
// 同样写在道具的itemEffect中
|
||||
core.setFlag("no_zone", true); // 免疫领域
|
||||
core.setFlag("no_snipe", true); // 免疫阻击
|
||||
core.setFlag("no_laser", true); // 免疫激光
|
||||
core.setFlag("no_betweenAttack", true); // 免疫夹击
|
||||
// 写在获得道具后事件
|
||||
[
|
||||
{"type": "setValue", "name": "no_zone", "value": "true"}, // 免疫领域
|
||||
{"type": "setValue", "name": "no_snipe", "value": "true"}, // 免疫阻击
|
||||
{"type": "setValue", "name": "no_laser", "value": "true"}, // 免疫激光
|
||||
{"type": "setValue", "name": "no_betweenAttack", "value": "true"}, // 免疫夹击
|
||||
]
|
||||
```
|
||||
4. 如果有更高的需求,例如想让吸血效果变成一半,则还是在上面这些地方进行对应的修改即可。
|
||||
|
||||
|
||||
@ -219,6 +219,7 @@ HTML5的塔都是可以进行控制台调试的。
|
||||
- `core.setFlag('xxx', 1)` 设置某个flag/自定义变量的值。
|
||||
- `core.getFlag('xxx', 10)` 获得某个flag/自定义变量的值;如果该项不存在(未被定义),则返回第二个参数的值。
|
||||
- `core.hasFlag('xxx')` 返回是否存在某个变量且不为0。等价于`core.getFlag('xxx', 0)!=0`。
|
||||
- `core.removeFlag('xxx')` 删除某个flag/自定义变量
|
||||
- `core.insertAction(list)` 执行一段自定义事件。比如 `core.insertAction(["剧情文本"])` 将执行一个剧情文本显示事件。
|
||||
- `core.changeFloor('MT2', 'downFloor')` 立刻执行楼层切换到MT2层的下楼点位置。
|
||||
- `core.changeFloor('MT5', null, {'x': 4, 'y': 7})` 立刻切换楼层到MT5层的(4,7)点。
|
||||
|
||||
@ -2533,6 +2533,12 @@ control.prototype.hasFlag = function(flag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
////// 删除某个自定义变量或flag //////
|
||||
control.prototype.removeFlag = function(flag) {
|
||||
if (!core.isset(core.status.hero)) return;
|
||||
delete core.status.hero.flags[flag];
|
||||
}
|
||||
|
||||
////// 锁定状态栏,常常用于事件处理 //////
|
||||
control.prototype.lockControl = function () {
|
||||
core.status.lockControl = true;
|
||||
|
||||
@ -1247,6 +1247,12 @@ core.prototype.hasFlag = function(flag) {
|
||||
return core.control.hasFlag(flag);
|
||||
}
|
||||
|
||||
////// 删除某个自定义变量或flag //////
|
||||
core.prototype.removeFlag = function(flag) {
|
||||
core.control.removeFlag(flag);
|
||||
}
|
||||
|
||||
////// 执行下一个自定义事件 //////
|
||||
core.prototype.doAction = function() {
|
||||
core.events.doAction();
|
||||
}
|
||||
|
||||
@ -759,7 +759,7 @@ events.prototype.doAction = function() {
|
||||
core.setWeather(data.name, data.level);
|
||||
if (core.isset(data.name))
|
||||
core.setFlag('__weather__', [data.name, data.level]);
|
||||
else core.setFlag('__weather__', null);
|
||||
else core.removeFlag('__weather__');
|
||||
this.doAction();
|
||||
break;
|
||||
case "openDoor": // 开一个门,包括暗墙
|
||||
|
||||
@ -509,6 +509,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
var vampire_damage = hero_hp * enemy.value;
|
||||
|
||||
// 如果有神圣盾免疫吸血等可以在这里写
|
||||
// 也可以用hasItem和hasEquip来判定装备
|
||||
// if (core.hasFlag('shield5')) vampire_damage = 0;
|
||||
|
||||
vampire_damage = Math.floor(vampire_damage) || 0;
|
||||
@ -1066,7 +1067,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
// 如果某个flag为真
|
||||
if (core.hasFlag("xxx")) {
|
||||
// 千万别忘了将该flag清空!否则下次仍然会执行这段代码。
|
||||
core.setFlag("xxx", false);
|
||||
core.removeFlag("xxx");
|
||||
// 使用insertAction来插入若干自定义事件执行
|
||||
core.insertAction([
|
||||
{"type":"openDoor", "loc":[0,0], "floorId": "MT0"}
|
||||
|
||||
@ -367,10 +367,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"centerFly": "core.playSound('centerFly.mp3');\ncore.clearMap('hero');\ncore.setHeroLoc('x', (core.bigmap.width||13)-1-core.getHeroLoc('x'));\ncore.setHeroLoc('y', (core.bigmap.height||13)-1-core.getHeroLoc('y'));\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');",
|
||||
"upFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\tcore.replay();\n});",
|
||||
"downFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\tcore.replay();\n});",
|
||||
"poisonWine": "core.setFlag('poison', false);",
|
||||
"weakWine": "core.setFlag('weak', false);\ncore.status.hero.atk += core.getFlag('weakAtk', core.values.weakValue);\ncore.status.hero.def += core.getFlag('weakDef', core.values.weakValue);",
|
||||
"curseWine": "core.setFlag('curse', false);",
|
||||
"superWine": "core.setFlag('poison', false);\nif (core.hasFlag('weak')) {\n\tcore.setFlag('weak', false);\n\tcore.status.hero.atk += core.getFlag('weakAtk', core.values.weakValue);\n\tcore.status.hero.def += core.getFlag('weakDef', core.values.weakValue);\n}\ncore.setFlag('curse', false);",
|
||||
"poisonWine": "core.removeFlag('poison');",
|
||||
"weakWine": "core.removeFlag('weak');\ncore.status.hero.atk += core.getFlag('weakAtk', core.values.weakValue);\ncore.status.hero.def += core.getFlag('weakDef', core.values.weakValue);",
|
||||
"curseWine": "core.removeFlag('curse');",
|
||||
"superWine": "core.removeFlag('poison');\nif (core.hasFlag('weak')) {\n\tcore.removeFlag('weak');\n\tcore.status.hero.atk += core.getFlag('weakAtk', core.values.weakValue);\n\tcore.status.hero.def += core.getFlag('weakDef', core.values.weakValue);\n}\ncore.removeFlag('curse');",
|
||||
"lifeWand": "core.insertAction([\n\t{\"type\": \"input\", \"text\": \"请输入生命魔杖使用次数:(0-${item:lifeWand})\"},\n\t{\"type\": \"if\", \"condition\": \"flag:input<=item:lifeWand\",\n\t\t\"true\": [\n\t\t\t{\"type\": \"setValue\", \"name\": \"item:lifeWand\", \"value\": \"item:lifeWand-flag:input\"},\n\t\t\t{\"type\": \"setValue\", \"name\": \"status:hp\", \"value\": \"status:hp+flag:input*100\"},\n\t\t\t\"成功使用${flag:input}次生命魔杖,恢复${flag:input*100}点生命。\"\n\t\t],\n\t\t\"false\": [\"输入不合法!\"]\n\t},\n]);\ncore.addItem('lifeWand', 1);",
|
||||
"jumpShoes": "core.insertAction({\"type\":\"jumpHero\",\"loc\":[core.nextX(2),core.nextY(2)]});",
|
||||
"redPotion": "core.status.hero.hp += core.values.redPotion",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user