Comunidad Game Maker

Ayuda => Preguntas y respuestas => Mensaje iniciado por: yokaiworld en Mayo 30, 2014, 04:38:05 AM

Título: que este script se ejecute automaticamente
Publicado por: yokaiworld en Mayo 30, 2014, 04:38:05 AM
hola este script que pongo aqui sirve que para cuando se presione un boton se ejecute el ataque para player 1 y tambien para player2. Yo lo que necesito es que el player 2 se ejecute automaticamente y aleatoriamente hasta que el round termine pero por mi falta de conocimiento no he podido lograrlo
en step:

if object_index == obj_player1{
scr_drawattack(ord('A'), stand, jab,   jab_box,   5, 'normal')
scr_drawattack(ord('S'), stand, cross, cross_box, 7, 'normal')
scr_drawattack(ord('Z'), stand, low,   low_box,   5, 'normal')
scr_drawattack(ord('X'), stand, high,  high_box,  6, 'juggle')}
else{
scr_drawattack(ord('G'), stand, jab,   jab_box,   5, 'normal')
scr_drawattack(ord('Y'), stand, cross, cross_box, 7, 'normal')
scr_drawattack(ord('H'), stand, low,   low_box,   5, 'normal')
scr_drawattack(ord('U'), stand, high,  high_box,  6, 'juggle')

como pueden ver este script llama otro script al precionar un boton, ¿como puedo hacer creer al game maker que el boton fue precionado virtualmente para que desencadene la accion?


este es el otro script que llama
var key, spr_base, spr_atk, spr_atk_hitbox, damage, type;
key = argument0
spr_base = argument1
spr_atk = argument2
spr_atk_hitbox = argument3
damage = argument4
type = argument5



//this code looks to see if attack animation has completed
//if so, return back to base sprite       
if sprite_index == spr_atk//if currently attacking
    {if image_index == image_number - 1//check if animation finished
        {
        sprite_index = spr_base;
         action = false}
    }//if animation finished return to base

   
if scr_preventattack(){exit}

if keyboard_check_pressed(key)
    {var atkbox;
    atkbox = instance_create(x,y, obj_attackbox)
    atkbox.owner = self.id
    atkbox.sprite_index = spr_atk_hitbox
    atkbox.image_index = 0
    atkbox.damage = damage
    atkbox.type = type
    }
   

//if currently not attacking, and a key has been pressed
//change sprite to attack sprite
if keyboard_check_pressed(key)
    {if sprite_index != spr_atk
        {image_index = 0;
        sprite_index = spr_atk;
        action = true}
    }
   
gracias por su colaboracion
Título: Re:que este script se ejecute automaticamente
Publicado por: 3dgeminis en Mayo 30, 2014, 11:47:09 PM
La pregunta es cuando queres que se ejecute el script. Tenes que ver que condicion se cumple para que se ejecute el script; queres que se ejecute cuando es atacado, cuando salta, despues de cierto ataque ???
Si el otro jugador me ataca por arriba me cubro arriba, si es por abajo me cubro abajo, si esta lejos me acerco, etc..........