Jump to content
Asharonapaul

Diplomacy Script, First Attempt at Scripting in VX ACE

Recommended Posts

Im kinda aware that it is a thing, but I really can't see how it would help my script thus far.

Share this post


Link to post
Share on other sites

Well, you kinda need to do it to add it to the save game properly.

Share this post


Link to post
Share on other sites

Well, you ever look in other people's scripts? Whenever they want to add or change something in the default scripts they mostly use aliases to make a copy of any method they want to add to and overwrite the original while calling the copy. It's handy! It's like a patch that changes what something does without changing the original code! It's kinda more tricky for modules like DataManager but the same idea applies. But we can wait till you are done with everything else before you worry about that I guess?

Share this post


Link to post
Share on other sites

sounds complex. I think I should focus on the initial status for everything, then worry about how interaction occurs without need of a player.

Share this post


Link to post
Share on other sites

Okay! It's not too complex but it is a bit tricky sometimes!

Share this post


Link to post
Share on other sites

so for the code you wrote, how do I set $factions = {} in the data manager? do I add a code to include the variable in the data manager? how would that look?

Share this post


Link to post
Share on other sites

Well, let me show you:

 

 

 

module DataManager
  
  # opens the module's "singleton class", allows aliasing modules of self. methods
  # you don't need to use self. before method names this way either.
  class << self 
    
    # alias for copying old method
    alias create_game_objects_factions_base create_game_objects
    # set $factions = {} when a new game starts
    def create_game_objects
      # call the old method
      create_game_objects_factions_base
      $factions = {}
    end
    
    # alias for copying old method
    alias make_save_contents_factions_base make_save_contents
    # save the game
    def make_save_contents
      # set contents to what the old method returned
      contents = make_save_contents_factions_base
      # savegames themselves are a big hash, this will set the right key for it
      contents[:factions] = $factions
      # return the modified hash (the return keyword is not really needed for the last line in a method)
      contents
    end

    # alias for copying old method
    alias extract_save_contents_factions _base extract_save_contents
    # load the game
    def extract_save_contents(contents)
      extract_save_contents_factions_base(contents)
      # set $factions to whatever was saved in the hash.
      # The || {} just lets saved games made before the script was added work.
      $factions = contents[:factions] || {}
    end
    
  end # end for singleton class

end # end for module

 

 

I hope my comments help you understand what is going on.

Edited by KilloZapit

Share this post


Link to post
Share on other sites

before I mess around with anything else, you think you could help me make a window that is accesable from the menu that displays the faction names, and when you select the faction name of your choosing, it displays the information? Eventually there will be another class made for cultures, but I think I can save that for later. but I included a diagram of how I wanted the window display to look.


post-60764-0-07055000-1444150493_thumb.png


it's pretty basic, but hopefully it explains the layout I'm going for.

Share this post


Link to post
Share on other sites

It's part of the normal saved games and goes in the same file.

 

Hmmm... I think you might be better off asking someone else for window stuff. It's something I can do, but I don't think I am as good at explaining it as others.

Edited by KilloZapit

Share this post


Link to post
Share on other sites

I think you're far more respectable as a teacher then you let yourself assume. I saw your tutorial on cursors. and I was actually thinking of using it for the game :)

Share this post


Link to post
Share on other sites

You must be mistaken, that wasn't my topic...

Share this post


Link to post
Share on other sites

Well, the data manager uses hashes though, that's how saved games are stored. It takes all the global variables and puts them in a hash and then saves that hash to a file using something that is a lot like Ruby's Marshal module (a special version made to use RPG Maker VX Ace's encryption I think, though I don't think saved games are encrypted).

Share this post


Link to post
Share on other sites

I attempted to write the code you sampled for data module, and I got an error for nil class.

Share this post


Link to post
Share on other sites

 

 

module DataManager
  class << self
    alias create_game_objects_factions_base create_game_objects
    def create_game_objects
      create_game_objects_factions_base
      $factions = {}
    end
    alias make_save_contents_factions_base make_save_contents
    def make_save_contents
      contents = make_save_contents_factions_base
      contents[:factions] = $factions
      contents
    end
    alias extract_save_contents_factions_base extract_save_contents
    def extract_save_contents(contents)
      extract_save_contents(contents)
      $factions = contents[:factions] || {}
    end
  end
end

#Establishes the settings for Factions
class Factions
  def initialize
    @status = "Neutral"
    @enemy = "None"
    @taxes = 0
    @diplomacy = 100
  end
  def status
    @status
  end
  def status=(val)
    @status = val
  end
  def enemy
    @enemy
  end
  def enemy=(val)
    @enemy = val
  end
  def ally
    @ally
  end
  def ally=(val)
    @ally = val
  end
  
  def taxes
    @income
  end
  def taxes=(val)
    @taxes = val
  end
  def vulnerability
    @vulnerability
  end
  def vulnerability=(val)
    @vulnerability = val
  end
  def diplomacy
    @diplomacy
  end
  def diplomacy=(val)
    @diplomacy = val
  end
end




#Initialize Rome
$factions[:SenateOfRome] = Factions.new
$factions[:SenateOfRome].taxes = 1000
$factions[:SenateOfRome].vulnerability = 50
$factions[:SenateOfRome].status = "War"
$factions[:SenateOfRome].enemy = ["Dacia", "Thracia", "Cappadocia", "Pontus Kingdom"]
$factions[:SenateOfRome].ally = ["Mauretania", "Egypt", "Osroene", "Mascat", "Galatian Confederacy", "Jerusalem", "Bosporan Kingdom"]
#Initialize Dacia
$Dacia = Factions.new
$Dacia.taxes = 50
$Dacia.vulnerability = 20
$Dacia.status = "War"
$Dacia.enemy = ["Senate Of Rome"]
$Dacia.ally = ["None"]
#Initialize Xiongnu
$Xiongnu = Factions.new
$Xiongnu.taxes = 700
$Xiongnu.vulnerability = 35
$Xiongnu.status = "War"
$Xiongnu.enemy = ["Han Empire"]
$Xiongnu.ally = ["Goguryeo", "Okjeo", "Buyeo", "Dongye"]
#Initialize Han Empire
$Han_Empire = Factions.new
$Han_Empire.taxes = 1200
$Han_Empire.vulnerability = 70
$Han_Empire.status = "War"
$Han_Empire.enemy = ["Xiongnu", "Goguryeo", "Okjeo", "Doongye", "Byeonhan", "Mahan", "Jinhan", "Japan", "Yuezhi"]
$Han_Empire.ally = ["None"]
#Initialize Buyeo
$Buyeo = Factions.new
$Buyeo.taxes = 200
$Buyeo.vulnerability = 40
$Buyeo.status = "War"
$Buyeo.enemy = ["Han Empire", "Goguryeo", "Okjeo", "Dongye"]
$Buyeo.ally = ["Xiongnu"]
#Initialize Goguryeo
$Goguryeo = Factions.new
$Goguryeo.taxes = 120
$Goguryeo.vulnerability = 30
$Goguryeo.status = "War"
$Goguryeo.enemy = ["Han Empire", "Buyeo", "Okjeo", "Dongyeo"]
$Goguryeo.ally = ["Xiongnu"]
#Initialize Okjeo
$Okjeo = Factions.new
$Okjeo.taxes = 150
$Okjeo.vulnerability = 15
$Okjeo.status = "War"
$Okjeo.enemy = ["Han Empire", "Goguryeo", "Buyeo", "Dongye"]
$Okjeo.ally = ["Xiongnu"]
#Initialize Yuezhi
$Yuezhi = Factions.new
$Yuezhi.taxes = 71
$Yuezhi.vulnerability = 40
$Yuezhi.status = "War"
$Yuezhi.enemy = ["Han Empire"]
$Yuezhi.ally = ["None"]
#Initialize Dongye
$Dongye = Factions.new
$Dongye.taxes = 600
$Dongye.vulnerability = 34
$Dongye.status = "War"
$Dongye.enemy = ["Han Empire", "Goguryeo", "Buyeo", "Okjeo"]
$Dongye.ally = ["Xiongnu"]
#Initialize Byeonhan
$Byeonhan = Factions.new
$Byeonhan.taxes = 150
$Byeonhan.vulnerability = 45
$Byeonhan.status = "War"
$Byeonhan.enemy = ["Han Empire", "Mahan", "Jinhan", "Japan"]
$Byeonhan.ally = ["None"]
#Initialize Mahan
$Mahan = Factions.new
$Mahan.taxes = 75
$Mahan.vulnerability = 67
$Mahan.status = "War"
$Mahan.enemy = ["Byeonhan", "Han Empire", "Jinhan", "Japan"]
$Mahan.ally = ["None"]
#Initialize Jinhan
$Jinhan = Factions.new
$Jinhan.taxes = 271
$Jinhan.vulnerability = 12
$Jinhan.status = "War"
$Jinhan.enemy = ["Byeonhan", "Han Empire", "Mahan", "Japan"]
$Jinhan.ally = ["None"]
#Initialize Japan
$Japan = Factions.new
$Japan.taxes = 126
$Japan.vulnerability = 23
$Japan.status = "War"
$Japan.enemy = ["Byeonhan", "Han Empire", "Jinhan", "Mahan"]
$Japan.ally = ["None"]
#Initialize Parthian Empire
$Parthian = Factions.new
$Parthian.taxes = 780
$Parthian.vulnerability = 40
$Parthian.status = "War"
$Parthian.enemy = ["Media", "Armenia", "Osorene", "Yadavas Kingdom"]
$Parthian.ally = ["None"]
#Initialize Yadavas Kingdom
$Yadavas = Factions.new
$Yadavas.taxes = 340
$Yadavas.vulnerability = 34
$Yadavas.status = "War"
$Yadavas.enemy = ["Parthian Empire", "Indo Scythian Confederacy", "Magadha dynasty"]
$Yadavas.ally = ["None"]
#Initialize Indo Scythian COnfederacy
$Scythia = Factions.new
$Scythia.taxes = 300
$Scythia.vulnerability = 24
$Scythia.status = "War"
$Scythia.enemy = ["Yadavas Kingdom"]
$Scythia.ally = ["Magadha Dynasty", "Satavahana"]
#Initialize Magadha Dynasty
$Magadha = Factions.new
$Magadha.taxes = 450
$Magadha.vulnerability = 45
$Magadha.status = "War"
$Magadha.enemy = ["Yadavas Kingdom"]
$Magadha.ally = ["Indo Scythian Confederacy"]
#Initialize Satavahana
$Satavahana = Factions.new
$Satavahana.taxes = 350
$Satavahana.vulnerability = 24
$Satavahana.status = "War"
$Satavahana.enemy = ["Pandyas"]
$Satavahana.ally = ["Kalinga Dynasty", "Chutus", "Cholas", "Ceras"]
#Initialize Kalinga Dynasty
$Kalinga = Factions.new
$Kalinga.taxes = 120
$Kalinga.vulnerability = 39
$Kalinga.status = "War"
$Kalinga.enemy = ["Pandyas"]
$Kalinga.ally = ["Satavahana", "Chutus", "Cholas", "Ceras"]
#Initialize Chutus
$Chutus = Factions.new
$Chutus.taxes = 241
$Chutus.vulnerability = 34
$Chutus.status = "War"
$Chutus.enemy = ["Pandyas"]
$Chutus.ally = ["Satavahana", "Kalinga Dynasty", "Cholas", "Ceras"]
#Initialize Cholas
$Cholas = Factions.new
$Cholas.taxes = 145
$Cholas.vulnerability = 45
$Cholas.status = "Peace"
$Cholas.enemy = ["None"]
$Cholas.ally = ["Satavahana", "Chutus", "Kalinga Dynasty", "Pandyas", "Ceras"]
#Initialize Pandyas
$Pandyas = Factions.new
$Pandyas.taxes = 134
$Pandyas.vulnerability = 34
$Pandyas.status = "War"
$Pandyas.enemy = ["Satavahana", "Chutus", "Kalinga Dynasty"]
$Pandyas.ally = ["Cholas", "Ceras"]
#Initizlize Ceras
$Ceras = Factions.new
$Ceras.taxes = 124
$Ceras.vulnerability = 24
$Ceras.status = "War"
$Ceras.enemy = ["Pandyas"]
$Ceras.ally = ["Satavahana", "Chutus", "Cholas", "Kalnga Dynasty"]
#Initialize Pyu
$Pyu = Factions.new
$Pyu.taxes = 34
$Pyu.vulnerability = 20
$Pyu.status = "Peace"
$Pyu.enemy = ["None"]
$Pyu.ally = ["Monn Cities", "Funan"]
#Initialize Monn Cities
$Monn = Factions.new
$Monn.taxes = 51
$Monn.vulnerability = 30
$Monn.status = "Peace"
$Monn.enemy = ["None"]
$Monn.ally = ["Pyu Cities", "Funan"]
#Initialize Funan
$Funan = Factions.new
$Funan.taxes = 32
$Funan.vulnerability = 34
$Funan.status = "Peace"
$Funan.enemy = ["None"]
$Funan.ally = ["Pyu Cities", "Monn Cities"]
#Initialize Mauretania
$Mauretania = Factions.new
$Mauretania.taxes = 43
$Mauretania.vulnerability = 32
$Mauretania.status = "Peace"
$Mauretania.enemy = ["None"]
$Mauretania.ally = ["Senate of Rome"]
#Initialize Thracia
$Thracia = Factions.new
$Thracia.taxes = 32
$Thracia.vulnerability = 21
$Thracia.status = "War"
$Thracia.enemy = ["Senate Of Rome"]
$Thracia.ally = ["None"]
#Initialize Sarmatian Confederacy
$Sarmatia = Factions.new
$Sarmatia.vulnerability = 32
$Sarmatia.status = "Peace"
$Sarmatia.enemy = ["None"]
$Sarmatia.ally = ["Bosporan Kingdom"]
#Initialize Galatian Confederacy
$Galatia = Factions.new
$Galatia.taxes = 53
$Galatia.vulnerability = 21
$Galatia.status = "Peace"
$Galatia.enemy = ["None"]
$Galatia.ally = ["Senate Of Rome"]
#Initialize Pontus Kingdom
$Pontus = Factions.new
$Pontus.taxes = 121
$Pontus.vulnerability = 32
$Pontus.status ="War"
$Pontus.enemy = ["Senate Of Rome", "Cappadocia", "Armenia"]
$Pontus.ally = ["Colchis", "Iberia"]
#Initialize Cappadocia
$Cappadocia = Factions.new
$Cappadocia.taxes = 34
$Cappadocia.vulnerability = 23
$Cappadocia.status = "War"
$Cappadocia.enemy = ["Senate Of Rome", "Pontus Kingdom", "Armenia", "Osroene"]
$Cappadocia.ally = ["None"]
#Initialize Bosporan Kingdom
$Bospora = Factions.new
$Bospora.taxes = 56
$Bospora.vulnerability = 34
$Bospora.status = "Peace"
$Bospora.enemy = ["None"]
$Bospora.ally = ["Sarmatian Confederacy"]
#Initialize Colchis
$Colchis = Factions.new
$Colchis.taxes = 32
$Colchis.vulnerability = 25
$Colchis.status = "War"
$Colchis.enemy = ["Iberia"]
$Colchis.ally = ["Pontus Kingdom"]
#Initialize Iberia
$Iberia = Factions.new
$Iberia.taxes = 24
$Iberia.vulnerability = 34
$Iberia.status = "War"
$Iberia.enemy = ["Colchis", "Armenia", "Albania"]
$Iberia.ally = ["Pontus Kingdom"]
#Initialize Armenia
$Armenia = Factions.new
$Armenia.taxes = 54
$Armenia.vulnerability = 24
$Armenia.status = "War"
$Armenia.enemy = ["Pontus Kingdom", "Cappadocia", "Iberia", "Albania", "Media"]
$Armenia.ally = ["None"]
#Initialize Albania
$Albania = Factions.new
$Albania.taxes = 24
$Albania.vulnerability = 34
$Albania.status = "War"
$Albania.enemy = ["Iberia", "Armenia", "MEdia", "Parthian Empire"]
$Albania.ally = ["None"]
#Initialize Media
$Media = Factions.new
$Media.taxes = 134
$Media.vulnerability = 24
$Media.status = "War"
$Media.enemy = ["Parthian Empire", "Armenia", "Albania"]
$Media.ally = ["None"]
#Initialize Osroene
$Osroene = Factions.new
$Osroene.taxes = 99
$Osroene.vulnerability = 29
$Osroene.status = "War"
$Osroene.enemy = ["Parthian Empire"]
$Osroene.ally = ["Senate Of Rome", "Mascat"]
#Initialze Mascat
$Mascat = Factions.new
$Mascat.taxes = 101
$Mascat.vulnerability = 30
$Mascat.status = "Peace"
$Mascat.enemy = ["None"]
$Mascat.ally = ["Senate Of Rome", "Osroene"]
#Initialize Jerusalem
$Jerusalem = Factions.new
$Jerusalem.taxes = 204
$Jerusalem.vulnerability = 49
$Jerusalem.status = "War"
$Jerusalem.enemy = ["Nabatene"]
$Jerusalem.ally = ["Senate Of Rome"]
#Initialize Nabatane
$Nabatane = Factions.new
$Nabatane.taxes = 124
$Nabatane.vulnerability = 21
$Nabatane.status = "War"
$Nabatane.enemy = ["Jerusalem", "Egypt"]
$Nabatane.ally = ["None"]
#Initialize Egypt
$Egypt = Factions.new
$Egypt.taxes = 1354
$Egypt.vulnerability = 32
$Egypt.status = "War"
$Egypt.enemy = ["Mascat", "Kush Kingdom"]
$Egypt.ally = ["Senate Of Rome"]
#Initialize Kush Kingdom
$Kush = Factions.new
$Kush.taxes = 345
$Kush.vulnerability = 24
$Kush.status = "War"
$Kush.enemy = ["Egypt", "Aksum Kingdom"]
$Kush.ally = ["None"]
#Initialize Aksum Kingdom
$Aksum = Factions.new
$Aksum.taxes = 124
$Aksum.vulnerability = 29
$Aksum.status = "War"
$Aksum.enemy = ["Egypt", "Kush Kingdom", "Himyarites"]
$Aksum.ally = ["None"]
#Initialize Himyarites
$Himyarites = Factions.new
$Himyarites.taxes = 98
$Himyarites.vulnerability = 32
$Himyarites.status = "War"
$Himyarites.enemy = ["Aksum Kingdom"]
$Himyarites.ally = ["None"]
#Initialize Garamentes
$Garamentes = Factions.new
$Garamentes.taxes = 34
$Garamentes.vulnerability = 25
$Garamentes.status = "War"
$Garamentes.enemy = ["Senate Of Rome"]
$Garamentes.ally = ["None"]
#Initialize Teotihuacan
$Teotihuacan = Factions.new
$Teotihuacan.taxes = 34
$Teotihuacan.vulnerability = 19
$Teotihuacan.status = "War"
$Teotihuacan.enemy = ["Totonac", "Maya"]
$Teotihuacan.ally = ["Tarascan", "Mixtec", "Zapotec"]
#Initialize Tarascan
$Tarascan = Factions.new
$Tarascan.taxes = 120
$Tarascan.vulnerability = 20
$Tarascan.status = "War"
$Tarascan.enemy = ["Totonac", "Maya"]
$Tarascan.ally = ["Teotihuacan", "Mixtec", "Zapotec"]
#Initialize Totonac
$Totonac = Factions.new
$Totonac.taxes = 90
$Totonac.vulnerability = 30
$Totonac.status = "War"
$Totonac.enemy = ["Tarascan", "Teotihuacan", "Maya", "Mixtec", "Zapotec"]
$Totonac.ally = ["None"]
#Initialize Maya
$Maya = Factions.new
$Maya.taxes = 121
$Maya.vulnerability = 20
$Maya.status = "War"
$Maya.enemy = ["Tarascan", "Teotihuacan", "Totonac", "Mixtec", "Zapotec"]
$Maya.ally = ["None"]
#Initialize Mixtec
$Mixtec = Factions.new
$Mixtec.taxes = 57
$Mixtec.vulnerability = 30
$Mixtec.status = "War"
$Mixtec.enemy = ["Maya", "Totonac", "Zapotec"]
$Mixtec.ally = ["Tarascan", "Teotihuacan"]
#Initialize Zapotec
$Zapotec = Factions.new
$Zapotec.taxes = 103
$Zapotec.vulnerability = 27
$Zapotec.status = "War"
$Zapotec.enemy = ["Maya", "Totonac", "Mixtec"]
$Zapotec.ally = ["Tarascan", "Teotihuacan"]

