Need help with Yanfly's Enemy Thieves Tips and Tricks code.

Joined
Jan 22, 2016
Messages
613
Reaction score
223
First Language
English
Primarily Uses
After Eval>


if (user.isEnemy(1)) {


var successRate = 0.5;


if (Math.random(1) < successRate) {


var items = [1];


var total = $gameParty.items(1).length;


for (var i = 0; i < total; ++i) {


var item = $gameParty.items(1);


if (item.itypeId !== 2) items.push(item);


}


var random = Math.floor(Math.random() * items.length);


var item = items[random];


$gameParty.loseItem(item, 1);


var text = user.name(1) + ' stole ' + item.name + ' from the party!';


SoundManager.playEquip(1);


} else {


var text = user.name(1) + ' failed to steal an item!';


SoundManager.playBuzzer(1);


}


var window = SceneManager._scene._logWindow;


window._lines.push(text + '<CENTER>');


window.refresh(1);


}


</After Eval>
Okay, I must be doing something wrong here. I just tried to do the Enemy Thieves thing with my Steal Item (partially to see if it was successfully working and partially because I'm trying to still do the "Enemies Steal Weapons thing") skill. At first I copy pasted the code exactly as you put it in the video. That got me this. I tried again, adding in numbers to any paratheses I found. Same result when the Slime went up to perform the Pilfer action.


 


For what it's worth, here's the code for the regular action:

<Steal Item>


 


<setup action>


display action


immortal: targets, true


</setup action>


 


<target action>


move user: targets, front, 20


motion standby: user


wait for movement


face user: target


action animation: target


move user: targets, base, 10


motion thrust: user, no weapon


wait: 15


action effect


jump user: 50, 10


move user: targets, front, 10


face user: forward


wait: 60


</target action>
Does anybody know what I'm doing wrong?


Screenshot 2016-04-04 01.27.02.png






 

 

Punamaagi

Hero on their own terms
Veteran
Joined
Jan 23, 2016
Messages
212
Reaction score
314
First Language
Finnish
Primarily Uses
RMMV
I decided to fiddle with the Enemy Thieves notetags a bit and managed to make enemies steal actor's weapons. It works... sort of.


<After Eval>
if (user.isEnemy()) {
var successRate = 0.5;
if (Math.random() < successRate) {
var weapons = [];
var total = target.weapons().length;
for (var i = 0; i < total; ++i) {
var weapon = target.weapons();
}
if (weapon === "null") {
var text = user.name() + ' found nothing to steal!';
} else {
target.discardEquip(weapon);
var text = user.name() + ' stole ' + weapon.name + '!';
SoundManager.playEquip();
}
} else {
var text = user.name() + ' failed to steal a weapon!';
SoundManager.playBuzzer();
}
var window = SceneManager._scene._logWindow;
window._lines.push(text + '<CENTER>');
window.refresh();
}
</After Eval>


There's just one major downside: I haven't managed to figure out how to get the code check if the target has no weapon (i.e. the part with if (weapon === "null") doesn't work). Currently, the game crashes if the enemy tries to steal weapon from a target which doesn't have one equipped because it can't read the 'name' value of 'weapon'.


I can try to find a solution later on, but it might take a couple of days because I am busy with work. I decided to post the code nevertheless in case you or someone else managed to point out where I went wrong. :)
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
I decided to fiddle with the Enemy Thieves notetags a bit and managed to make enemies steal actor's weapons. It works... sort of.


There's just one major downside: I haven't managed to figure out how to get the code check if the target has no weapon (i.e. the part with if (weapon === "null") doesn't work). Currently, the game crashes if the enemy tries to steal weapon from a target which doesn't have one equipped because it can't read the 'name' value of 'weapon'.


I can try to find a solution later on, but it might take a couple of days because I am busy with work. I decided to post the code nevertheless in case you or someone else managed to point out where I went wrong. :)


Try either


if (weapon === null) // without quotes


or

Code:
if (!weapon)
 

Punamaagi

Hero on their own terms
Veteran
Joined
Jan 23, 2016
Messages
212
Reaction score
314
First Language
Finnish
Primarily Uses
RMMV
Try either



if (weapon === null) // without quotes


or



if (!weapon)
The latter one seemed to do the trick, thanks! At least on my quick test run everything worked as intended.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top