function Compare(a,attacker,target) {
var stat = {armor:0, crit:1, critDmg:2, dmg:3, mhp:4, hp:5, shotcount:6};
var aArmor = attacker.split(",")[stat.armor];
var aCrit = attacker.split(",")[stat.crit];
var aCritDmg = attacker.split(",")[stat.critDmg];
var aDmg = attacker.split(",")[stat.dmg];
var aMHp = attacker.split(",")[stat.mhp];
var aHp = attacker.split(",")[stat.hp];
var aShotCount = attacker.split(",")[stat.shotcount];
var tArmor = target.split(",")[stat.armor];
var tCrit = target.split(",")[stat.crit];
var tCritDmg = target.split(",")[stat.critDmg];
var tDmg = target.split(",")[stat.dmg];
var tMHp = target.split(",")[stat.mhp];
var tHp = target.split(",")[stat.hp];
var tShotCount = target.split(",")[stat.shotcount];
return eval(a);
}[/code:o1ddw9dm]
create js variables in your script, set their values to Construct variables values (use aliases) and then operate with those js variables.
That's what I thought I had to do, but I don't think I understand how to do that properly
I don't think I can send you the file because it's a huge mess, but what I'm trying to do is very simple.
In my game there are many items, and they can have conditions to activate (like based on a random chance, or when the enemy has a certain % hp, or based on the enemy armor, etc) and I want to write this condition in an external file, as a string, so I don't need to add an event for each and every item to do the comparison.
In this engine, both enemies and the player are in the same family, and they use a dictionary to store their stats. Every time someone attacks someone else, a "calculate damage" function is run, and it sets local variables to do all the calculations regarding the attacker and the target
So if I have an item that increases the damage only if the target's health is below 50%, i'd add a condition later in this function that would compare if tHP is lower than 50%. But I plan on having around 80 items, so that's a lot of hard-coded conditions
So I made it so all the items have their conditions written somewhere else, in a text file. So the condition would read "tHp < 0.5" and I'd use the JS plugin to eval that expression. But like I said, I can't pass the variable as a parameter because the expression could be anything.
So if I got this right, I could Alias the variables right after I set them (in the image above) and then the JS would be able to use the variable, right?