JavaScript questions that don't deserve their own thread

tsukasa102938

Villager
Member
Joined
Dec 15, 2013
Messages
10
Reaction score
1
Primarily Uses
I'm trying to make it so actors and enemies die when either HP or MP hits 0. I know with VX Ace it was basically added MP to the death check, but how do you go about doing it in MV? I found where the death state is applied to HP damage around like 9013 in rpg_objects. It uses changeHp, but there is no changeMp. 


How would I go about doing this?
 

ThePotatoOfFire

Stop, in the name of candy!
Veteran
Joined
Jan 15, 2016
Messages
153
Reaction score
57
First Language
English
Primarily Uses
RMMV
I'm trying to make it so actors and enemies die when either HP or MP hits 0. I know with VX Ace it was basically added MP to the death check, but how do you go about doing it in MV? I found where the death state is applied to HP damage around like 9013 in rpg_objects. It uses changeHp, but there is no changeMp. 


How would I go about doing this?
I believe Himeworks has a Custom Death States plugin to do just that. Just search that plugin name on the forum and you'll find it.
 
Last edited by a moderator:

Prescott

argggghhh
Veteran
Joined
Aug 28, 2014
Messages
469
Reaction score
357
First Language
English
Primarily Uses
RMMV
What is the plugin command to refresh the game (like using F5 but forcing it instead)?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
window.location.reload()


Since the game is basically a webpage running inside a browser, you reload it the same way as any other webpage.
 

lithkast

Quirky mini boss
Veteran
Joined
May 12, 2014
Messages
105
Reaction score
49
First Language
english
Primarily Uses
How do I check equipped weapons and armor in battle for a damage formula?

I know it has something to do with a.equips but I don't know how to get it to check weapons and armors from there.  Any help would be appreciated.
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
229
Reaction score
74
First Language
German
How do I check equipped weapons and armor in battle for a damage formula?

I know it has something to do with a.equips but I don't know how to get it to check weapons and armors from there.  Any help would be appreciated.


What exactly do you want to do with it?


With a.equips you'll get an array with the equipped items.


a.equips()[0] would be the weapon object


1 is the shield


2 is the head piece


3 is the body piece


4 is the accessory
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
You can use


a.armors()


or


a.weapons()


to get all armors and weapons, respectively.
 

ThePotatoOfFire

Stop, in the name of candy!
Veteran
Joined
Jan 15, 2016
Messages
153
Reaction score
57
First Language
English
Primarily Uses
RMMV
How do I check equipped weapons and armor in battle for a damage formula?

I know it has something to do with a.equips but I don't know how to get it to check weapons and armors from there.  Any help would be appreciated.
Himeworks has a Weapon Damage plugin that lets you reference the equipped weapon in formulas.
 

lithkast

Quirky mini boss
Veteran
Joined
May 12, 2014
Messages
105
Reaction score
49
First Language
english
Primarily Uses
I know about hime's plugin ^.^  No my goal wasn't to assign a piece of gear a damage value, but rather get around state usage by seeing if a specific piece of equipment was equipped.  

I just went with states because its easier.  That being said, for other people who may be having this similar problem...

I was trying to reference a specific piece of equipment.  The item in question would be an accessory called "God's Ring" and equipping it would allow that character to exceed damage limits.  I was hoping I could reference the item directly for an if statement, but ultimately couldn't figure it out.  Using a state is much easier in that regard.   
 

rhyme

Level 99 Demi-fiend
Member
Joined
Mar 18, 2012
Messages
38
Reaction score
77
First Language
body language
Primarily Uses
Am I doing something wrong?
I seem to always land in trouble when I use bitmap.blt() in RMMV.


The below code will fail to produce the image, but the fillRect line works properly.


var bmp = ImageManager.loadSystem("ctbicon_a_0");
this.contents.fillRect(0, 0, this.contents.width, itemHeight, this._bgColor);
this.contents.blt(bmp, 0, 0, 128, 192, 0, 0, 128, 192);


And this line works for creating a sprite based off a bitmap. 


this.hazardGaugeBack= new Sprite_Base();
this.hazardGaugeBack.bitmap = ImageManager.loadSystem('hazback');



I can then clearRect and fillRect on it, but


this.hazardGaugeFill.bitmap = ImageManager.loadSystem('hazfillempty');
var hazFillImage = ImageManager.loadSystem('hazfillnormal');
this.hazardGaugeFill.bitmap.blt(hazFillImage, sx, 0, sw, 16);



The moment I try to use a blt, it just won't work. 


Does anyone know if I'm just doing something wrong?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
Your last example seems to be missing some parameters, so that can't work, anyway. For the first example make sure, that:


- Your given width (the first 128) and height (the first 192) aren't greater, than the source bitmap's dimensions. Otherwise, blt will silently fail.


- The bitmap has loaded, already. Usually this is done by loading bitmaps during Scene.create and rendering them in Scene.start and later. If you are loading the bitmap dynamically, you'll need to add a load listener, that will wait until it's loaded and draw it, afterwards.


The easier way would be to simply display another sprite on top of the background. Uses up slightly more memory, but you won't get any issues with asynchronous loading.


/edit: Here's the (luckily documented) source for the blt function:

Code:
/**
 * Performs a block transfer.
 *
 * @method blt
 * @param {Bitmap} source The bitmap to draw
 * @param {Number} sx The x coordinate in the source
 * @param {Number} sy The y coordinate in the source
 * @param {Number} sw The width of the source image
 * @param {Number} sh The height of the source image
 * @param {Number} dx The x coordinate in the destination
 * @param {Number} dy The y coordinate in the destination
 * @param {Number} [dw=sw] The width to draw the image in the destination
 * @param {Number} [dh=sh] The height to draw the image in the destination
 */
Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
    dw = dw || sw;
    dh = dh || sh;
    if (sx >= 0 && sy >= 0 && sw > 0 && sh > 0 && dw > 0 && dh > 0 &&
            sx + sw <= source.width && sy + sh <= source.height) {
        this._context.globalCompositeOperation = 'source-over';
        this._context.drawImage(source._canvas, sx, sy, sw, sh, dx, dy, dw, dh);
        this._setDirty();
    }
};
 
Last edited by a moderator:

rhyme

Level 99 Demi-fiend
Member
Joined
Mar 18, 2012
Messages
38
Reaction score
77
First Language
body language
Primarily Uses
- The bitmap has loaded, already. Usually this is done by loading bitmaps during Scene.create and rendering them in Scene.start and later. If you are loading the bitmap dynamically, you'll need to add a load listener, that will wait until it's loaded and draw it, afterwards.
The objects(sprites) are currently within a window each, is it possible/recommended to load the bitmap during the Window_~~~.initialize() function? (Would that also mean I have to create any sprites bound to the window in initialize() as well?)

The easier way would be to simply display another sprite on top of the background. Uses up slightly more memory, but you won't get any issues with asynchronous loading.
Does that mean to create another sprite with a blank bitmap on top of the sprite in question?
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
Assuming your window is displayed during Scene_Map, you would load the bitmap during Scene_Map.prototype.create. This is because, Scene_Base.prototype.isReady will return false, as long as the ImageManager hasn't finished loading all bitmaps and they are guaranteed to be available in Scene_Map.prototype.start and later.


The window class itself shouldn't bother with loading images, since it has to draw them und thus assumes, that they are already available.


As for the additional sprite, you can add it as a child to the parent sprite, like this:


parentSprite.addChild(sprite);


This way, it will always be positioned relative to the parent, so you don't have to manually sync them.
 

rhyme

Level 99 Demi-fiend
Member
Joined
Mar 18, 2012
Messages
38
Reaction score
77
First Language
body language
Primarily Uses
I think I got the basic idea and have edited my code to do so!


It's now working!


Thank you for your assistance!
 

Swood Druid

Warper
Member
Joined
Feb 24, 2016
Messages
2
Reaction score
2
First Language
English
Primarily Uses
I recently found a plugin that allows healing after every battle. This is very useful for my game because I need healing to full after combat. However, I'm having some issues figuring out how to lower mana after battles (TP won't work, as it's used for another aspect). This plugin doesn't contain anything but health, and while useful, I need a bit extra. Here's the code - (Originally written by Gilles Meyer)


// Only gain HP if not dead
if(!this.isDead()) {
var regainHP = this.mhp;
if(useMaxHp < 1) {
regainHP = this.hp;
}
var onePercent = regainHP/100;
this.gainHp(onePercent * percentage);
}
}
_Game_Battler_onBattleEnd.call(this,arguments);
};


Now, this part works perfectly. In short, what I'm asking is what kind of lines are needed in order to lower all actor's mana. I was unsure if this warranted its own thread, if so, I'd be happy to move it. Thanks.


Edit: Disregard, figured it out!
 
Last edited by a moderator:

staf00

Veteran
Veteran
Joined
Feb 22, 2016
Messages
84
Reaction score
9
First Language
English
Primarily Uses
Copy pasted from my reddit post:
 


I'm trying to make a state that changes the element rate of a certain element for certain situations (if then function). I've tried elementRate and calcElementRate and neither have worked. What's the proper syntax for referencing Element Rate?


E.g. (for simplicity's sake)


<Custom Select Effect>


target.elementRate(4) == 1000;


</Custom Select Effect>


"4" is the ElementID for fire in my game btw, I just set it to 1000 to see if it would have any obvious effect, which it didn't. Also I'm using Yanfly's buffstatescore plugin. I've tried other notetags too like <Custom Apply Effect> or <Custom Turn Start Effect>, to no avail. If I could just get an example of elementRate being used in a notetag, that'd help a lot. Also have tried "=" "==" "*=".


I intend to use this to make my burn state make the target take more fire damage, but I want it to scale with how many turns left of the burn there are (elementRate *= 1 + turns left of burn * 0.1) and then consume (remove) the state. So I'll have to reference _stateSteps or perhaps its something else. Anyway just trying to figure out the elementRate portion before I get into that. Oh right, and I'm using most of Yanfly's plugins as well.
 
Last edited by a moderator:

lokirafael

Veteran
Veteran
Joined
Jun 25, 2012
Messages
152
Reaction score
77
First Language
Portuguese
Primarily Uses
RMMV
Hello there,


I'm trying to make a effect using Yanfly Lunatic and was wondering if its possible to use Luck as a chance to activate the effect.


Logic would be something like:


<Reaction Tag>


Chance = a.luck * 0.5


Hit = rand(100)


if Hit <= Chance then


(Effect)


</Reaction Tag>


Thanks


As a side question: Anyone made a list of common javascript commands like Formar did on rgss3? That was a big help for someone with low programming skills. :/
 
Last edited by a moderator:

TheGamedawg

Veteran
Veteran
Joined
Aug 29, 2014
Messages
350
Reaction score
133
First Language
English
Primarily Uses
I have a question for Yanfly's YEP_GabWindow plugin.  Basically, whenever you open up the menu while a gab is being displayed, it will replay the gab form the start, including the sound effect if you have one set.  I hear this is intentional, but I don't think it fits my game.  It doesn't appear there's an easy way to fix this though.  Can anyone help?
 

zerobeat032

Cloaked Wanderer...
Veteran
Joined
Mar 28, 2014
Messages
214
Reaction score
146
First Language
English
Primarily Uses
RMMV
is there a list of things that can plugged into statements like this...


<Instant Eval>if (user.atk >= 300) instant = true;</Instant Eval>


I'm curious, not just for this particular example which is Yanfly's Instant Cast, but in general what kind of things can go in these kind of checks. I think I understand checking for switches and variables (I think), but i'm not sure what other things can be put in these.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

convention concluded, i'm glad the books well received and sold out
not every content is decent, but i'll be better for the next work.

now back to game developing
I hope to be able to post my vxace resource edits this Wednesday.
Not sure if I'll get to the library though.
Me: Man, I'm definitely burned out this time. Time for a break. Me three hours later: I'm ready to work again, let's go! Me another hour later: Okay, I can't do this anymore. Repeat for infinity.
Just got MV and am working on porting over my new game from VX Ace to it! I haven't done much with my new game so it should be pretty quick.
I was doing forge runs on D2 with my wife last night, and singing like a leprechaun to annoy her XD. I was calling it 'The Farge'

Forum statistics

Threads
94,448
Messages
921,037
Members
124,279
Latest member
Lacy
Top