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.
What do you mean modify the environment? Like a skill that makes it rain?
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.
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?
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.
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.
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.
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
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?
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
Thanks, I'll get right on that!
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.
class BlizzABS::Processor
I think you changed that?
Yeah, I think I moved that method to Game_System (and renamed it).
Any suggestions for fixing this?
Bump.
Ok, I've had a look at the script. What was Blizzabs::processor renamed to?
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.
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?
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.
*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
== is a comparison operator...
What you're doing is waaaaay wrong.
And hm... maybe I did fix the event removal location o-o
Then how come it works all of a sudden? Or at least, the first line does.
.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.
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).
So I've used the wrong event id?
Possibly yes.
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.
Lemme see what edits you made first.
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
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
Thanks!