Return projectile to launcher

kimono

Well-known member
Good evening, Openbor fans;
I'd like to return a projectile to its launcher.
The projectile will return in the opposite direction and may injure the enemy.

The change of direction and the candamage changes simply by attacking it.
This is how the knife entity is made up:
Code:
name        knife
health        1
type        none
shootnum     10
candamage     player obstacle
projectilehit 0
remove         0
shadow        0

alternatepal data/chars/soldier/alt1.gif
alternatepal data/chars/soldier/alt2.gif
alternatepal data/chars/soldier/alt3.gif

##ANIMATIONS#############################################################################

anim idle
    loop    1
    delay    5
    offset    4 4
    bbox 0 0 16 5
    attack1 0 0 16 5 2 1 0 0 0 0
    frame    data/chars/weapons/knife.png
Have you ever coded something like this?
I think @Kratus did something like this in SORX.
 

Attachments

  • My Mod - 0003.png
    My Mod - 0003.png
    25 KB · Views: 4
Good evening, Openbor fans;
I'd like to return a projectile to its launcher.
The projectile will return in the opposite direction and may injure the enemy.

The change of direction and the candamage changes simply by attacking it.
This is how the knife entity is made up:
Code:
name        knife
health        1
type        none
shootnum     10
candamage     player obstacle
projectilehit 0
remove         0
shadow        0

alternatepal data/chars/soldier/alt1.gif
alternatepal data/chars/soldier/alt2.gif
alternatepal data/chars/soldier/alt3.gif

##ANIMATIONS#############################################################################

anim idle
    loop    1
    delay    5
    offset    4 4
    bbox 0 0 16 5
    attack1 0 0 16 5 2 1 0 0 0 0
    frame    data/chars/weapons/knife.png
Have you ever coded something like this?
I think @Kratus did something like this in SORX.
Will the knife flip direction when blocked by the player or when taking a hit?
 
@kimono,

Something like I had going here?
  • Flies a set distance, then reverses and returns.
  • Reverses instantly if it hits an enemy.
  • Can hit on the return - does NOT reverse if already returning.
  • The owner is locked into waiting position until catching the return or hit by an enemy.

DC
 
The boomerang weapon is an interesting idea; however, the scenario here would be that a knife is thrown, potentially damaging the player.
The player attacks the knife, which is thrown back in the opposite direction of its thrower and can injure them.
The knife originates from an enemy entity.
 
Yes, this is correct: the knife flips direction when being attacked and candamage enemy 🙂
You can use the ondoattack event for the knife, like this.

Code:
void main()
{
    void self = getlocalvar("self");
    int currentDir = getentityproperty(self, "direction");
    int newDir;

    newDir = currentDir == 1 ? 0 : 1; //DEFINE DIRECTION

    if(getlocalvar("which")){ //WORKS FOR DEFENDER
        changeopenborvariant("lasthitc", 0); //DISABLE THE COLLISION
        changeentityproperty(self, "direction", newDir); //CHANGE DIRECTION
    }
}

 
Thanks Kratus! Here's where I am now:
Code:
ondoattackscript       data/scripts/projectile_return.c
Code:
name        knife
health        10
type        none
candamage     player obstacle
projectile       1
projectilehit 0
remove           0
falldie 0

alternatepal data/chars/soldier/alt1.gif
alternatepal data/chars/soldier/alt2.gif
alternatepal data/chars/soldier/alt3.gif

##ANIMATIONS#############################################################################

anim idle
    loop    1
    delay    5
    offset    4 4
    bbox 0 0 16 5
    attack1 0 0 16 5 2 1 0 0 0 0
    frame    data/chars/weapons/knife.png

And what this means in game:

I would like any enemy projectile to be reflected by any attack with the
Code:
candamage enemy obstacle
attribute
simply because "Hokuto Shinken muteki da" ("the Hokuto school is invincible").

The demo in question:
 
Back
Top Bottom