Okay, i've started working on this plugin that will check around the event that activates it for a specific event name. I'm using this for a scarecrow event that when the day starts the filed/plant events evaluate if the scare crow is around them and if not there is a chance the plant get destroyed.
now the problem i have is with the script getting the events location. When checking a specific coordinate, the script works fine, but when if asks for the events location I get crazy errors. I was told a line $gameMap.events()[this._eventId].x; should get the x coord for the event, but it doesn't seem to. same code switch x for y to get the Y coord.
anyway, here is what I have so far. On lines 25 and 26 i set static numbers and commented out the dynamic xy. if any one knows whats wrong let me know.
/*:
* @author Dolarmak
* @plugindesc Checks if a scarecrow event is within 3 tiles of the event
*
* @help
* =============================================================================
* What does it do?
* =============================================================================
*
* Checks if a scarecrow event is within 3 tiles of the event
*
* =============================================================================
*/
var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args)
{
aliasPluginCommand.call(this, command, args);
if(command == "scarecrow")
{
//----- Check if Scarecrow Event is in range -----//
//$gameMessage.add("checking");
var sc_event_x = 4; //$gameMap.events()[this._eventId].x;
var sc_event_y = 4; //$gameMap.events()[this._eventId].y;
var sc_event_true = false;
for(var sc_event_y_check = (sc_event_y - 3); sc_event_y_check < (sc_event_y + 4); sc_event_y_check = (sc_event_y_check + 1))
{
for(var sc_event_x_check = (sc_event_x - 3); sc_event_x_check < (sc_event_x + 4); sc_event_x_check = (sc_event_x_check + 1))
{
if ($gameMap.isXyHasEventName(/scarecrow/i,sc_event_x_check,sc_event_y_check) == 1)
{
var sc_event_true = true;
}
}
}
//----- End Result ----//
if (sc_event_true == true)
{
//----Scarecrow is in Range ----//
//$gameMessage.add("Scarecrow detected");
$gameSelfSwitches.setValue([this._mapId, this._eventId, 'A'], false);
$gameSelfSwitches.setValue([this._mapId, this._eventId, 'B'], true);
}
else
{
//----Scarecrow is not in Range ----//
//$gameMessage.add("No scarecrow detected");
$gameSelfSwitches.setValue([this._mapId, this._eventId, 'A'], true);
$gameSelfSwitches.setValue([this._mapId, this._eventId, 'B'], false);
}
}
}
Okay, i've started working on this plugin that will check around the event that activates it for a specific event name. I'm using this for a scarecrow event that when the day starts the filed/plant events evaluate if the scare crow is around them and if not there is a chance the plant get destroyed.
now the problem i have is with the script getting the events location. When checking a specific coordinate, the script works fine, but when if asks for the events location I get crazy errors. I was told a line $gameMap.events()[this._eventId].x; should get the x coord for the event, but it doesn't seem to. same code switch x for y to get the Y coord.
anyway, here is what I have so far. On lines 25 and 26 i set static numbers and commented out the dynamic xy. if any one knows whats wrong let me know.
/*: * @author Dolarmak * @plugindesc Checks if a scarecrow event is within 3 tiles of the event * * @help * ============================================================================= * What does it do? * ============================================================================= * * Checks if a scarecrow event is within 3 tiles of the event * * ============================================================================= */ var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function(command, args) { aliasPluginCommand.call(this, command, args); if(command == "scarecrow") { //----- Check if Scarecrow Event is in range -----// //$gameMessage.add("checking"); var sc_event_x = 4; //$gameMap.events()[this._eventId].x; var sc_event_y = 4; //$gameMap.events()[this._eventId].y; var sc_event_true = false; for(var sc_event_y_check = (sc_event_y - 3); sc_event_y_check < (sc_event_y + 4); sc_event_y_check = (sc_event_y_check + 1)) { for(var sc_event_x_check = (sc_event_x - 3); sc_event_x_check < (sc_event_x + 4); sc_event_x_check = (sc_event_x_check + 1)) { if ($gameMap.isXyHasEventName(/scarecrow/i,sc_event_x_check,sc_event_y_check) == 1) { var sc_event_true = true; } } } //----- End Result ----// if (sc_event_true == true) { //----Scarecrow is in Range ----// //$gameMessage.add("Scarecrow detected"); $gameSelfSwitches.setValue([this._mapId, this._eventId, 'A'], false); $gameSelfSwitches.setValue([this._mapId, this._eventId, 'B'], true); } else { //----Scarecrow is not in Range ----// //$gameMessage.add("No scarecrow detected"); $gameSelfSwitches.setValue([this._mapId, this._eventId, 'A'], true); $gameSelfSwitches.setValue([this._mapId, this._eventId, 'B'], false); } } }Share this post
Link to post
Share on other sites