Need help starting a script

Started by The Niche, October 05, 2010, 04:17:08 pm

Previous topic - Next topic

The Niche

Alright, I've kinda got a massive problem. See, I've just learnt some basic scripting and decided to make a script which allows skills to modify the environment as my debut. I realise I've bitten off more than I can chew, but I've committed myself already, so I want someone to give me a few pointers on where I should start, e.g. what classes should my script inherit from, one or two classes that I'll need to make, etc.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Calintz

What do you mean modify the environment? Like a skill that makes it rain?

Blizzard

There is not much need for any new classes. It mostly depends on the environment changes you want to implement, but a simple aliasing of Scene_Map#update or Scene_Map#main and adding your additional stuff using simply statements like "if any actor has learned skill X, then do this and that" should be enough.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

The Niche

October 05, 2010, 04:30:28 pm #3 Last Edit: October 05, 2010, 04:34:37 pm by The Niche
What I want is that you modify the weather, and it powers up skills, weakens others and so on. Not just weather modding though. Like maybe a fire randomly starts or spirits start flying around. Actually, bringing in common events will make this much easier.

Actually, I just realised I can event most of this. What I'll need to script is putting  the extra events like the flying ghosts on the map, any thoughts on how I can do this?
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Blizzard

I agree, events are a lot more suitable for this.

You can use Aqua's event generation code from the Field of Aether plugin for Blizz-ABS to create events dynamically. The rest would be simply putting the right piece of code where I already said in my previous post.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

Although eventing in this case would be a better option, it wouldn't hurt to attempt it in a script for learning purposes. That is kinda how I learned.
I set a goal, and kept on trying different things until I got it.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

The Niche

The field of aether system is my starting point. It's currently incompatible and I don't like the way it's done, but I'm taking inspiration from it. I'm still not sure how it works exactly, but I'll figure it out.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Aqua

October 05, 2010, 05:34:02 pm #7 Last Edit: October 05, 2010, 05:35:19 pm by Aqua
What battle system are you using?

If you're using Blizz-ABS, I can just give you a script that spawns events on skill use XD

The Niche

