Solved Change "candamage" of player projectiles and weapons dependig Game Mode

Question that is answered or resolved.

dantedevil

Well-known member
I've been working a lot on my game lately and I'm adding new game modes, including "Versus Mode" and "Royal Rumble".
In these game modes we can cause damage to other players, that's when we find the problem that projectiles and weapons do not affect them.
After researching a lot, I managed to find a solution. I do not know if it is the best, but it works correctly, so I decided to share it in the forum.

Next, I am going to give you an example of how to make a projectile, or a weapon, can harm enemies and players, depending on the stage we are in.

Here we have a Carolina projectile, as we can see it only damages enemies:
Code:
name     maigen
health   1
type    none
offscreenkill   50
shadow    0
nomove  1 1
remove 1
speed   0
candamage enemy obstacle
#antigravity 100
alpha 1

animationscript data/scripts/script.h

anim spawn
    loop    1 4 0
    delay    10
    offset    134 118
        hitfx   data/sounds/hold.wav
        hitflash    mhit
        attack 104 105 38 41 5 0 1 0 0
        nokill  1
        stun    3
    frame    data/chars/heroes/caro/eb1.gif
    frame    data/chars/heroes/caro/eb2.gif
    offset    124 122
        frame    data/chars/heroes/caro/eb3.gif
    offset    118 124
    delay    2
        move    5
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif

anim follow2
    loop    0
    offset    118 124
    delay    2
    drawmethod    scale 0.6 0.6
        move    2
        movea   -10
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb14.gif
        @cmd    killentity getlocalvar("self")
    frame data/chars/misc/empty.png

anim    follow1
    loop    0
@script
    void self = getlocalvar("self");

    if(frame == 0){
      changeentityproperty(self, "velocity", 0, 0, 0);
      changeentityproperty(self, "speed", 0);
    }
    if(frame == 11){
      killentity(self);
    }
@end_script
    Delay    3
    OffSet    30 13
        @cmd    spawn01 "mhit" 0 10 1
        sound   data/sounds/hitfire.wav
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        @cmd    killentity getlocalvar("self")
    frame    data/chars/misc/empty.png


What we are going to do now is use a script that, depending on the "branch" level, changes to a different animation.
This scrit is courtesy of @Bloodbane :
Code:
void branchAni(void branch, void Ani)
{// Branch Checker and Animation changer
// Dantedevil

    void self = getlocalvar("self");
    char branchC = openborvariant("current_branch");

    if(branch==branchC){
      changeentityproperty(self, "animation", openborconstant(Ani), 2); //Change the animation
    }
}



Now we do the following:
1) We need duplicate the animation that has attack frames and we rewrite the new as an "ANIM FOLLOW..."
2) In the new "ANIM FOLLOW..." we need set the "candamage" via script.
Code:
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE"));
@end_script
3) In the original animation we must call the script, adjusting the "branch" and the "ANIM FOLLOW..."
@cmd branchAni "Rrumble30" "ANI_FOLLOW3"


After making all the changes, this is the result:
Code:
name     maigen
health   1
type    none
offscreenkill   50
shadow    0
nomove  1 1
remove 1
speed   0
candamage enemy obstacle
#antigravity 100
alpha 1

animationscript data/scripts/script.h

anim spawn
        @cmd  branchAni "Rrumble30" "ANI_FOLLOW1"
    loop    1 4 0
    delay    10
    offset    134 118
        hitfx   data/sounds/hold.wav
        hitflash    mhit
        attack 104 105 38 41 5 0 1 0 0
        nokill  1
        stun    3
    frame    data/chars/heroes/caro/eb1.gif
    frame    data/chars/heroes/caro/eb2.gif
    offset    124 122
        frame    data/chars/heroes/caro/eb3.gif
    offset    118 124
    delay    2
        move    5
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif

anim follow2
    loop    0
    offset    118 124
    delay    2
    drawmethod    scale 0.6 0.6
        move    2
        movea   -10
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb14.gif
        @cmd    killentity getlocalvar("self")
    frame data/chars/misc/empty.png