class Leaders
  def initialize
    @Faction = "None"
    @Family = "None"
    @Influence = 100.0
    @Age = 45
    @Child = "None"
    @Father = "None"
    @Mother = "None"
    @Brother = "None"
    @Sister = "None"
    @Personality = "Agressive"
    @Name = "None"
  end
  def Faction
    @Faction
  end
  def Faction=(val)
    @Faction = val
  end
  
  def Family
    @Family
  end
  def Family=(val)
    @Family = val
  end
  
  def Influence
    @Influence
  end
  def Influence=(val)
    @Influence = val
  end
  
  def Age
    @Age
  end
  def Age=(val)
    @Age = val
  end
  
  def Child
    @Child
  end
  def Child=(val)
    @Child = val
  end
  
  def Father
    @Father
  end
  def Father=(val)
    @Father = val
  end
  
  def Mother
    @Mother
  end
  def Mother=(val)
    @Mother = val
  end
  
  def Brother
    @Brother
  end
  def Brother=(val)
    @Brother = val
  end
  
  def Sister
    @Sister
  end
  def Sister=(val)
    @Sister = val
    end
  def Personality
    @Personality
  end
  def Personality=(val)
    @Personality = val
  end
  
  def Name
    @Name
  end
  def Name=(val)
    @Name = val
  end
  
