Lunatic code explain?

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Hi, i just start working with Lunatic Code. I take a look on this example
but i am not sure what does it do and there are some lines i don't understand.
Can you guys help me to explain those : D thanks

<Custom Apply Effect>
// Sets the counter on the state to 4.
user.setStateCounter(stateId, 4);
// Determine the damage of the roots being cut.
user._thornBindDmg = origin.mat * 2;
What is these 2 value? user._thornBindDmg & origin.mat (if i understand it right,
this is base magicpower of the user without any additional from weapons/buffs?)


// Determine the maximum cap of the damage.
user._thornBindDmg = Math.min(user._thornBindDmg, 1000);
</Custom Apply Effect>

<Custom Deselect Effect>
// Get the result of the target.
var result = target.result();
// Check if the target is hit, alive, the action is physical, and dealing damage.
if (result.i****() && !target.isDead() && this.isPhysical() && this.isDamage()) {
// Play animation on target.
target.startAnimation(12);
// Get the amount of damage dealt.
var dmg = target._thornBindDmg || 1;
This value target._thornBindDmg seem to be user._thornBindDmg above??

// Make the target lose HP.
target.gainHp(-dmg);
Is this necessary? i thought "Deselect Effect" happen after damage execution?
Isn't this going to apply damage on target a second time?


// Disable critical hit effects.
target.result().critical = false;
Again, what is this for since damage execution happened?

// Start the damage popup.
target.startDamagePopup();
// Clear the result.
target.clearResult();
??? is this for bug catch?
// Change the counter on the state to drop by 1.
target.addStateCounter(stateId, -1);
// Check if the counter has reached 0.
if (target.getStateCounter(stateId) <= 0) {
// Remove the state.
target.removeState(stateId);
}
}
</Custom Deselect Effect>

Final question, now i see that there were some assignment like:
var result = target.result();
user._thornBindDmg = origin.mat * 2;
I wonder what is scope of these value? is 'result' value access-able while no battler performing attack? or it is available in this trunk of code only? a temporary variable?
What about user._thornBindDmg? this look more like an object/property to me but i am not sure...
what is scope of this one? global in that battle? or that turn only? that trunk of code only?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
EDIT: Sorry to mods for keeping the red color in quoted texts, but I keep it there to make it clearer for the OP to find the quoted passage.
What is these 2 value? user._thornBindDmg & origin.mat (if i understand it right,
this is base magicpower of the user without any additional from weapons/buffs?)
Not sure what origin is, but apparently the state caster. If you want, you can try to track origin if it's in Yanfly's scripts for example to see where it is defined.
user._thornBindDmg is a newly defined property for the state's target. Just like you have $gameActors.actor(1)._hp, now you'll have $gameActors.actor(1)._thornBindDmg as well as long as actor 1 is affected by that state.
This value target._thornBindDmg seem to be user._thornBindDmg above??
Seems that way.

target.gainHp(-dmg);
Is this necessary? i thought "Deselect Effect" happen after damage execution?
Isn't this going to apply damage on target a second time?
It is necessary. Damage execution is for attack, this dmg is for the state. In other words after the attack the user will receive additional damage from that thorn bind state.

target.result().critical = false;
Again, what is this for since damage execution happened?
Depending on the state effects, this could mean a lot. For example many states, thanks to lunatic code, can have additional state effect apart from damage, based on critical hits and such.

// Clear the result.
target.clearResult();
??? is this for bug catch?
No idea here.

var result = target.result();
user._thornBindDmg = origin.mat * 2;
I wonder what is scope of these value? is 'result' value access-able while no battler performing attack? or it is available in this trunk of code only? a temporary variable?
origin is a custom defined variable that apparently references a caster. It should therefore be accessible on global scope if it's a global variable or on a local scope of the eval if it's defined, let's say, at the beginning of the attack for example.
If you want to be sure what exactly that origin is, use console.log (origin) inside that notetag.
As for user._thornBindDmg, as I said, it's another variable. You're right, it's a property of the user, so whoever has this state cast upon themselves, be it game actors or game enemies, they will have it as a property possible to be seen.
As long as they're not cleared, action results are another game objects, stored after each action inside target. For example if a beast attacks on actor 2, it will generate an action result being possible to see by $gameActors.actor(2)._result. It will always show the last result though, so any attack on actor 2 will overwrite the previous result.
 

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Thanks @Poryg , i didn't realize that we can give target a new property like that and while target is affecting by state only :LZSexcite:
I got it better now, many thanks to you
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,845
Messages
1,016,961
Members
137,561
Latest member
JaCrispy85
Top