[Solved] Enemy only attacking one player?

Viper Snake

Member
I have an enemy that acts as a one way door, it "opens" when the player gets within the door's attack range on the left only. However, it only seems to attack one player and never the other, so the player the door does not respond too can become unable to proceed.

[attachment deleted by admin]
 
The script gave me the same result. Maybe I'm overlooking something? The door does attack the other player if the player it was first attacking dies.

Code:
name    	door1wayL
nomove  	1 1
facing 1
type            enemy
cantgrab 	1
nodrop  	2
falldie 	1
nodieblink 	2
nodrop  	2
setlayer        10
offscreenkill	9999
aggression 9999
offscreen_noatk_factor 1
palette data/chars/objects/door/0.gif

anim	attack
	range	-30 0
	delay	2
	sound	data/sounds/door.wav
	offset	8 128
	frame	data/chars/objects/door/0.gif
	offset	6 126
	frame	data/chars/objects/door/5.gif
	offset	10 126
	frame	data/chars/objects/door/6.gif
	offset	14 126
	frame	data/chars/objects/door/7.gif
	offset	18 126
	frame	data/chars/objects/door/8.gif
	delay	3
	offset	22 126
	frame	data/chars/objects/door/9.gif
	offset	26 126
	frame	data/chars/objects/door/10.gif
	offset	30 126
	frame	data/chars/objects/door/11.gif
	delay	4
	offset	34 126
	frame	data/chars/objects/door/12.gif
	offset	38 126
	frame	data/chars/objects/door/13.gif
	offset	42 126
	frame	data/chars/objects/door/14.gif
	offset	44 126
	frame	data/chars/objects/door/15.gif
	offset	48 126
	frame	data/chars/objects/door/16.gif
	offset	52 126
	frame	data/chars/objects/door/17.gif
	offset	54 126
	frame	data/chars/objects/door/18.gif
	offset	58 126
	frame	data/chars/objects/door/19.gif
	offset	60 126
	frame	data/chars/objects/door/20.gif
	offset	62 126
	frame	data/chars/objects/door/21.gif
	offset	60 126
	frame	data/chars/objects/door/22.gif
	delay	200
	offset	60 126
	frame	data/chars/objects/door/23.gif
	delay	2
	offset	60 126
	frame	data/chars/objects/door/22.gif
	frame	data/chars/objects/door/21.gif
	frame	data/chars/objects/door/20.gif
	offset	58 126
	frame	data/chars/objects/door/19.gif
	offset	54 126
	frame	data/chars/objects/door/18.gif
	offset	52 126
	frame	data/chars/objects/door/17.gif
	offset	48 126
	frame	data/chars/objects/door/16.gif
	offset	44 126
	frame	data/chars/objects/door/15.gif
	offset	42 126
	frame	data/chars/objects/door/14.gif
	offset	38 126
	frame	data/chars/objects/door/13.gif
	offset	34 126
	frame	data/chars/objects/door/12.gif
	offset	30 126
	frame	data/chars/objects/door/11.gif
	offset	26 126
	frame	data/chars/objects/door/10.gif
	offset	22 126
	frame	data/chars/objects/door/9.gif
	offset	18 126
	frame	data/chars/objects/door/8.gif
	offset	14 126
	frame	data/chars/objects/door/7.gif
	offset	10 126
	frame	data/chars/objects/door/6.gif
	offset	6 126
	frame	data/chars/objects/door/5.gif
	attack6	0 0 12 128 999 0 1 0 0 0
	sound	data/sounds/doorshut.wav
	offset	8 128
	frame	data/chars/objects/door/0.gif	
		
anim	death
	loop	0
	delay	1
	offset	1 1
	frame	data/chars/marianne/blank.png
		
anim	idle
	loop	1
	delay	5
	platform	-12 -12 20 20 10 140
	offset	8 128
	frame	data/chars/objects/door/0.gif
	frame	data/chars/objects/door/1.gif
	frame	data/chars/objects/door/2.gif
	frame	data/chars/objects/door/3.gif
	frame	data/chars/objects/door/4.gif
		
anim	spawn
	loop	0
	delay	5
	platform	-12 -12 20 20 10 140
	offset	8 128
	frame	data/chars/objects/door/0.gif
	frame	data/chars/objects/door/1.gif
	frame	data/chars/objects/door/2.gif
	frame	data/chars/objects/door/3.gif
	frame	data/chars/objects/door/4.gif
 
Your door has FACING 1 so it's not facing the player ;) it should be facing 2

facing {int}

    ~ This is for forcing the entity to face certain direction regardless where he/she is going.
        0 = no force (default).
        1 = force the entity to face right.
        2 = force the entity to face left.
        3 = force the entity to face same direction with level's direction.
    ~ Setting this allows players to play BACKWALK.


Thou try changing ATTACK animation to IDLE2 instead.  It should be more simple and work better this way.  IDLE2 triggers when enemies are in range, or for enemies when player is in range.  Make sure to increase the max idles in models.txt.

IDLE# (used by all entities)

    ~Played if there's opponent within set 'range' while in IDLE.
    ~# is the number of animation. Do not type # but type a number instead.
    ~For instance, IDLE2 has 'range 0 100'. Entity will play default IDLE when enemy is farther than 100 pixels but once an enemy is within 100 pixels, IDLE2 will be played instead.
    ~If there are multiple IDLE# animations, the one with lowest number has the highest priority.
    ~Before using this, increase the maximum number of IDLE with 'maxidles' in models.txt (see Models.txt above).
    ~These animation ARE NOT related to PAIN#, FALL# or DEATH# at all!



 
I couldn't get idle2 to play at all. Range must have some sort of issue with negative numbers. I deleted the facing parameter altogether and changed the range from -30 0 to 0 30 and it works for both players now. I'll have to create some reversed sprites for the door animation but I'm just glad it works now. Thank you BeasTie!
 
Np glad you sorted it. :)

Another trick for doors is a switch that the player can attack that opens the doors.  The door and switch are one just made as one sprite.
 
Back
Top Bottom