DOLARMAK'S PROFILE

Search

[RMMV] event location/check around event

EDIT: a friend on another forum solved my problem. I was using thje wrong syntax on the event command.
$gameMap._events._x;
is the correct code if any one ever needs it. I also edited it in the code below.

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().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 = $gameMap._events[this._eventId]._x;
var sc_event_y = $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);
}

}

}
Pages: 1