Power Attacks
7 replies



28.07.17 01:07:28 am
I'm trying to implement power attacks for melee weapons. I want this to be done by right clicking with a melee weapon such as the machete, increasing it's damage on the flesh material with that attack while the player loses more hunger, thirst and fatigue. However I don't know how to combine...
along with...
Help would be much obliged.
Code:
1
2
3
2
3
on:attack2 {
jade 0.3;
}
jade 0.3;
}
along with...
Code:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
on:impact {
$tmp=impact_class();
$tmp2=impact_id();
//+6 Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,6;
}
freevar $tmp;
freevar $tmp2;
}
$tmp=impact_class();
$tmp2=impact_id();
//+6 Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,6;
}
freevar $tmp;
freevar $tmp2;
}
Help would be much obliged.

I love SII, and the Crystal Blade. I always make it craftable!
I would just add a switch of some sort using a variable.
Like:
So:
if the player clicks attack2 then $attack=2 and a jade of 0.8
if the player clicks attack1 then $attack=1 and a jade of 0.3
on:impact you see if $attack=2 then the bonus is applied@12, ELSE if $attack=1 then the bonus remains@6.
Also note in this script if impact is NOT FLESH then only the weapon's base damage will be inflicted. That is listed under the weapon ID as Damage=#
Like:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
on:attack2 {
$attack=2;
jade 0.8;
}
on:attack1 {
$attack=1;
jade 0.3;
}
on:impact {
if $attack==2{
$tmp=impact_class();
$tmp2=impact_id();
//+12 Power Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,12;
}
}else{
$tmp=impact_class();
$tmp2=impact_id();
//+6 Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,6;
}
}
}
$attack=2;
jade 0.8;
}
on:attack1 {
$attack=1;
jade 0.3;
}
on:impact {
if $attack==2{
$tmp=impact_class();
$tmp2=impact_id();
//+12 Power Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,12;
}
}else{
$tmp=impact_class();
$tmp2=impact_id();
//+6 Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,6;
}
}
}
So:
if the player clicks attack2 then $attack=2 and a jade of 0.8
if the player clicks attack1 then $attack=1 and a jade of 0.3
on:impact you see if $attack=2 then the bonus is applied@12, ELSE if $attack=1 then the bonus remains@6.
Also note in this script if impact is NOT FLESH then only the weapon's base damage will be inflicted. That is listed under the weapon ID as Damage=#
edited 5×, last 29.07.17 05:12:06 am
The Survivalist_12-24-19 is now available. DOWNLOAD HERE
The Survivalist 12-24-19 | Performance-In options keep Water Detail off

while this should work it might be better to use a simple damage variable instead:
(I also took the freedom to rename some variables since "tmp" is kind of a bad name
)
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
on:attack2 {
$bonusDamage = 12;
jade 0.8;
}
on:attack1 {
$bonusDamage = 6;
jade 0.3;
}
on:impact {
$tempClass = impact_class();
$tempID = impact_id();
if (compare_material($tempClass, $tempID, "flesh") == 1){
damage $tempClass, $tempID, $bonusDamage;
}
}
$bonusDamage = 12;
jade 0.8;
}
on:attack1 {
$bonusDamage = 6;
jade 0.3;
}
on:impact {
$tempClass = impact_class();
$tempID = impact_id();
if (compare_material($tempClass, $tempID, "flesh") == 1){
damage $tempClass, $tempID, $bonusDamage;
}
}