end

$Leaders_Rome = ["Manius", "Gaius", "Julius", "Septimus", "Decius", "Leuke", "Maximus", "Spartacus", "Aemilianus", "Aemilus", "Aetius", "Agrippa"]
$Families_Rome = ["Juliana", "Trilian", "Scipio", "Brutti"]
$Sons_Rome = $Leaders_Rome
$Daughters_Rome = ["Julia", "Gaia", "Mania", "Septima", "Decia", "Lucia", "Maxine", "Spartia", "Aemi", "Amilia", "Aetia", "Agris"]
$Personality_Rome = ["Agressive", "Loyal", "Cautious", "Peaceful"]

$name_rome = $Leaders_Rome[rand(12)] 
$surname_rome = $Families_Rome[rand(4)]
$Rome_son_or_daughter = rand(2)

if $Rome_son_or_daughter == 1
  $child_rome = $Sons_Rome[rand(12)]
else
  $child_rome = $Daughters_Rome[rand(12)]
end

$Roman_Leader = Leaders.new
$Roman_Leader.Name = $name_rome
$Roman_Leader.Faction = "Rome"
$Roman_Leader.Family = $surname_rome
$Roman_Leader.Age = rand(100)
if $Roman_Leader.Age < 18
  $Roman_Leader.Age = 18
