Trajectory Bounce against Walls and Z limits (Along with Ground Off Limits Too)

maxman

Well-known member
I'm having trouble with dropped rolling grenades after throwing them. That's because when they reach beyond the wall or the Z (min/max) boundary, they disappear invisibly (not killed off; though you can hear an exploding sound).

I tried using tosser and created my own random velocity animation script for moving randomly. But when I tried using tosser to throw grenades laterally against the walls or the boundaries, they never bounce off. Instead, (after landing on the ground) they disappear before making an exploding sound.

Code:
anim freespecial3
delay 6
offset 170 200
frame data/chars/boss03/tossg100.png
frame data/chars/boss03/tossg101.png
delay 15
@cmd tosser "gurenehdoA" 15 41 0 1.5 2 0
frame data/chars/boss03/tossg102.png
delay 6
frame data/chars/boss03/tossg101.png
delay 15
@cmd tosser "gurenehdoA" 15 41 0 1.5 2 -0.2
frame data/chars/boss03/tossg102.png
delay 6
frame data/chars/boss03/tossg101.png
delay 15
@cmd tosser "gurenehdoA" 15 41 0 1.5 2 0.2
frame data/chars/boss03/tossg102.png
delay 6
frame data/chars/boss03/tossg101.png
frame data/chars/boss03/tossg100.png