(I also took the freedom to rename some variables since "tmp" is kind of a bad name

edited 2×, last 29.07.17 11:01:39 am
I guess I wasn't too clear about everything. When I added the script to my game and used the second attack key (Right Mouse Button for me) I didn't swing my weapon at all... I figured that was because of the weapon behavior, if I wanted to use a second attack I would have to use the Net behavior, but it doesn't deal damage to anything.
edited 1×, last 31.07.17 12:12:11 am
I love SII, and the Crystal Blade. I always make it craftable!
hmm. . .in my example you could have the player "set up" for a power attack by Right Click mouse button first to "set up" the damage, then when you click to attack with the normal Left Click it would check for the set up variable, like this:
So (attack1)Right Click will turn Power Attack on and off when you click it. If it is ON it automatically goes back to OFF after 1 impact as you see in (attack2) Left Click.
On impact you can add POWER ATTCK! so the player knows it happened when he hit the target.
p.s. Hi ya Hurry! *pokes u in the eye*
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
on:attack2 {
if ($powerattack==1){
$powerattack=0 //turns off power attack each click
$attack=2;
jade 0.8;
}else{
$powerattack=0;
$attack=1;
jade 0.3;
}
}
on:attack1 {
if ($powerattack=1)[
$powerattack=0;
msg "POWER ATTACK OFF!,2";
}else{
$powerattack=1;
msg "POWER ATTACK READY!,4";
}
}
if ($powerattack==1){
$powerattack=0 //turns off power attack each click
$attack=2;
jade 0.8;
}else{
$powerattack=0;
$attack=1;
jade 0.3;
}
}
on:attack1 {
if ($powerattack=1)[
$powerattack=0;
msg "POWER ATTACK OFF!,2";
}else{
$powerattack=1;
msg "POWER ATTACK READY!,4";
}
}
So (attack1)Right Click will turn Power Attack on and off when you click it. If it is ON it automatically goes back to OFF after 1 impact as you see in (attack2) Left Click.
On impact you can add POWER ATTCK! so the player knows it happened when he hit the target.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
on:impact {
if $attack==2{
$tmp=impact_class();
$tmp2=impact_id();
//+12 Power Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,12;
msg "POWER ATTACK!,3"; //tells the player a PA was made
}
}else{
$tmp=impact_class();
$tmp2=impact_id();
//+6 Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,6;
}
}
}
if $attack==2{
$tmp=impact_class();
$tmp2=impact_id();
//+12 Power Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,12;
msg "POWER ATTACK!,3"; //tells the player a PA was made
}
}else{
$tmp=impact_class();
$tmp2=impact_id();
//+6 Bonus Damage on Flesh
if (compare_material($tmp,$tmp2,"flesh")==1){
damage $tmp,$tmp2,6;
}
}
}
p.s. Hi ya Hurry! *pokes u in the eye*

edited 9×, last 31.07.17 02:11:08 am
The Survivalist_12-24-19 is now available. DOWNLOAD HERE
The Survivalist 12-24-19 | Performance-In options keep Water Detail off

if the net behaviour works apart from not dealing damage then you can just add 1 line to my script (see line 14):
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
on:attack2 {
$bonusDamage = 12;
jade 0.8;
}
on:attack1 {
$bonusDamage = 6;
jade 0.3;
}
on:impact {
$tempClass = impact_class();
$tempID = impact_id();
damage $tempClass, $tempID, 10;
if (compare_material($tempClass, $tempID, "flesh") == 1){
damage $tempClass, $tempID, $bonusDamage;
}
}
$bonusDamage = 12;
jade 0.8;
}
on:attack1 {
$bonusDamage = 6;
jade 0.3;
}
on:impact {
$tempClass = impact_class();
$tempID = impact_id();
damage $tempClass, $tempID, 10;
if (compare_material($tempClass, $tempID, "flesh") == 1){
damage $tempClass, $tempID, $bonusDamage;
}
}
@Hurry
that won't work due to impact collision, the net behavior is the same as the weapon in that left click (attack2) has impact collision dealing damage and right click (attack1) does NOT have a impact collision, therefore, no damage is dealt.
attack1 - It's like your swinging at the air when you try to hit something. There is no impact.
that won't work due to impact collision, the net behavior is the same as the weapon in that left click (attack2) has impact collision dealing damage and right click (attack1) does NOT have a impact collision, therefore, no damage is dealt.
attack1 - It's like your swinging at the air when you try to hit something. There is no impact.
The Survivalist_12-24-19 is now available. DOWNLOAD HERE
The Survivalist 12-24-19 | Performance-In options keep Water Detail off

right. could try something with an invisible
projectile then.




