Envision, Create, Share

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.

Creating Events using SCripts Help

I need to spawn an actor to one square besides the Player how can I do this?
I found this script somewhere, but not sure how to implement it (the Call Script window is too small). Thanks for any help.

Code:
ev = RPG::Event.new(x, y)

    ev.id = $game_map.events.size + 1

    ev.pages = []

 

    # Create a game event object using map id and ev value

    event =  Game_Event.new($game_map.map_id, ev)

    event.through = false

 

    # Set the event at ev.id to our event (include it in map)

    $game_map.events[ev.id] = event

    @index = ev.id        

    #$event_instance[ev.id] = event

    #$game_map.map.events.keys.push(@index)

    $game_map.map.events[@index] = ev

    #print $game_map.events

 

    # Map needs to be redrawn because a new event was added

    $game_map.need_refresh = true

    $scene.spriteset.add_additional_sprites
 
[rgss]# make new event with the main hero's sprite
#  sprite = "001:fighter01"
#  name = "EV000:SomeName"
#  through = false
#  $game_map.new_event(name, sprite, x, y, through)
   
class Game_Map
 
 def new_event(name, sprite, x, y, through)
    # create unique ID for the event
    event_id = @map.events.keys.max + 1
    new_event = RPG::Event.new(x,y)
    new_event.name = name.nil? ? "EV00" + event_id.to_s  : name
    new_event.pages[0].graphic.character_name = sprite
    new_event.pages[0].through = through
    # now, create a map event from the new RPG::Event
    l = @map.events.keys.length
    @map.events.keys[l]=event_id
    @map.events[event_id]=new_event
    game_event = Game_Event.new(@map_id, new_event)
    @events[event_id] = game_event
    refresh
  end
 
end
 
[/rgss]
The x, y, should be numbers. they mark the square on the map:
eventxy2.jpg

To create an event of Aluxes sprite at that square:
$game_map.new_event("someName", "001:fighter01", 17, 18, false)
OR if you can't bother with giving the event a name:
$game_map.new_event(nil, "001:fighter01", 17, 18, false)
 
thanks this is very useful but honestly since i dont know code I wouldn't know how to control it even after I created it hahaa..
I need it to create a weapon thrusting animation as an event but would not know how to control cause it's created intangibly if i am not mistaken.
 
No, it's not intangibly created. if the graphic is Aluxe's sprite, he'll show up on the map.
However, it won't be created until you play the game, so in the editor you can't edit the event.

But, If all you need is showing an animation, this is an overkill !
I suggest you use a normal event, I'll show you how:
First, whenever the player uses the weapon, turn a certain switch ON, I called mine 'play animation'.
It's an event with 2 pages:
thrust1.PNG
thrust2.PNG
Make sure the top left box says 'Target'. That's the name of our event.
thrust3.PNG
The idea is: moving this invisible event, until it stands in front of the player- where the target is. When the animation plays, our event stands on the target, so the animation 'hits' the enemy.
Ask me is something isn't clear.
 
I did the spear animation using frame by frame animation like
2zdq2rs.png


But it would be great to animate the special effect as well. Your method requires an event to be placed on every map, is there a way to animate the special effect without that, maybe using script? Cause it would be great if you can use variables with the special effect which I am sure you cant using GUI. It only allows for events to be used on the sp effect.

Thanks for being so helpful.
 
However, it won't be created until you play the game
If you use a script to create the event, you cannot 'play animation' on it. When the editor asks you to select the target event, your event will NOT be on the list. And yes, it is possible with a script. However, since you're not comfortable with scripts, I recommend you to use events instead. It'll give you more control.
My method lets you use the animations in the database. Any animation. Simply add a condition: if Aluxes is equipped with sword, play 'sword' animation, if 'Fire Axe', play 'Fire' animation, etc.

Oh, about the special animation. Just add a play animation command in your common event, and select the player.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top