JavaScript questions that don't deserve their own thread

JakHydro

Villager
Member
Joined
Jul 31, 2014
Messages
8
Reaction score
0
Primarily Uses
I need help with Java Script for the Equip Requirement


I want to make a weapon requirement where a character can dual-wield only if there is a type of weapon, but if single wielding then can equip any. Example: A character can wield Light Blade, Dark Blade, and Twilight Blade, however if decide to dual-wield, can dual wield Light Blade with Darkblade, darkblade with light blade, but cannot dual wield light blade with light blade, darkblade with darkblade, twilight with twilight, twilight with darkblade, twilight with light blade, and vice versa. Using the lunatic mode how would


<Custom Equip Requirement Condition>


if (user.has weapon type){


condition = true;


}else if (user has no weapon equipped){


condition = true;


}else{


condition = false;


}


</Custom Equip Requirement Condition>


 be used, I know we can have a if no blade is equipped to return true, and then else if there is (if light) a dark type of blade equipped to return true, but what are the java script command for these?
 

Chester

Meow Kitten
Veteran
Joined
Nov 5, 2014
Messages
693
Reaction score
294
First Language
Cat Tongue
Primarily Uses
N/A
I have the code that disables the OPTION menu and so where do I put this in MV ?
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
568
Reaction score
319
First Language
English
Primarily Uses
RMMV
I'm looking for a way to detect and swap the weaponsprite animation of an actor's mainhand weapon to the corresponding offhand weapon.


Long story short - I've got dual wielding set up so that it attacks with the mainhand and then the offhand in sequence, showing the battle animation of weapon1, damage of weapon1, then animation and damage from weapon2. The problem is that the actor swings twice with the weapon type of the weapon in his mainhand. If the actor is using a flail in his mainhand, and a sword in his offhand, I want the individual swings to show the weaponsprite for the correct weapon.


I'm sure this information is stored on items somewhere, but I'm sort of new at this and am not sure how to go about finding/storing/changing these values on the fly.


Any help is appreciated.


edit:


After some more extensive testing, if the actor has no weapon in his mainhand, he uses the weaponanimation of his offhand both times instead.


if I modify $dataWeapons[3018].wtypeId at run time, it has no effect on the weapon swing animation on the first attack (for testing I was using a flail animation), then the second reverted to the offhand weapon because it updated and removed the unequippable weapon from the actor after his attack.


edit2:


If I modify $dataWeapons[3018].weaponImageIndex seems to be what I'm looking for.


edit3:


I managed to cook up something after several hours using @Yanfly's weapon animations script, which it appears weaponImageIndex is coming from, as the weapons that I didn't set notetags for didn't have this property to pull from.


by saving the index to a variable, and then swapping them around in the Window_BattleLog.prototype.showActorAttackAnimation function, I was able to get actors to alternate weaponindexes as well as swapping the battle animations from the main and offhand. The only thing left to fix now is getting actors to swap swing/thrust/missile animations when they're dual wielding weapons of different types.

View attachment Test Project 001 2016-03-06 5_17_16 AM_VP8.webm
 
Last edited by a moderator:

Firgof

Artist / Designer
Veteran
Joined
Jul 29, 2012
Messages
236
Reaction score
214
First Language
English
Primarily Uses
Is there a faster way to grab the screen and save it to a bitmap than Bitmap.snap()?


Trying to have a 'ghosting' effect like I did in the VX Ace game where I used these methods and it's a lot slower in JS than it was in RGSS.
 

ThePotatoOfFire

Stop, in the name of candy!
Veteran
Joined
Jan 15, 2016
Messages
153
Reaction score
56
First Language
English
Primarily Uses
RMMV
Being the flop at Javascript that I am, I have a question. I'm trying to eliminate the standard levels in MV, and am using Yanfly's Job Points/Fox JP Levels instead. What should I do to get rid of default levels, or is this a plugin request-worthy subject?
 

Vatra

Warper
Member
Joined
Mar 19, 2016
Messages
2
Reaction score
0
First Language
English
Primarily Uses
Hello, I'm currently kind of "trial and error"-ing my way through code when I need to use it. In other words, I don't know what I'm doing. I'm having an "undefined is not a function" type error on this and would appreciate any advice I could get. I'm probably missing something fundamental ^^;


<Custom Apply Effect>


if (target.isActor()) {


if (target.hasState(12) == false) {


var hp = Math.floor(target.mhp * 0.15);


target.gainHp(hp);


target.addState(12);


}


}