end

$Roman_Leader.Influence = ($Roman_Leader.Age * 1.5)
$Roman_Leader.Child = $child_rome
$Roman_Leader.Father = $Leaders_Rome[rand(12)]
$Roman_Leader.Mother = $Daughters_Rome[rand(12)]
$Roman_Leader.Brother = $Leaders_Rome[rand(12)]
$Roman_Leader.Sister = $Daughters_Rome[rand(12)]
$Roman_Leader.Personality = $Personality_Rome[rand(4)]

#Initialize 

event = nil


#Diplomacy Eventer
#Set Cycle for Event to every 7 days


#Diplomacy for Senate of Rome
if event == true
  if $factions[:SenateOfRome].diplomacy > 20
    if $Dacia.diplomacy <= $factions[:SenateOfRome].diplomacy
      if $factions[:SenateOfRome].enemy.include? != "Dacia"
              $factions[:SenateOfRome].enemy += ["Dacia"]
              $Dacia.enemy += ["Senate of Rome"]
              $factions[:SenateOfRome].status = "War"
              $Dacia.status = "War"
      end
        else
    
          if $factions[:SenateOfRome].diplomacy == $Dacia.diplomacy
      
            if $factions[:SenateOfRome].enemy == "Dacia"
        
              $factions[:SenateOfRome].enemy -= ["Dacia"]
              $Dacia.enemy -= ["Senate of Rome"]
            end
          end
      end

      
