Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
djskagnetti

Help! Variables not increasing after battle.

Question

can somebody please help me with this?

 

I have a simple job system where you get xp and gold when you kill a set amount of a certain type of monster.

 

I have a variable for each type of monster.

 

I have, on the troop screen, When [monster]'s HP < 0 then [monster]'s variable increase +1. I have it set to Turn for the span.

 

I realized after a while that the Turn span is flawed, as it checks each turn, and, for every turn that that specific monster's hp is below 0, it adds +1. Which is great if it lasts only 1 turn after it dies. But if, say, it lasts 10 turns more as you kill the other monsters in it's group, you get +1 for every turn. So it registers as 10 kills.

 

So I tried this instead in the troop screen.

I added a conditional branch.

If self switch A is on

[do nothing]

Else

Increase [monster]'s variable +1

self switch A = on

 

So this seems to work for stopping it from counting 10 or whatever number of turns it is after it dies.

 

EDIT: ^^ The above conditional doesn't work after all. I guess self switches don't work in the troop window? because it's still registering for every turn it is dead, which, I assume, is because self switch A is not turning on and thus not triggering the conditional branch of A=on...

 

But, let's say I'm fighting 2 Goblins.

If I kill both in the same turn, ending the battle, it only registers 1.

If I use a skill that attacks all monsters at once, and it kills everything on the screen on the first turn, it doesn't register at all!

 

I tried setting it to moment and it froze the battle screen.

I tried setting it to battle and it only registers 1.

 

 

Please somebody help!

 

EDIT:

 

Thanks to ForeverZero for making me this script. This adds 1 to the variable at the end of battle to whatever enemy is specified, completely fixing all my problems! Thanks again ForeverZero!

 

 

"Place the script anywhere below Game_Enemy and fill out the simple configuration at the top of the script."

 

class Game_Enemy

#-------------------------------------------------------------------------------
# CONFIGURATION
#-------------------------------------------------------------------------------
#  Define the variable used for each enemy here. Follow this pattern:
#
#    when ENEMY_ID then VARIABLE_ID
#
#  If more than one eneky share the same variable, you can define multiple
#  IDs on one line. For example, say you had a Goblin whose ID was 1, and an
#  Orc whose ID was 17. You wanted both of them to be of the same "type", and
#  use the variable with ID of 6:
#
#     when 1, 17 then 6
#
#-------------------------------------------------------------------------------

 def enemy_variable(enemy_id)
   return case enemy_id
   when 1 then 1
   when 2 then 2
   when 3 then 3
   when 4 then 4
   when 5 then 5
   end
 end

#-------------------------------------------------------------------------------
# END CONFIGURATION
#-------------------------------------------------------------------------------

 def increase_count(enemy_id)
   var_id = enemy_variable(enemy_id)
   if var_id != nil
     $game_variables[var_id] += 1
   end
 end

 alias zer0_enemy_type_attack attack_effect
 def attack_effect(attacker)
   result = zer0_enemy_type_attack(attacker)
   if self.dead? && @counted == nil
     increase_count(@enemy_id)
     @counted = true
   end
   return result
 end

 alias zer0_enemy_type_skill skill_effect
 def skill_effect(user, skill)
   result = zer0_enemy_type_skill(user, skill)
   if self.dead? && @counted == nil
     increase_count(@enemy_id)
     @counted = true
   end
   return result
 end

 alias zer0_enemy_type_item item_effect
 def item_effect(item)
   result = zer0_enemy_type_item(item)
   if self.dead? && @counted == nil
     increase_count(@enemy_id)
     @counted = true
   end
   return result
 end
end

Edited by djskagnetti

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...