Adding dust effect to bouncing projectile

MysticalMist

Well-known member
It has been a while since I really focused on OpenBOR in a while so I'm super rusty.

I have a player character that throws a bouncing keg as a attack. I was able to add a dust effect for its FALL animation just fine, but I've yet to do the same for its idle.

Here is the script for it:
Code:
name vkeg1
speed 9
health 1
remove   0
type none
subtype flydie
speed 9
gfxshadow    1
lifespan 5
offscreenkill 500
falldie    0
bounce 1
nodieblink 1
dust dust dust dust
candamage enemy obstacle
animationscript data/scripts/script.c


anim idle
bouncefactor 1
loop 1
@script
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "y");
    int z = getentityproperty(self, "z");
    int C;

    if(Dir == 1){
      C = 6;
    } else {
      C = -6;
    }
    

    if(frame > 0 && y <= checkwall(x+C,z)){
      changeentityproperty(self, "velocity", 0, 0, 0);
      changeentityproperty(self, "subject_to_gravity", 1);
      changeentityproperty(self, "animation", openborconstant("ANI_FALL"));
    }
@end_script
        delay 5
        offset 31 35
    attack.block.penetrate 0
    attack.damage.force 40
    attack.damage.type 1
    attack.effect.hit.flash.disable 0
    attack.position.x -2
    attack.position.y 5
    attack.reaction.fall.force 999
    attack.reaction.fall.velocity.x 2.0
    attack.reaction.fall.velocity.y 2.0
    attack.reaction.pause.time 0
    attack.size.x 68
    attack.size.y 56
    attack.size.z.background 0
        frame data/chars/vortex/barrel/0.png
        frame data/chars/vortex/barrel/1.png
        frame data/chars/vortex/barrel/2.png
        frame data/chars/vortex/barrel/3.png
        frame data/chars/vortex/barrel/4.png
        frame data/chars/vortex/barrel/5.png
        frame data/chars/vortex/barrel/6.png
        frame data/chars/vortex/barrel/7.png

anim fall
bouncefactor 2
loop 0
delay 99
offset 31 35
landframe 1 dust
sound data/sounds/klunk.wav
frame data/chars/vortex/barrel/5.png
delay 40
frame data/chars/vortex/barrel/4.png
delay 3
frame data/chars/vortex/barrel/4.png
frame data/chars/misc/empty.gif
frame data/chars/vortex/barrel/4.png
frame data/chars/misc/empty.gif
frame data/chars/vortex/barrel/4.png
frame data/chars/misc/empty.gif
frame data/chars/vortex/barrel/4.png
frame data/chars/misc/empty.gif
frame data/chars/vortex/barrel/4.png
frame data/chars/misc/empty.gif

Addition: I guess while I'm here, I just realized I could ask something else. Is there a way to swap out the normal falling collision sound for the klunk.wav instead?
 
Is there a way to swap out the normal falling collision sound for the klunk.wav instead?

Falling collision sound.... you mean hitfx when thrown enemy hits other enemies right? the SFX is called indirect.wav in data/sounds folder. Just replace that SFX with desired SFX and same name to swap it.

For main topic, you'd need to use ondrawscript to spawn dust on bouncing projectile. Like this one:
Dusbons.c
C:
void main()
{ // Spawns dust when touching ground
    void self = getlocalvar("self");
    int y = getentityproperty(self, "y");

    if(y <= 0){
      spawn01("Dust", 0, 0, 0);
    }
}

void spawn01(void vName, float fX, float fY, float fZ)
{
    //spawn01 (Generic spawner)
    //Damon Vaughn Caskey
    //07/06/2007
    //
    //Spawns entity next to caller.
    //
    //vName: Model name of entity to be spawned in.
    //fX: X location adjustment.
    //fY: Y location adjustment.
      //fZ: Z location adjustment.

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

    if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
    }

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
    
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    
    return vSpawn; //Return spawn.
}

Save that script and declare it in projectile with this line:
onmoveascript data/scripts/dusbons.c

This script will spawn Dust when projectile hits the ground briefly while bouncing.
However, the spawned Dust will act like regular entity instead of hitflash. IOW it won't remove itself automatically like the latter so you'd need to add blank frame at end of dust animation and set lifespan.
 
Falling collision sound.... you mean hitfx when thrown enemy hits other enemies right? the SFX is called indirect.wav in data/sounds folder. Just replace that SFX with desired SFX and same name to swap it.

My mistake, I meant when it hits the ground. Essentially, the fall.wav, but instead of using that, I want it to use the klunk sound instead.

Thank you very much for the script, though! It works perfectly!
 
Back
Top Bottom