anim    follow1
    loop    0
@script
    void self = getlocalvar("self");

    if(frame == 0){
      changeentityproperty(self, "velocity", 0, 0, 0);
      changeentityproperty(self, "speed", 0);
    }
    if(frame == 11){
      killentity(self);
    }
@end_script
    Delay    3
    OffSet    30 13
        @cmd    spawn01 "mhit" 0 10 1
        sound   data/sounds/hitfire.wav
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        @cmd    killentity getlocalvar("self")
    frame    data/chars/misc/empty.png

anim    follow3
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE"));
@end_script
    loop    1 4 0
    delay    10
    offset    134 118
        hitfx   data/sounds/hold.wav
        hitflash    mhit
        attack 104 105 38 41 5 0 1 0 0
        nokill  1
        stun    3
    frame    data/chars/heroes/caro/eb1.gif
    frame    data/chars/heroes/caro/eb2.gif
    offset    124 122
        frame    data/chars/heroes/caro/eb3.gif
    offset    118 124
    delay    2
        move    5
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif

With this method we can add the levels that are necessary in each entity (projectiles & weapons), always keeping in mind that each level must have a designated branch.

I hope it can be of use and if anyone has a better method, I appreciate that you can share it. :)
 
Last edited:
Solution
Ok, I finally understood what you explained to me @DCurrent
To make it work, I need to remove the "candamage" of the projectile, so that it takes the one that the player (parents) has.
Now all works ok. :D
Thanks for you greart help my friend!
I've been working a lot on my game lately and I'm adding new game modes, including "Versus Mode" and "Royal Rumble".
In these game modes we can cause damage to other players, that's when we find the problem that projectiles and weapons do not affect them.
After researching a lot, I managed to find a solution. I do not know if it is the best, but it works correctly, so I decided to share it in the forum.

Next, I am going to give you an example of how to make a projectile, or a weapon, can harm enemies and players, depending on the stage we are in.

Here we have a Carolina projectile, as we can see it only damages enemies:
Code:
name     maigen
health   1
type    none
offscreenkill   50
shadow    0
nomove  1 1
remove 1
speed   0
candamage enemy obstacle
#antigravity 100
alpha 1

animationscript data/scripts/script.h

anim spawn
    loop    1 4 0
    delay    10
    offset    134 118
        hitfx   data/sounds/hold.wav
        hitflash    mhit
        attack 104 105 38 41 5 0 1 0 0
        nokill  1
        stun    3
    frame    data/chars/heroes/caro/eb1.gif
    frame    data/chars/heroes/caro/eb2.gif
    offset    124 122
        frame    data/chars/heroes/caro/eb3.gif
    offset    118 124
    delay    2
        move    5
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif

anim follow2
    loop    0
    offset    118 124
    delay    2
    drawmethod    scale 0.6 0.6
        move    2
        movea   -10
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb14.gif
        @cmd    killentity getlocalvar("self")
    frame data/chars/misc/empty.png

anim    follow1
    loop    0
@script
    void self = getlocalvar("self");

    if(frame == 0){
      changeentityproperty(self, "velocity", 0, 0, 0);
      changeentityproperty(self, "speed", 0);
    }
    if(frame == 11){
      killentity(self);
    }
@end_script
    Delay    3
    OffSet    30 13
        @cmd    spawn01 "mhit" 0 10 1
        sound   data/sounds/hitfire.wav
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        @cmd    killentity getlocalvar("self")
    frame    data/chars/misc/empty.png


What we are going to do now is use a script that, depending on the "branch" level, changes to a different animation.
This scrit is courtesy of @Bloodbane :
Code:
void branchAni(void branch, void Ani)
{// Branch Checker and Animation changer
// Dantedevil

    void self = getlocalvar("self");
    char branchC = openborvariant("current_branch");

    if(branch==branchC){
      changeentityproperty(self, "animation", openborconstant(Ani), 2); //Change the animation
    }
}



