Problem mit Helfer

  • GM 8

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Problem mit Helfer

    Hey Leute!
    Ich hab ein kleines(oder großes :huh: ) Problem...

    Und zwar hab ich in meinem Game einen Helfer, der selbstständig zu Gegnern hinläuft und sie mit seinem Schwert killt
    Nur stimmt irgendwas mit den Codes nicht und hab den Überblick verloren
    Der Helfer soll nur zum Gegner hinlaufen und ihn mit den Schwert schlagen, aber er lässt die schlagen Animation schon am Anfang wenn das spiel beginnt abspielen obwohl kein gegner in der nähe ist
    und er hört nicht auf zu schlagen.

    Hier die Codes:

    Create Event

    GML-Quellcode

    1. followlink = 0
    2. followenemy = 0
    3. phcpurun = 0
    4. attack = 0


    Alarm 1 Event

    GML-Quellcode

    1. attack = 0


    Step Event

    GML-Quellcode

    1. if distance_to_object(obj_link)>16 && attack = 0 {followlink = 1}
    2. if followlink = 1 && attack = 0 {move_towards_point(obj_link.x,obj_link.y,2.5);phcpurun = 1}
    3. if distance_to_object(obj_link)<16 && followlink = 1 && attack = 0 {followlink = 0;phcpurun = 0}
    4. if phcpurun = 0 {speed = 0}
    5. if direction <45 && phcpurun = 0 {sprite_index = spr_phantom_stay_right}
    6. if direction >315 && phcpurun = 0 {sprite_index = spr_phantom_stay_right}
    7. if direction <45 && phcpurun = 1 && followlink = 1 or followenemy = 1{sprite_index = spr_phantom_run_right; image_speed = 0.7}
    8. if direction >315 && phcpurun = 1 && followlink = 1 or followenemy = 1{sprite_index = spr_phantom_run_right; image_speed = 0.7}
    9. if direction <135 && direction >45 && phcpurun = 0 {sprite_index = spr_phantom_stay_up}
    10. if direction <135 && direction >45 && phcpurun = 1 && followlink = 1 or followenemy = 1 {sprite_index = spr_phantom_run_up; image_speed = 0.7}
    11. if direction <225 && direction >135 && phcpurun = 0 {sprite_index = spr_phantom_stay_left}
    12. if direction <225 && direction >135 && phcpurun = 1 && followlink = 1 or followenemy = 1{sprite_index = spr_phantom_run_left; image_speed = 0.7}
    13. if direction <315 && direction >225 && phcpurun = 0 {sprite_index = spr_phantom_stay_down}
    14. if direction <315 && direction >225 && phcpurun = 1 && followlink = 1 or followenemy = 1{sprite_index = spr_phantom_run_down; image_speed = 0.7}
    15. if instance_nearest(x,y,obj_enemy_basic) && distance_to_object(obj_enemy_basic)<80 {followenemy = 1}
    16. if followenemy = 1 {move_towards_point(obj_enemy_basic.x,obj_enemy_basic.y,3) followlink = 0}
    17. if distance_to_object(obj_enemy_basic)<5
    18. {attack = 1;followenemy = 0;motion_set(360,0)}
    19. if attack = 1 && sprite_index = spr_phantom_stay_down or spr_phantom_run_down
    20. {instance_create(x,y,obj_ph_sword_down);sprite_index = spr_phantom_slash_down; alarm[1]=15}
    21. else
    22. if attack = 1 && sprite_index = spr_phantom_stay_right or spr_phantom_run_right
    23. {instance_create(x,y,obj_ph_sword_right);sprite_index = spr_phantom_slash_right; alarm[1]=15}
    24. else
    25. if attack = 1 && sprite_index = spr_phantom_stay_left or spr_phantom_run_left
    26. {instance_create(x,y,obj_ph_sword_left);sprite_index = spr_phantom_slash_left; alarm[1]=15}
    27. else
    28. if attack = 1 && sprite_index = spr_phantom_stay_up or spr_phantom_run_up
    29. {instance_create(x,y,obj_ph_sword_up);sprite_index = spr_phantom_slash_up; alarm[1]=15}
    Alles anzeigen


    Hoffe jemand kann mir helfen.