Forum

> > Stranded II > Scripts > Power Attacks
ForenübersichtStranded II-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Power Attacks

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Power Attacks

Xephoriah
User Off Offline

Zitieren
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...
1
2
3
on:attack2 {
			jade 0.3;
	}
along with...
1
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;
	}
Help would be much obliged.

alt Re: Power Attacks

JasJack67
Super User Off Offline

Zitieren
I would just add a switch of some sort using a variable.

Like:
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
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;
          }
      }
}

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=#
5× editiert, zuletzt 29.07.17 05:12:06

alt Re: Power Attacks

Hurri04
Super User Off Offline

Zitieren
while this should work it might be better to use a simple damage variable instead:
1
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;
	}
}


(I also took the freedom to rename some variables since "tmp" is kind of a bad name )
2× editiert, zuletzt 29.07.17 11:01:39

alt Re: Power Attacks

Xephoriah
User Off Offline

Zitieren
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.
1× editiert, zuletzt 31.07.17 00:12:11

alt Re: Power Attacks

JasJack67
Super User Off Offline

Zitieren
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:

1
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";
       }
}

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.
1
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;
          }
      }
}

p.s. Hi ya Hurry! *pokes u in the eye*
9× editiert, zuletzt 31.07.17 02:11:08

alt Re: Power Attacks

Hurri04
Super User Off Offline

Zitieren
if the net behaviour works apart from not dealing damage then you can just add 1 line to my script (see line 14):
1
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;
	}
}

alt Re: Power Attacks

JasJack67
Super User Off Offline

Zitieren
@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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtStranded II-ÜbersichtForenübersicht