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.
did anyone played wizardry 8? in that game, when you talk to an NPC you can write some word (or choose one from a word list) and then it answers to you,
like i can say "dark sevanth" (which is the main enemy in the game) and it will answer something like
"ohh, i don't want to talk about him!"
or if i'l say "jtkrhrkrhgblrjkghrl" it will probably answer
"i did not understand you..."
what i need, is a script that when i call it, it will go to a window where you can write words, or choose from a word list... and in the script i will write the answers to every event... including an answer for words that are not in the event answer list or something like this... is there any script that does this?
or can anyone make one for me?
This is a rather interesting system, I'd like to see it scripted too.
It's not all that complicated so I even might get into it myself if I get enough free time...which has been rather nonexistent lately ><
EDIT
I just opened my old game project and realized I've been working on a similar script the last time XD wow, my memory sure is great XD
I might as well try to finish it XD
So much to do, so little time to do it XD
I'm working on your request right now, hopefully I'll have it finished by tomorrow but if not it'll be a week (hopefully not two, but with R/L lately...) As far as being able to type something in the box for "Where is..." or "Talk about..." that is going to be the most challenging part, and it'll require a Keyboard script. I faithfully always used AWorks (formerly Aleworks) by vgvgf so I hope you don't mind thats what I'll be using.
The 3 items you pointed out in your screenshot I understand and that is what I'll be working on, if there is anything further needed to be said about the request please do so now.
BTW the second object in the screenshot (the box with "People", "Places", "Items", "Misc") and the word box I'll make easy to setup/add to. All you'll have to do is...
I'm sorry Fallen, I wasn't even paying attention that you were working on this I guess I shoulda read that XD I didn't mean to steal your thunder, I feel bad now. I won't do that to you again, I promise, that was messed up that I did that! :/
The script is half-done so far, and I'm expecting it to actually be finished by the 22nd (this upcoming Wednesday) but don't take my word for it, I'm expecting little issues that might still need to be worked out. The next step I need to do is code the Ask Question/Talk About window, which I'll be coding with AWorks Keyboard module, please tell me if theres another keyboard script you'd rather use. I've always stuck with AWorks because it is still supported and works the best (IMO) but I don't know if you already use something else.
Here's how the script works so far;
You setup your initial words (that come preset in a new game) via this module...
Code:
#===============================================================================
# ** TalkAndAnswer
#===============================================================================
Â
module TalkAndAnswer
 #-----------------------------------------------------------------------------
 # * Trigger
 #-----------------------------------------------------------------------------
 Trigger = Input::A
 #-----------------------------------------------------------------------------
 # * Commands
 #-----------------------------------------------------------------------------
 Commands = Hash.new
 Commands[1] = "People"
 Commands[2] = "Places"
 Commands[3] = "Things"
 Commands[4] = "Misc."
 Commands[5] = "All"
 #-----------------------------------------------------------------------------
 # * Words List
 #-----------------------------------------------------------------------------
 WordsList = Hash.new
 WordsList[1] = ["Dark Minion"]
 WordsList[2] = []
 WordsList[3] = []
 WordsList[4] = []
end
To add words later, you'll be doing $game_message.add_word(word, category) where word is the word and category is 1 for people, 2 for places, 3 for items, 4 for misc, etc... but obviously you can name your categories whatever you want, but they'll be represented by index not name. I'll shorten the syntax but either way it'll be handled by the $game_message class.
In order to activate the TalkAndAnswer scene, you walk up to a NPC and hit Shift (Input::A or whatever you want to set it as in the script). When you pick your word or whatever to get a response from them, then the event will activate like...
Code:
@> Conditional Branch : Script : $game_message.word == "Dark Minion"
 @> Text : Oh, I don't even wanna talk about him!
@> Branch End
@> Conditional Branch : Script : $game_message.word == "Elsa"
 @> Text : Yeah, I heard about her... I hope she gets
     : through it. The good usually die young, its
     : a damn shame!