</Custom Apply Effect>
This is for use with Yanfly's Buff & States Core, which, in this case, would run custom code when a state is applied. This is on my state 1 "knockout." What I'm trying to achieve is to revive an actor with a small amount of hp, but also apply a "near-death" state. If the actor's hp hits 0 again, and still has state 12, "near-death", then they would remain under state 1, "knockout", with 0 hp.
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
229
Reaction score
74
First Language
German
Hello, I'm currently kind of "trial and error"-ing my way through code when I need to use it. In other words, I don't know what I'm doing. I'm having an "undefined is not a function" type error on this and would appreciate any advice I could get. I'm probably missing something fundamental ^^;


<Custom Apply Effect>


if (target.isActor()) {


if (target.hasState(12) == false) {


var hp = Math.floor(target.mhp * 0.15);


target.gainHp(hp);


target.addState(12);


}


}


</Custom Apply Effect>


My guess would be your target.hasState(12).


Try target.isStateAffected(12) instead
 
Last edited by a moderator:

DuraLexSedLex

Villager
Member
Joined
Feb 13, 2016
Messages
26
Reaction score
4
Primarily Uses
Hello everyone! I'd like to make a variable randomizer accompanied with an if else statement. I'm going to use it with yanfly's action sequence pack, wherein the player shouts or not upon attacking an enemy.


Ex. 


1. Generate random variable from 1 to 3


2. if variable <= 2


3. play SE


4. else


5. none(or play another SE)


6. end


Thank you in advance!


EDIT: Solved! For yanfly's actseq pack atleast.


if Math.randomInt(3)+1 <= 2


se: filename1


else


se: filename2


end
 
Last edited by a moderator:

Vatra

Warper
Member
Joined
Mar 19, 2016
Messages
2
Reaction score
0
First Language
English
Primarily Uses
My guess would be your target.hasState(12).


Try target.isStateAffected(12) instead
Thank you very very much, that was exactly it. I've been trying to find the rpgm specific calls, but have only found incomplete lists.


My method here was flawed, but I've since fixed it up.
 

MagicMagor

Veteran
Veteran
Joined
Apr 7, 2012
Messages
201
Reaction score
38
First Language
German
I'm currently using  this plugin Custom Stats to have some additional values attached to enemies and actors.


Using Yanflys script i use these values in calculating the final attack value - that works without a problem.


The problem however is the equip-screen which shows the stat-change when changing equipment. I narrowed the problem down, to calculate this change a temporary actor-copy is created using JsonEx.makeDeepCopy - and in this copy my additional values are not included.


I assume that this arise because the script above will not store the actual values on the actor/enemey but instead somewhere else and just has the getter-function on the actor/enemy.


So i thought about writing my own plugin for what i need (i started writing utility-function for this anyway), so now my question is probably really simple: What do i need to ensure my additional values are included in the deepCopy? Do i just have to make them part of the BattlerBase-object? (Like this._myExtraStats = 1234) I would assume so, but i want to be sure.


Edit:


Answering my own question. After writing my own plugin i can conclude that having them part of the Game_BattlerBase object itself is enough.
 
Last edited by a moderator:

staf00

Veteran
Veteran
Joined
Feb 22, 2016
Messages
84
Reaction score
9
First Language
English
Primarily Uses
Is there anything wrong with the following? Cube root, and also what's the correct term for the user's level if it's not a.lvl?


<damage formula>


value = Math.cbrt(a.atk * a.mat / a.lvl) * 100 / (100 + b.def);


</damage formula>
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
229
Reaction score
74
First Language
German
Is there anything wrong with the following? Cube root, and also what's the correct term for the user's level if it's not a.lvl?


<damage formula>


value = Math.cbrt(a.atk * a.mat / a.lvl) * 100 / (100 + b.def);


</damage formula>


user's level should be

Code:
a.level
 

Dungeonmind

Lvl 4000 Humanoid
Veteran
Joined
Sep 2, 2013
Messages
440
Reaction score
272
First Language
English
Primarily Uses
RMMV
Hello all. Can anyone help me with showing picture above message window in MV without adding any of the bust plugins. I don't want to use those cause I have a system completely evented and I show busts in another style then the plugins available provide. So if someone with enough JS knowledge can lead me any way to accomplish this, It would be much appreciated.
 
Joined
Jul 18, 2015
Messages
3
Reaction score
0
First Language
German
Primarily Uses
So I would like to use the script below to use specific skills from the actor with the use of buttons.


http://forums.rpgmakerweb.com/index.php?/topic/56988-button-cast-plugin/


The problem now is that currently there is now way that the user of the game can change the skills or the buttons used, while playing the game.


So in the moba mode you can press for example "q" and then it uses skill "dual attack" (for the first actor).


My question now is, if it would be possible and how it would look like to use a variable in the notetag like this:


<ButtonCast Key: var1: var2>


[SIZE=13.6px]where var 1 is set to for example "t" (button)[/SIZE]


