Tutorial-Blog There and Back Again: Making Camp with an Item

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,577
Reaction score
5,454
First Language
english
Primarily Uses
RMMZ
@xDRAGOONx Yeah, I was trying to find a way to get my idea working well and kind of stumbled into the idea of using notetags for it. I've played around with custom item notetags before, but this was my first try with map notetags so I was glad I was able to find something that works.

I was hoping that people would find the info useful, it'll be cool to see what other people come up with. :rwink:
 

WaywardMartian

Is sometimes a giant bee
Veteran
Joined
Jan 1, 2017
Messages
223
Reaction score
624
First Language
English
Primarily Uses
RMMV
@hiddenone I really like this idea. No use for it in any of my current projects but I like items that do unusual things like this. One to tuck into the back pocket for later. ^_^
 

Touchfuzzy

Rantagonist
Staff member
Lead Eagle
Joined
Feb 28, 2012
Messages
7,513
Reaction score
9,482
First Language
English
Primarily Uses
RMMZ
@xDRAGOONx Yeah, I was trying to find a way to get my idea working well and kind of stumbled into the idea of using notetags for it. I've played around with custom item notetags before, but this was my first try with map notetags so I was glad I was able to find something that works.

I was hoping that people would find the info useful, it'll be cool to see what other people come up with. :rwink:

Yeah, I think to me that was the highlight of the tutorial. Even I was like "why have I never thought of doing this".
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,755
Reaction score
14,507
First Language
English
Primarily Uses
RMVXA
Interestingly enough I use this idea for my world map when the player checks the map. So with some extension you can use this idea in other creative ways too.
 

ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
276
Reaction score
235
First Language
English
Primarily Uses
RMMV
@xDRAGOONx Yeah, I was trying to find a way to get my idea working well and kind of stumbled into the idea of using notetags for it. I've played around with custom item notetags before, but this was my first try with map notetags so I was glad I was able to find something that works.

I was hoping that people would find the info useful, it'll be cool to see what other people come up with. :rwink:
So your comment about custom item notetags got me thinking about the way I currently handle giving away a random item, it's easy enough because I have all my items grouped together by tier. But let's say I wanted to award a random type of weapon, i.e. a random sword from all the sword-type weapons. I know I could manually define the new array of swords, but I am interested in using js and a custom notetag on each sword to not have to do it manually.

I was looking at the Array.prototype.map() method but I couldn't quite figure out which function to pass...I can reference an individual item's notedata with $dataItems[1].note, but haven't been able to figure out how to check the entire $dataItems array.

I was trying a for loop:
JavaScript:
for (var i = 1; i < $dataItems.length;  i ++) { var note = $dataItems[i].note;}
but I was getting a 'cannot read property "note" of null.

So I tried:
JavaScript:
for (var i = 1; i < $dataItems.length;  i ++) { if ($dataItems[i].note !== null) {var note = $dataItems[i].note;}}


-Pre-Post Edit-

I realized that using Yanfly's item core extends $dataItems.length beyond 2000 and that is where the null was coming from.

Using:
JavaScript:
for (var i = 1; i < 2001;  i ++) {
    if ($dataItems[i].note !== null) {
        var note = $dataItems[i].note;
        if (note.includes('array test>')) {
            array.push($dataItems[i].id)}
    }
};

I was able to create a new array that contains the item Id's of any item with <array test> in it's notetag!

Thank you for the inspiration‼


Now, I can give my items, weapons and armors custom notetags to group them together in various ways and award them accordingly!

While I still fully support organizing the database, this will definitely add a dynamic layer to my project, thanks again!

Also, I realize that I could probably do the random sword-type reward without the custom notetag, considering the nature of the preexisting weapon types, but that was just a simple example to make it easier to realize. My current thoughts on how to implement this align more with the idea of making 'sub-categories' such as:

  • Items that could be secondary fishing rewards, such as seaweed or wood,
  • Ingredients from a particular dish or crafting recipe,
  • Linking particular gems to particular ores as potential secondary rewards when mining,
  • The party leaders preferred food, giving incentive to swap leaders.

I also see this being a great way to have loot pools that award random loot but remove the item from the pool after awarding it.

These tutorials are absolutely helping me expand my knowledge and abilities!


-UPDATE-


I thought I'd drop back by and share the result of what I have been working on in regards to utilizing custom notetags. I would like to preface this by saying that I have only recently started really getting into the js of MV so while this might not be perfect, I am happy with my progress so far. That being said, I am completely open to any and all criticism, advice, suggestions, all of it. Honestly, that's why I am here. Anyway, here is the code I came up with:
JavaScript:
/*----------------------------------------------------------
* These strings are used to denote members of a loot array.
* ---------------------------------------------------------*/

ThreeSixNine.lootStrings = [
    '<harvestLoot>', '<harvestHerb>', '<harvestCook>',
    '<fishingLoot>', '<dayOcean>', '<nightOcean>',
    '<dayRiver>', '<nightRiver>', '<dayLake>',
    '<nightLake>', '<dayCave>', '<nightCave>',
    '<miningLoot>', '<tier1>', '<tier2>', '<tier3>',
    '<diggingLoot>', '<dirt>', '<sand>', '<grass>','<cave>'
];

/*----------------------------------------------------------
* buildLoot loops over $dataItems searching the notebox
* for the strings. The loot array variable Ids are exactly
* 600 more than the matching lootStrings index.
* $gameVariables.value(600) is storing the <harvestLoot>
* item Ids, and so on.
-----------------------------------------------------------*/

ThreeSixNine.buildLoot = function (variable) {
    var loot = [];
    var item = $dataItems;
    for (var i = 1; i < 2001; i++) {
        if (item[i].note !== null && item[i].note.includes(ThreeSixNine.lootStrings[variable - 600])) {
            loot.push(item[i].id);
            $gameVariables.setValue(variable, loot);
        }
    }
};

/*----------------------------------------------------------
* Provides the buildLoot function with its (variable) arg
-----------------------------------------------------------*/
ThreeSixNine.initializeLootArrays = function () {
    for (var i = 600; i < 621; i++) {
        ThreeSixNine.buildLoot(i);
    }
};

/*----------------------------------------------------------
* Awards a random item from a supplied loot array.
* I am using $gameMapInterpreter so mogHunter's treasure
* pop-up will work with through a script call.
-----------------------------------------------------------*/

ThreeSixNine.getRandomLoot = function(array, type, num) {
    var loot = $gameVariables.value(array);
    var length = loot.length;
    var id = Math.floor(Math.random() * length);
    var itemId = $gameVariables.value(array)[id];
    var incDec = 0; //0 for increase, 1 for decrease
    var constVar = type || 0; //0 for constant, 1 for variable
    var value = num || 1; //Constant Value or Variable Id
    $gameMap._interpreter._params = [itemId, incDec, constVar, value];
    $gameMap._interpreter.command126();   
};
 
Last edited:

Latest Threads

Latest Profile Posts

Jeez...
I finally decide, after several ppl asking me to, to create a gamethread about project M... And my internet craps out on me halfway through the process :(
making my first game is like trying to stuff all my experience with old games into one
so its slow and painful when i dont get it right... i bet the next game is gonna be finished earlier!
When you don't find any time to work... :kaocry:
First Ten Minutes of my Caretaker inspired game

Finally, I got a good Gmail message [from smg5urded]
"This game does look a bit plain, but, I'm sure this does not destroy the experience as a whole. Monsters fit your style of game-play, mapping looks crude but I'm sure you can make it better if you do a remake of Forgotten Eclipse"

Forum statistics

Threads
110,397
Messages
1,052,960
Members
143,455
Latest member
Pirata12
Top