How to make a script that changes the attack animation depending on what weapon you have

Markh10156

Villager
Member
Joined
Oct 24, 2019
Messages
12
Reaction score
0
First Language
English
Primarily Uses
RMMV
I have weapon animations I use with Yanfly for melee weapons but I want to add a ranged weapon and I don't want my characters sliding in and hitting the enemy with a slingshot. Any way I can change what happens when you choose the "Attack" option based on what weapon you're using
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,685
First Language
English
Primarily Uses
RMMZ
Since this concerns Yanfly's plugins and how to mofidy/adapt them, I'm moving this to Javascript/Plugin Support.

I've moved this thread to Javascript/Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
279
Reaction score
244
First Language
French
Primarily Uses
RMMV
Hello! What Yanfly plugins do you use for this? I assume you have Yanfly Battle Engine Core with it's Action Sequences pack, but do you have YEP_WeaponAnimation?
Pretty easy to do if you have those...
 

Markh10156

Villager
Member
Joined
Oct 24, 2019
Messages
12
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello! What Yanfly plugins do you use for this? I assume you have Yanfly Battle Engine Core with it's Action Sequences pack, but do you have YEP_WeaponAnimation?
Pretty easy to do if you have those...
Yeah I have all of those and that's the issue I made an attack animation with it for the base attack that makes the characters move in to attack but I want it to cancel if they're holding a slingshot
 

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
279
Reaction score
244
First Language
French
Primarily Uses
RMMV
You mean somethig like this?
Code:
<target action>
  if user.equips()[0].wtypeId === X
      move user: 25 
      motion attack: user
      motion wait: user
      action animation
      action effect: target
  else
      move user: target, front base, 15, auto offset x -20
      motion attack: user
      motion wait: user
      action animation
      action effect: target
  end
</target action>
*X is to be change for the weapon type Id of slingshots in your Database.
 

Markh10156

Villager
Member
Joined
Oct 24, 2019
Messages
12
Reaction score
0
First Language
English
Primarily Uses
RMMV
You mean somethig like this?
Code:
<target action>
  if user.equips()[0].wtypeId === X
      move user: 25
      motion attack: user
      motion wait: user
      action animation
      action effect: target
  else
      move user: target, front base, 15, auto offset x -20
      motion attack: user
      motion wait: user
      action animation
      action effect: target
  end
</target action>
*X is to be change for the weapon type Id of slingshots in your Database.
Oh thank you I had no idea you could do that. Is there any way I can change the button that says attack to shoot only if he weapon is equipped

Edit: It also crashes my game that code
 
Last edited:

Markh10156

Villager
Member
Joined
Oct 24, 2019
Messages
12
Reaction score
0
First Language
English
Primarily Uses
RMMV
You mean somethig like this?
Code:
<target action>
  if user.equips()[0].wtypeId === X
      move user: 25
      motion attack: user
      motion wait: user
      action animation
      action effect: target
  else
      move user: target, front base, 15, auto offset x -20
      motion attack: user
      motion wait: user
      action animation
      action effect: target
  end
</target action>
*X is to be change for the weapon type Id of slingshots in your Database.
that code just crashes my game Idk why maybe i don't have the plugins in the right ow
Oh thank you I had no idea you could do that. Is there any way I can change the button that says attack to shoot only if he weapon is equipped

Edit: It also crashes my game that code
 

Attachments

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
279
Reaction score
244
First Language
French
Primarily Uses
RMMV
Hello again, maybe you should show us screenshots of your plugin manager and of the actual skill as this "code" works perfectly. It won't crash even if user doesn't have anything equiped in slot 0 or if you let there the X (tested it).
 

Markh10156

Villager
Member
Joined
Oct 24, 2019
Messages
12
Reaction score
0
First Language
English
Primarily Uses
RMMV
Ok so this is the code:
<setup action>

clear battle log

display action

immortal: targets, true

perform start

wait for movement

cast animation

wait for animation

</setup action>



<whole action>

</whole action>



<target action>

<target action>

if user.equips()[0].wtypeId === ShlingShot

move user: 25

motion attack: user

motion wait: user

action animation

action effect: target

else

move user: targets, front, 10

wait for movement

camera screen: target, front center, 15

camera focus: target, front center, 15

wait for camera

perform action

motion attack: user

action animation

wait for animation

action effect: target

death break



</target action>



<follow action>

</follow action>

<finish action>

immortal: targets, false

wait for new line

clear battle log

perform finish

wait for movement

wait for effect

</finish action>

And I'll send Images of the Plugin Manager
 

Attachments

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
279
Reaction score
244
First Language
French
Primarily Uses
RMMV
First, the Weapon Type Id should be a number. Check in your database 'Types' section.

Second you didn't close the if block; you miss a 'end' statement at the end, as in the exemple I provided above... :p

EDIT: ...and you have 2 <target action> notetags...
 

Markh10156

Villager
Member
Joined
Oct 24, 2019
Messages
12
Reaction score
0
First Language
English
Primarily Uses
RMMV
First, the Weapon Type Id should be a number. Check in your database 'Types' section.

Second you didn't close the if block; you miss a 'end' statement at the end, as in the exemple I provided above... :p

EDIT: ...and you have 2 <target action> notetags...
oh wow now I have a whole seperate error oh mans it says "Cannot read property 'toUpperCase' of undefined

New Code:
<setup action>

clear battle log

display action

immortal: targets, true

perform start

wait for movement

cast animation

wait for animation

</setup action>



<whole action>

</whole action>



<target action>

if user.equips()[0].wtypeId === 13

move user: 25

motion attack: user

motion wait: user

action animation

action effect: target

else

move user: targets, front, 10

wait for movement

camera screen: target, front center, 15

camera focus: target, front center, 15

wait for camera

perform action

motion attack: user

action animation

wait for animation

action effect: target

death break

end

</target action>



<follow action>

</follow action>

<finish action>

immortal: targets, false

wait for new line

clear battle log

perform finish

wait for movement

wait for effect

</finish action>

EDIT: Removing the second Target Action did not stop the error
 
Last edited:

TSR

The Northern Frog
Veteran
Joined
Nov 14, 2019
Messages
279
Reaction score
244
First Language
French
Primarily Uses
RMMV
Hello!
It's because the line 'move user: 25' should be write 'move user: forward, 25'.
My bad, sorry :dizzy:
Writed the sequence quickly, just to show an exemple of the use of a conditionnal branch in action sequence... Thought you would input your own sequence :p
Anyway, that should work now.
 

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

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top