GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2015-05-30 10:49:32

phinto
Member
Registered: 2015-05-30
Posts: 7

RPG enemy

I need allot of help.
I need a easy code for the turn based enemy, or bullet, shoot at any of my players.

read this information below

ExpandInformation about object: enemy
Sprite: spr_enemy
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: 
Children: 
Mask: 

No Physics Object
Create Event:

set variable HP to 10
set variable atk to 1
set variable def to 1
set variable spd to 1
set variable pwr to random(50)
set Alarm 0 to 5
set the sprite to spr_enemy with subimage random(13) and speed 0
Alarm Event for alarm 0:

set variable pwr relative to spd
set Alarm 0 to 5
Step Event:

      if HP is less than or equal to 0
            destroy the instance
                  create a medium effect of type ellipse relative at (16,16) of  color 0 below objects
else
      if pwr is greater than or equal to 55
            set variable pwr to 0
                  create instance of object bullet at relative position (0,0)
Draw Event:

Draw the instance
set the font for drawing text to font0 and align left
at relative position (0,-18) draw the value of: HP
at relative position (-18,0) draw the value of: pwr


I just need a code for those white bullets behind those enemy's on a right.

mangle.png

i can't just make the bullets move towerds player.x player.y, tried...

Offline

#2 2015-05-30 12:53:16

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: RPG enemy

Possible solution 1:

In the Create Event of the bullet, use a Move Towards Action with x, y, speed set to player.x, player.y, 10.

However, if you want the bullets to target different instances, a script might work better.

Possible solution 2:

Create a script called "shoot_at_instance":

Expand/// shoot_at_instance(id)
with (instance_create(x, y, bullet))
{
    direction = point_direction(x, y, argument0.x, argument0.y);
}

Replace: "create instance of object bullet at relative position (0,0)"
With: "execute script shoot_at_instance with arguments (player.id,0,0,0,0)".

My computer died two weeks ago and I cannot use GameMaker: Studio right now.


Abusing forum power since 1986.

Offline

#3 2015-05-30 13:19:34

phinto
Member
Registered: 2015-05-30
Posts: 7

Re: RPG enemy

in object enemy, in  event stepnormalevent action number 11 at line 13 : function "shoot_at_instance_id" expects 1 arguments, 5 provided

complete fail...

whats wrong?

Offline

#4 2015-05-30 13:43:53

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: RPG enemy

That's my fault. I was giving you the answer expecting you to use the Execute Script Action. If you are calling from GML code, only use one argument, player.id.

Expandshoot_at_instance_id(player.id);

Abusing forum power since 1986.

Offline

#5 2015-05-30 13:51:34

phinto
Member
Registered: 2015-05-30
Posts: 7

Re: RPG enemy

so whare should I put it?


i put
set variable pwr to 0
                  execute code:

shoot_at_instance_id(player.id);

on enemy

and with a move towreds, there still shooting a same middle guy...

Last edited by phinto (2015-05-30 13:58:39)

Offline

#6 2015-05-30 13:55:20

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: RPG enemy

I don't know. Wherever you put it before.

event stepnormalevent action number 11 at line 13


Abusing forum power since 1986.

Offline

#7 2015-05-30 14:03:02

phinto
Member
Registered: 2015-05-30
Posts: 7

Re: RPG enemy

we need more users to help us...

and i did put it here sad

Offline

#8 2015-05-30 14:17:23

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: RPG enemy

If you want more users, post a question at The GMC. That's a better place for beginners to get help. This forum is for advanced scripting problems and has very few visitors.


Abusing forum power since 1986.

Offline

#9 2015-05-30 14:20:15

phinto
Member
Registered: 2015-05-30
Posts: 7

Re: RPG enemy

xot wrote:

If you want more users, post a question at The GMC. That's a better place for beginners to get help. This forum is for advanced scripting problems and has very few visitors.

didn't mean to rain on your parade but...

I came from GMC... some friend asked me to go here on this site...

Offline

#10 2015-05-30 14:44:12

phinto
Member
Registered: 2015-05-30
Posts: 7

Re: RPG enemy

also I was using GM studio standard edition...

Offline

#11 2015-05-30 15:15:54

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: RPG enemy

Well, I hate to rain on your parade but you need to go back to your topics and listen to what HandsomeGuy and s0lt4r telling you. You are not providing enough information to get the help you need. You need to put more effort into explaining your problem clearly with details about what you have done, what it does now, and what you want it to do instead.

This is a very basic problem. I think that's why it is hard to help you. It's not easy to know just how much help you need.

Please stop sending me email messages. I do not have time for this. There are people already trying to help you.


Abusing forum power since 1986.

Offline

Board footer

Powered by FluxBB