@> Branch End
I still have bugs to work out, and I need to figure out how the setup of event responses will work. I think I'm gonna make it where each event must have a page with a certain switch/variable as a condition before it allows the scene to open, then you just put your responses on that page. If the event doesn't have a page with this condition, it just isn't going to do anything when you press Shift. (For instance, you won't be giving your Treasure/Door events this page/condition, just your NPCs).
Since this is your request, I'm open to any suggestions/changes you want me to make before I finish this. I've blabbed enough I gotta get back to work on it, see ya later.
woow, thanks Kain, that's awesome to see it getting worked on, take as much time as you need!
i am not using any keyboard script, so feel free to use any one that will work,
if you need i can post a list of scripts that i'm using...
the system looks really nice and easy to use! right now i can't think of anything i whould like to improve
i just got one question: can an event not only say stuff, but also do another event commands?
example:
Conditional Branch : Script : $game_message.word == "Dark Minion"
Text : Oh, I don't even wanna talk about him!
and then the event move backwards
OR
Conditional Branch : Script : $game_message.word == "Elsa"
Text : Yeah, I heard about her... I hope she gets: through it. The good usually die young, its: a damn shame!
and it plays a music
i think you got my point... can it?
and thanks for you'r help!! be sure i'll credit you and make a word "easter egg" with your name (only if you agree!)
There has been some unexpected delay in getting it finished, but nonetheless its still getting worked on. I'd estimate 2 more weeks before its finished, I'll post you the half-version right now just to let you know I'm getting down to bussiness with it. Please don't think this is final, half the script is missing and I might make minor/major changes to existing coding, just so it'll run smoother.
So far, if you're wanting to just see it so far (keep in mind this is unfinished), you'll need SDK 2.4 parts 1 & 2. To be more specific it uses these classes from SDK.
More importantly, it'll need these methods, they're stuff I've submitted to MACL that aren't in the official version yet.
Code:
]#===============================================================================
# ** RGSS.Map
#===============================================================================
#-------------------------------------------------------------------------------
# * MACL Loading
#-------------------------------------------------------------------------------
if Object.const_defined?(:MACL)
MACL::Loaded << 'RGSS.Map'
end
#===============================================================================
# ** Game_Map
#===============================================================================
class Game_Map
#-----------------------------------------------------------------------------
# * Name : Events At
# Info : Returns an array of events at location
# Author : Kain Nobel
# Call Info : Two Arguments Integer X, Y - Position to Check
# D (Optional) Integer - Directional modifier to check
#-----------------------------------------------------------------------------
def events_at(x, y, d = 0)
events = Array.new
x += (d == 6 ? 1 : d == 4 ? -1 : 0)
y += (d == 2 ? 1 : d == 8 ? -1 : 0)
@events.each_value {|e| events << e if (e.x == x && e.y == y)}
return events
end
#-----------------------------------------------------------------------------
# * Name : Event At
# Info : Returns very first event from events_at method.
# Author : SephirothSpawn / Kain Nobel
# Call Info : Two Arguments Integer X, Y - Position to Check
# D (Optional) Integer - Directional modifier to check
#-----------------------------------------------------------------------------
def event_at(x, y, d = 0)
return events_at(x, y, d)[0]
end
end
Code:
#===============================================================================
# ** RGSS.Character
#===============================================================================
class Game_Character
#-----------------------------------------------------------------------------
# * Name : XY
# Info : Returns @x and @y properties to array.
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def xy
return [self.x, self.y]
end
#-----------------------------------------------------------------------------
# * Name : XYD
# Info : Returns @x, @y and @direction properties to array.
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def xyd
return [self.x, self.y, self.direction]
end
#-----------------------------------------------------------------------------
# * Name : Next X
# Info : Returns next X coord for facing direction
# Author : Kain Nobel
# Call Info : Direction is the direction character is facing
#-----------------------------------------------------------------------------
def next_x(d = self.direction, steps = 1)
return (self.x + (steps * (d == 6 ? 1 : d == 4 ? -1 : 0)))
end
#-----------------------------------------------------------------------------
# * Name : Next Y
# Info : Returns next Y coord for facing direction
# Author : Kain Nobel
# Call Info : Direction is the direction character is facing
#-----------------------------------------------------------------------------
def next_y(d = self.direction, steps = 1)
return (self.y + (steps * (d == 2 ? 1 : d == 8 ? -1 : 0)))
end
#-----------------------------------------------------------------------------
# * Name : Next X/Y
# Info : Returns next X & Y coord for facing direction (to an array)
# Author : Kain Nobel
# Call Info : Direction is the direction character is facing
#-----------------------------------------------------------------------------
def next_xy(d = self.direction, steps = 1)
return [self.next_x(d, steps), self.next_y(d, steps)]
end
#-----------------------------------------------------------------------------
# * Name : Events Front
# Info : Returns all events on same tile
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def events_here
return $game_map.events_at(*self.xy)
end
#-----------------------------------------------------------------------------
# * Name : Events Front
# Info : Returns all events on tile front
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def events_front
return $game_map.events_at(*self.xyd)
end
#-----------------------------------------------------------------------------
# * Name : Events Behind
# Info : Returns all events on tile behind
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def events_behind
d = case self.direction
when 2 then 8
when 4 then 6
when 6 then 4
when 8 then 2
end
return $game_map.events_at(self.x, self.y, d)
end
#-----------------------------------------------------------------------------
# * Name : Events Left
# Info : Returns all events on tile to left hand of self
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def events_left
d = case self.direction
when 2 then 6
when 4 then 2
when 6 then 8
when 8 then 4
end
return $game_map.events_at(self.x, self.y, d)
end
#-----------------------------------------------------------------------------
# * Name : Events Right
# Info : Returns all events on tile to right hand of self
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def events_right
d = case self.direction
when 2 then 4
when 4 then 8
when 6 then 2
when 8 then 6
end
return $game_map.events_at(self.x, self.y, d)
end
#-----------------------------------------------------------------------------
# * Name : This Event
# Info : Returns 'event_here' or 'event_front' or nil
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def this_event
return self.event_here unless self.event_here.nil?
return self.event_front
end
#-----------------------------------------------------------------------------
# * Name : Event Here
# Info : Returns very first event from 'events_here'
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def event_here
return self.events_here[0]
end
#-----------------------------------------------------------------------------
# * Name : Event Front
# Info : Returns very first event from 'events_front'
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def event_front
return self.events_front[0]
end
#-----------------------------------------------------------------------------
# * Name : Event Behind
# Info : Returns very first event from 'events_behind'
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def event_behind
return self.events_behind[0]
end
#-----------------------------------------------------------------------------
# * Name : Event Left
# Info : Returns very first event from 'events_left'
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def event_left
return self.events_left[0]
end
#-----------------------------------------------------------------------------
# * Name : Event Right
# Info : Returns very first event from 'events_right'
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def event_right
return self.events_right[0]
end
end
Code:
#===============================================================================
# ** TalkAndAnswer
#===============================================================================
module TalkAndAnswer
#-----------------------------------------------------------------------------
# * Trigger
#-----------------------------------------------------------------------------
Trigger = Keys::O
#-----------------------------------------------------------------------------
# * Commands
#-----------------------------------------------------------------------------
Commands = Hash.new
Commands[1] = "People"
Commands[2] = "Places"
Commands[3] = "Things"
Commands[4] = "Misc."
Commands[5] = "All"
#-----------------------------------------------------------------------------
# * Words List
#-----------------------------------------------------------------------------
WordsList = Hash.new
WordsList[1] = ["Dark Minion", "Elsa"]
WordsList[2] = []
WordsList[3] = []
WordsList[4] = []
end
#===============================================================================
# ** Game_Temp
#===============================================================================
class Game_Temp
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :talking_and_answering
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :talkandanswer_gmtemp_initialize, :initialize
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize
talkandanswer_gmtemp_initialize
@talking_and_answering = false
end
end
#===============================================================================
# ** Game_Message
#===============================================================================
class Game_Message
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :current_category
attr_accessor :current_word
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize
@current_category = 1
@current_word = ''
@words_list = TalkAndAnswer::WordsList
end
#-----------------------------------------------------------------------------
# * $game_message.add_word
#-----------------------------------------------------------------------------
def add_word(word, category)
unless @words_list.include?(word)
@words_list[category] << word
end
@words_list.sort! unless @adding_multiple_words
end
#-----------------------------------------------------------------------------
# * $game_message.delete_word
#-----------------------------------------------------------------------------
def delete_word(word, category = nil)
if category.nil?
@words_list.each_key do |i|
@words_list[i].delete(word)
end
return
end
@words_list[category].delete(word)
end
#-----------------------------------------------------------------------------
# * $game_message.add_words
#-----------------------------------------------------------------------------
def add_words(words, category)
@adding_multiple_words = true
words.each {|word| add_word(word, category)}
@adding_multiple_words = false
@words_list.compact!
end
#-----------------------------------------------------------------------------
# * $game_message.delete_words
#-----------------------------------------------------------------------------
def delete_words(words, category = nil)
words.each {|word| delete_word(word, category)}
end
#-----------------------------------------------------------------------------
# * $game_message.start_message
#-----------------------------------------------------------------------------
def start_message
unless $scene.is_a?(Scene_Map)
$scene = Scene_Map.new
end
$game_player.this_event.start
end
#-----------------------------------------------------------------------------
# * Words In Category
#-----------------------------------------------------------------------------
def words_in_category?(category = @current_category)
words = Array.new
if category.nil?
@words_list.each_key do |key|
@words_list[key].each {|word| words << word}
end
else
@words_list[category].each {|word| words << word}
end
return words
end
end
#===============================================================================
# ** Game_Player
#===============================================================================
class Game_Player < Game_Character
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :talkandanswer_gmplayer_updateacttrigger, :update_action_trigger
#-----------------------------------------------------------------------------
# * Update Action Trigger
#-----------------------------------------------------------------------------
def update_action_trigger
if Input.trigger?(TalkAndAnswer::Trigger)
Scene_TalkAndAnswer.new(self.this_event)
return
end
talkandanswer_gmplayer_updateacttrigger
end
end
#===============================================================================
# ** Window_TnA_Commands
#===============================================================================
class Window_TnA_Command < Window_HorizCommand
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize
commands = Array.new
commands << "Word List"
commands << "Sort!"
commands << "Ask Question?"
super(640, commands)
end
end
#===============================================================================
# ** Window_TnA_Words
#===============================================================================
class Window_TnA_Words < Window_Command
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :words
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize
super(160, $game_message.words_in_category?)
self.x = 640 - (self.width + 100)
self.y = 64
self.height = 224
self.active = false
end
end
#===============================================================================
# ** Scene_TalkAndAnswer
#===============================================================================
class Scene_TalkAndAnswer < SDK::Scene_Base
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize(event)
unless event.nil?
@event = event
$scene = self
end
end
#-----------------------------------------------------------------------------
# * Main Window
#-----------------------------------------------------------------------------
def main_window
@window_command = Window_TnA_Command.new
@window_words = Window_TnA_Words.new
#@window_sort = Window_TnA_Sort.new
#@window_questions = Window_TnA_Questions.new
super
end
#-----------------------------------------------------------------------------
# * Main Spriteset
#-----------------------------------------------------------------------------
def main_spriteset
@spriteset = Spriteset_Map.new
super
end
#-----------------------------------------------------------------------------
# * Back To Command
#-----------------------------------------------------------------------------
def back_to_command
$game_system.se_play($data_system.cancel_se)
@window_command.active = true
case @window_command.index
when 0 ; @window_words.active = false
#when 1 ; @window_sort.active = false
#when 2 ; @window_questions.active = false
end
end
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
super
if @window_command.active
update_command
return
elsif @window_words.active
update_words
return
#elsif @window_sort.active
# update_sort
# return
#elsif @window_questions.active
# update_questions
# return
end
end
#-----------------------------------------------------------------------------
# * Update Command
#-----------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::C)
update_command_decision
return
elsif Input.trigger?(Input::B)
update_command_cancel
return
end
end
#-----------------------------------------------------------------------------
# * Update Words
#-----------------------------------------------------------------------------
def update_words
if Input.trigger?(Input::B)
back_to_command
return
elsif Input.trigger?(Input::C)
update_words_decision
return
end
end
#-----------------------------------------------------------------------------
# * Update Sort
#-----------------------------------------------------------------------------
def update_sort
if Input.trigger?(Input::B)
back_to_command
return
elsif Input.trigger?(Input::C)
update_sort_decision
return
end
end
#-----------------------------------------------------------------------------
# * Update Questions
#-----------------------------------------------------------------------------
def update_questions
if Input.trigger?(Input::B)
back_to_command
return
elsif Input.trigger?(Input::C)
update_questions_decision
return
end
end
#-----------------------------------------------------------------------------
# * Update Command : Cancel
#-----------------------------------------------------------------------------
def update_command_cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
#-----------------------------------------------------------------------------
# * Update Command : Decision
#-----------------------------------------------------------------------------
def update_command_decision
$game_system.se_play($data_system.decision_se)
case @window_command.index
when 0 ; @window_words.active = true
#when 1 ; @window_sort.active = true
#when 2 ; @window_questions.active = true
end
@window_command.active = false
end
#-----------------------------------------------------------------------------
# * Update Words : Decision
#-----------------------------------------------------------------------------
def update_words_decision
$game_system.se_play($data_system.decision_se)
$game_message.current_word = @window_words.command
$scene = Scene_Map.new
@event.start
end
#-----------------------------------------------------------------------------
# * Update Sort : Decision
#-----------------------------------------------------------------------------
def update_sort_decision
$game_system.se_play($data_system.decision_se)
@window_sort.update_word_list
end
#-----------------------------------------------------------------------------
# * Update Question : Decision
#-----------------------------------------------------------------------------
def update_question_decision
$game_system.se_play($data_system.decision_se)
end
end
#===============================================================================
# ** Scene_Title
#===============================================================================
class Scene_Title < SDK::Scene_Base
#-----------------------------------------------------------------------------
# * Alias Listing
#-----------------------------------------------------------------------------
alias_method :talkandanswer_scntitle_commandnewgame, :command_new_game
#-----------------------------------------------------------------------------
# * Command New Game
#-----------------------------------------------------------------------------
def command_new_game
talkandanswer_scntitle_commandnewgame
$game_message = Game_Message.new
end
end
#===============================================================================
# ** Scene_Save
#===============================================================================
class Scene_Save < Scene_File
#-----------------------------------------------------------------------------
# * Alias Listing
#-----------------------------------------------------------------------------
alias_method :talkandanswer_scnsave_writesavedata, :write_save_data
#-----------------------------------------------------------------------------
# * Read Save Data
#-----------------------------------------------------------------------------
def write_save_data(file)
talkandanswer_scnsave_writesavedata(file)
Marshal.dump($game_message, file)
end
end
#===============================================================================
# ** Scene_Load
#===============================================================================
class Scene_Load < Scene_File
#-----------------------------------------------------------------------------
# * Alias Listing
#-----------------------------------------------------------------------------
alias_method :talkandanswer_scnload_readsavedata, :read_save_data
#-----------------------------------------------------------------------------
# * Read Save Data
#-----------------------------------------------------------------------------
def read_save_data(file)
talkandanswer_scnload_readsavedata(file)
$game_message = Marshal.load(file)
end
end
You can basically do whatever you normally can with an event, just enclose it within a scripted conditional branch (like I showed above). There's alot of workaround though until I come up with a cleaner eventing-scheme for this, I'm thinking of making Comments in place of the Conditional "Branch : Script" scheme like the example...
@> Comment : T&A START
@> Comment : Dark Minion
@> Text : Blah, Dark Minion, he's ugly!
@> Play SE : "Fart Noise", 100, 50
@> Comment : Elsa
@> Text : Ooh, Elsa... what a hottie!
@> Play SE : "Whistle Noise", 100, 100
@> Comment : T&A END
@> Text : So long as I'm not between T&A
: START and T&A End, I'll do whatever
: normally happens
@> Text : when you hit the action button.
These shortcut calls are probably going to be the most difficult of everything to code (only because I'm rusty on event/interpreter-coding), but I need to do them anyways so this is what I'm gonna be spending the most time on in the end. The biggest thing that needs to be done is "Comment : T&A END" will ensure that $game_message.word = nil, then the rest of your event will run normal (not based off T&A).
On a side note, I'm working on a new Mouse Windows script based off AWorks, since I'm using that for your script anyway I'll probably post that seperate but you'll be able to use it with this script.
The script isn't finished (I just posted it so the requester knows that its half done), but in the end I'm probably either going to remove all SDK or make a seperate non-SDK version. There's still two windows and some Event/Interpreter code that I have to work on before it is final though, so please be patient.