Requesting help with a simple target id to variable script.

sartha

Veteran
Veteran
Joined
Jan 15, 2013
Messages
31
Reaction score
6
First Language
English, French
Primarily Uses
Good day,

I'm looking for something which I think should be relatively simple but I can't seem to figure out on my own.

The intended behaviour is $game_variables[56] = b.enemy_id

once that information is created, (each time the skill is used), a common event fires with conditional branches

if Variable 56 = 1 then Force Action actor[11] skill [50] on random target.

rinse and repeat a few hundred similar conditions with different force action skills for different enemy id's.

Unfortunately it isn't working as intended.

If I put $game_variables[56] = b.enemy_id in the damage formula, it damages the enemy exactly as per the enemy id (I did this to verify things) however the forced actions in the common event are not firing. but putting it in as a Script in the common event prior to the conditional branches yields an interpreter error even if I put it as:

 

class Game_Battler < Game_BattlerBase

$game_variables[56] = b.enemy_id

end

 

I've also tried defining a script call inside the Game_Battler class like so:

 

def sketch(a, B)

$game_variables[56] = b.enemy_id

end

 

and calling on a.sketch(a, B) or even just sketch(a, B)

 

Any ideas or help with this would be greatly appreciated.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
show the exact damage formula... also your first script errors since b is a variable that is defined locally by the damage formula's eval call...
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
AND b MAY refer to an actor, and not an enemy at all ;)


You might try target.id instead.
 

sartha

Veteran
Veteran
Joined
Jan 15, 2013
Messages
31
Reaction score
6
First Language
English, French
Primarily Uses
show the exact damage formula... also your first script errors since b is a variable that is defined locally by the damage formula's eval call...
$game_variables[56] = b.enemy_id

That is the entire damage formula.

Again this was just to test to see if I actually got the appropriate ID and it was being placed in the variable as desired. Which it does. The skill itself will not actually deal damage in the final product, the corresponding forced action skill will.

Hmm after some testing I found there's a bug with Ace Battle Engine which I have installed. when I put this damage formula, the forced actions fire if the Battle Engine is not installed, but if it's installed it gives me:

Script 'Ace Battle Engine' line 688: NoMethodError occured.

undefined method 'forced_action_remove' for Switch:Module

Here is the entire rewrite of the forced action in that script:

  def self.force_action(battler)    @action_forced = [] if @action_forced == nil    @action_forced.push(battler)    return unless Switch.forced_action_remove    @action_battlers.delete(battler)  end

though even if it didn't crash I still don't know how to store the id into a variable without dealing damage ^.^;;

AND b MAY refer to an actor, and not an enemy at all ;)

You might try target.id instead.
I can't seem to make target.id work, it keeps complaining that "target" is and undefined local variable or method.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
It seems like you didn't fully understand what the damage formula is.

$game_variables[56] = b.enemy_id


That is the entire damage formula.
The damage formula is basically a field that returns a value to the engine how many points should be substracted from the enemy HP (or added in case of a healing skill).


The way how ruby's eval function works allows you to add different commands to the sequence, but nothing can change the basic fact that the damage formula HAS TO return a value, and that value WILL be used to damage the target.


If you set the damage formula in the way you did, then the only number used is the enemy ID, and that number will become the damage number for the rest of the skill. To prevent that, you need to add the true damage number after you stored the enemy ID into the variable.


Second problem is that the call commmon event feature of the skills is a feature, not part of the damage process. This means that it will be executed independent of the damage procedure - actually after the entire skill has completed damage processing. And you don't get access to the skill's data from that common event, you have to keep in mind that the common events are completely independent.


That said, your common event should have worked. The damage formula should have stored the enemy ID into the variable, and the common event should have been able to process that info.


This means that the logic inside your common event probably has a few glitches, and you'll need to give us a screenshot of that event to see where the errors there are.


I've got some ideas what might have happened, most probably you got confused with enemy_ID (which is the identification on the database) and the index (which is needed to identify the enemy as target in the battlescreen), and the fact that the special shortcuts a and b do not exist outside the damage formula (you'll need other ways to identify user and target in the common event).
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
There is no difference between $game_variables and v in the context of a damage formula.
 

sartha

Veteran
Veteran
Joined
Jan 15, 2013
Messages
31
Reaction score
6
First Language
English, French
Primarily Uses
To prevent that, you need to add the true damage number after you stored the enemy ID into the variable.
This skill isn't supposed to deal damage, putting that formula in the damage formula box however is the only way to use that exact formula. Hence why I started this thread, to see about finding a way to accomplish the same thing (storing the target's enemy id in a variable) without the use of the damage formula (or at least without causing damage)

Here are links to my screenshots:

https://drive.google.com/file/d/0B2_0Qf63O4RoRWx6aVZZaC1jem8/edit?usp=sharing

This is the Troop I'm testing with, the Guard was inserted first, the Bat was inserted second and the Ghost was inserted third. The enemy ids are 1, 9 and 10. So I'm setting the troop event to input those enemy id values manually (though I suppose there could be better way?) You can ignore the switch, that's related to a different skill which works.

https://drive.google.com/file/d/0B2_0Qf63O4RoZFdwQzR5OXAtSFU/edit?usp=sharing

These are the variables, from Enemy 1 to 8 (for the 8 possible enemies in a troop) and Enemy Target (used with the common event or skill.

https://drive.google.com/file/d/0B2_0Qf63O4RoR1ZMN0VvM0RuZWM/edit?usp=sharing

This is the skill that uses the Common Event, as mentioned currently I'm using the damage formula but I'd really like to move that somewhere else like the notetags if possible because the skill should not deal damage, only the forced action skill should.

https://drive.google.com/file/d/0B2_0Qf63O4RoVWowcmxSTzhZMlE/edit?usp=sharing

This one is for the Common Event which currently only takes into consideration the monsters I'm testing with (1, 9 and 10) The idea here is that the Enemy Target variable set by the skill is compared to the Enemy id to determine which skill gets forced.

For clarification, if there is a formation of 3 Guards and nothing else, then it doesn't matter which target is hit, they all would lead to the same skill. But when the formation includes more than one monster type, I need to be able to tell which monster type I hit.

Hope this information is more clear now.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
This skill isn't supposed to deal damage,
That doesn't change that you NEED a damage number at the end of the damage formula, that's a requirement from the programmed function.This damage number can be zero if the skill isn't supposed to do any damage, but you still have to add that number for the formula box to function correctly.

Code:
$game_variables[56] = b.enemy_id; 0
This would be the correct damage formula if you want the damage formula to set the variable and then deal zero damage.
 

sartha

Veteran
Veteran
Joined
Jan 15, 2013
Messages
31
Reaction score
6
First Language
English, French
Primarily Uses
That doesn't change that you NEED a damage number at the end of the damage formula, that's a requirement from the programmed function.

This damage number can be zero if the skill isn't supposed to do any damage, but you still have to add that number for the formula box to function correctly.

$game_variables[56] = b.enemy_id; 0This would be the correct damage formula if you want the damage formula to set the variable and then deal zero damage.
That makes sense, though now I get a "Null" popup from Ace Battle Engine. Speaking of Ace Battle Engine I get an error from it when I use this skill (this pre-dates this new formula but also occurs with it)

https://drive.google.com/file/d/0B2_0Qf63O4Rocm5GdWlfY2Y3NzA/edit?usp=sharing

This is the error message I get.

https://drive.google.com/file/d/0B2_0Qf63O4RoTmNFVUM3c2FUZG8/edit?usp=sharing

This is the line from the error message...

When I remove Ace Battle Engine the skill works and the forced action triggers but I'd like to keep the battle engine if possible.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
That makes sense, though now I get a "Null" popup from Ace Battle Engine.
Yanfly also has a script to suppress the null-message (which also happens with skills that only add states and a few other skill-scripts)
As your other error - that is either a missing initialisation (did you start a new game after the latest script changes? such errors often happen when an old savegame was loaded).


If that isn't the cause, then you'll have to wait until someone analyses the scripts in more detail, I don't have time for that.


I also suggest to use the "more reply options" to attach the pictures to posts, googledrive has several problems for me, and attachments are automatically visible in the post...
 

sartha

Veteran
Veteran
Joined
Jan 15, 2013
Messages
31
Reaction score
6
First Language
English, French
Primarily Uses
Yanfly also has a script to suppress the null-message (which also happens with skills that only add states and a few other skill-scripts)

As your other error - that is either a missing initialisation (did you start a new game after the latest script changes? such errors often happen when an old savegame was loaded).

If that isn't the cause, then you'll have to wait until someone analyses the scripts in more detail, I don't have time for that.

I also suggest to use the "more reply options" to attach the pictures to posts, googledrive has several problems for me, and attachments are automatically visible in the post...
I have the Anti-Fail script installed, unfortunately it's not triggering despite putting the tag in the skill. I'll look around more to solve this issue.

I start a new game every time I change stuff since right now I spawn on a "test" map that I created that gets modified to test whatever I'm working on at the time.

As for the pictures, I shall post them here then using the more reply options: (Refer to previous posts for what these pictures are for, I posted them in the same order)

troop.png

This is the Troop screenshot

var.png

This is the variables screenshot

Skill.png

This is the skill screenshot

CE.png

This is the common event screenshot

error.png

This is the error I get with Ace Battle Engine

script.png

This is the script location where the error points me to.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Don't attach your pictures to posts ... each person only has a limited area for pictures, and it fills up really quickly.


Post them to a photo sharing site (if the one you're using has troubles, maybe look around for others), and then insert them as images rather than links. Like this:

Code:
[img [URL="http://url.to.image/image.jpg%5D"]http://url.to.image/image.jpg][/URL]
That'll put the image itself into your post. If it's a big image, or you have a lot of them, you might also want to consider using spoilers:
Code:
[spoiler][img [URL="http://url.to.image/image.jpg%5D"]http://url.to.image/image.jpg][/URL][/spoiler]
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I have the Anti-Fail script installed, unfortunately it's not triggering despite putting the tag in the skill. I'll look around more to solve this issue.
Then you did something wrong
 

sartha

Veteran
Veteran
Joined
Jan 15, 2013
Messages
31
Reaction score
6
First Language
English, French
Primarily Uses
Then you did something wrong
I just started a new project to see what I could have done wrong. I re-downloaded the anti-fail script anew in case I changed something in it by accident. My skill, common event and troop are as on the screenshots above and I ONLY installed Ace Battle Engine + Anti-Fail... I still get the above mentioned error and the anti-fail is not kicking in. I've double checked my stuff. <anti fail> is in the skill note for example.

Since Ace Battle Engine keeps crashing I will try to find an alternative to it and it's associated script that required it and see if I can at least get this working. I already know that it works without Ace Battle Engine (albeit still with "Guard took no damage" message popping up)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
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

Forum statistics

Threads
105,857
Messages
1,017,015
Members
137,563
Latest member
MinyakaAeon
Top