Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Kio's reputation system

Hi

I'm using Kios reputation system (ver. 1.2), but I dont remember the call scripts to use it. In example, how to decrease fanction's reputation.

Here's the code:

PHP:
#==============================================================
# Kio's Reputation System v1.2
#==============================================================


class Game_System
attr_accessor :fac_rep
attr_accessor :fac_active

alias rep_initialize initialize
def initialize
rep_initialize
@fac_rep=[]
@fac_active=[]
end
end

class Scene_Title
alias cng command_new_game
def command_new_game
cng
#Determine the initial settings for the faction's reputations here
$game_system.fac_rep = [50, 50, 50, 50, 50, 50, 50, 50]
#Determine the inital factions you can see here.
$game_system.fac_active = ["active", "active", "active", "active", "active", "active", "active"]
end
end

class Scene_Reputation
def main
@status_window = Window_Reputation.new
@sprite = Spriteset_Map.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@status_window.dispose
@sprite.dispose
end

def update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5)
return
end
end
end

class Window_Reputation < Window_Base
attr_accessor :factions
attr_accessor :fac_rep
attr_accessor :reptypes
attr_accessor :fac_active

def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.back_opacity = 120
@factions = ["Test1", "Test2", "Test3", "Test4", "Test5", "Test6", "Test7"]
@rep = ["Test", "Test", "Test", "Test", "Test", "Test", "Test"]
refresh
end

def draw_repbar(x, y, width, height, current, max)
x -= 10
for i in 0..(height+2)
self.contents.fill_rect(x-3+i, y - 1 + i, width+5, 1, Color.new(255, 255, 255, 255))
end
for i in 0..height
self.contents.fill_rect(x+i, y+i, width+1, 1, Color.new(0, 0, 0, 255))
end
for i in 0..height
for j in 0..current
self.contents.fill_rect(x+j+i, y+i, 1, 1, Color.new(0, 0 + (1.25*j), 255 - (1.25*j), 255 - (5*i)))
end
end
end

def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 32
self.contents.draw_text(20, 40, 184, 32, "Arvostus", 2)
self.contents.font.size = $fontsize
for i in [email=0...@factions.size]0...@factions.size[/email]
y = 80 + (i * 70)
x = -30
if i > 4
x = 280
y = 80 + ((i - 5) * 70)
end
if $game_system.fac_rep[i] > 100
$game_system.fac_rep[i] = 100
end
if $game_system.fac_rep[i] < 0
$game_system.fac_rep[i] = 0
end
if $game_system.fac_active[i] == "active"
draw_fac(x, y, i)
end
self.contents.font.color = normal_color
end
end

def draw_fac(x, y, i)
self.contents.draw_text(x+40, y, 160, 32, @factions[i], 0)
draw_repbar(x+90, y+32, 200, 14, 2 * $game_system.fac_rep[i], 100)
self.contents.font.color = system_color
if $game_system.fac_rep[i] >= 90
self.contents.draw_text(x+210, y, 96, 32, @rep[0], 2)
elsif $game_system.fac_rep[i] >= 75
self.contents.draw_text(x+210, y, 96, 32, @rep[1], 2)
elsif $game_system.fac_rep[i] >= 55
self.contents.draw_text(x+210, y, 96, 32, @rep[2], 2)
elsif $game_system.fac_rep[i] >= 45
self.contents.draw_text(x+210, y, 96, 32, @rep[3], 2)
elsif $game_system.fac_rep[i] >= 25
self.contents.draw_text(x+210, y, 96, 32, @rep[4], 2)
elsif $game_system.fac_rep[i] >= 10
self.contents.draw_text(x+210, y, 96, 32, @rep[5], 2)
else
self.contents.draw_text(x+210, y, 96, 32, @rep[6], 2)
end
end
end

Thanks if someone is willing to help :) . I'm not a scripter
 
ok i played around with this script for awhile
and i found out that you have to put this
$game_system.fac_rep = [50, 50, 50, 50, 50, 50, 50, 50] <-- set rep for the factions

example:
message:hey you took that without asking!
call script $game_system.fac_rep = [30, 50, 50, 50, 50, 50, 50, 50]
message: you lost 20 rep in faction 1

hope i helped ^_^
 
Thanks deon, but it just sets the reputation to 30. Yeah, it decreases, but if you use it more, it just stays in 30.

What I am looking for is something like this:
$factions_rep[faction id] +=20

I have tried to use that, but I get NoMethodError: Undefined method []' for Nil:Nilclass
 
Sorry, but didn't get it.

I meant, there are soldiers, that belong to the faction 0.
When you kill one of them, that factions reputation decreases -20.

If I use that array, and enter: $game_system.fac_rep = [30, 50, 50, 50, 50, 50, 50, 50]

it decreases to 30, but when you kill more soldiers it just stays in 30.
 
$game_system.fac_rep[0] -= 30

for faction 2 or whatever just change the number in the [ ] for the number of the faction -1

so if you want to change faction 3 rep:
$game_system.fac_rep[2] -= 30

and so on and so forth
 
Thanks Necrofear, you just saved my project :)

Another question, though.

What code I use when I have conditional branch that checks the reputation?

EDIT: Nevermind, I realised it by myself
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top