Forum

> > Stranded II > Scripts > Weapon Critical Hits
ForenübersichtStranded II-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Weapon Critical Hits

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Weapon Critical Hits

Xephoriah
User Off Offline

Zitieren
Hi, i'm implementing new weapons into my mod, one is a flail, the specialty of the flail is to have random critical hits whenever it hits an enemy. however I cannot seem to combine the code of
1
2
3
4
5
6
7
8
9
10
on:impact {
		$tmp=impact_class();
		$tmp2=impact_id();
		//+25 Critical Hit on Flesh
		if (compare_material($tmp,$tmp2,"flesh")==1){
			damage $tmp,$tmp2,25;
		}
		freevar $tmp;
		freevar $tmp2;
	}
and the random code
1
2
3
local $r;
		local $id;
		$r=random(1,7);
i'm trying to make it a 1/7 chance it will do more damage than normal, a 3/7 chance that it will do a mini-crit, A.K.A. smaller damaging crititcal, and the remaining chances normal damage of the weapon. if someone can help me peice together how the code would work, all i need to do is replace some of the damage values on the script. thanks, and sorry for my bad english, I was up all night playing Team Fortess 2.

alt Re: Weapon Critical Hits

Mephisto_
User Off Offline

Zitieren
If you want your script to apply critical damage only to flesh targets and not on trees or whatever it should look something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
on:impact {
          $tmp=impact_class();
          $tmp2=impact_id();
		local $r;
		$r = random(1,7);

          if (compare_material($tmp,$tmp2,"flesh")==1){

			if ($r >= 5) {
              		 damage $tmp,$tmp2, [standard damage];
			} else if ($r >= 2) {
              		 damage $tmp,$tmp2 ,[small crit damage];
			} else {
              		 damage $tmp,$tmp2, [critical damage];
			}
          }
          freevar $tmp;
          freevar $tmp2;
		freevar $r;
     }

just insert a number for the damage into the square brackets.

alt Re: Weapon Critical Hits

Hurri04
Super User Off Offline

Zitieren
just as a hint, you really don't need the s2 cmd local and s2 cmd freevar commands here because the variables will be created again anyway when the next object is hit.

so from user Mephisto_'s script lines 4, 17, 18 and 19 can be removed without any problem.

alt Re: Weapon Critical Hits

Nova
User Off Offline

Zitieren
Removing the s2 cmd local for r would overwrite any global variable r. Removing the s2 cmd freevar would save the variable into the save file. Would not matter much, but is no nice coding style. I would also make tmp and tmp2 local.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtStranded II-ÜbersichtForenübersicht