tosser:
C:
void tosser(void Bomb, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{
    void self = getlocalvar("self");
    int Direction = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    if (!Direction){
        dx=-dx;
    }else{}
    void Shot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
    changeentityproperty(Shot, "parent", self);
    tossentity(Shot, Vy, Vx, Vz);
    changeentityproperty(Shot, "speed", Vx);
    changeentityproperty(Shot, "hostile", getentityproperty(self, "hostile")+openborconstant("TYPE_RESERVED"));
    changeentityproperty(Shot, "candamage", getentityproperty(self, "candamage")+openborconstant("TYPE_RESERVED"));
}

I created a new script for moving randomly as well trying to stop them from moving beyond boundaries and walls.

C:
void randVel(float Vx, float Vz){
//Randomized velocity

    void self = getlocalvar("self");
    int r = rand()%20;
    int x = getentityproperty(self, "x");
    int z = getentityproperty(self, "z");
    int y = getentityproperty(self, "y");
    int zmin = openborvariant("player_min_z");
    int zmax = openborvariant("player_max_z");

    if(r >= -20 && r <= -17){
        changeentityproperty(self, "velocity", -Vx, NULL(), NULL());
    }else if(r > -17 && r <= -14){
        changeentityproperty(self, "velocity", Vx, NULL(), NULL());
    }else if(r > -14 && r <= -11){
        changeentityproperty(self, "velocity", NULL(), -Vz, NULL());
    }else if(r > -11 && r <= -8){
        changeentityproperty(self, "velocity", NULL(), Vz, NULL());
    }else if(r > -8 && r <= -5){
        changeentityproperty(self, "velocity", -Vx, Vz, NULL());
    }else if(r > -5 && r <= -2){
        changeentityproperty(self, "velocity", Vx, Vz, NULL());
    }else if(r > -2 && r <= 1){
        changeentityproperty(self, "velocity", Vx, -Vz, NULL());
    }else if(r > 1 && r <= 4){
        changeentityproperty(self, "velocity", -Vx, -Vz, NULL());
    }

    if(z > zmin){
        if(r >=4 && r < 7){
            changeentityproperty(self, "velocity", NULL(), Vz, NULL());
        }else if(r >=7 && r < 10){
            changeentityproperty(self, "velocity", -Vx, Vz, NULL());
        }else if(r >=10 && r < 13){
            changeentityproperty(self, "velocity", Vx, Vz, NULL());
        }
    }
    
}

Code:
name           gurenehdoA
type npc
subject_to_wall 1
#subject_to_platform 1
#subject_to_obstacle 1
#subject_to_minz     1
#subject_to_maxz     1
shootnum       1
health         1
antigravity    40
speedf         0.9
jumpheight     1
gfxshadow      0
candamage      player npc obstacle
nolife         1

noquake  1 1

script  data/scripts/bounce2.c
animationscript   data/scripts/animation.c

anim idle
       loop           0
       delay          4
       bbox           0
       offset        39 70
load gurenehdoB
       custentity    gurenehdoB
       spawnframe    8 0 0 0 0 
       landframe      8
       frame     data/chars/misc/bomb/grena01.gif
       frame     data/chars/misc/bomb/grena02.gif
       frame     data/chars/misc/bomb/grena03.gif
       frame     data/chars/misc/bomb/grena04.gif
       frame     data/chars/misc/bomb/grena05.gif
       frame     data/chars/misc/bomb/grena06.gif
       frame     data/chars/misc/bomb/grena01.gif
@cmd    updateframe getlocalvar("self") 1
       frame     data/chars/misc/bomb/grena04.gif
       delay     1
       frame     data/chars/misc/empty.gif    
@cmd killentity getlocalvar("self")
       frame     data/chars/misc/empty.gif

Code:
name          gurenehdoB
type          npc
health        1
speedf        0.9
jumpheight    1
gfxshadow     0
hostile       player 
candamage     player enemy obstacle
nolife        1
aggression    999999
noquake       1 1
subject_to_wall 1
subject_to_platform 1
subject_to_obstacle 1
subject_to_minz     1
subject_to_maxz     1


animationscript   data/scripts/animation.c

anim spawn
       loop           0
       delay          1
       bbox           0
       offset        39 70
       frame     data/chars/misc/bomb/grena04.gif

anim idle
@script
    void self = getlocalvar("self");

    if(frame==0){
      changeentityproperty(self, "Subject_to_wall", 1);
    }
    if(frame==13){
      changeentityproperty(self, "Subject_to_Gravity", 0);
    }
@end_script
       loop           1
       delay          4
       bbox           0
       offset        39 70
       frame     data/chars/misc/bomb/grena01.gif
       frame     data/chars/misc/bomb/grena02.gif
       frame     data/chars/misc/bomb/grena03.gif
       frame     data/chars/misc/bomb/grena04.gif
       frame     data/chars/misc/bomb/grena05.gif
       frame     data/chars/misc/bomb/grena06.gif
       frame     data/chars/misc/bomb/grena01.gif
       frame     data/chars/misc/bomb/grena02.gif
       frame     data/chars/misc/bomb/grena03.gif
       frame     data/chars/misc/bomb/grena04.gif
       frame     data/chars/misc/bomb/grena05.gif
       frame     data/chars/misc/bomb/grena06.gif
       delay     1
@cmd jump001 1 0 0
       frame     data/chars/misc/bomb/grena06.gif
drawmethod scale 1.25
@cmd velo001 0 0 0
       delay    3
sound   data/sounds/exp02.wav
       frame    data/chars/misc/bomb/grex01.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
hitfx    data/sounds/exp03.wav
       attack22    20 31 41 40 30 1 1 0 8 10
       dropv    1.7 2 0
       frame    data/chars/misc/bomb/grex02.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex03.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex04.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex05.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex06.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex07.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex08.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex09.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex10.gif
@cmd killentity getlocalvar("self")
       frame     data/chars/misc/empty.gif


anim walk
@script
    void self = getlocalvar("self");
    if(frame==0){
      changeentityproperty(self, "Subject_to_wall", 1);
    }
    if(frame==19){
      changeentityproperty(self, "Subject_to_Gravity", 0);
    }
@end_script
       loop           1
       delay          4
       bbox           0
       offset        39 70
@cmd performattack getlocalvar("self") openborconstant("ANI_FOLLOW1")
       frame     data/chars/misc/bomb/grena01.gif
@cmd performattack getlocalvar("self") openborconstant("ANI_FOLLOW1")
       frame     data/chars/misc/bomb/grena02.gif
       frame     data/chars/misc/bomb/grena03.gif
       frame     data/chars/misc/bomb/grena04.gif
       frame     data/chars/misc/bomb/grena05.gif
       frame     data/chars/misc/bomb/grena06.gif
       frame     data/chars/misc/bomb/grena01.gif
       frame     data/chars/misc/bomb/grena02.gif
       frame     data/chars/misc/bomb/grena03.gif
       frame     data/chars/misc/bomb/grena04.gif
       frame     data/chars/misc/bomb/grena05.gif
       frame     data/chars/misc/bomb/grena06.gif
       frame     data/chars/misc/bomb/grena01.gif
       frame     data/chars/misc/bomb/grena02.gif
       frame     data/chars/misc/bomb/grena03.gif
       frame     data/chars/misc/bomb/grena04.gif
       frame     data/chars/misc/bomb/grena05.gif
       frame     data/chars/misc/bomb/grena06.gif
       delay     1
@cmd jump001 1 0 0
       frame     data/chars/misc/bomb/grena06.gif
drawmethod scale 1.25
@cmd velo001 0 0 0
       delay    3
sound   data/sounds/exp02.wav
       frame    data/chars/misc/bomb/grex01.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
hitfx    data/sounds/exp03.wav
       attack22    20 31 41 40 30 1 1 0 8 10
       dropv    1.7 2 0
       frame    data/chars/misc/bomb/grex02.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex03.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex04.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex05.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex06.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex07.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex08.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex09.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex10.gif
@cmd killentity getlocalvar("self")
       frame     data/chars/misc/empty.gif

anim attack
       range         -20 20
       loop           0
       delay          1
       bbox           0
       offset        39 70
drawmethod scale 1.25
@cmd velo001 0 0 0
sound   data/sounds/exp02.wav
       frame    data/chars/misc/bomb/grex01.gif
       delay         1
       frame        data/chars/misc/empty.gif
       delay    3
hitfx    data/sounds/exp03.wav
       attack22    20 31 41 40 30 1 1 0 8 10
       dropv    1.7 2 0
       frame    data/chars/misc/bomb/grex02.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex03.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex04.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex05.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex06.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex07.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex08.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex09.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex10.gif
@cmd killentity getlocalvar("self")
       frame     data/chars/misc/empty.gif

anim follow1
@script
    void self = getlocalvar("self");
    int y = getentityproperty(self, "y");
    if(frame==0){
      changeentityproperty(self, "Subject_to_wall", 1);
      changeentityproperty(self, "position", NULL(), NULL(), y+0);
    }
    if(frame==20){
      changeentityproperty(self, "Subject_to_Gravity", 0);
    }
@end_script
       loop           1
       delay          4
       bbox           0
       offset        39 70
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena01.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena02.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena03.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena04.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena05.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena06.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena01.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena02.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena03.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena04.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena05.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena06.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena01.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena02.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena03.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena04.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena05.gif
@cmd randVel 0.25 0.25
       frame     data/chars/misc/bomb/grena06.gif
@cmd stop
       delay     1
       frame     data/chars/misc/bomb/grena06.gif
@cmd jump001 1 0 0
       frame     data/chars/misc/bomb/grena06.gif
drawmethod scale 1.25
@cmd velo001 0 0 0
       delay    3
sound   data/sounds/exp02.wav
       frame    data/chars/misc/bomb/grex01.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
hitfx    data/sounds/exp03.wav
       attack22    20 31 41 40 30 1 1 0 8 10
       dropv    1.7 2 0
       frame    data/chars/misc/bomb/grex02.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex03.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex04.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex05.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex06.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex07.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex08.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex09.gif
       delay    1
       frame        data/chars/misc/empty.gif
       delay    3
       frame    data/chars/misc/bomb/grex10.gif
@cmd killentity getlocalvar("self")
       frame     data/chars/misc/empty.gif

Here's an illustration of what I'm trying to achieve from going beyond walls and Z limits.

air trajectory bounce to ground off limits.png

I don't know how to use checkwall on this. Even I tried using "player_min_z" and "player_max_z" for Z limits, it's still not working. Any clue on how this works?
 
Looks like you need to use checkwall function.
This is how I've scripted it for coins in my games:
Code:
anim    idle
@script
    void self = getlocalvar("self");
    float Vx = getentityproperty(self,"xdir");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "y");
    int z = getentityproperty(self, "z");
    int C;

    if(Vx > 0){
      C = 10;
    } else {
      C = -10;
    }

    if(y <= checkwall(x+C,z)){
      changeentityproperty(self, "velocity", -Vx);
    }
