Fantasist's Tips for Eventers Events are a way to control the default scripts, eventing IS scripting in a way. There are certain things you can't do directly with event commands, but you don't need to resort to large script systems for a solution. Sometimes, pieces of code can be very useful. I'll be gathering those tips here in this thread. I'll keep this post updated with any new ideas I have. Feel free to suggest/request/ask anything. If you feel events are not getting your job done and you need a little more, this is your place.
Player and Event Positions on the Map
The map is a grid of 32x32 pixel tiles. Each tile has an adress in terms of X and Y coordinates. For some reason, if you want to know the player's/event's position on the current map, these are the lines of code:
Player's position:
$game_player.x # The player's X coordinate
$game_player.y # The player's Y coordinate
An Event's position:
$game_map.events[ID].x # X position of the event. ID is the ID of the event in the map
$game_map.events[ID].y # Y position of the event. ID is the ID of the event in the map
These can be very useful for things like minimaps. There is also another potential use for which I actually dug these lines: ranged actions. You can compare the distance between two events/player and make something happen. For example, you can make a caterpillar system where the event 'Follows the Hero' if the distance is more that 1 tile. You can make pets too: follow the hero if the distance is more than, say 6 tiles and move around randomly otherwise. That way, your pet wanders around near you but will follow you if you're too far.
Power of variables - Storing Strings
You know that variables are used to store numbers, right? Fact is, they can store pretty much ANYTHING, like text and even your current party. But for storing these other things, you should the Call Script command and use this code:
$game_variables[ID] = (thing to store)
where ID is the ID of the variable you intend to use. (thing to store) can be anything, mostly
or other things like
How is this useful? You know that \n[1] will be replaced by the name of the first actor in the party, but what if you wanted to display the name of the first actor in the database? Or actually, if you want to display a frequently used or changing text in a message, what would you do? You'd use variables to store the text.
Let's cover the name of the actor first. To store the name of the 4th actor in the database, you'll use:
$game_variables[ID] = $data_actors[4].name
$data_actors[4].name is the name of the 4th actor in the database.
Now here's another use. Say you have multiple possibilities in your game, where a message is different depending on a switch. So instead of doing this:
<>Conditional Branch: Switch [0036: Heaven's Blade Unlocked] == ON
<>Message: Heaven's Blade is the strongest weapon in existance.
Else Handler
<>Message: Ultima Blade is the strongest weapon in existance.
End
You can do this:
<>Conditional Branch: Switch [0036: Heaven's Blade Unlocked] == ON
<>Script: $game_variables[1] = 'Heaven's Blade'
Else Handler
<>Script: $game_variables[1] = 'Ultima Blade'
End
<>Message: \v[1] is the strongest weapon in existance.
And actually, you can simple use \v[1] whenever you want to refer to the strongest weapon in existance.
Range - distance between two points
Let's say there's two ppoints on the map and you want to find the distance between them. These two points can be anywhere, one below the other, vertically aligned, horizontally aligned, or diagonally placed at a distance. If you're familiar with the Pythogoran rule for the hypotenuse of a right angled triangle, this is exactly that, it gives the distance between two points:
Math.hypot(x2 - x1, y2 - y1)
where x1, x2, y1 and y2 are the coordinates of the points (x1, y1) and (x2, y2).
It's mostly cartesian geometry, nothing complex once you know the basics. This piece of code can be VERY WELL USED in conjunction with
Player and Event Positions on the Map to make
ranged systems, the same things discussed in
Player and Event Positions on the Map.
Get All Items
Ever wanted to have ALL the items during debug? I for one find it irritating using lots of 'Add Item' event command. Now, paste the following code into a 'Call Script' event command and you have all the items:
itemdata = load_data('Data/Items.rxdata')
wpndata = load_data('Data/Weapons.rxdata')
armordata = load_data('Data/Armors.rxdata')
(1..itemdata.size).each {|id| $game_party.gain_item(id, 99)}
(1..wpndata.size).each {|id| $game_party.gain_weapon(id, 99)}
(1..armordata.size).each {|id| $game_party.gain_armor(id, 99)}
$game_party.gain_gold(999999999)
The last line makes you VERY rich, you can remove it if you want.
Shop Everything
Same as above, for shops. Paste this anywhere above 'Main' and below 'Window_ShopBuy'. You need to set the SHOP_EVERYTHING_ID to the ID an item you make in the database. When you call a shop with that item, it'll call a shop with ALL items, weapons and armors (no exceptions).
class Window_ShopBuy
SHOP_EVERYTHING_ID = 1
alias fant_shop_everything_win_shop_buy_init initialize
def initialize(shop_goods)
if shop_goods[0][0] == 0 && shop_goods[0][1] == SHOP_EVERYTHING_ID
goods = []
# Items
(1..$data_items.size).each {|i| goods.push([0, i])}
# Weapons
(1..$data_weapons.size).each {|i| goods.push([1, i])}
# Armors
(1..$data_armors.size).each {|i| goods.push([2, i])}
end
fant_shop_everything_win_shop_buy_init(goods)
end
end
love that code
$game_player.x # The player's X coordinate
$game_player.y # The player's Y coordinate
it can be used for when passing through an area to trigger an autorun instead of lot's of player touches. Oh btw Fantasist would it possible for some code to say after 10 steps after some event you can make another event
yea acually u dont need a script for that one :P
wait a min ill show you :P
okay 2 things..
1 why do i have -1 energy :( :( :( :(
and 2:
hear u go nortos!
Even one place on map
<>Message: After 10 steps after this event there will be another
: : event :)
<>Switch: [0001: Event-up] = ON
<>
Common event:
NAME: event Trigger: Parallell Process Trigget switch: 0001: Event-up
<>Variable: [0001: steps] = Steps
<>Conditional Branch Variable [0001: steps == 10
<>Message: see? 10 steps after! :) no scripts
: :
: : -Sally
<>
: End
<>
oh ty must of overlooked variables...
@Susy, i think someone defame/powerdown/minus your energy.
you've got to ask who did that, and why.
Its just my opinion, it might be wrong. :-\
that's only way I could think of she could get it unless a bug, oh and maybe put if want to continue this convo in feedback board, don't want to get too offtopic
oh yeah, sorry bout that.
why will anyone defame me :'( :'(
Your doing a great job Fantasist!
ty Calintz :)
@Susys:
Quotewhy do i have -1 energy
I have the same problem at RMRevolution. Dunno what the problem is. I'll give you energy if it helps :)
Hey, I was wondering if someone can help me out with the player and event potition event. If its possible can someone explain to me how it works? So like how I can use it for other things like mini-maps and that dog thing. Im still n00b to this so help would be appretiated. ;D
Quote from: Justin on February 12, 2008, 10:56:31 pm
Hey, I was wondering if someone can help me out with the player and event potition event. If its possible can someone explain to me how it works? So like how I can use it for other things like mini-maps and that dog thing. Im still n00b to this so help would be appretiated. ;D
^
|
| My bad, thats me ;D. Didnt realize I wasnt logged in. :-\
basically the best use I've found for it is a conditional branch where the condition is them being more than say 1x and less than 5 x which would mean they are 1-5 tiles away from the event and I aint that sure about the mini map part but that's basic of it
Oh. lol :P Not really sure what you meant exactly, but I guess I'll just fool around with it for a couple hours.
check my stealth event system uses it in there
Alright, thanks! ;D
These are useful, thanks for sharing!
QuoteRange - distance between two points
that could help me in makeing arrows in my event ABS mini game :) and spells
I said long back that i'll explain the function 'hypot', sigh, I've lost touch... maybe another time...
EDIT: Added "Get All Items".
PS: Do anyone even find this useful?
EDIT 2:
Added Shop Everything code.
Quote from: Fantasist on February 20, 2008, 08:51:32 am
EDIT: Added "Get All Items".
PS: Do anyone even find this useful?
Until just now I had no idea it existed, however I find it EXTREMELY useful... I've been puzzling over player and event coords for days now... and the hypot function is awesome!
is there any way to check a player/event's direction (well, rather, could you list it here?) ((I know there's a way, I just don't know what it is...))
EDIT: Powered up for this glittering gem of knowledge, and I'm surprised it hasn't attained stickitude yet....
Quote from: Satoh on October 21, 2008, 11:22:30 pm
is there any way to check a player/event's direction (well, rather, could you list it here?) ((I know there's a way, I just don't know what it is...))
Control Variables > Character > (Choose what character) > Direction - 3rd in the dropdown.
Remember that
2 - Down
4 - Left
6 - Right
8 - Up
:)
Is there a code equivalent to that as well?
I want to be able to test if both the direction and the distance of the player relative to the event is a certain value and only execute the action if both are true.
One could say a event-sight pattern... I'm sure I could dig through the stealth demo and try to find the relevant information in there... but decompiling the events is actually more confusing than pure script... to me...
I'm not using my laptop now, but hang on, I have just the thing. Wait, I posted this somewhere in the scripts section. I'll look it up...
EDIT: I dug it in my laptop, but I realized it only returns where the first event is. I'll have to tweak the code. Could you wait for one day max? I'm working on it.
These tips are really neat! :)
*puts in bookmarks*
<3
I know I'm necroposting, but I could really do with some help, and I dont really want to start a new topic.
(I'm not hurting anyone!)
Anyway, I have this
if $game_player.x = $game_map.events[14].x
and this
if $game_player.y = $game_map.events[14].y
inside conditional branches, but it's not co-operating...
What am I doing wrong?!?
to compare two objects as equal use the == operator = justs sets values
Haha! :haha: :haha:
thankyou so much!
I knew I wasn't doing something right!
And it also works with variables!
$game_variables[#] == $game_map.events[#].x
Brilliant!
Thanks again! :haha:
Hey, umm, could someone tell me something else real quick?
How do could I make it for THIS map events x and y co-ordinates, instead of having to change the id number for every event?
thanks! :P
Hurray for triple posts! :^_^':
Just thought 'd stop and say I'm a little surprised I'm the first one to relise this, because I'm the biggest n00b at scripting, but here, have this
$game_map.events[@event_id].x
$game_map.events[@event_id].y
Oh yes, that is the event scripty command for THIS events x and y co-ordinates :haha: