Guest Access
The only one
The only one
The only one
profile
NuKa_BuBble
profile
Remember my work on a karma script? Finally updated it!
Demo:
Demo
Version: 4.0
~ Version 2.0: Working version
~ Version 3.0: Karma HUD added
~ Version 4.0: A new weapon conditon and some little things was rewrote
Features:
~ A karma system
Features to do:
~ I don't actually know what I want to make for...
Scripts:
NuKa - Drawing Methods
Karma Script
Graphics:
They all must be place in windowskin
Demo:
Demo
Version: 4.0
~ Version 2.0: Working version
~ Version 3.0: Karma HUD added
~ Version 4.0: A new weapon conditon and some little things was rewrote
Features:
~ A karma system
Features to do:
~ I don't actually know what I want to make for...
Scripts:
NuKa - Drawing Methods
- Code:
class Window_Base < Window
#--------------------------------------------------------------------------
# * draw_numbers (x, y, value, file_name, align, space, lines, line_index)
#--------------------------------------------------------------------------
# X - horizontal position
# Y - Vertical Position
# VALUE - The variable or the value wanted to be display
# FILE_NAME - File name of the number picture
# ALIGN - Center 0 - 1 Left - 2 Center - Right
# SPACE - Space between numbers.
# LINES - Quantity of lines in the image.
# LINE_INDEX - The line you want to use.
#--------------------------------------------------------------------------
def draw_numbers(x, y, value, file_name, align, space, lines, line_index)
# Some variable for the computation
numbers_picture = RPG::Cache.windowskin(file_name)
cw = numbers_picture.width / 10
ch = numbers_picture.height / lines
h = ch * line_index
number = value.abs.to_s.split(//)
# If the lines is equal or less than 0
if lines <= 0
# lines is set to 1
lines = 1
end
# If the line_index is up to lines -1
if line_index > lines -1
line_index = lines -1 # Set it to lines -1
end
# If the aligment is up to 2
if align > 2
align = 2 #Set the alignment to 2
elsif align < 0 # If the aligment is lower than 0
align = 0 #Set it to 0
end
case align
when 0 # If the alignment is equal to 0
align_x = (-cw + space) * number.size # Change the numbers positions
when 1
align_x = (-cw + space) * number.size
align_x /= 2
when 2
align_x = 0
end
for r in 0..number.size - 1
number_string = number[r].to_i
number_rect = Rect.new(cw * number_string, h, cw, ch)
self.contents.blt(align_x + x + ((cw - space) * r), y , numbers_picture, number_rect)
end
numbers_picture.dispose
end
#--------------------------------------------------------------------------
# * draw_picture (x, y, fx, fy, hframes, vframes, file_name)
#--------------------------------------------------------------------------
# X - Horizontal position
# Y - Vertical Position
# HFRAMES - Amount of frames in the horizontal (in the picture)
# VFRAMES - Amount of frames in the verical (in the picture)
# FX - The frame desired on the X position
# FY - The frame desired on the Y position
# FILE_NAME - The picture file name
#--------------------------------------------------------------------------
def draw_picture(x, y, fx, fy, hframes, vframes, file_name)
picture = RPG::Cache.windowskin(file_name)
cw = picture.width / hframes
ch = picture.height / vframes
src_rect = Rect.new(fx, fy, cw, ch)
self.contents.blt(x, y, picture, src_rect)
end
end
Karma Script
- Code:
################################################################################
# #
# Karma points system #
# #
# #
# By: NuKa_BuBble #
# Version: 4.0 #
# Started: 24/08/2011 #
# http://gameface101.playogame.com/ #
# #
################################################################################
# #
# Graphics are needed #
# #
# One of the graphics must be a number picture, the others must be an evil #
# karma picture, good karma picture and a neutral karma picture. #
# #
################################################################################
module NuKaBuBbles_Karma
#------ Karma variables ------#
KPVAR = 25
KPSWITCH = 25
Evil = -1 # Change the Karma color for a red one
Good = 100 # Change the Karma color for a yellow one
#--------- Karma HUD ---------#
Number_Pic = "karma_numbers"
Good_Pic = "good_karma"
Evil_Pic = "evil_karma"
Neutral_Pic = "karma"
HUDX = 5 # The X position of the HUD on the screen
HUDY = 320 # The Y position of the HUD on the screen
#-----------------------------#
EKP = {
#A = ENEMY ID, B = NUMBER OF KARMA POINTS GAINED
#Here, it's a slime. You gain 2 karma points when you kill it.
1 => 150,
2 => -150
}
#----------------------------------#
Weapon_Karma = {
# If the weapon is neutral, set the value to 0
# Item ID => Karma required
2 => 150,
3 => -150,
4 => 0
}
Armor_Karma = {
# If the armor is neutral, set the value to 0
# Item ID => Karma required
2 => 150,
3 => -150,
4 => 0
}
#----------------------------------#
# The amount of time the unequip window is displayed in seconds
Window_Time = 10
end
if $xrxs_xas == true
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# Enemy Defeat Process
#--------------------------------------------------------------------------
alias kp_parameter_enemy_defeat_process enemy_defeat_process
def enemy_defeat_process(enemy)
$game_party.gain_karma(NuKaBuBbles_Karma::EKP[enemy.id])
$game_party.keep_equip
kp_parameter_enemy_defeat_process(enemy)
end
end
else
#==============================================================================
# ** Scene_Battle (part 2)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Defeat Process
#--------------------------------------------------------------------------
alias kp_defeat_process start_phase5
def start_phase5
for enemy in $game_troop.enemies
# If enemy is not hidden
unless enemy.hidden
$game_party.gain_karma(NuKaBuBbles_Karma::EKP[enemy.id])
$game_party.keep_equip
end
end
kp_defeat_process
end
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :unequip_window
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias nukabubble_karma_gametemp_initialize initialize
def initialize
@unequip_window = false
nukabubble_karma_gametemp_initialize
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
include NuKaBuBbles_Karma
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :karma # The player karma
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias nukabubbles_karmapoints_party_initialize initialize
def initialize
@karma = 0
nukabubbles_karmapoints_party_initialize
end
#--------------------------------------------------------------------------
# * Gain Karma
#--------------------------------------------------------------------------
def gain_karma(karma)
@karma += karma if karma != nil
end
#--------------------------------------------------------------------------
# * Lose Karma
#--------------------------------------------------------------------------
def lose_karma(karma)
gain_karma(-karma)
end
#--------------------------------------------------------------------------
# * If the player can still equip the equipments
#--------------------------------------------------------------------------
def keep_equip
for actor in @actors
weapon = $game_actors[actor.id].weapon_id # Weapon
shield = $game_actors[actor.id].armor1_id # Shield
helmet = $game_actors[actor.id].armor2_id # Helmet
armor = $game_actors[actor.id].armor3_id # Armor
accessory = $game_actors[actor.id].armor4_id # Accessory
unequip_weapon = false
unequip_shield = false
unequip_helmet = false
unequip_armor = false
unequip_accessory = false
# Weapon
if Weapon_Karma[weapon] != nil
return if actor.weapon_id == 0
weapon_karma = Armor_Karma[weapon]
if weapon_karma <= Evil
if $game_party.karma <= weapon_karma
unequip_weapon = false
else
unequip_weapon = true
end
elsif weapon_karma >= Good
if $game_party.karma >= unequip_weapon_karma
unequip_weapon = false
else
unequip_weapon = true
end
elsif weapon_karma >= Evil and weapon_karma <= Good
if $game_party.karma <= Good and $game_party.karma >= Evil
unequip_weapon = false
else
unequip_weapon = true
end
end
end
# Shield
if Armor_Karma[shield] != nil
return if actor.armor1_id == 0
shield_karma = Armor_Karma[shield]
if shield_karma <= Evil
if $game_party.karma <= shield_karma
unequip_shield = false
else
unequip_shield = true
end
elsif shield_karma >= Good
if $game_party.karma >= shield_karma
unequip_shield = false
else
unequip_shield = true
end
elsif shield_karma >= Evil and shield_karma <= Good
if $game_party.karma <= Good and $game_party.karma >= Evil
unequip_shield = false
else
unequip_shield = true
end
end
end
# Helmet
if Armor_Karma[helmet] != nil
return if actor.armor2_id == 0
helmet_karma = Armor_Karma[helmet]
if shield_karma <= Evil
if $game_party.karma <= helmet_karma
unequip_helmet = false
else
unequip_helmet = true
end
elsif helmet_karma >= Good
if $game_party.karma >= helmet_karma
return
else
unequip_helmet = true
end
elsif helmet_karma >= Evil and helmet_karma <= Good
if $game_party.karma <= Good and $game_party.karma >= Evil
unequip_helmet = false
else
unequip_helmet = true
end
end
end
# Body Armor
if Armor_Karma[armor] != nil
return if actor.armor3_id == 0
armor_karma = Armor_Karma[armor]
if armor_karma <= Evil
if $game_party.karma <= armor_karma
unequip_armor = false
else
unequip_armor = true
end
elsif armor_karma >= Good
if $game_party.karma >= armor_karma
unequip_armor = false
else
unequip_armor = true
end
elsif armor_karma >= Evil and armor_karma <= Good
if $game_party.karma <= Good and $game_party.karma >= Evil
unequip_armor = false
else
unequip_armor = true
end
end
end
# Accessories
if Armor_Karma[accessory] != nil
return if actor.armor3_id == 0
accessory_karma = Armor_Karma[accessory]
if accessory_karma <= Evil
if $game_party.karma <= accessory_karma
unequip_accessory = false
else
unequip_accessory = true
end
elsif accessory_karma >= Good
if $game_party.karma >= accessory_karma
unequip_accessory = false
else
unequip_accessory = true
end
elsif accessory_karma >= Evil and accessory_karma <= Good
if $game_party.karma <= Good and $game_party.karma >= Evil
unequip_accessory = false
else
unequip_accessory = true
end
end
end
if unequip_weapon or unequip_shield or unequip_helmet or unequip_armor or unequip_accessory
unequip = true
end
if unequip == true
if unequip_weapon == true
actor.equip(0, 0)
end
if unequip_shield == true
actor.equip(1, 0)
end
if unequip_helmet == true
actor.equip(2, 0)
end
if unequip_armor == true
actor.equip(3, 0)
end
if unequip_accessory == true
actor.equip(4, 0)
end
$game_temp.unequip_window = true
end
end # For
end # Keep_Weapon
end # Class
#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
# This window displays choices when opting to change equipment on the
# equipment screen.
#==============================================================================
class Window_EquipItem < Window_Selectable
include NuKaBuBbles_Karma
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_karma = Weapon_Karma[item.id]
when RPG::Armor
number = $game_party.armor_number(item.id)
item_karma = Armor_Karma[item.id]
end
if item_karma != nil
if item_karma <= Evil
if $game_party.karma <= Evil
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
elsif item_karma >= Good
if $game_party.karma >= Good
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
elsif item_karma >= Evil and item_karma <= Good
if $game_party.karma >= Evil and $game_party.karma <= Good
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
else
self.contents.font.color = normal_color
end
else
self.contents.font.color = normal_color
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs equipment screen processing.
#==============================================================================
class Scene_Equip
include NuKaBuBbles_Karma
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
item = @item_window.item
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
item_karma = Weapon_Karma[item.id]
when RPG::Armor
number = $game_party.armor_number(item.id)
item_karma = Armor_Karma[item.id]
end
if item_karma != nil
if item_karma <= Evil
if $game_party.karma <= Evil
equip = true
else
equip = false
end
elsif item_karma >= Good
if $game_party.karma >= Good
equip = true
else
equip = false
end
elsif item_karma >= Evil and item_karma <= Good
if $game_party.karma >= Evil and $game_party.karma <= Good
equip = true
else
equip = false
end
else
equip = true
end
else
equip = true
end
if equip == true
# Play SE
$game_system.se_play($data_system.equip_se)
# Change equipment
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
# Activate right window
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# Remake right window and item window contents
@right_window.refresh
@item_window.refresh
return
else
# Play SE
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
end
#==============================================================================
# ** Karma_Hud
#------------------------------------------------------------------------------
# This class handles the karma HUD.
#==============================================================================
class Karma_Hud < Window_Base
include NuKaBuBbles_Karma
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(HUDX, HUDY, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 24
length = 1
length = 0 if $game_party.karma.abs.to_s.size == 1
length = ($game_party.karma.abs.to_s.size * 15) - (48 / 2) if $game_party.karma.to_s.size > 2
if $game_party.karma >= Good
draw_picture(-4, 2, 0, 0, 1, 1, Good_Pic)
draw_numbers(16+48+length, 0, $game_party.karma, Number_Pic, 0, 0, 3, 0)
elsif $game_party.karma <= Evil
draw_picture(-4, 2, 0, 0, 1, 1, Evil_Pic)
draw_numbers(16+48+length, 0, $game_party.karma, Number_Pic, 0, 0, 3, 2)
else
draw_picture(-4, 2, 0, 0, 1, 1, Neutral_Pic)
draw_numbers(16+48+length, 0, $game_party.karma, Number_Pic, 0, 0, 3, 1)
end
if $game_switches[KPSWITCH] == true
self.visible = true
else
self.visible = false
end
end
end
#==============================================================================
# ** Unequip_Window
#------------------------------------------------------------------------------
# This class is the window displayed when the player is unequip
# because the karma don't fit with the equipments
#==============================================================================
class Unequip_Window < Window_Base
include NuKaBuBbles_Karma
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@frame_count = Graphics.frame_count
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 640, 480, "One or many party member(s) unequipped something due to the karma", 0)
time = (Graphics.frame_count - @frame_count) / 40
if time >= Window_Time
$game_temp.unequip_window = false
@frame_count = Graphics.frame_count
self.visible = false
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
include NuKaBuBbles_Karma
#--------------------------------------------------------------------------
# * Main
#--------------------------------------------------------------------------
alias karma_hud_main main
def main
@karma_hud = Karma_Hud.new
@unequip_window = Unequip_Window.new
@unequip_window.visible = false
karma_hud_main
@karma_hud.dispose
@unequip_window.dispose
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
alias karma_hud_update update
def update
karma_hud_update
@karma_hud.refresh
if $game_temp.unequip_window
@unequip_window.visible
end
@unequip_window.refresh
end
end
Graphics:
They all must be place in windowskin
- Spoiler:
The only one
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
Nice, you can improve this by changing this line.
$game_party.gain_karma(enemy.karma)
To this line.
$game_party.gain_karma(EKP[enemy.id])
And you can shrink the class and make it more efficient.
Great work, your showing lots of improvements and learning fast.
$game_party.gain_karma(enemy.karma)
To this line.
$game_party.gain_karma(EKP[enemy.id])
And you can shrink the class and make it more efficient.
Great work, your showing lots of improvements and learning fast.
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
The only one
profile
NuKa_BuBble
profile
Thank you for the tip mr_wiggles. I'll see for it in the next update.
The only one
Show Signature
Administrator
Administrator
Administrator
profile
G@MeF@Ce
profile
at a boy Nuka! You now have 50000000000235258762352 karma points! :~P
see this is why you have in your profile
your effort shows in your play on programming.
will you be adding to the hud? graphic?? counter??? bar????
I can see this system playing yet another condition as to how the NPC's will interact with the Hero ~ Villain based upon Karma.
thanks for sharing!
see this is why you have in your profile
your effort shows in your play on programming.
will you be adding to the hud? graphic?? counter??? bar????
I can see this system playing yet another condition as to how the NPC's will interact with the Hero ~ Villain based upon Karma.
thanks for sharing!
Administrator
Show Signature
The only one
The only one
The only one
profile
NuKa_BuBble
profile
@G@MeF@Ce: The hud actually exist. I'll add graphics for it and see for more add-ons. Like a weapon that can't be hold if your karma is under a X number.
The only one
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
If you wanted too you could update it to have a new feature.
What about divided karma, like in "Fallout: New Vegas".
Where not only can be a karma keeper, it can hold a towns individual thought of you. For dynamic conversations with Npcs.
What about divided karma, like in "Fallout: New Vegas".
Where not only can be a karma keeper, it can hold a towns individual thought of you. For dynamic conversations with Npcs.
EVENTALIST
Show Signature
EVENTALIST
The only one
The only one
The only one
profile
NuKa_BuBble
profile
I don't understand what you mean by divided karma but, it was updated. Look at the new HUD.
The only one
Show Signature
Administrator
Administrator
Administrator
profile
G@MeF@Ce
profile
@nuka - I like how you incorporated a graphic counter for your HUD ~ well done!
I took a peep at the graphics folder and noticed the evil KP
what's that!? do I have to battle enough in the demo for that to appear?
I took a peep at the graphics folder and noticed the evil KP
what's that!? do I have to battle enough in the demo for that to appear?
Administrator
Show Signature
The only one
The only one
The only one
profile
NuKa_BuBble
profile
@G@MeF@Ce: Fight against the ghost in the demo. I think it's two times. After, the ghosts will be replace by another enemy type and fight two times again to low the karma. Will try to make nicer numbers later.
The only one
Show Signature
The only one
The only one
The only one
profile
NuKa_BuBble
profile
WAZUP? This script was updated. I know, there's more complicated way to do it but, I choosed the easiest.
Anyway, that work. Isn't the most important?
EDIT: The demo have a leak with XAS. The script is the most recent version. Should fix that later. DONE!
Anyway, that work. Isn't the most important?
The only one
Show Signature
#11 Re: Karma Script