end
event = nil
end
p $factions[:SenateOfRome]
p $Roman_Leader

 



above is the entire diplomacy code as stands. the leaders need to be defined for the diplomacy aspect of the game to work. I only made the senate of rome into a hash. when I execute the game, it says undefined method = '[] for nil:NillClass'

 

Share this post


Link to post
Share on other sites

Oh, you will need to set the default in the create_game_objects though you could put it somewhere else and call it from there. Also remember what I said, every new $variable you make you will have to add to the saved game, so putting it all in a hash is easier.

 

You know... have you seen my database script thing? It might be helpful.

Share this post


Link to post
Share on other sites

I don't really understand it, but it looks cool.

I removed the code from the script, and decided to look at a tutorial that included windows. trouble is, it's not quite easily understood either.

it seems the simpler, yet indecernable scripts use things I can't figure out where they came from. like item.name. no where in the script is a name method created, but it works for theirs, and when I rework it, it does not.

The result is a window that lists the factions, from an array I had to create because .compact doesn't work for hashes, on one side, and a blank window ion the other side. and I have no idea what I did. if you feel like explaining it for me, I'll include it below.

 



class Window_FactionList < Window_Selectable
  def initialize(x, y, width)
    super(x, y, width, Graphics.height - y)
    data = []
    self.index = 0
    activate
    refresh
  end
  
  def item_max
    @data ? @data.size : 1
  end
  
  def make_item_list
    @data = $faction_names.compact
  end
  
  def draw_item(index)
    item  = @data[index]
    if item
      rect = item_rect_for_text(index)
      draw_text(rect, item)
    end
  end
  
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  
  

