Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

[Scripting] Single Event Not All Events

Status
Not open for further replies.

LTN Games

Master Mind
Resource Team
Xy$
0.01
Okay, so I'm trying to make this plugin that allows you to set a Visibility Range for an event and whatever that range is the event's opacity will change. So the closer you get the better you see it, the further away from the event the less you see it.
I have all I the foundation ready to go all should work fine but I have an issue and I think it may be the class I'm working under. So I'm using Game_Event to do all my work but I've come to notice that the opacity changes for all events instead of a single event. My first guess here is that Game_Event is for all events, so one of my questions is what class is for a single event? If I remember correctly it's Game_CharacterBase. So I guess my question is how do I change the opacity of a single event and not all events.
 

Boy Who Codes

Praised Adventurer
Xy$
0.00
Game_Event class handles all events. You have to specify the Game_Event's id or name for you to specifically work on that particular event. It would be better if you also do use comments, and read the comment of that event via a comment tag reader reg exp.
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
I ended up getting it working for a single event, I just call my Game_Event.updateOpacity method inside Game_Event.prototype.updateSelfMovement.
It would be better if you also do use comments, and read the comment of that event via a comment tag reader reg exp.
This is something I considered, my original idea was to have it similar to Yanfly's event chase player, where you go inside the move route and do a script call to set the range variable, this is how I'm currently doing it. I'm not 100% sure how to the comment for regexp, though I will give it a try, maybe this is something you should do for you video tutorials :D
I know this, but have gone to bed already, will paste the object that controls the opacity tomorrow
I won't close this topic yet as I would like to see what object you are speaking of, it may still be helpful for me.
 

eivl

Local Hero
Xy$
0.00
Event is a prototype of Game_Character that is a prototype of Game_CharacterBase

Game_CharacterBase inherits a method called setOpacity
Game_CharacterBase.prototype.setOpacity

this is the method you call when you run your own Game_Event.updateOpacity.

information on the events are stored in the object $gameMap


the first event is here : $gameMap._events[1]
and the opacity setting is here : $gameMap._events[1]._opacity

remember what i have said and written, you do not change anything with an underscore in it. the only thing that would change is that the value stored would change, but nothing would be updated. for that you need to use the updateOpacity method on the event.

I am creating a wiki with a more structured way to link code, i could then just link you to the Game_CharacterBase.prototype.setOpacity method for easy reading ;)
But i am failing on the wiki part, need to read the documentation for it so i can get it working ;)
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
This method works as well, awesome. I never tested thoroughly yet I will do this once I'm done figuring out this simple HUD plugin I want to make. This is my method which updates opacity, it now reflects the method you described above and it works well so far.

JavaScript:
Game_Event.prototype.updateEventOpacity = function() {
  if(this._visibleRange === 0){
    this._orginOpacity = this._opacity;
  } else {
    this.setOpacity( this._orginOpacity - 50  *(this.distanceFromPlayer() - this._visibleRange));
  }
};
Here is a little video I made to show you the progress with both of my plugins lol Anyways thanks for sharing that method, it's quite simple to use.
 
Status
Not open for further replies.
Top