Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

How to get an equipped weapon ID?

Well... I'm writing a plugin that checks for weapons in inventory and for equipped weapons, store them in an array,
take a random weapon and remove it from player (even if it's equipped). So far so good. The problem is, when I try to store the ID of the chosen weapon in a variable I got some messed numbers like 3001, 3010, The code works but the ID part don't.

Here it is. Don't mind this strange words, some of them are in Portuguese.

JavaScript:
DataManager.roubarArma = function(variable){
    var armaPool = [];
    var armaEqpPool = [];
    var partySize = $gameParty.size();
    var total = $gameParty.weapons().length;

    for (var i = 1; i <= partySize; i++) {
        var actor = $gameActors.actor(i);
        if(!actor.hasNoWeapons()){
            if(actor.weapons()[0]){
                armaEqpPool.push(actor.weapons()[0]);
            }
            if (actor.weapons()[1]){
                armaEqpPool.push(actor.weapons()[1]);
            }
        } 
    }

    if (total > 0){
        for (var i = 0; i < total; i++) {
            var arma = $gameParty.weapons()[i];
            armaPool.push(arma);
        }
    }

    if (armaEqpPool.length > 0){
        for (var i = 0; i < armaEqpPool.length; i++) {
            var arma = armaEqpPool[i];
            armaPool.push(arma);
        }
    }
    if (armaPool.length > 0){
        var random = Math.floor(Math.random() * armaPool.length);
        $gameParty.loseItem(armaPool[random], 1, true);
        $gameVariables.setValue(variable, armaPool[random].id);
        $gameMessage.add("Fulano roubou " + String(armaPool[random].name));
    }   
};
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
I'm sorry what exactly are you attempting to do? Maybe explain it in terms of how you want the final outcome to be. What is it that you are trying to do for your players? Maybe if I understand more of the mechanics and reasoning behind what you're attempting to do, I could help you out.
 
Top