查看: 2829|回复: 0

[有事请教] 求问如何在战斗中用脚本使用道具

[复制链接]
梦石
0
星屑
3938
在线时间
444 小时
注册时间
2019-3-3
回帖
80
发表于 2019-5-14 12:38:32 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 多卡多卡 于 2019-5-14 18:31 编辑

在制作插件时,想实现战斗中HP低于一定比例时使用药品回复时遇到了问题
比如某个角色血量小于一半时使用1号道具
if (this.hp < 0.5 * this.mhp)
    $gameActors.actor(this._actorId).useItem($dataItems[1]);
但里面的useItem()这个函数却无法执行从而使角色无法做出行动,站着不动(没有弹出错误窗口)
请问有没有解决的方法?


换了个方法把现在问题解决了
    if (this.hp < 0.5 * this.mhp && $gameParty.numItems($dataItems[1]) > 0)
    {
        var action = new Game_Action(this);
        action.setItemObject($dataItems[1]);
        action._targetActorId = this._actorId;
        this._actions.push(action);
        this.setActionState('waiting');
    }

评分

参与人数 2赞 +2 收起 理由
新耀012478 + 1 精品文章
白嫩白嫩的 + 1 精品文章

查看全部评分

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部