October 06, 2010, 03:26:10 am #8 Last Edit: October 06, 2010, 11:47:42 am by The Niche
Yup, that's exactly what I'm using. Edit: Please do send me the script, :D.
Ok, I'm having a bit of trouble with an event which checks the player's position so I can center the field (I decided enemies won't be able to use the system, someone else can do that)

Code is: Skill calls common event which controls a variable and calls the central common event, which equalizes the variables player_x and player_y with the player's map x and y respectively and checks what the variable in the last common event is, calling the next common event, which has the field effects. Problem is that the central common event isn't bothering to equalize the x and y variables. Anyone have this problem before?
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Aqua

You need to make a map that has all the events you'll spawn in there.
This script will spawn a new instance of an event when you use a certain skill.
module AquaEventSkills
 
MAPID = 'Data/Map014.rxdata'
 
def self.eventid(id)
  case id
  #when [skill ID] then return [event id]
 
  when 120 then return 1

 
  end
  return 0
end
end

class Map_Battler
alias skill_effect_aqua_event_skills skill_effect
  def skill_effect(character, _battler, skill)
    if skill_effect_aqua_event_skills(character, _battler, skill)
      @eventskill = AquaEventSkills.eventid(skill.id)
      if @eventskill != 0
        map = load_data(AquaEventSkills::MAPID)
        max = ($game_map.events.keys + $game_map.map.events.keys).max
        max = 0 if max == nil
        max += 1
        event = map.events[@eventskill]
        event.id = max
        event.x = (@real_x + 64) / 128
        event.y = (@real_y + 64) / 128
        $game_map.map.events[max] = event
        $game_map.events[max] = Game_Event.new($game_map.map_id, event)
        sprite = Sprite_Character.new($scene.spriteset.viewport1, $game_map.events[max])
        $scene.spriteset.character_sprites.push(sprite)
        $game_map.events[max].spawned = true
      end
    end
    return
  end
end

class Game_Character
     attr_accessor :spawned
end
   
class BlizzABS::Processor
  alias event_removal_aqua_x event_removal
  def event_removal
    # Delete all spawned events that should be terminated
     ($game_map.events.values.find_all {|event|
         event.spawned && event.terminate}).each {|event|
         $game_map.events.delete(event.id)} 
  event_removal_aqua_x
  end
end


Use this to delete spawned events
$game_map.events.each_value {|e| e.terminate = true if e.spawned}


I don't think it'll work with the newest version of Blizz-ABS since Blizz moved some classes around...
But maybe you can edit to make it work :D

The Niche

Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Blizzard

Quote from: Aqua on October 07, 2010, 04:49:53 pm
I don't think it'll work with the newest version of Blizz-ABS since Blizz moved some classes around...


On first sight I don't actually see a reason why it shouldn't. I could be wrong. Meh.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Aqua

class BlizzABS::Processor
I think you changed that?

Blizzard

Yeah, I think I moved that method to Game_System (and renamed it).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

The Niche

Any suggestions for fixing this?
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

The Niche

Bump.
Ok, I've had a look at the script. What was Blizzabs::processor renamed to?
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Blizzard

The name is the same, but the method event_removal was moved into Game_System. I just don't remember if it is named event_removal. I think its new name is remove_event.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

The Niche

October 12, 2010, 01:12:22 pm #17 Last Edit: October 12, 2010, 01:16:28 pm by The Niche
Thanks, I'll get right on that!

Edit: Nope, still in module Blizzabs, under class processor and the name is still event removal. Blizzard, you lied to me!!! Anyway, that means something else is being troublesome -.- Any suggestions?
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Blizzard

October 12, 2010, 02:14:57 pm #18 Last Edit: October 12, 2010, 02:16:00 pm by Blizzard
Nope.

Quote from: Blizzard on October 07, 2010, 05:27:11 pm
Yeah, I think I moved that method to Game_System (and renamed it).


I never said I actually did.

EDIT: Now I remember. I moved it from Game_System to BlizzABS::Processor.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

The Niche

October 12, 2010, 03:02:19 pm #19 Last Edit: October 12, 2010, 03:38:14 pm by The Niche
*Obliberates stress ball* Blizzard, you owe me a new one.

Right, now it's time for me to do some code hunting!

EDIT: OH UNHOLY SHIT I AM SUCH A TOOL! I had the fucking script above BABS! Specifically, it needs to be under part three. Alright, expect some results some time soon!

EDIDIT: Ok, I'm still a tool, but now I'm a tool who's got a slightly more problematic problem. When I try to use a field creation skill, the following error is returned:

undefined method 'x' for nil:NilClass. Now, the thing is, .x is in class map_battler, so it should be coming up as undefined method 'x' for class map_battler. The next problem is that x isn't a method. And by the way Aqua, you had
event.id = max
        event.x = (@real_x + 64) / 128
        event.y = (@real_y + 64) / 128


Which caused method errors for id=, x= and y=, so I changed it to:
event.id == max
        event.x == (@real_x + 64) / 128
        event.y == (@real_y + 64) / 128

Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Aqua

== is a comparison operator...
What you're doing is waaaaay wrong.

And hm... maybe I did fix the event removal location o-o

The Niche

Then how come it works all of a sudden? Or at least, the first line does.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Aqua

.x isn't in the class Map_Battler.

id, x, and y are attributes of the event class.

I think you set up the map for events wrong.

Blizzard

x and y are attributes of the Game_Character class which both classes share as superclass. The problem is that for some reason the ID does not match anymore and it's accessing probably a non-existent event (hence it being nil).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

The Niche

So I've used the wrong event id?
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

The Niche

Alright, I have gotten the thingy workulating. However, it only works if I create one event. Any more and it explodes. Aqua, how do I set where the event will spawn? At present it spawns on the player's location, which is fine for a moving event, but not a stationery one.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Aqua

Lemme see what edits you made first.

The Niche

Quoteclass AquaEventSkills
 
MAPID = 'Data/Map002.rxdata'
 
def self.eventid(id)
  case id
  #when [skill ID] then return [event id]
 
  when 1 then return 5

 
  end
  return 0
end
end

class Map_Battler
alias skill_effect_aqua_event_skills skill_effect
  def skill_effect(character, _battler, skill)
    if skill_effect_aqua_event_skills(character, _battler, skill)
      @eventskill = AquaEventSkills.eventid(skill.id)
      if @eventskill != 0
        map = load_data(AquaEventSkills::MAPID)
        max = ($game_map.events.keys + $game_map.map.events.keys).max
        max = 0 if max == nil
        max += 1
        event = map.events[@eventskill]
        event.id = max
        event.x = (@real_x + 64) / 128
        event.y = (@real_y + 64) / 128
        $game_map.map.events[max] = event
        $game_map.events[max] = Game_Event.new($game_map.map_id, event)
        sprite = Sprite_Character.new($scene.spriteset.viewport1, $game_map.events[max])
        $scene.spriteset.character_sprites.push(sprite)
        $game_map.events[max].spawned = true
      end
    end
    return
  end
end

class Game_Character
     attr_accessor :spawned
end
   
class BlizzABS::Processor
  alias event_removal_aqua_x event_removal
  def event_removal
    # Delete all spawned events that should be terminated
     ($game_map.events.values.find_all {|event|
         event.spawned && event.terminate}).each {|event|
         $game_map.events.delete(event.id)} 
  event_removal_aqua_x
  end
end
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Aqua

So when you use skill ID 1, it'll spawn event ID 5 found in map ID 2

o-o
Did you change the actual code at all?
I thought you said you made edits...

Lol and looking at the code again, it's not really the best coding.
@eventskill can just be eventskill

Anyway, where the event is spawned are these two lines.

event.x = (@real_x + 64) / 128
event.y = (@real_y + 64) / 128

Have fun editing

The Niche

Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!