Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 48 Guests
Online:

LATEST FORUM THREADS

»
coduo mapping tools
CoDUO Mapping
Gaming
Q4 General
eXtreme+ v2.9
CoDBO Map + Mod Releases
map loading error
CoD2 MP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: setWaypoint() problem
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Oct. 17, 2012 10:43 am
Hey!

I try to create a bar + background with the setWaypoint()-function.
the problem is: if my HUD uses setWaypoint() it will ignore alpha, color, and the size of setShader() or scaleOverTime() also setValue()
is setWaypoitn() only supporting static shaders/strings? ~.~
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Wednesday, Oct. 17, 2012 02:07 pm
serthy writes...
Quote:
Hey!

I try to create a bar + background with the setWaypoint()-function.
the problem is: if my HUD uses setWaypoint() it will ignore alpha, color, and the size of setShader() or scaleOverTime() also setValue()
is setWaypoitn() only supporting static shaders/strings? ~.~


Waypoints are really 3D world entities, even though they it takes either a level or client hud element to create them. They are shaders only. No strings. You cannot create 3D strings as waypoints (wish that you could!). As they are shaders, you cannot use functions like scaleover() or setValue(). You can't do that with standard shader hud elements, irrespective of whether they are waypoints or not. As long as you get the principle that they are shaders, you can use most - if not all - of standard shader functions on a waypoint.

For example, there are a number of attributes you mention that waypoints do accept: alpha and size, although the size is a relative one, depending on how big you want the 3D world effect to look.

This is the waypoint code from stock CTF:

Code:
createFlagWaypoint()
{
	self deleteFlagWaypoint();

	waypoint = newHudElem();
	waypoint.x = self.origin[0];
	waypoint.y = self.origin[1];
	waypoint.z = self.origin[2] + 100;
	waypoint.alpha = .61;
	waypoint.archived = true;

	if(level.splitscreen)
		waypoint setShader(self.objpointflag, 14, 14);
	else
		waypoint setShader(self.objpointflag, 7, 7);

	waypoint setwaypoint(true);
	self.waypoint = waypoint;
}


As you can see, it has both alpha and size attributes.

As a more complex example of waypoint coding, here is my bombsquad code from Demon mod for COD2:

Code:
setupBombSquad()
{
	self.bombSquadIds = [];
	
	if( isDefined( self.detectExplosives ) && !self.bombSquadIcons.size )
	{
		for( index = 0; index < 4; index++ )
		{
			self.bombSquadIcons[index] = newClientHudElem( self );
			self.bombSquadIcons[index].x = 0;
			self.bombSquadIcons[index].y = 0;
			self.bombSquadIcons[index].z = 0;
			self.bombSquadIcons[index].alpha = 0;
			self.bombSquadIcons[index].archived = true;
			self.bombSquadIcons[index] setShader( "waypoint_bombsquad", 13, 13 );
			self.bombSquadIcons[index] setWaypoint( false );
			self.bombSquadIcons[index].detectId = "";
		}
	}
	else if( !isDefined( self.detectExplosives ) )
	{
		for( index = 0; index < self.bombSquadIcons.size; index++ )
			self.bombSquadIcons[index] destroy();
			
		self.bombSquadIcons = [];
	}
}

showHeadIcon( trigger )
{
	triggerDetectId = trigger.detectId;
	useId = -1;
	for( index = 0; index < 4; index++ )
	{
		detectId = self.bombSquadIcons[index].detectId;

		if( detectId == triggerDetectId )
			return;
			
		if( detectId == "" )
			useId = index;
	}
	
	if( useId < 0 )
		return;

	self.bombSquadIds[triggerDetectId] = true;
	
	self.bombSquadIcons[useId].x = trigger.origin[0];
	self.bombSquadIcons[useId].y = trigger.origin[1];
	self.bombSquadIcons[useId].z = trigger.origin[2]+24+128;

	self.bombSquadIcons[useId] fadeOverTime( 0.25 );
	self.bombSquadIcons[useId].alpha = 1;
	self.bombSquadIcons[useId].detectId = trigger.detectId;
	
	while( isAlive( self ) && isDefined( trigger ) && self isTouching( trigger ) )
		wait( 0.05 );
		
	if( !isDefined( self ) )
		return;
		
	if( !isDefined( self.bombSquadIcons[useId] ) )
		return;
		
	self.bombSquadIcons[useId].detectId = "";
	self.bombSquadIcons[useId] fadeOverTime( 0.25 );
	self.bombSquadIcons[useId].alpha = 0;
	self.bombSquadIds[triggerDetectId] = undefined;
}


As you can see it has all sorts of attributes like size, alpha, and even fadeOverTime().
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Oct. 17, 2012 02:25 pm
wow thanks again Tally!

well this sucks :( but yeha, this explains it why all cod's uses shaders as waypoints (didnt think of that)
this way i have to forget about some nice looking bars as waypoints, mhh damnit so i have to rethink and use some other workarounds to create some hud elements that arent this 'standart'
maybe there is a way for it.. ill keep u updated!

and thanks again Tally!

edited on Oct. 17, 2012 02:47 pm by serthy

on setWaypoint() setShader( shader , length , width ) >> length == width!
there is no other way, the shader is a square..
it scales just fine, but it will remains squared.
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Oct. 19, 2012 05:52 pm
another problem on the HUD's: is there a way to have a loadbar that goes from the bottom to the top?
its easy to manage bars that goes from the left to the right and also from the top to the bottom, but the reverse ones are nuts!
the bars starts somewhere in nirvana , scales over time and aligns only at the very end to its supposed sizes..

maybe im missing something at this time

cheers serthy
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Oct. 20, 2012 03:49 am
Easy:
Start off with your loading bar at the bottom. Make it scaleovertime() to the correct size. Then, call moveovertime() (or smthing similar) to move it to the TOP of the surrounding hud element in the exact same time.

tl;dr: combine moveovertime() with scaleovertime() and be smart about it.
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Saturday, Oct. 20, 2012 05:50 am
hell yeah, thank you, this is working!

my problem now:
sometimes the bar is at the wrong position and moves to the place where it should be for either the movetime or just for a frame

here is my code:
Code:
/*>> self == trigger * * */
monitorPlayer( player )
{
	self endon( "death" );

	size = 60;		/* * *  size of the bar * * */
	border = 3;		/* * * surrounding box is abit larger thn the bar * * */
	xOffset = -100;	/* * * xPos * * */
	yOffset = 0;	/* * * yPos * * */

	/* * * cleanup * * */
	if( isDefined( player.hud_box ) )
		player.hud_box destroy();
	if( isDefined( player.hud_bar ) )
		player.hud_bar destroy();

	for( ; ; )
	{
		if( !isDefined( player ) )
			break;
		else if( player.sessionstate != "playing" )
			break;
		else if( !player isTouching( self ) )
			break;

		if( !isDefined( player.hud_box ) )	/* * * draw the surrounding box (static frame) * * */
		{
			player.hud_box = newClientHudElem( player );
			player.hud_box.x = xOffset - border;
			player.hud_box.y = yOffset - border;
			player.hud_box.horzAlign = "right";
			player.hud_box.vertAlign = "middle";
			player.hud_box setShader( "serthy_box" , size + ( 2 * border ) , size + ( 2 * border ) );
		}

		if( !isDefined( player.hud_bar ) )
		{
			player.hud_bar = newClientHudElem( player );
			player.hud_bar.x = xOffset;
			player.hud_bar.y = yOffset + ( size * ( 1 - self.ratio ) );
			player.hud_bar.horzAlign = "right";
			player.hud_bar.vertAlign = "middle";
			player.hud_bar.rate = 100;
		}

		/* * * if the rate of the bar changes... * * */
		if( player.hud_bar.rate != self.rate )
		{
			player.hud_bar.rate = self.rate;	/* * * assign the new change-rate (speed of the bar) * * */
			player.hud_bar setShader( "white" , size , max( 1 , int( ( size * self.ratio ) + 0.5 ) ) );	/* * * set the shader (range: 1-size) * * */

			/* * * self.ratio = current bar fraction * * */
			if( self.rate > 0 && self.ratio < 1 ) /* * * bar should scale from the bottom to the top * * */
			{
				/* * * time is calculating correct * * */
				time = ( 1 - self.ratio ) / ( 20 / self.captureTime * self.rate );

				player.hud_bar scaleOverTime( time , size , size );
				player.hud_bar moveOverTime( time );
				player.hud_bar.x = xOffset;
				player.hud_bar.y = yOffset; /* * * bar is at the top * * */
			}
			else if( self.rate < 0 && self.ratio > 0 ) /* * * bar should scale from the top to the bottom * * */
			{
				/* * * time is calculating correct * * */
				time = self.ratio / ( -1 * ( 20 / self.captureTime * self.rate ) );

				player.hud_bar scaleOverTime( time , size , 1 );
				player.hud_bar moveOverTime( time );
				player.hud_bar.x = xOffset;
				player.hud_bar.y = yOffset + size; /* * * bar is at the bottom * * */
			}
		}

		wait( 0.05 );
	}

	/* * * cleanup * * */
	if( isDefined( player ) )
	{
		if( isDefined( player.hud_box ) )
			player.hud_box destroy();
		if( isDefined( player.hud_bar ) )
			player.hud_bar destroy();
	}
}


hopefully its not an engine bug ~.~

edited on Oct. 20, 2012 05:59 am by serthy

this is freaking me out... i never have used a moveOverTime on the hud_box element, but sometimes its moving! lol i guess i have to optimize my code -.-

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EDIT: i located it, but it seems there will be no solution..

code:
Code:
monitorPlayer( player )
{
	self endon( "death" );

	size = 60;
	border = 3;
	xOffset = -100;
	yOffset = 0;
	
	if( isDefined( player.hud_basezonebar_bar ) )
		player.hud_bar destroy();
	if( isDefined( player.hud_box ) )
		player.hud_box destroy();

	player.hud_box = newClientHudElem( player );
	player.hud_box.x = xOffset - border;
	player.hud_box.y = yOffset - border;
	player.hud_box.horzAlign = "right";
	player.hud_box.vertAlign = "middle";
	player.hud_box.color = ( 1 , 1 , 1 );
	player.hud_box.foreground = true;
	player.hud_box.sort = -1;
	player.hud_box.archived = true;
	player.hud_box setShader( "serthy_basezone_box" , size + ( 2 * border ) , size + ( 2 * border ) );
	player.hud_box.alpha = 1;

	player.hud_bar = newClientHudElem( player );
	player.hud_bar.x = xOffset;
	player.hud_bar.y = yOffset + ( size * ( 1 - self.ratio ) );
	player.hud_bar.horzAlign = "right";
	player.hud_bar.vertAlign = "middle";
	player.hud_bar.alpha = 1.0;
	player.hud_bar.foreground = true;
	player.hud_bar.sort = -2;
	player.hud_bar.rate = 100;
	player.hud_bar.archived = true;
	player.hud_bar setShader( "white" , size , max( 1 , int( ( size * self.ratio ) + 0.5 ) ) );

	for( ; ; )
	{
		wait( 0.05 );

		if( !isDefined( player ) )
			break;
		else if( player.sessionstate != "playing" )
			break;
		else if( !player isTouching( trigger ) )
			break;

		if( player.hud_bar.rate != self.rate )
		{
			player.hud_bar.rate = self.rate;
			player.hud_bar setShader( "white" , size , max( 1 , int( ( size * self.ratio ) + 0.5 ) ) );

			if( self.rate > 0 && self.ratio < 1 )
			{
				time = ( 1 - self.ratio ) / ( 20 / self.captureTime * self.rate );

				player.hud_bar scaleOverTime( time , size , size );
				player.hud_bar moveOverTime( time );
				player.hud_bar.x = xOffset;
				player.hud_bar.y = yOffset;
			}
			else if( self.rate < 0 && self.ratio > 0 )
			{
				time = self.ratio / ( -1 * ( 20 / self.captureTime * self.rate ) );

				player.hud_bar scaleOverTime( time , size , 1 );
				player.hud_bar moveOverTime( time );
				player.hud_bar.x = xOffset;
				player.hud_bar.y = yOffset + size - 1;
			}
			else
			{
				player iprintlnbold( "^1STOP FRIGGIN MOVEOVERTIME" );
			}
		}
	}

	if( isDefined( player ) )
	{
		if( isDefined( player.hud_box ) )
			player.hud_box destroy();
		if( isDefined( player.hud_bar ) )
			player.hud_bar destroy();
	}
}


guess what happens... yeah you are right, the HUD's move while it prints me the message >.<
so how to stop this moveovertime()?
i tried without success:
> setshader()
> setshader() + setting the x and y coords
> destroy the hud and recreate it without moveovertime() + right coords
> destroy the hud + wait a frame + recreate it without moveovertime() + right coords

the result remains the same: the bar is moving from the topleft to its position
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Oct. 20, 2012 08:51 am
Try to set x and y coordinates. Just that.

Works with normal moveto()
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Oct. 20, 2012 11:24 am
More solution:

set hud.aligny to "top" to make it go down.
easy fix is better :)
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, Oct. 25, 2012 06:35 am
okay it seems like either my other code is messed up or the cod2 installment is kind of damaged

i noticed that the damagefeedback onetime was also moving, without having modified this.. so ill reinstall cod2 and hope it will work then

cheers serthy
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»