로그인 유지
정확하게 어떤 기능을 만드시려는지 설명이 우선 필요합니다. 어떤 상황에서 어느 쪽이 어떤 효과를 받는지 등등의 일련의 흐름을 알려주시지 않으면 정확하게 캐치해드릴 수 없습니다. 그리고 모호하게 생각하는 부분에 대해서 먼저 이야기하겠습니다. 1. $gameActors 부분에서 $gameActors.actor(7)부분은 Game_Action.prototype.subject = function() { if (this._subjectActorId > 0) { return $gameActors.actor(this._subjectActorId); } else { return $gameTroop.members()[this._subjectEnemyIndex]; } }; 를 참고하셔서 작성하신 것 같은데 맵을 이동하거나 바뀔 때마다 액터의 배열 인덱스 번호는 바뀌게 되어 현재 맵에서 사용할 수 없는 this._subjectActorId 일 경우에는 제대로 실행이 되지 않을 수 있습니다. 우선 this._subjectActorId에 해당하는 액터가 존재하는가를 살펴야합니다. 2. target.result().critical 이부분은 특정 객체(Game_Action 등) 내에서 사용되는 외부로부터 전달되어 온 파라미터 변수 값을 기반으로 로직이 기동하는 것이기 때문에 그냥 쓰게 되면 존재하지 않거나 올바르지 않은 값이라는 에러가 뜨게 됩니다. Game_Action 객체는 배틀러의 각종 행동에 대한 처리를 담당합니다. 배틀러로 등록된 $gameParty.members() $gameTroop.members() 에 연관된 모든 행동에 연관된다고 보시면 되겠습니다. 그러므로 target.result().critical처럼 사용하시려면 target을 가져올 수 있는 시점에 대해서 먼저 아셔야 합니다. BattleManager.startAction() 함수를 살펴보시면 (js/rpg_manager.js : 2138줄) 실행하는 중에 tartget들이 생성됩니다. BattleManager.startAction = function() { var subject = this._subject; var action = subject.currentAction(); var targets = action.makeTargets(); this._phase = 'action'; this._action = action; this._targets = targets; subject.useItem(action.item()); this._action.applyGlobal(); this.refreshStatus(); this._logWindow.startAction(subject, action, targets); }; 살펴보시면 여기에서는 직접적으로 실행해서 크리티컬이 터졌는지까지는 알 수 없습니다. targets로 묶여있기 때문인데요. Game_Action.prototype.apply = function(target) { var result = target.result(); this.subject().clearResult(); result.clear(); result.used = this.testApply(target); result.missed = (result.used && Math.random() >= this.itemHit(target)); result.evaded = (!result.missed && Math.random() < this.itemEva(target)); result.physical = this.isPhysical(); result.drain = this.isDrain(); if (result.isHit()) { if (this.item().damage.type > 0) { result.critical = (Math.random() < this.itemCri(target)); var value = this.makeDamageValue(target, result.critical); this.executeDamage(target, value); } this.item().effects.forEach(function(effect) { this.applyItemEffect(target, effect); }, this); this.applyItemUserEffect(target); } }; (js/rpg_object.js : 1644줄) 를 살펴보시게 되면 케에데님께서 원하시는 부분이 나옵니다. result.critical = (Math.random() < this.itemCri(target)); 해당부분은 BattleManager 객체에서 전투시에 모두 접근이 가능합니다. BattleManager..actor()로 즉각적으로 $gameParty.members()[this._actorIndex] or 대상없음 으로 값을 알 수 있고 전투시가 아니면 제대로된 값을 얻기 힘듭니다. 추가적으로 모르시겠다면 질문해주세요.
여기에 파일을 끌어 놓거나 파일 첨부 버튼을 클릭하세요.
파일 크기 제한 : 0MB (허용 확장자 : *.*)
파일 업로드 중... (0%)
정확하게 어떤 기능을 만드시려는지 설명이 우선 필요합니다.
어떤 상황에서 어느 쪽이 어떤 효과를 받는지 등등의
일련의 흐름을 알려주시지 않으면 정확하게 캐치해드릴 수 없습니다.
그리고 모호하게 생각하는 부분에 대해서 먼저 이야기하겠습니다.
1. $gameActors 부분에서 $gameActors.actor(7)부분은
Game_Action.prototype.subject = function() {
if (this._subjectActorId > 0) {
return $gameActors.actor(this._subjectActorId);
} else {
return $gameTroop.members()[this._subjectEnemyIndex];
}
};
를 참고하셔서 작성하신 것 같은데
맵을 이동하거나 바뀔 때마다 액터의 배열 인덱스 번호는 바뀌게 되어
현재 맵에서 사용할 수 없는 this._subjectActorId 일 경우에는 제대로
실행이 되지 않을 수 있습니다.
우선 this._subjectActorId에 해당하는 액터가 존재하는가를 살펴야합니다.
2. target.result().critical 이부분은 특정 객체(Game_Action 등) 내에서
사용되는 외부로부터 전달되어 온 파라미터 변수 값을 기반으로
로직이 기동하는 것이기 때문에 그냥 쓰게 되면 존재하지 않거나
올바르지 않은 값이라는 에러가 뜨게 됩니다.
Game_Action 객체는 배틀러의 각종 행동에 대한 처리를 담당합니다.
배틀러로 등록된
$gameParty.members()
$gameTroop.members()
에 연관된 모든 행동에 연관된다고 보시면 되겠습니다.
그러므로 target.result().critical처럼 사용하시려면 target을
가져올 수 있는 시점에 대해서 먼저 아셔야 합니다.
BattleManager.startAction() 함수를 살펴보시면
(js/rpg_manager.js : 2138줄)
실행하는 중에 tartget들이 생성됩니다.
BattleManager.startAction = function() {
var subject = this._subject;
var action = subject.currentAction();
var targets = action.makeTargets();
this._phase = 'action';
this._action = action;
this._targets = targets;
subject.useItem(action.item());
this._action.applyGlobal();
this.refreshStatus();
this._logWindow.startAction(subject, action, targets);
};
살펴보시면 여기에서는 직접적으로 실행해서
크리티컬이 터졌는지까지는 알 수 없습니다.
targets로 묶여있기 때문인데요.
Game_Action.prototype.apply = function(target) {
var result = target.result();
this.subject().clearResult();
result.clear();
result.used = this.testApply(target);
result.missed = (result.used && Math.random() >= this.itemHit(target));
result.evaded = (!result.missed && Math.random() < this.itemEva(target));
result.physical = this.isPhysical();
result.drain = this.isDrain();
if (result.isHit()) {
if (this.item().damage.type > 0) {
result.critical = (Math.random() < this.itemCri(target));
var value = this.makeDamageValue(target, result.critical);
this.executeDamage(target, value);
}
this.item().effects.forEach(function(effect) {
this.applyItemEffect(target, effect);
}, this);
this.applyItemUserEffect(target);
}
};
(js/rpg_object.js : 1644줄)
를 살펴보시게 되면 케에데님께서 원하시는 부분이 나옵니다.
result.critical = (Math.random() < this.itemCri(target));
해당부분은 BattleManager 객체에서 전투시에 모두 접근이 가능합니다.
BattleManager..actor()로 즉각적으로
$gameParty.members()[this._actorIndex] or 대상없음
으로 값을 알 수 있고
전투시가 아니면 제대로된 값을 얻기 힘듭니다.
추가적으로 모르시겠다면 질문해주세요.