Spawning a new event with a script call

Started by legacyblade, January 03, 2009, 04:16:28 pm

Previous topic - Next topic

legacyblade

I've been trying to figure out how to do this, but I can't without downloading a very laggy, highly incompatible script I found. I know it can't be that hard, so I decided to check with the script troubleshooting crew.

I want to spawn an event on the map. The only things I really need to set are the event's graphics, and its name. If I wasn't using the blizzABS, I could easily simulate this via eventing, with maybe a script call or two, but renaming events (via script call) that have been erased due to them dieing causes a lot of bugs.

Thanks for reading, I'll really appreciate it if someone knows how to do this.

Aqua

The way my FoA system for Blizz-ABS works is that it spawns an existing event from a different map onto the current map.  Sooooo you could take the code from there...

I'll actually give you the code to the way that I get regular skills to spawn events.  Hopefully you'll understand it since it doesn't have too many comments.

Spoiler: ShowHide

module AquaEventSkills
 
MAPID = 'Data/Map014.rxdata'
 
def self.eventid(id)
  case id
  #when [skill ID] then return [event id]
 
  when 120 then return 1 #Healing Wind

 
  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)                   # Gets the event ID to spawn
      if @eventskill != 0
        map = load_data(AquaEventSkills::MAPID)  # Map where the events that are going to be spawned are in
        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         # X of spawned event
        event.y = (@real_y + 64) / 128        # Y of spawned event
        $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])     # Gets sprite
        $scene.spriteset.character_sprites.push(sprite)                      # Adds sprite
        $game_map.events[max].stolen = true                 # Signals that an event is spawn
      end
    end
    return
  end
end

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


And you can use this script call to clear all of the map's spawned events.
$game_map.events.each_value {|e| e.terminate = true if e.stolen}



Blizzard

I was going to add an event spawn where you can define a name and a common event code that should be put into it. It was mainly so enemies might be able to use summoning skills after all.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

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.

legacyblade

Thanks for the help aqua!

@Bliz, yah, event spawning would be really useful. A way to spawn enemies (and clear all corpses from the map) would be VERY useful