Forum

> > Stranded II > Scripts > Freezing weapon?
Forums overviewStranded II overview Scripts overviewLog in to reply

English Freezing weapon?

2 replies
To the start Previous 1 Next To the start

old Freezing weapon?

Warbringer
User Off Offline

Quote
I tried to make a weapon that freezes units.
This is my script:
1
2
3
4
5
6
7
8
9
10
on:impact {
		$tmp=impact_class();
		$tmp2=impact_id();
		//Freezing
		if ($tmp==("unit")){
			freeze $tmp2,1;
		}
		freevar $tmp;
		freevar $tmp2;
	}
but it doesn't work.
If anyone knows how to make it work, please post here.

old Re: Freezing weapon?

JasJack67
Super User Off Offline

Quote
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;
	}
}

IMG:https://www.mediafire.com/convkey/37ad/ulj4a0w73n5ok5n6g.jpg


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

old Re: Freezing weapon?

Warbringer
User Off Offline

Quote
Dude, you're the best!
I already figured it out though, it goes like this:
1
2
3
4
5
6
7
8
9
10
11
on:impact {
	      $tmp=impact_class();
          $tmp2=impact_id();
		  if ($tmp==2){
		  	if (lives($tmp,$tmp2)==1){
          freeze $tmp2,1;
			}
	      }
	      freevar $tmp;
		  freevar $tmp2;
     }
It's meant to freeze every living unit.
But, thanks for suggestion with adding particles.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview