Tower that shoot player

I need your help on this one. I see a lot of way for doing it.
First I didt want parallele process. But I got a common event called each time player move. So code can go there.

I look for the most speed optimized solution.

Basicly what its need to do. If player pass in the same row or columb then the monster, the monster shoot a projectile to him and player die.

Player can be protected by objet on map.

Current way I start it:
I use HimeCustumPageCondition.
So I was thinking to make the page B of the event react if the player was on the same row or columb then player.
I will need the best code for check that.
Then the code start and probably with a select case check witch side...
But now I need to evaluate if ennemie can shoot the player.

The monster can shoot trought some ennemie but not trough some other... So i need a way to calculate that.

I can tell that he cant shoot trought any moving objet of the game.
For none moving objet, its depend.
Maybe I can add tag to note for tell that, I think its the best way.
other option will be using frequence or thing like this... but ugly...

Now he will check each case for try to find an event with the block tag...
if didt find, then shoot player..

I got no idea or to do a nice anymation for that, rpg maker was really limited on that.

Thanks for your recommandation, and dont forgot that I look for the most optimized and faster wy as possible for that



thanks for your help.
What I'm picturing for projectiles is an endless supply of cloned events as ammo. I've got all the rotation geometry in mind for a 360° fireball or something, but I'm having trouble spawning a new event.

This is what I got so far. I'm going to leave it on here so I don't lose it. I'm kinda sleepy right now.

PHP:
var shootMissile = function(event1, selfSwitch){
   var id = event1._eventId;
   var newId = $dataMap.events.length;
   var newEvent = JSON.parse(JSON.stringify($gameMap._events[id]));
   var newData = JSON.parse(JSON.stringify($dataMap.events[id]));
   newEvent._eventId = newId;
   newData.id = newId;
   newData.x += 1;
   newData.y += 1;
   newEvent._x += 1;
   newEvent._y += 1;
   newEvent._realX = newEvent._x;
   newEvent._realY = newEvent._x;
   $dataMap.events[newId] = newData;
   $gameMap._events[newId] = new Game_Event(event1._mapId, newId);
   var key = [event1._mapId, newId, selfSwitch];
   $gameSelfSwitches.setValue(key, true);
   // this needs about 10-15 more lines after it...
};
I've been calling it like...
PHP:
shootMissile(this, "A"); // where self switch A has a fire ball character page
But it's not working... The cloned event is there. I can touch it and talk to it and it has its own _eventId, but it's invisible for some reason.
Did you create an instance of Sprite_Character for it and add it to the map spriteset?
to be exact, tower will not shoot until player was reachable. If reachable, its an instant kill, player cant avoid it you can do laser animation, that will be fine too. thanks so much for helping me because this one give me head cache.

Each shooting tower have page 4 activated if player was in same row or columb with a pluggin that check that. So jsut need the code that go inside event. But I want to do it without an even that move on the map, maybe a animation made by sprite manipulation. Bot for now the most important was not the animation but how its work.
@Trihan You know. For some reason I always thought the sprite bitmap thing was somewhere in $gameMap or something. I learned it's in SceneManager.
PHP:
// shootMissile(this, "A", $gamePlayer, 3);
// call by event script like this ^
shootMissile = function(event1, selfSwitch, event2, speed){
   var id = event1._eventId;
   var newId = $dataMap.events.length + 1;
   delete event1._character;
   var newEvent = JSON.parse(JSON.stringify($gameMap._events[id]));
   var newData = JSON.parse(JSON.stringify($dataMap.events[id]));
   newEvent._eventId = newId;
   newData.id = newId;
   $dataMap.events[newId] = newData;
   $gameMap._events[newId] = new Game_Event(event1._mapId, newId);
   var key = [event1._mapId, newId, selfSwitch];
   $gameSelfSwitches.setValue(key, true);
   var chr = SceneManager._scene._spriteset._characterSprites.length;
   SceneManager._scene._spriteset._characterSprites[chr] =
       new Sprite_Character($gameMap._events[newId]);
   var projectile = SceneManager._scene._spriteset._characterSprites[chr];
   SceneManager._scene._spriteset._tilemap.addChild(projectile);
   if(Array.isArray(event2)){
       var px = event2[0];
       var py = event2[1];
   }else{
       var px = event2._x;
       var py = event2._y;
   }
   var ex = $gameMap._events[newId]._x;
   var ey = $gameMap._events[newId]._y + 1;
  
   var angle = Math.atan2((py - ey),(px - ex));
   $gameMap._events[newId]._isProjectile = true;
   $gameMap._events[newId]._projectileAngle = angle;
   $gameMap._events[newId]._projectileSprite = projectile;
   $gameMap._events[newId]._xSpeed = Math.cos(angle) * speed * 0.08;
   $gameMap._events[newId]._ySpeed = Math.sin(angle) * speed * 0.08;
};
Game_Map.prototype.updateOld = Game_Map.prototype.update;
Game_Map.prototype.update = function(sceneActive) {
    this.updateOld.call(this,arguments);
    for(var i = 0; i < $gameMap._events.length; i++){
       if($gameMap._events[i] === null || $gameMap._events[i] === undefined)
           continue;
       var ev = $gameMap._events[i];
       if(ev._isProjectile === undefined)
           ev._isProjectile = false;
       if(ev._isProjectile){
           ev._realX += ev._xSpeed;
           ev._realY += ev._ySpeed;
           if(ev._realX - 1 < $gamePlayer._realX
           && ev._realX + 1 > $gamePlayer._realX
           && ev._realY - 1 < $gamePlayer._realY
           && ev._realY + 1 > $gamePlayer._realY){
               ev._opacity = 0;
               ev.start();
           }
       }
    }
};

The old man has a page with a fireball character game switch A.
The fireball page has a collide with player thing so that's where you can put your damage.

fireballs-o.gif


I couldn't for the life of me figure out how to rotate the fireball. It seem to ignore _context.rotate for some reason.
I have a plugin that might be of interest to do things like this:
https://galvs-scripts.com/2016/09/13/mv-map-projectiles/
Im getting an error
Spoiler
upload_2017-5-30_9-49-2.png

upload_2017-5-30_9-49-52.png
Eval at <anonymous>, looks like you put the plugin in event script. This is a plugin called by event script.
Code:
shootMissile(this, "A", $gamePlayer, 3);
can you explain with screen captures, im confused..
thanks for responding

Original thread: https://forums.rpgmakerweb.com/threads/tower-that-shoot-player.75560/