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:
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 :
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.
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:
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.
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
@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: