Some questions on unit scriting

Some questions on unit scriting

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Some questions on unit scriting

Post 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?
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Some questions on unit scriting

Post 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
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Some questions on unit scriting

Post 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?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Some questions on unit scriting

Post 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.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Some questions on unit scriting

Post by Erik »

Well most other forums have a "one subject per thread" rule to avoid cross discussing but nvm...
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Some questions on unit scriting

Post 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).
Post Reply

Return to “Game Development”