Texture Problems - Page 2

Texture Problems

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

User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2700
Joined: 25 Aug 2004, 13:31

Re: Texture Problems

Post by bobthedinosaur »

cute tank btw
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Texture Problems

Post by smoth »

also:
Image

RESPECT!
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Texture Problems

Post by SanadaUjiosan »

My next question is probably a pretty lame one, but I'm trying to figure out how to have my commander and my builders build units... I've tried searching the forums for any info but I haven't found anything I can make sense of. If someone could give me a jumpstart, or point me in the right direction that'd be great.

So far I've used the CA commander unit LUA file and entered the information to make it look like my own unit. I entered one of my unit in the buildoptions list, and I can place where I want the unit built, but it never gets built. I noticed there was no place in the unit LUA file for the animation script, so maybe that's the problem. It's lacking a point for the nanospray to come from.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Texture Problems

Post by smoth »

you specify that stuff in the unit script.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Texture Problems

Post by SanadaUjiosan »

Ok, so there's no other file or anything I have to deal with?

Could someone possibly give me an example to work off of? I haven't had any luck trying to track one down.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Texture Problems

Post by smoth »

Code: Select all

piece GP,head,base,l_forearm2,left,right,l_forearm3,nano1,nano2,turret1,turret2,dustl,dustr,flare3,flare4;

static-var restore_delay, ISMOVING, bAiming, bCanAim, peeeee, shooting_numb;


#define SIG_AIM				2
#define SIG_MOVE			16

#define lildirt 					1024+0 

#define SMOKEPIECE1 base

#include "smokeunit.h"
#include "exptype.h"
#include "StateChg.h"


StartMoving()
{   ISMOVING = TRUE;  }

StopMoving()
{	ISMOVING = FALSE; }	

Flamingass()
	{
		while(TRUE)
		{
			if (ISMOVING)		
			{
			emit-sfx 		lildirt 		from dustl;
			emit-sfx 		lildirt 		from dustr;
			}		
		sleep 130;
		}

	}

//------------------------------------------------------
//start ups :)
//------------------------------------------------------
Create()
	{
	// Initial State
	ISMOVING = FALSE;
	bAiming = FALSE;
	bCanAim = TRUE;
	peeeee = 0;
	restore_delay=3000;

	start-script SmokeUnit();
//	start-script Flamingass();
	}
	
SweetSpot(piecenum)
	{	piecenum=GP;	}	
	
AimFromPrimary(piecenum)
	{    
		if (shooting_numb==1) 
		{	piecenum=flare3;	}
	
		if (shooting_numb==2)
		{	piecenum=flare4;	}     	
	}
		
QueryNanoPiece(piecenum)
	{	
	
	if( peeeee == 1 )
	{	piecenum = nano2;	}
	
	if( peeeee == 2 )
	{	piecenum = nano1;	}
	
	++peeeee;
	
	if( peeeee >= 3 )
	{	peeeee = 1;	}
	
	}
	
//------------------------------------------------------------
//Reload delay function
//------------------------------------------------------------		
SetMaxReloadTime(time)
	{	restore_delay = time * 2;	}

AimPrimary(heading,pitch)//
	{
	signal SIG_AIM;
	set-signal-mask SIG_AIM;
	
	// Announce that we would like to aim, and wait until we can
	while (NOT bCanAim)
		{
		sleep 100;
		}
		turn head to y-axis heading speed <60>;
		turn r_forearm to x-axis (0-pitch) speed <250>;
		turn l_forearm to x-axis (0-pitch) speed <250>;
					
		wait-for-turn head  around y-axis;
		wait-for-turn r_forearm around x-axis;
		wait-for-turn l_forearm around x-axis;
		start-script RestoreAfterDelay();
	
		return(TRUE);
	}
		