@end_script
    loop    1
    delay    5
    offset    10 20
    bouncefactor 2
    itembox    0 0 20 20
    frame    data/chars/misc/items/coin1.png
    frame    data/chars/misc/items/coin1.png
    frame    data/chars/misc/items/coin1.png
    frame    data/chars/misc/items/coin1.png
    frame    data/chars/misc/items/coin1.png
    frame    data/chars/misc/items/coin1.png

Yes, it's only for horizontal movement only. It could be expanded for z axis movement.
 
It would be better to expand for Z axis movement because I'm dealing with checkwall and constant's player_min_z which I partially succeeded for the grenade to bounce off from Z min limit, but it doesn't bounce on the ground. I have no clue how to get to bounce off from Z max limit like I did with Z min. I think my problem for this could be the 2nd parameter of checkwall which is the Z part.

Code:
name gurenehdo
type none
speed 10
candamage player enemy obstacle
subject_to_wall 1
subject_to_minz 1
subject_to_maxz 1
animationscript data/scripts/animation/default.c
script data/scripts/entity/bounce.c

anim idle
    delay    10
    offset    12 13
bouncefactor 2
    frame data/chars/misc/grenade/gren01.gif
    frame data/chars/misc/grenade/gren02.gif
    frame data/chars/misc/grenade/gren03.gif
    frame data/chars/misc/grenade/gren04.gif
    frame data/chars/misc/grenade/gren05.gif
    frame data/chars/misc/grenade/gren06.gif
    frame data/chars/misc/grenade/gren07.gif
    frame data/chars/misc/grenade/gren08.gif
