Solved Helicopter in the background

Question that is answered or resolved.

Crimsondeath

Active member
Hi again.
It's possible to stick an entity to the background and make it moves only in it? I need it for this helicopter enemy:

It's also posible that the helicopter balance a little, on the direction he is moving?

Here is the full Helicopter Code:
"Heli_Propeller" and "Heli_target" are separated entities:

Code:
name Helicopter_
health    500
mp 100
score   50000 5
nolife 1
speed 10
type    enemy
nomove 0 1
shadow 0
agression 50
paingrab 1
setlayer -6
jugglepoints 15
knockdowncount 15
offscreenkill 500
turndelay   12
nopain 1
aimove avoidz
aimove chasex
hostile player npc
candamage player npc obstacle
subject_to_wall 0
subject_to_platform 0
subject_to_hole 0
subject_to_gravity 0
noquake     1
stealth 6 10

load    Heli_propeller
load    Heli_target
load    Heli_shoot

hostile player npc

palette data/chars/helicopter/idle1a.gif

animationscript data/scripts/entities/helicopter/helicopter.c
onmovexscript data/scripts/entities/helicopter/helicopter_onmovex.c #<--- I tried to do the balace with onmovexscript but my script didn't work, down is the code.






anim    follow1
    loop    1    12 14
    offset    48 26
    delay    7
    seta    100
    @cmd    spawnbind2 "Heli_Propeller" 0 18 0 1
    frame    data/chars/helicopter/idle1a.gif
    offset    57 26
    frame    data/chars/helicopter/turn1a.gif
    frame    data/chars/helicopter/turn1b.gif
    frame    data/chars/helicopter/turn1c.gif
    frame    data/chars/helicopter/turn1d.gif
    frame    data/chars/helicopter/turn1e.gif
    frame    data/chars/helicopter/turn1f.gif
    frame    data/chars/helicopter/turn1g.gif
    frame    data/chars/helicopter/turn1h.gif
    @cmd    dasher 1 0 0 1
    offset    90 37
    frame    data/chars/helicopter/walk1a.gif
    frame    data/chars/helicopter/walk1b.gif
    frame    data/chars/helicopter/walk1c.gif
    frame    data/chars/helicopter/walk1c.gif
    frame    data/chars/helicopter/walk1c.gif
        
anim    freespecial
    loop    0
    offset    48 26
    delay    12
    seta    100
    range    0 0
    rangea    0 0
    rangez    0 0
    energycost    0
    mponly    1
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind "Heli_shoot" -20 -10 1
    @cmd    spawnbind "Heli_shoot" 20 -10 1
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind "Heli_shoot" -20 -10 1
    @cmd    spawnbind "Heli_shoot" 20 -10 1
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind "Heli_shoot" -20 -10 1
    @cmd    spawnbind "Heli_shoot" 20 -10 1
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind "Heli_shoot" -20 -10 1
    @cmd    spawnbind "Heli_shoot" 20 -10 1
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind "Heli_shoot" -20 -10 1
    @cmd    spawnbind "Heli_shoot" 20 -10 1
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind "Heli_shoot" -20 -10 1
    @cmd    spawnbind "Heli_shoot" 20 -10 1
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind "Heli_shoot" -20 -10 1
    @cmd    spawnbind "Heli_shoot" 20 -10 1
    frame    data/chars/helicopter/idle1a.gif
        
anim    idle
    loop    1
    offset    48 26
    delay    7
    seta    100
    frame    data/chars/helicopter/idle1a.gif
        
anim    spawn
    loop    0
    offset    48 26
    delay    1
    seta    100
    frame    data/chars/helicopter/idle1a.gif
    @cmd    spawnbind2 "Heli_Propeller" 0 18 0 1
    @cmd    spawner4 "Heli_target" 0 0 0 2
    frame    data/chars/helicopter/idle1a.gif
    frame    data/chars/helicopter/idle1a.gif
        
anim    walk
    loop    0
    offset    48 26
    delay    7
    seta    100
    frame    data/chars/helicopter/idle1a.gif
    frame    data/chars/helicopter/idle1a.gif

the onmovexscript code:
C++:
void main(){
    void self = getlocalvar("self");
    void propeller = getentityvar(self, 1);
    float velocity = getentityproperty(self, "xdir");

    if(velocity < 0){
      changeentityproperty(propeller, openborconstant("ANI_FOLLOW1"), 1);
    }

    if(velocity > 0){
        changeentityproperty(propeller, openborconstant("ANI_FOLLOW2"), 1);
    }
}

Thanks
 
Solution
Yeah, you can limit his Z position using script.
If I am not mistaken, I am using this code:
C-like:
void main()
{ // Limits z movement to certain z coords
    void self = getlocalvar("self");
    int z = getentityproperty(self,"z"); //Get character's z coordinate

    if(z != 200){ // Reached z limit
      changeentityproperty(self, "position", NULL(), 200);
      changeentityproperty(self, "velocity", NULL(), 0);
    }
}

About to make him to balance, you can add a walk and a backwalk animations, and use drawmethod rotate - So it will lean to the right when in the WALK animation and lean to the left in the BACKWALK animation.

This is how I did:
drawmethod rotate 2
drawmethod fliprotate 1
Yeah, you can limit his Z position using script.
If I am not mistaken, I am using this code:
C-like:
void main()
{ // Limits z movement to certain z coords
    void self = getlocalvar("self");
    int z = getentityproperty(self,"z"); //Get character's z coordinate

    if(z != 200){ // Reached z limit
      changeentityproperty(self, "position", NULL(), 200);
      changeentityproperty(self, "velocity", NULL(), 0);
    }
}

About to make him to balance, you can add a walk and a backwalk animations, and use drawmethod rotate - So it will lean to the right when in the WALK animation and lean to the left in the BACKWALK animation.

This is how I did:
drawmethod rotate 2
drawmethod fliprotate 1
 
Solution
Yeah, you can limit his Z position using script.
If I am not mistaken, I am using this code:
C-like:
void main()
{ // Limits z movement to certain z coords
    void self = getlocalvar("self");
    int z = getentityproperty(self,"z"); //Get character's z coordinate

    if(z != 200){ // Reached z limit
      changeentityproperty(self, "position", NULL(), 200);
      changeentityproperty(self, "velocity", NULL(), 0);
    }
}

About to make him to balance, you can add a walk and a backwalk animations, and use drawmethod rotate - So it will lean to the right when in the WALK animation and lean to the left in the BACKWALK animation.

This is how I did:
drawmethod rotate 2
drawmethod fliprotate 1
I used the code as "onmovezscript" instead of "onmovexscript" and works great :D .

Thanks again @O Ilusionista .
 
Back
Top Bottom