FirePrimary()
	{
			if(shooting_numb==1)
			{
			show flare3;
			sleep 120;
			hide flare3;
			}
			if(shooting_numb==2)
			{
			show flare4;
			sleep 120;
			hide flare4;
			}
				
	shooting_numb=shooting_numb+1;
		
				if( shooting_numb == 3)
				{
				shooting_numb=1;
				}
	}
	
//---------------------------------------------------------------------
//gun functions;
//---------------------------------------------------------------------	
RestoreAfterDelay()
	{
	sleep restore_delay;
	
	turn head 		to y-axis <0> speed <35>;
	turn turret1		to x-axis <0> speed <250>;
	turn turret2		to x-axis <0> speed <250>;
	turn l_forearm3		to x-axis <0> speed <250>;
	turn l_forearm2		to x-axis <0> speed <250>;
	bAiming = FALSE;
	}
	
/*==============================================
//nano functions
==============================================*/

StartBuilding(heading,pitch)
	{
	// Announce that we would like to aim, and wait until we can
	bAiming = TRUE;
	while (NOT bCanAim)
		{		sleep 100;		}

	// Aim
	turn head to y-axis heading speed <300>;
	turn turret1 to x-axis (<-40> - pitch) speed <245>;
	turn turret2 to x-axis (<-40> - pitch) speed <145>;
	
	turn l_forearm3 to x-axis <-40> speed <145>;
	turn l_forearm2 to x-axis <-40> speed <245>;
	
	wait-for-turn turret2 around x-axis;
	wait-for-turn turret1 around x-axis;
	wait-for-turn head around y-axis;
	// Announce that we are ready
	set INBUILDSTANCE to TRUE;
	return TRUE;
	}

TargetCleared(which)
	{
	signal SIG_AIM;
	set-signal-mask SIG_AIM;
	call-script RestoreAfterDelay();
	}

StopBuilding()
	{// We are no longer in a position to build
	set INBUILDSTANCE to FALSE;

	signal SIG_AIM;
	set-signal-mask SIG_AIM;
	call-script RestoreAfterDelay();
	}
	

Killed( severity, corpsetype )
	{
	if (severity <= 25)
		{
		corpsetype = 1;
	explode base 		type		SHATTER | BITMAP2;
	explode head 		type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode l_forearm2 	type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode left 		type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode right 		type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode l_forearm3 	type		FALL  | EXPLODE_ON_HIT | BITMAP3;
		return( 0 );
		}

	if (severity <= 50)
		{
		corpsetype = 2;
	explode base 		type		SHATTER | EXPLODE_ON_HIT | BITMAP1;
	explode head 		type		SHATTER | EXPLODE_ON_HIT | BITMAP1;
	explode l_forearm2 	type		SHATTER | EXPLODE_ON_HIT | BITMAP3;
	explode left 		type		SHATTER | EXPLODE_ON_HIT | BITMAP3;
	explode right 		type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode l_forearm3 	type		FALL  | EXPLODE_ON_HIT | BITMAP3;
		return( 0 );
		}

	if (severity <= 99)
		{
		corpsetype = 3;
	explode base 		type		SHATTER | EXPLODE_ON_HIT | BITMAP1;
	explode head 		type		SHATTER | EXPLODE_ON_HIT | BITMAP1;
	explode l_forearm2 	type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode left 		type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode right 		type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode l_forearm3 	type		FALL  | EXPLODE_ON_HIT | BITMAP3;
		return( 0 );
		}

	corpsetype = 3;
	explode base 		type		SHATTER | EXPLODE_ON_HIT | BITMAP1;
	explode head 		type		SHATTER | EXPLODE_ON_HIT | BITMAP1;
	explode l_forearm2 	type		SHATTER | EXPLODE_ON_HIT | BITMAP3;
	explode left 		type		SHATTER | EXPLODE_ON_HIT | BITMAP3;
	explode right 		type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	explode l_forearm3 	type		FALL  | EXPLODE_ON_HIT | BITMAP3;
	return( 0 );
	}
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Texture Problems

Post by FLOZi »

N.B. Smoth's example is in BOS (source)/COB(compiled file read by Spring) format. There is a new lua format unit script, but it is so new that there are very few examples generally, and most that do exist are for mobile units such as generic tanks etc, rather than factories.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Texture Problems

Post by SanadaUjiosan »

Yeah for the project oksnoop2 and I are working on, we decided to go the way of lua. It's been rough so far, as neither of us really know much of anything about scripting.

So I take it there are basically no building lua scripts for me to use as references?
User avatar
Masse
Damned Developer
Posts: 979
Joined: 15 Sep 2004, 18:56

Re: Texture Problems

Post by Masse »

SanadaUjiosan wrote:So I take it there are basically no building lua scripts for me to use as references?
I head little birds singing and they were saying someone somewhere has building script Luafied somewhere.
So bring your knowledge to everyone! please... Damned needs your examples too!
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

Re: Texture Problems

Post by PTSnoop »

Here's a pretty basic Lua builder script.

Code: Select all

local base = piece "base"
local nanoturret = piece "nanoturret"
local nano = piece "nano"

local SIG_BUILD = 2

function script.Create()
end

function script.StartBuilding(heading, pitch)
	Signal(SIG_BUILD)
	SetSignalMask(SIG_BUILD)
	Turn(nanoturret, y_axis, heading, math.rad(90))
	WaitForTurn(nanoturret, y_axis)
	SetUnitValue(COB.INBUILDSTANCE, 1)
	return 1
end

function script.QueryNanoPiece() return nano end
function script.AimFromWeapon() return nanoturret end

function script.StopBuilding()
	Signal(SIG_BUILD)
	SetSignalMask(SIG_BUILD)
	SetUnitValue(COB.INBUILDSTANCE, 0)
	Turn(nanoturret, y_axis, 0, math.rad(90))
	WaitForTurn(nanoturret, y_axis)
	Sleep(1)
	return 0
end

function script.Killed(recentDamage, maxHealth)
	return 0
end
And here's a similar factory script:

Code: Select all

local building = piece "building"
local nano = piece "nano"
local pad = piece "pad"

function script.Create(unitID)
end

function script.QueryBuildInfo() return pad end
function script.QueryNanoPiece() return nano end

function script.Activate()
	SetUnitValue(COB.YARD_OPEN, 1)
	SetUnitValue(COB.INBUILDSTANCE, 1)
	SetUnitValue(COB.BUGGER_OFF, 1)
	return 1
end

function script.Deactivate()
	SetUnitValue(COB.YARD_OPEN, 0)
	SetUnitValue(COB.INBUILDSTANCE, 0)
	SetUnitValue(COB.BUGGER_OFF, 0)
	return 0
end

function script.Killed(recentDamage, maxHealth)
	return 0
end
User avatar
Masse
Damned Developer
Posts: 979
Joined: 15 Sep 2004, 18:56

Re: Texture Problems

Post by Masse »

PTSnoop wrote:Here's a pretty basic Lua builder script.
Thanks that did it! I wasn't far with my attempts tho :)
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Texture Problems

Post by oksnoop2 »

function script.Deactivate()
SetUnitValue(COB.YARD_OPEN, 0)
SetUnitValue(COB.INBUILDSTANCE, 0)
SetUnitValue(COB.BUGGER_OFF, 0)
return 0
end

What does that mean?^
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

Re: Texture Problems

Post by PTSnoop »

I'm not too sure. It was on the example that I was working from when I wrote my animation scripts, but I don't think it's ever called. I've not tested it, though.

My vague guesses:
function script.Deactivate() - probably originally intended to be called when the factory stops building. It'll probably work more as intended if you use script.StartBuilding() and script.StopBuilding() instead of script.Activate() and script.Deactivate(). Having said that, I've not noticed any problems with using Activate and Deactivate.

SetUnitValue(COB.YARD_OPEN, 0) - set the COB value YARD_OPEN to 0, ie. stop units from being able to move around inside the factory.
SetUnitValue(COB.INBUILDSTANCE, 0) - the factory's not able to build any more.
SetUnitValue(COB.BUGGER_OFF, 0) - stop repelling units out of the factory.
end - end.

Hope any of this answers your question.
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Texture Problems

Post by oksnoop2 »

local building = piece "building"

I don't see "building" anywhere else in the code. Why is it defined?
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Texture Problems

Post by SanadaUjiosan »

Well I greatly appreciate the two scripts you posted, and I'm working on the factory first. But I can't get it to work. As you could probably tell, oksnoop2 is helping me work it out too.

The closest I can get is that my factory has buttons for the units, and I can queue them up, but nothing ever gets built. I've made my factory model have the same objects as the script says it needs, and I just don't know what to think anymore.

I'm going to post all of the files I'm working with. There's the Tank Factory, and then one of the tanks it will build. If someone could look at it and tell me what I'm doing wrong, oksnoop2 and I would be deeply grateful.
Attachments
btankfactory.rar
(98.61 KiB) Downloaded 15 times
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

Re: Texture Problems

Post by PTSnoop »

There's nothing wrong with the files you've given, as far as I can tell. The reason you can't get the factory working is because of the other files in your mod.

Probable solutions:
1) Your tank's got movementClass = "TANK4"; this needs a corresponding movedef in gamedata/MoveDefs.lua . An example:

Code: Select all

local moveDefs =
{
	{
		name = "TANK4",
		footprintX = 2,
		maxWaterDepth = 10,
		maxSlope = 20,
		crushStrength = 25,
	},
}

return moveDefs
2) If your Lua unit animations aren't working, you might need a bunch more files in your LuaRules folder to persuade it to work. I got it working with these (originally from Spring1944, I think):
LuaRules.zip
(1.41 KiB) Downloaded 18 times
I've put the unit in Flozi's empty mod base and got it working.
BTankFactoryMDK.sdz
(103.59 KiB) Downloaded 18 times
EDIT: while I remember, your factory model had two "nano" points. I think it's generally a better idea to give each point a separate name (in the example mod I changed them to "nano" and "nano1"; whether this actually affected anything I'm not sure).

oksnoop: The piece "building" was just included for completeness. I prefer not to have to look these things up in UpSpring if I can't remember what my model's pieces are called. It doesn't affect anything in the script, though.
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Texture Problems

Post by oksnoop2 »

Why are buildings and builders treated differently?

Why does a building need a pad and builder does not?
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Texture Problems

Post by SanadaUjiosan »

Okay well I appreciate your help PTSnoop but I haven't been able to replicate a working factory. I've basically just used the example you uploaded. I'm convinced magic is involved somewhere.

So the next step for me is getting a builder unit to work. Of course, no luck on my end. I copied the lua you posted into the script lua. I used a unit lua from CA for the beaver, but Spring just won't accept it, so I don't know what is going wrong there. I took a unit lua I know that works and used it, and tried changing builder to True, and gave it a build list, but still nothing.

I've got to say, scripts are just an enormous pain. Especially when you have no foundation for understanding them, like I do.

Anyone's assistance would be great.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Texture Problems

Post by SinbadEV »

oksnoop2 wrote:Why are buildings and builders treated differently?

Why does a building need a pad and builder does not?
"Factories" build inside themselves and then order the units to move away, "Builders" build units outside themselves at a specific order-point on the map... so Factories need to have that "location that unit will be built" specified game side (the pad) while Builders have the "location that unit will be built" specified by the player when they issue the order to build.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Texture Problems

Post by KDR_11k »

Note that OPEN_YARD and BUGGER_OFF are not implemented in Spring, the corresponding behaviour is controlled by the engine itself.
Post Reply

Return to “Game Development”