Gathering information about attacks, doing things on hit

ArronYagger

Villager
Member
Joined
Jan 9, 2016
Messages
23
Reaction score
1
First Language
English
So I want to do a couple of things:


1) When a player attacks/uses a skill/uses magic/uses special/uses item in battle and only battle and successfully hits either an enemy or a another player I want to do x.


The issue?


First, where is this logic?


Second, How do I tell what they used


Third, How do I tell that yes you hit, either your self, another player or an enemy.


Once I have that info Ill be set. Thanks for your help all.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
That is not how the default damage sequence works.


Similiar things can be done, but with different structures. If a skill hits, the damage formula of the skill gets executed. That can do much more than just calculating a number - please search the forum for the topic on javascript code used inside the damage formula.


Also, check this for the skill/damage sequence:
 

ArronYagger

Villager
Member
Joined
Jan 9, 2016
Messages
23
Reaction score
1
First Language
English
I am not looking to do stuff for the damage I just want to say:


When player X hits with either item, weapon, armor, skill, spell or special - Do x on a successful hit and only in battle. I essentially just want to reward xp on a successful hit ... 


I also need to know who is attacking so I can reward the XP.


Looking at the info graphic didn't really help because it doesn't say, go to this line of code to see a successful hit ... 


There has to be some where in the code to determine what you used to attack and who you attacked and who is attacking. For example if ralph uses a sword to attack enemy B where is that located? or the pieces of that located?
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
When player X hits with either item, weapon, armor, skill, spell or special - Do x on a successful hit and only in battle. I essentially just want to reward xp on a successful hit ... 
That is exactly what I was telling you - that's why I also mentioned that things work differently in RM.


Equipment like weapons and armors can hit nothing, because they are nothing other than ways to add to actor values. So in your example ralph had used the skill attack and is executing the damage formula from the attack skill. He cannot use a sword, he can only have it equipped while using the skill attack. And if the sword has any features/traits they get added to any skill that uses the "normal attack" element/state/trait.


There are only skills and items that can hit/can have an effect on any target - spells and special and whatever are nothing but skills in the engine.


And the damage formula is the hit detector - if a target is hit, the damage formula gets processed. If nothing hits, the damage formula will not get processed. There is no additional flag to determine a hit because that is not needed.


And if the damage formula is executed, the a inside is the placeholder for the skill user while the b is the placeholder for the target. And if you want to add EXP to the skill user, you simply do that by adding EXP to a inside the damage formula.
 

ArronYagger

Villager
Member
Joined
Jan 9, 2016
Messages
23
Reaction score
1
First Language
English
Ok. So looking back at the image heres the three things I want based off the image you linked:


A ) Who is attacking/using item/using skill - essentially who the heck is doing what right now. I don't care what you are targeting I just want to know who you are. Are you a game actor or are you a game enemy. that is what I want to know. Where is the code for that?


B ) Lets look at the image you linked: Damage or heal the target (at the very bottom) Where is this code?


C ) Again with the image, Apply States buffs and/or debuffs (very bottom) Where is this code?


These "functions" where ever they are are the ones I want to change. It should be:


Who is doing the action, when the action is finished reward the exp based on the target of the action.


So example:


Ralph targets slime and uses skill attack. Ralph hits the slime and does 5 damage. Ralph then gains 10 xp.




Hope that was more clear ??
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
I always understood what you're trying to do - what I was trying to explain to you is that the engine framework already provides a better way to do what you want, and that your way of changing the code will cause you problems with compatibilities, and that you need to rethink your approach to make use of the existing structure.


If you try to implement your way, you'll have to do everything manually and have the problem that a lot of the existing scripts will not work together with your code.


Just as an example: there is no check for "Hit", because the engine checks for MISS - it aborts the damage flow if the skill user misses, and continues on "not missed".


For example, if you write the following code into a skills damage formula:


a.gainExp(10);5


and the actor Ralph uses that skill, then Ralph will gain 10 EXP and 5 damage will be done to the target. If on the other hand Actor XYZ will use the same skill, then Actor XYZ will gain those 10 EXP - you do not need to code to identify which actor had used the skill, because the engine will handle that automatically.


Any javascript code can be executed inside the damage formula - including if-checks for values of both skill user and skill target without ever needing to identify that user/target yourself, the engine will handle that identification automatically when you use the placeholders a and b in the javascript code of your damage formula. And that is also why you don't need to find the lines in the engine where that is decided - something that is extremely different anyway because the engine uses eval for the damage formula.


You can check here for code to be used:







And even if you do want to change the existing code - asking for the lines is still the wrong way to go. A better way would be to write a plugin that aliases (preferably) or overwrites (may cause compatibility issues) the existing formula with the code you need. That is needed because the code had been minimalized and is almost unreadable in its base form - if you want to check how it works in the original, better use the following variant (which has different line numbers, you can't use those lines to find the code in the original files):
 

ArronYagger

Villager
Member
Joined
Jan 9, 2016
Messages
23
Reaction score
1
First Language
English
Ok so this answers 90% of my questions as now I can give XP via the DMG formulas for basically anything.


The final peice of this which is still on topic, just shifts it a tiny bit, is the following code - which I am sure based on this discussion there is a better way to do it, yes I have overwritten some things but keep in mind this is nothing more then a proof of concept.


This all coincides with me trying to do a FFT or a fire emblem type of xp thing where actions in battle  give you XP, so consider the following for a split second:


Game_Actor.prototype.expForLevel = function(level) {
return 100;
};

Game_Actor.prototype.currentLevelExp = function() {
return 0;
};

Game_Actor.prototype.changeExp = function(exp, show) {
this._exp[this._classId] = Math.max(exp, 0);
var lastLevel = this._level;
var lastSkills = this.skills();

while (!this.isMaxLevel() && this.currentExp() >= this.nextLevelExp()) {
this.levelUp();
this.changeExp(this.currentExp() - 100);
}

while (this.currentExp() < this.currentLevelExp()) {
this.levelDown();
}

if (show && this._level > lastLevel) {
this.displayLevelUp(this.findNewSkills(lastSkills));
}

this.refresh();
};


What I am trying to do here is say you need 100 xp for each level regardless of level and at the gain of each level we subtract your current exp from 100, so imagine you are rewarded 875 exp, well with this logic you gain 8 levels and have 75 exp towards your ninth level gain. (the goal is that if you are rewarded 100 exp then your current level exp goes back to 0 instead of staying 100)


I wonder, if this is even required or if there is a simpler way to go about this, as it stands should you gain -800 exp you don't loose any levels, which im not sure if thats a good thing or a bad thing given that your currentLevelExp is 0 and you next level exp is 100 (always 100, you could be level 80 and you still only need from 100 xp to gain a level)


Now this would break any existing exp based scripts and disables the use of the exp charts in game.


The question is, is this even required, is there a way to set this up in the database or some other way?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,430
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
On one side there is no way to set it up exactly like that - the EXP-System is rather fixed, and also rather deeply installed in the engine.


However, what you want is about what the player sees and not how the engine handles this internally - so I would do something entirely different: change the display.


The value for "XPl" display can be calculated independently from the real XP. Still have the XP added up internally, but on the display that the player sees calculate the number for current EXP to be displayed by substracting the XP needed for the previous level.


That way you only need to change one small part of the engine and still keep full internal compatibility to all other changes.
 

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top