end

  class Window_Factions < Window_Base
    def initialize(faction_window, x, y, width, height)
      super(x, y, width, height)
      @faction_window = faction_window
      refresh
    end
  end
  
  def refresh
    contents.clear
  
  end
class Scene_Diplomacy < Scene_MenuBase
  def start
    super
    @list_window = Window_FactionList.new(0, 0, 200)
    @faction_window = Window_Factions.new(@list_window, 200, 0, Graphics.width - 200, Graphics.width - 300)
    @faction_window.viewport = @viewport
    @list_window.set_handler(:cancel, method(:return_scene))
  end
end

 

 

Share this post


Link to post
Share on other sites

Well item usually is an RPG::BaseItem class or one of it's subclasses (you can read more about those hidden classes in the RPG Maker VX Ace help ffile) which has a name method.

Share this post


Link to post
Share on other sites

what would I have to do to display the hashes in the second window? would I do something like class draw_infromation($faction)? or would I place the draw_text code in the Window_Factions class?

Share this post


Link to post
Share on other sites

You would need to place draw_text code in the Window_Factions class. I think you should look through some other people's scripts and the default scripts to see if you can get a handle on what they are doing. I am probably not going to be able to be a big help here.

Share this post


Link to post
Share on other sites

I'm lost. I can't understand a single thing about windows. plug and play scripts I have found that offers displaying information in a window doesn;'t offer enough information, and are not using classes. And no one has ever thought of doing anything like diplomacy based a.i. for RPG VX ACE, or from what I have gathered, any RPG Maker engine ever.

perhaps I should just give up?

The team discussed the purpose of the game, and having diplomacy in the menu, along with all our other ideas, seemed to be something that would hinder gameplay, and cause confusion. For all purposes of game play, and game play experience, we have decided that the information on the various AI systems we wish to include, can be accessed from designated NPCs.

Share this post


Link to post
Share on other sites

Good luck whatever you do! *sprinkles fairy dust on you*

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted