Page 1 of 1

Some questions on unit scriting

Posted: 01 Oct 2009, 11:24
by Erik
How do i detect if a unit is on water?
Is there sth like a default call where i can insert stuff like smoke coming from a exhaust or custom calculations with variables?

Re: Some questions on unit scriting

Posted: 01 Oct 2009, 13:25
by Master-Athmos
For like a hovercraft driving on water there's this:

Code: Select all

setSFXoccupy(Func_Var_1)
{
	Static_Var_1 = Func_Var_1;
}
... you can use like this then (here a hovercraft spawning some "wave" particles):

Code: Select all

StartMoving()
{
	signal SIG_MOVE;
	set-signal-mask SIG_MOVE;
	while( TRUE )
	{
		if( Static_Var_1 == 1 )
		{
			emit-sfx 3 from wake1;
			emit-sfx 3 from wake2;
			emit-sfx 3 from wake3;
			emit-sfx 3 from wake4;
			emit-sfx 3 from wake5;
			emit-sfx 3 from wake6;
			emit-sfx 3 from wake7;
			emit-sfx 3 from wake8;
			emit-sfx 5 from wake1;
			emit-sfx 5 from wake2;
			emit-sfx 5 from wake3;
			emit-sfx 5 from wake4;
			emit-sfx 5 from wake5;
			emit-sfx 5 from wake6;
			emit-sfx 5 from wake7;
			emit-sfx 5 from wake8;
		}
		if( Static_Var_1 == 2 )
		{
			emit-sfx 3 from wake1;
			emit-sfx 3 from wake2;
			emit-sfx 3 from wake3;
			emit-sfx 3 from wake4;
			emit-sfx 3 from wake5;
			emit-sfx 3 from wake6;
			emit-sfx 3 from wake7;
			emit-sfx 3 from wake8;
			emit-sfx 5 from wake1;
			emit-sfx 5 from wake2;
			emit-sfx 5 from wake3;
			emit-sfx 5 from wake4;
			emit-sfx 5 from wake5;
			emit-sfx 5 from wake6;
			emit-sfx 5 from wake7;
			emit-sfx 5 from wake8;
		}
		sleep 300;
	}
}
There's also the IN_WATER value (probably should be in the exptype.h - should be number 28 of the get/set values). You can use that like this:

Code: Select all

if (isMoving && GET IN_WATER) 
{
do stuff
}
everything here is COB code

Re: Some questions on unit scriting

Posted: 01 Oct 2009, 14:39
by Erik
When is the setSFXoccupy function called and what does it exactly return?

where would i have to place the lowest part? Is there a function thats always called, even if the unit stands still and does nothing?

Re: Some questions on unit scriting

Posted: 01 Oct 2009, 15:04
by smoth
erik, would you be so kind to try and limit your new threads? You do not need a thread for each and every new issue that you come uppon.

We do have a general help thread.

Re: Some questions on unit scriting

Posted: 01 Oct 2009, 15:57
by Erik
Well most other forums have a "one subject per thread" rule to avoid cross discussing but nvm...

Re: Some questions on unit scriting

Posted: 01 Oct 2009, 17:53
by yuritch
Erik wrote:When is the setSFXoccupy function called and what does it exactly return?
AFAIK setSFXoccupy is called when a unit enters water, leaves water, is picked up or dropped by a transport.
Erik wrote:where would i have to place the lowest part? Is there a function thats always called, even if the unit stands still and does nothing?
There is no 'timer' function, however you can easily make one yourself. Like that:

Code: Select all

MyTimer()
{
   while(TRUE)
   {
      <do whatever you want>
      sleep 200;
   }
}

Create()
{
   <usual Create() stuff>
   start-script MyTimer();
}
This will do <whatever> 5 times per second (once per 200 milliseconds). You can set the delay to anything you want (beware of 0 though, an endless loop with that causes game to freeze).