@cmd looper 0 8
@cmd suicide
    frame data/chars/misc/grenade/gren08.gif

I modified this bouncing script for Z limit.

bounce.c:
C:
void main()
{
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int z = getentityproperty(self, "z");
    int Vx = getentityproperty(self, "xdir");
    int Vz = getentityproperty(self, "zdir");
    int C;
    int D;
    int Zmin = openborconstant("PLAYER_MIN_Z");
    int Zmax = openborconstant("PLAYER_MAX_Z");
    int hres = openborvariant("hresolution");
    int xpos = openborvariant("xpos");

    if(Dir == 1){
        C = 15;
        D = 0;
    } else {
        C = -15;
        D = 1;
    }

    if(y <= checkwall(x+C,z) || z <= Zmin){
        changeentityproperty(self, "velocity", Vx, 0.5);
        changeentityproperty(self, "direction", D);
    }

    /*if(y <= checkwall(x+C,z) || z > Zmax){
        changeentityproperty(self, "velocity", Vx, -0.5);
        changeentityproperty(self, "direction", D);
    }*/
}

When I try using shooterW function, it only spawns its projectile as a toss once. Can't use shooterW multiple times like I can do with tosser.

Code:
name Birdo
type enemy
health 80
speed 12
animationscript data/scripts/animation/default.c
load gurenehdo

anim idle
    loop    1
    @cmd    clearL
    offset    45 116
    bbox    17 6 51 101
    delay    25
    frame    data/chars/enemies/topan/idle02.gif
    frame    data/chars/enemies/topan/idle03.gif
    frame    data/chars/enemies/topan/idle02.gif
    delay    100
    frame    data/chars/enemies/topan/idle01.gif

anim walk
    loop    1
    delay    5
    offset    41 136
    bbox    30 41 27 96
    frame    data/chars/enemies/topan/walk01.gif
    frame    data/chars/enemies/topan/walk02.gif
    frame    data/chars/enemies/topan/walk03.gif
    frame    data/chars/enemies/topan/walk04.gif
    frame    data/chars/enemies/topan/walk05.gif
    frame    data/chars/enemies/topan/walk06.gif
    frame    data/chars/enemies/topan/walk07.gif
    frame    data/chars/enemies/topan/walk08.gif
    frame    data/chars/enemies/topan/walk09.gif
    frame    data/chars/enemies/topan/walk10.gif
    frame    data/chars/enemies/topan/walk11.gif
    frame    data/chars/enemies/topan/walk12.gif

anim pain
    offset    36 106
    bbox    17 6 51 101
    delay    6
    frame    data/chars/enemies/topan/hurt1.gif
    delay    12
    frame    data/chars/enemies/topan/hurt2.gif
    delay    6
    frame    data/chars/enemies/topan/hurt1.gif

anim fall
    delay    25
    landframe 3
    offset    55 110
    attack4 35 23 44 59 10 1 1
    frame    data/chars/enemies/topan/fall01.gif
    attack4 22 57 60 34 10 1 1
    frame    data/chars/enemies/topan/fall02.gif
    delay    1000
    offset    55 120
    attack4 20 84 61 39 10 1 1
    frame    data/chars/enemies/topan/fall03.gif
    delay    25
    attack    0
    frame    data/chars/enemies/topan/fall04.gif

anim rise
    offset    52 102
    delay    10
    frame    data/chars/enemies/topan/rise01.gif
    frame    data/chars/enemies/topan/rise02.gif
    move    12
    offset    64 104
    frame    data/chars/enemies/topan/rise03.gif
    move    10
    offset    74 104
    frame    data/chars/enemies/topan/rise04.gif
    move    0
    #@cmd    riseattack 120 75 "ANI_ATTACK4"
    #@cmd    riseattack 250 35 "ANI_FOLLOW1"
    frame    data/chars/enemies/topan/rise05.gif


anim attack1
    delay    7
    offset    37 141
    bbox    11 35 34 107
    frame    data/chars/enemies/topan/tossU01.gif
    frame    data/chars/enemies/topan/tossU02.gif
    delay    20
    #@cmd    target 1.5 0.7 0 0 1
    #@cmd    toss2 "Gurenehdo" 0 130 0 2
    @cmd    tosser "Gurenehdo" 0 130 0 1 2 0
#@cmd shooterW    "Gurenehdo" 0 130 0 1 2 -1
    frame    data/chars/enemies/topan/tossU03.gif
delay 7
    frame    data/chars/enemies/topan/tossU02.gif
    #@cmd    target 2 1 0 0 1
delay 20
    #@cmd    toss2 "Gurenehdo" 0 130 0 2.5
    #@cmd    tosser "Gurenehdo" 0 130 0 1 2 -1
    @cmd    shooterW "Gurenehdo" 0 130 0 1 2 -1
    frame    data/chars/enemies/topan/tossU03.gif
delay 7
    frame    data/chars/enemies/topan/tossU02.gif
    #@cmd    target 2.5 1.3 0 0 1
delay 20
    #@cmd    toss2 "Gurenehdo" 0 130 0 3
    #@cmd    tosser "Gurenehdo" 0 130 0 1 2 1
    @cmd    shooterW "Gurenehdo" 0 130 0 1 2 1
    frame    data/chars/enemies/topan/tossU03.gif
    delay    8
    frame    data/chars/enemies/topan/tossU02.gif
    frame    data/chars/enemies/topan/tossU01.gif
 
Good news, I've expanded the bounce script to work with walls on z axis and zmin + zmax also.
Here's the script:
Code:
anim    idle
@script
    void self = getlocalvar("self");
    float Vx = getentityproperty(self,"xdir");
    float Vz = getentityproperty(self,"zdir");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "y");
    int z = getentityproperty(self, "z");
    int ZMin = openborvariant("PLAYER_MIN_Z");
    int ZMax = openborvariant("PLAYER_MAX_Z");
    int Sx, Sz; int D = 5; int C = 10;

    if(Vx < 0){
      Sx = -Vx;
    } else {
      Sx = Vx;
    }

    if(Vz < 0){
      Sz = -Vz;
    } else {
      Sz = Vz;
    }

    if(y <= checkwall(x-C,z) && Vx < 0){
      changeentityproperty(self, "velocity", Sx);
    } else if(y <= checkwall(x+C,z) && Vx > 0){
      changeentityproperty(self, "velocity", -Sx);
    }
    if(y <= checkwall(x,z-D) && Vz < 0){
      changeentityproperty(self, "velocity", Vx, Sz);
    } else if(z <= ZMin+D && Vz < 0){
      changeentityproperty(self, "velocity", Vx, Sz);
    } else if(y <= checkwall(x,z+D) && Vz > 0){
      changeentityproperty(self, "velocity", Vx, -Sz);
    } else if(z >= ZMax-D && Vz > 0){
      changeentityproperty(self, "velocity", Vx, -Sz);
    }
@end_script
    loop    1
    delay    5
    otg    1
    followanim    1
    followcond    1
    offset    14 15
    bouncefactor 1
    attack    11 11 8 8 10 1 1
    frame    data/chars/misc/shot/sball.png
    frame    data/chars/misc/shot/sball.png
    frame    data/chars/misc/shot/sball.png
    frame    data/chars/misc/shot/sball.png
    frame    data/chars/misc/shot/sball.png

When I try using shooterW function, it only spawns its projectile as a toss once

I don't know which shooterW you're referring here. IIRC that function is for throwing currently held weapon away. That's why it can only be run once.
Why are you using that function anyways?
 
Why are you using that function anyways?
Because I wanted to try it out for a bounce effect, but then I realized it comes from bounce.c. I didn't realize it's used for throwing a weapon until I did way too late. BTW that shooterW function comes from DD Mini.

C:
void shooterW(void vName, float fX, float fY, float fZ, float Vx, float Vy, float Vz)
{//Spawns projectile next to caller and move it with speed ONLY if entity variable 7 is not set
 //vName: Model name of entity to be spawned in
 //fX: X location adjustment
 //fY: Y location adjustment
 //fZ: Z location adjustment
 //Vx: X speed
 //Vy: Y speed
 //Vz: Z speed

   void self = getlocalvar("self"); //Get calling entity
   int Var = getentityvar(self, 7);

   if(Var == NULL()){                
     shooter2(vName, fX, fY, fZ, Vx, Vy, Vz);
     setentityvar(self, 7, 1);
   }
}

Thank you for your new script. It works when it bounces off from both Z limit sides on air. This is just the beginning of landing. Now, I would like to have it move (randomly) around on ground (like walking/wandering around in anim walk) before I give it a stop for an explosion. I tried using my randVel function for moving its velocity randomly, but it only moves in X axis only.

Yes, I do use looper for looping how many times it repeats until it ends. Mind if I have the grenade move around on ground (in 1-2 seconds) after landing? When it moves around/randomly until it reaches to either walls or Z limit, it should move away from said certain boundaries, or it can move in X axis (as long as it doesn't move to the boundaries again).
 
Last edited:
Back
Top Bottom