Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: nathmatt on November 03, 2010, 12:21:26 pm

Title: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on November 03, 2010, 12:21:26 pm
Individual Enemy Kill Counter for Blizz ABS
Authors: Nathmatt
Version: 2.0
Type: Enemy Counter
Key Term: Blizz-ABS Plugin



Introduction

keeps individual counters for each enemy


Features




Screenshots

no screen shot


Demo

No Demo


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Individual Enemy Kill Counter for Blizz ABS by Nathmatt
# Version: 2.0
# Type: Enemy Counter
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Script Calls:
#
#   $game_player.start_counter(id,enemy_id)   creates a new counter for enemy_id
#
#   $game_player.get_counter(id)              gets the ammount on that counter
#
#   $game_player.stop_counter(id)             clears and stops id's counts
#
#   $game_player.total_killed                 returns the total amount of enemies
#                                             killed
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Game_Player < Map_Actor
 
 attr_accessor :counters,:total_killed
 
 alias counter_initialize initialize
 def initialize
   counter_initialize
   @counters = {}
   @total_killed = 0
 end
 
 def start_counter(id,enemy_id)
   @counters[id] = Enemy_Counter.new(enemy_id)
 end
 
 def get_counter(id)
   return if !@counters[id].is_a?(Enemy_Counter)
   return @counters[id].count
 end
 
 def stop_counter(id)
   @counters[id] = nil
 end
 
end
   
class Enemy_Counter
 
 attr_accessor :count
 attr_reader   :enemy
 
 def initialize(enemy)
   @enemy = enemy
   @count = 0
 end

end

class BlizzABS::Processor
 
 alias counter_remove_enemy remove_enemy
 def remove_enemy(enemy)
   counter_remove_enemy(enemy)
   return if enemy.execute || enemy.erased || enemy.body != nil
   check_counter(enemy.real_enemy.id)
   $game_player.total_killed += 1
 end
 
 def check_counter(enemy_id)
   $game_player.counters.each_value{|counter|
   counter.count += 1 if counter.enemy == enemy_id}
 end

end

class Map_Enemy < Map_Battler
 
 def real_enemy
   return @enemy
 end
 
end



RMX-OS Plugin

Spoiler: ShowHide
if !defined?(RMXOS) || RMXOS::VERSION < 1.09
 raise 'ERROR: The "Blizz-ABS Controller" requires RMX-OS 1.09 or higher.'
end
module RMXOS
 module Options
   SAVE_DATA[Game_Player].push('@counters')
   SAVE_DATA[Game_Player].push('@total_killed')
 end
end



Instructions

in the script



Compatibility

no compatibility issues known


Credits and Thanks




Author's Notes

if you have any issues or suggestions post here

Title: Re: Individual Enemy Kill Counter for Blizz ABS
Post by: keyonne on November 06, 2010, 05:24:32 pm
Quick question, as I'm still learning basic scripting. What code should I use to activate a switch when a certain monster ID reaches a desired number?
$game_player.enemy[id] should be used somewhere I'm assuming. I apologize for my noobishness, but I'm more of a designer and artist than scripter. :/
Title: Re: Individual Enemy Kill Counter for Blizz ABS
Post by: Wizered67 on November 06, 2010, 05:45:26 pm
Do a conditional branch

if $game_player.enemy[id] == X
Turn on switch.
Title: Re: Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on November 07, 2010, 10:57:00 am
first you want to turn the enemies counter on using this
$game_player.enemy_trigger[id] = true
then in a condition branch you could turn on a switch or just use a condition script as
$game_player.enemy[id] >= x
x being the amount needed to kill after so you will want to use
$game_player.enemy_reset(id)
to reset it back to 0 and
$game_player.enemy_trigger[id] = false
to turn it off so that it will be ready for the next quest that needs you to kill it
Title: Re: Individual Enemy Kill Counter for Blizz ABS
Post by: Wizered67 on November 07, 2010, 10:58:57 am
Would this script work with RMX-OS btw?
Title: Re: Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on November 08, 2010, 07:30:25 pm
i don't see y it wouldn't but it would need the save data configured

edit: just use the newly added plug-in place it below this script 
Title: Re: Individual Enemy Kill Counter for Blizz ABS
Post by: Dweller on December 01, 2010, 02:54:38 am
I was looking to a script like this one. Using now and working fine. Thanks nathmatt (lvl up)
Title: Re: Individual Enemy Kill Counter for Blizz ABS
Post by: Ryex on December 01, 2010, 06:14:34 pm
why the hell was this never moved? *moved to database after adding the [XP] tag to the title*
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on December 02, 2010, 03:38:46 am
The xp tag was probably the reason it didn't get moved
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: Blizzard on December 02, 2010, 04:17:22 am
nathmatt got it right. ;)
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: Ryex on December 02, 2010, 04:34:21 am
pssh, it's not like it take more than ten seconds to add the tag, lazy other mods.
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: Blizzard on December 02, 2010, 04:52:35 am
Nathmatt's been doing that a couple of times so I just decided not to fix his post this one time as a lesson. :P
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on December 02, 2010, 02:08:07 pm
i have to admit i didn't even notice it wasn't in the database until you mentioned it
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: WhiteRose on December 02, 2010, 05:05:43 pm
Quote from: Ryex on December 02, 2010, 04:34:21 am
pssh, it's not like it take more than ten seconds to add the tag, lazy other mods.


I plead innocent; I'm not a mod over this section.
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: Blizzard on December 03, 2010, 02:46:36 am
I plead innocent as well, because I can. :=
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: Dweller on January 22, 2011, 05:31:41 am
I´m having a problem using this script on my game. After killing an enemy if I use a Custom Event Triggers the $game_player.enemy[id] variable count +14 enemies killed instead +1. (I tested too on a new Blizz-ABS game with only Individual Enemy Kill Counter for Blizz ABS script and got the same error)
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on January 22, 2011, 08:14:59 am
send me a quick demo so i can see it
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: Dweller on January 22, 2011, 11:23:28 am
Demo explaining the problem:
http://www.sendspace.com/file/95nlto
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on January 22, 2011, 03:54:16 pm
update 1.10 fixed above error
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: Dweller on January 23, 2011, 02:54:30 am
updated my game to 1.10 and no errors, ty.
Title: Re: [XP] Individual Enemy Kill Counter for Blizz ABS
Post by: nathmatt on June 20, 2011, 08:38:37 pm
update 2.0 reworked this script you can now create as many counters as you want even for that same enemy