[SIZE=13.6px]and var 2 is set to "15" (skill id) in other script calls.[/SIZE]


[SIZE=13.6px]Or would it be possible to get the note and change it in a external script call alltogether ? like[/SIZE]


[SIZE=13.6px]$gameActors.actor(1).getNote("ButtonCast Key").setValues("t", 15);[/SIZE]


[SIZE=13.6px]sorry for false syntax and the like, first time working with javascript and wanted to know if it would be possible for something like this to be implemented.[/SIZE]
 

staf00

Veteran
Veteran
Joined
Feb 22, 2016
Messages
84
Reaction score
9
First Language
English
Primarily Uses
How do I properly reference state turns left. I want to make a spell that scales w/ the number of turns left on a state. 


something like...


<damage formula>


value = a.mat * .stateTurns or ._stateTurns[116];


</damage formula>


idk how's it supposed to be formatted
 

milk

Veteran
Veteran
Joined
Oct 18, 2015
Messages
44
Reaction score
45
First Language
english
Primarily Uses
I asked this last year but never got an answer or figured out a solution and it is extremely frustrating. I made the font size larger for my game and now the text gets cut off at the bottom if its a long letter like "g" or "y". there is also extra space at the top of the message windows because the text isnt aligned right. I need to figure out how to change the position of the text on the y axis so i can move it up slightly but there is no option for that in the yanfly message core. i tried messing with the window padding and text padding but it didn't work. 
 

Forthright

Veteran
Veteran
Joined
Mar 9, 2016
Messages
60
Reaction score
10
First Language
English
Primarily Uses
So I have a question and I'm not sure it's worthy of it's own thread.  I am having trouble with the equip screen.  My game uses custom stats like Strength, Dexterity and the like to determine Base Parameters like Attack, Defence and so on.  What I'm seeing is when I change equipment, it doesn't show what the change will be, whether it is unequipped or if I am putting on a new piece of equipment.  I'm using Bobstah's Custom Stats to define the stats, but I want to fix this show the equipment shows the before and after values properly.


I have added an image of my problem.

Capture.PNG
 

Reaxus

Villager
Member
Joined
Dec 13, 2015
Messages
14
Reaction score
1
First Language
English
I'm having a problem trying to get the party leader's actorID.
i tried using this code(i'm using yanfly's auto passive states plugin)


<Custom Passive Condition>
if ($gameParty.leader().actorId() == 3) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>




but it gives me back "Cannot read property 'actorId' of undefined.



what im trying to get is that it checks if the leader is party member #
I tried 3 equals,
removing the '()s' (it'll run the game but the passive skill wont work)
after checking the party leader's id it checks if he already learned a certain skill.



in short, what im trying to get is:
if party.leader.actorId == ##
  if actorid=3 islearnedskill ## == true      <-- something like that

hope you could help me out of this!
Thanks guys!
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
818
First Language
English
Primarily Uses
I'm having a problem trying to get the party leader's actorID.
i tried using this code(i'm using yanfly's auto passive states plugin)



<Custom Passive Condition>
if ($gameParty.leader().actorId() == 3) {
condition = true;
} else {
condition = false;
}

</Custom Passive Condition>




but it gives me back "Cannot read property 'actorId' of undefined.



what im trying to get is that it checks if the leader is party member #
I tried 3 equals,
removing the '()s' (it'll run the game but the passive skill wont work)
after checking the party leader's id it checks if he already learned a certain skill.



in short, what im trying to get is:
if party.leader.actorId == ##
  if actorid=3 islearnedskill ## == true      <-- something like that

hope you could help me out of this!
Thanks guys!
Try this.

Code:
if ($gameParty.leader() && $gameParty.leader().actorId() === 3) {

condition = true;

}

else {

condition = false;

}
 

Reaxus

Villager
Member
Joined
Dec 13, 2015
Messages
14
Reaction score
1
First Language
English
Try this.



if ($gameParty.leader() && $gameParty.leader().actorId() === 3) {

condition = true;

}

else {

condition = false;

}
tried this out, sadly the skill works even if the party leader isnt actor 3.
thanks for replying tho!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

"Hey there! Hope you're having a nice day, you are awesome!"

(Of course the hand is awful :kaoswt: )
I need a new option on YouTube that goes "Dont recommend videos/channels in this language because I do not speak it"
I've reconsidered having a subclass system for my first two games since there will already be plenty of variation in playable actors and usable items in the games. The third game will need it because of the basis for the story but I want the actors in the first two to be more focused in their roles.
Behold! The Sea Doggo.
I am dead tired but at the same time I really wanna write a tutorial x_x

Forum statistics

Threads
93,372
Messages
911,774
Members
122,870
Latest member
BrokenBratva
Top