Now we do the following:
1) We need duplicate the animation that has attack frames and we rewrite the new as an "ANIM FOLLOW..."
2) In the new "ANIM FOLLOW..." we need set the "candamage" via script.
Code:
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE")); 
@end_script
3) In the original animation we must call the script, adjusting the "branch" and the "ANIM FOLLOW..."
@cmd branchAni "Rrumble30" "ANI_FOLLOW3"


After making all the changes, this is the result:
Code:
name     maigen
health   1
type    none
offscreenkill   50
shadow    0
nomove  1 1
remove 1
speed   0
candamage enemy obstacle
#antigravity 100
alpha 1

animationscript data/scripts/script.h

anim spawn
        @cmd  branchAni "Rrumble30" "ANI_FOLLOW1"
    loop    1 4 0
    delay    10
    offset    134 118
        hitfx   data/sounds/hold.wav
        hitflash    mhit
        attack 104 105 38 41 5 0 1 0 0
        nokill  1
        stun    3
    frame    data/chars/heroes/caro/eb1.gif
    frame    data/chars/heroes/caro/eb2.gif
    offset    124 122
        frame    data/chars/heroes/caro/eb3.gif
    offset    118 124
    delay    2
        move    5
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif

anim follow2
    loop    0
    offset    118 124
    delay    2
    drawmethod    scale 0.6 0.6
        move    2
        movea   -10
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb14.gif
        @cmd    killentity getlocalvar("self")
    frame data/chars/misc/empty.png

anim    follow1
    loop    0
@script
    void self = getlocalvar("self");

    if(frame == 0){
      changeentityproperty(self, "velocity", 0, 0, 0);
      changeentityproperty(self, "speed", 0);
    }
    if(frame == 11){
      killentity(self);
    }
@end_script
    Delay    3
    OffSet    30 13
        @cmd    spawn01 "mhit" 0 10 1
        sound   data/sounds/hitfire.wav
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        frame    data/chars/misc\empty.png
        @cmd    killentity getlocalvar("self")
    frame    data/chars/misc/empty.png

anim    follow3
@script
    void self = getlocalvar("self");
    changeentityproperty(self, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE")); 
@end_script
    loop    1 4 0
    delay    10
    offset    134 118
        hitfx   data/sounds/hold.wav
        hitflash    mhit
        attack 104 105 38 41 5 0 1 0 0
        nokill  1
        stun    3
    frame    data/chars/heroes/caro/eb1.gif
    frame    data/chars/heroes/caro/eb2.gif
    offset    124 122
        frame    data/chars/heroes/caro/eb3.gif
    offset    118 124
    delay    2
        move    5
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        frame    data/chars/heroes/caro/eb4.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        frame    data/chars/heroes/caro/eb5.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
    frame    data/chars/heroes/caro/eb6.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        frame    data/chars/heroes/caro/eb7.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        frame    data/chars/heroes/caro/eb8.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        frame    data/chars/heroes/caro/eb9.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
    frame    data/chars/heroes/caro/eb10.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        frame    data/chars/heroes/caro/eb11.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        frame    data/chars/heroes/caro/eb12.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        frame    data/chars/heroes/caro/eb13.gif
        @cmd    wallhit2 5 "ANI_FOLLOW1"
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif
        frame    data/chars/heroes/caro/eb14.gif

With this method we can add the levels that are necessary in each entity (projectiles & weapons), always keeping in mind that each level must have a designated branch.

I hope it can be of use and if anyone has a better method, I appreciate that you can share it. :)
@dantedevil

To be honest I think you are way overcomplicating this. By default OpenBOR applies the parent's candamage to projectiles as they spawn. In special cases, you can always copy it with script.

Then, all you really need to do is set the parent candamage when level starts. The projectiles will handle themselves. Is there some reason you aren't doing that?

DC
 
Hello DC!

The reason I decided to do it this way is because it was the only one I found possible based on the information in the forum and my knowledge.
What you explain to me I understand in a certain way, but it far exceeds my knowledge.
I have spent a lot of time searching the forum for information and I can assure you that there is not much about it, in the same way that I could not find mods where I can see examples of this system in operation.

I really appreciate your explanation, but beyond the fact that I have been involved in the OpenBor world for years, there are things that are beyond my knowledge.

Thanks my friend! :)
 
Hello DC!

The reason I decided to do it this way is because it was the only one I found possible based on the information in the forum and my knowledge.
What you explain to me I understand in a certain way, but it far exceeds my knowledge.
I have spent a lot of time searching the forum for information and I can assure you that there is not much about it, in the same way that I could not find mods where I can see examples of this system in operation.

I really appreciate your explanation, but beyond the fact that I have been involved in the OpenBor world for years, there are things that are beyond my knowledge.

Thanks my friend! :)

In that case, give the candamage property a try. It could really cut down on a lot of work and mess for you. Don't even worry about the projectiles at first, just worry about parent. Candamage property uses bitwise logic, meaning you can set more than one value at a time because they are actually bits within an integer. If you don't understand that, don't worry too much. It's enough just to know how to make it work.

Here's an example:

C:
void acting_entity = getlocalvar("self")

changeentityproperty(acting_entity, "candamage", openborconstant("TYPE_ENEMY") | openborconstant("TYPE_PLAYER"));

Assuming I didn't make a dumb typo, that would enable damaging players and enemies.

DC
 
Last edited:
At each level that I need the "candamage" to affect player and enemies, I use the script like this in the spawn of an entity:

Code:
spawn   inout
@script
void main()
{
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P3 = getplayerproperty(2, "entity");
    int P4 = getplayerproperty(3, "entity");

    if(P1){
      changeentityproperty(P1, "position", 30, 155, 0);
    changeentityproperty(P1, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE"));   
    }
    if(P2){
      changeentityproperty(P2, "position", 450, 155, 0);
      changeentityproperty(P2, "direction", 0); //Face left
    changeentityproperty(P2, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE"));   
    }
    if(P3){
      changeentityproperty(P3, "position", 20, 270, 0);
    changeentityproperty(P3, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE"));   
    }
    if(P4){
      changeentityproperty(P4, "position", 460, 270, 0);
      changeentityproperty(P4, "direction", 0); //Face left
    changeentityproperty(P4, "candamage", openborconstant("TYPE_PLAYER"), openborconstant("TYPE_ENEMY"), openborconstant("TYPE_OBSTACLE"));   
    }
    changeopenborvariant("ypos", 260);
}
@end_script
coords  240 272
at      0


As you can see I have already adjusted the script so that it can damage enemies and players, but projectiles and weapons are not affected.
 
Ok, I finally understood what you explained to me @DCurrent
To make it work, I need to remove the "candamage" of the projectile, so that it takes the one that the player (parents) has.
Now all works ok. :D
Thanks for you greart help my friend!
 
Solution
@dantedevil

To be honest I think you are way overcomplicating this. By default OpenBOR applies the parent's candamage to projectiles as they spawn. In special cases, you can always copy it with script.

Then, all you really need to do is set the parent candamage when level starts. The projectiles will handle themselves. Is there some reason you aren't doing that?

DC
Spawn an entity with this script works to get points to the parent player, but not to adcquire candamage properties.

C#:
void spawnChild(void Name, float dx, float dy, float dz, int Num, void Ani)
{ // Spawn entity and set it as child with ani animation, store it and bind it
   void self = getlocalvar("self");
   void Spawn;


   Spawn = spawn01(Name, dx, dy, dz);
   changeentityproperty(Spawn, "parent", self);
   setentityvar(self, Num, Spawn); // Stores spawned gun to be killed later
   bindentity(Spawn, self, dx, dz, dy, 0, 0); // Bind spawned gun
   performattack(Spawn, openborconstant(Ani));
}


Entity spawned doesn't have candamage on header Openbor forces me to put it, and I would like to be able to leave it blank to take advantage of this feature.
Is something wrong with the script?
 
Entity spawned doesn't have candamage on header Openbor forces me to put it

what makes you think OpenBoR forces you to declare candamage? 🤨

Also there's no line in spawnChild function which changes candamage so should it be enough?
 
Back
Top Bottom