A weapon with certain hit

mmearrccii

Warper
Member
Joined
Oct 20, 2012
Messages
3
Reaction score
0
Primarily Uses
Hello


I'm playing around with covers in my game and I would like to make it so, that arrows can pierce through enemy cover (substitute should be ignored in case of bow weapon type). I know that I need to change this part of the code:

def check_substitute(target, item)
    (!item || !item.certain?)
  end



My problem is, that this method only has two parameters, none of which I can use for determining if the attacking weapon is a bow or not (the first is the enemy being attacked, the second is the skill which is being used).


I also saw a @subject variable but I have no idea what it's parameters are and the documentation has no info of it (Seriously though, in a case like this how should I know?). It frustrates me, because I know it should be simple to do, but I'm unable to do so because i can't see through the code >.<


 Any help would be greatly appriciated!
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,380
Reaction score
8,537
First Language
English
Primarily Uses
RMMV
Is this a part of specific script? If so, can you link it? If it's part of the default code, this should probably be best moved to Learning RGSS.
 

mmearrccii

Warper
Member
Joined
Oct 20, 2012
Messages
3
Reaction score
0
Primarily Uses
Is this a part of specific script? If so, can you link it? If it's part of the default code, this should probably be best moved to Learning RGSS.
It is part of the default code, so I guess it could be. There are some modifications for it (Like galv's substitute functionality). Sorry I wasn't quite sure if this is the right thread.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
I also saw a @subject variable but I have no idea what it's parameters are and the documentation has no info of it (Seriously though, in a case like this how should I know?). It frustrates me, because I know it should be simple to do, but I'm unable to do so because i can't see through the code >.<


You backtrack the @subject instance variable in these cases. 


If there is a variable, it must be set before any methods can be run on it. You will see that some methods are called on @subject in the code, so it is set somewhere for sure.


It is an instance variable, and because the default scripts are separated object by object, you can simply search for that variable there, and check where is it set.


Once you know that, you can see what value it gets, and will most probably know what is it used for than.


It is a battler object. It will always refer to the currently acting actor or enemy.


You can also solve your issue if you use a script which sets different skills to different weapons, or if you use a script which changes the "Attack" command in the battle to different skills you set for your actors/enemies. Yanfly made at least one of these script types.


With that, just make a different skill for your bow attacks and set the skill's "Hit Type" to "Certain Hit".


Or if you want to enable hit and evade calculations with the skill, you can do that too, because now you have access to the correct skill tied to the user's weapon which happens to have a note-tag. In this case, leave the "Hit Type" on "Physical". Check if the skill's note-tag has a specific phrase. If it has, you disable substitution at the method you have shown in your opening post, otherwise it should proceed with the substitute check.


I think, this is the right place to ask this, because you asked for help regarding an already existing script (default or not, it is already written).


The learning section should contain questions about syntax, correct code structuring, and such, in my opinion, not directly related to any existing script.
 

mmearrccii

Warper
Member
Joined
Oct 20, 2012
Messages
3
Reaction score
0
Primarily Uses
You backtrack the @subject instance variable in these cases. 


If there is a variable, it must be set before any methods can be run on it. You will see that some methods are called on @subject in the code, so it is set somewhere for sure.


It is an instance variable, and because the default scripts are separated object by object, you can simply search for that variable there, and check where is it set.


Once you know that, you can see what value it gets, and will most probably know what is it used for than.


It is a battler object. It will always refer to the currently acting actor or enemy.


You can also solve your issue if you use a script which sets different skills to different weapons, or if you use a script which changes the "Attack" command in the battle to different skills you set for your actors/enemies. Yanfly made at least one of these script types.


With that, just make a different skill for your bow attacks and set the skill's "Hit Type" to "Certain Hit".


Or if you want to enable hit and evade calculations with the skill, you can do that too, because now you have access to the correct skill tied to the user's weapon which happens to have a note-tag. In this case, leave the "Hit Type" on "Physical". Check if the skill's note-tag has a specific phrase. If it has, you disable substitution at the method you have shown in your opening post, otherwise it should proceed with the substitute check.


I think, this is the right place to ask this, because you asked for help regarding an already existing script (default or not, it is already written).


The learning section should contain questions about syntax, correct code structuring, and such, in my opinion, not directly related to any existing script.


Thanks, this helped a lot. I managed to do it with your help.


In the end this is what I got, if anyone is interested:


def check_substitute(target, item)
if @subject.actor?
if @subject.weapons[0] != nil
if @subject.weapons[0].wtype_id == 2 || item.certain?; return false end
end
end
if item.certain?; return false end
return true
end


Not sure what the !item part did so I removed it.
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
!item means that it checks if the item variable is not nil, so if it would not have a value, this check acts as a fail-proof against crashes (because you will call methods on the item variable, and if it happens to be nil, you will get a crash).


I'm surprised you didn't get an error with that snipped, because you haven't used the ; sign after your return "lines".


But what you wrote looks much cleaner with this syntax:


def check_substitute(target, item)
if @subject.actor?
if @subject.weapons[0] != nil
return false if @subject.weapons[0].wtype_id == 2 || item.certain?
end
end
return false if item.certain?
return true
end


Note that this will return false for ALL skills OR items used if the subject happens to have a weapon from weapon type 2 equipped.


If that is what you want, than yeah, the snippet will work.


But if you want only some skills to have this effect (for example, only your bow skills and not other skills) regardless if you have that weapon type equipped or not, you will have to change this snippet. This only matters if your actors can use other skills aside from bow skills when this weapon type is equipped, obviously.
 

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

Latest Threads

Latest Posts

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,047
Messages
1,018,539
Members
137,834
Latest member
EverNoir
Top