Hi Warbringer,
I think the problem is in the IF statement...it can not recognize if $tmp is a unit or not, so it never freezes anything. You might want to try this: ( remove brackets around (unit) )
1
2
3
4
5
6
7
on:impact {
$tmp=impact_class();
$tmp2=impact_id();
if ($tmp == "unit"){
freeze $tmp2,1;
}
}
or
1
2
3
4
5
6
on:impact {
$tmp=impact_id();
if (impact_class() == "unit"){
freeze $tmp,1;
}
}
or
1
2
3
4
5
6
on:impact {
$tmp=impact_id();
if (impact_class("unit")){
freeze $tmp,1;
}
}
This below works for certain cuz I just created/tested it;
Here you can see I am asking if the impacted thing is "flesh" or not, because I can compare the "material", and I only want to freeze UNITS. You should have in the DEFINITIONS of your UNITS declaring mat=flesh. This can also be used if you have a unit you want to be immune to freeze. You simply change it's material to something else like mat=dust. Or if you have this script attached to a axe and you are hitting a tree the script is not trying to "freeze the tree", because the tree mat=wood.
1
2
3
4
5
6
7
on:impact {
	$tmp=impact_class();
	$tmp2=impact_id();
	if(compare_material($tmp,$tmp2,"flesh")==1){
		freeze $tmp2,1;
	}
}
I added particles to give it an effect otherwise the unit is simply frozen. You can remove the addstate and statecolor if you do not want that.
1
2
3
4
5
6
7
8
9
on:impact {
	$tmp=impact_class();
	$tmp2=impact_id();
	if(compare_material($tmp,$tmp2,"flesh")==1){
		freeze $tmp2,1;
		addstate $tmp,$tmp2,25;
		statecolor "$tmp",$tmp2,25,0,255,255;
	}
}
Alternatively you can compare BEHAVIOR and only freeze aggressive units if you have the script choose RAPTOR behaviors. Also listed in the units definitions.
if(compare_behavior($tmp,$tmp2,"raptor")==1){
p.s. If you use a melee weapon attach the script to the weapon...if your using a ranged weapon (like a bow) make sure to attach the script to the ammo (arrow). edited 5×, last 16.01.17 09:26:18 pm