Jump to content


Photo

Theme: Light


  • Please log in to reply
45 replies to this topic

#21 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 21 February 2008 - 10:21 PM

I'd think, that if all the bots would be invisible, then they wouldn't fire any weapons ever, and thus would remain invisible. Easy way to check, would be to play against one bot in a cube room, and take note of whether you can see them or not.

#22 BoomerET

BoomerET
  • Members
  • 10 posts
  • Location:Northern California

Posted 22 February 2008 - 01:00 AM

Yea!!

And it's just things like this that I knew I'd have a reason to use that member who offered to make us maps!!!

(Yes, you are correct, I am unable to make even a simple one-room map).

I'm sure if I studied a couple tutorials, and spent time learning how to do it, I could do it.

But why spend time doing something others do so well and quickly, when I could spend that time learning the code!!!!!


I'm really lovin' this!


BoomerET
Inspire by Example
Posted Image

#23 BoomerET

BoomerET
  • Members
  • 10 posts
  • Location:Northern California

Posted 22 February 2008 - 05:21 AM

Done a bit more testing.

DeathMatch - AI can't see me, unless I fire upon them, or bump into them.

Then if I manage to get out of eyesight, I'm blind to them again.

Strange, to say the least.

I guess not a very useful Mutator, but it is week one :wink_new:
Inspire by Example
Posted Image

#24 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 22 February 2008 - 09:25 AM

Knowing how the editor works is always a good things, as it helps you to better understand how the game works - thus assisting your code.

A cube map is easy - load up UnrealEd, hit the new map button and choose 'subtractive'. Back click on the cube icon, change the values to 8192x8192x8192. Find the subtract button and click that. Put your view mode into 'unlit'. Back click on the middle of the room and add a playerstart, then add a point light. Move the point light to the center of the room and press F4, change it's radius to 8192. Build all on your map, then save it.

One cube map :wink_new:



I'll have a look over your mutator later :)

#25 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 22 February 2008 - 05:39 PM

An update.

I removed the GroupNames= - groups are used when mutators are known to be incompatible. By having the same group names, the mutators can't be used together.

I added one simple line - I changed the player skin to the Nightshade invisible texture. I played a quick game of 'stealthstagib'. It wasn't half bad.

Notably, I noticed that bots don't notice bots unless they walk right next to each other, nor do they notice you. They also notice shooting players/bots or flag/orb carrying bots :wink_new:

//-----------------------------------------------------------
//
//  - CUSM - Can You See Me
//  Written/tested by BoomerET (BoomerET@gmail.com)
//
//  Coded for Mutator Week/Shee Labs
//  When a player starts, he is invisible to AI (bots)
//  Once you touch a flag, or fire a weapon, or something else?
//  You are then fair game.
//
//-----------------------------------------------------------
class DB_Mutator_CUSM extends UTMutator;

var material StealthMaterial;

function ModifyPlayer(Pawn P)
{
	if ( UTPawn(P) != None )
	{
		UTPawn(P).SetInvisible(true);
		
		UTPawn(P).SetSkin(StealthMaterial);
	}
	super.ModifyPlayer(P);
}

DefaultProperties
{
   // Is anything really necessary here?
   name="Default__UTMutator_CanUSeeMe"
   StealthMaterial=Material'VH_NightShade.Materials.M_VH_NightShade_Skin'
}


#26 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 26 February 2008 - 08:32 AM

Hi all,
I have a question on defaultproperties, I'm facing a weird behavior.

I define a really simple GameRules

class EA_HTBHTW_Rules extends GameRules;

var int m_bonus;
var int m_malus;

function ScoreKill(Controller Killer, Controller Killed){

 LogInternal("Bonus value is: "@m_bonus);
 LogInternal("Malus value is: "@m_malus);
}

defaultproperties{
 m_bonus = 5;
 m_malus = 5;
}

Compilation and run work. However in my log file I have always:
Bonus value is: 0
Malus value is: 0

I didn't test a lot because it was late yesterday night. perhaps it's only typo mistakes but I find strange the compiler didn't see them.

Any help on defaultproperties is appreciated :xcahik_:


Another weird behavior
class EA_HTBHTW_Rules extends GameRules;

var int m_bonus;
var int m_malus;

function ScoreKill(Controller Killer, Controller Killed){

 LogInternal("Bonus value is: "@m_bonus);
 LogInternal("Malus value is: "@m_malus);
}

defaultproperties{
 bonus = 5;
 malus = 5;
}
this code compiles although the fields in defaultproperties are wrong

#27 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 26 February 2008 - 09:47 AM

Guidlines for Writing Code

Formatting is everything. You may have your own particular style, but in this case, you've been vetoed - the project will have all code written the Epic way - all those other little bits and pieces you sometimes like to rearrange. This organisation helps others read your code, and thus helps you improve it, as well as preventing potential annoying errors from occuring!

  • Parenthesis (squiggly brackets) always on their own lines.
  • DefaultProperties defined clearly at the bottom.
  • Tab out and indent your code to make it easy to read.
  • Always fully-qualify class names - this means means 'packagename.classname', not just 'classname'.


This is from the guidlines - stick to them!

Unreal does not use 'one true brace' style syntax, which is why it's not reading your default properties :xcahik_:

#28 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 26 February 2008 - 10:12 AM

Welcome back to Uscript Erwan :xcahik_:

if it's only this, i would be able to release something before thursday :xcahik_:

Thanks Luke

#29 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 26 February 2008 - 10:13 AM

Sounds good. I'm trying to squeeze an extra one out before the end of today too :xcahik_:

#30 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 27 February 2008 - 08:32 AM

All right here we go, I 've finally succeeded to release something.

The mutator'name is HTBHTW (Hit The Best Help The Worst). It 's dedicated for those (like me) who know Unrealscript but who never play UT ( called newbie I guess :shiftee:)
The mutator starts when the first kill occurs, it gives bonus or malus according to the player score (see Mutator header for more details)

Posted Image


//-----------------------------------------------------------
//
//  - HTBHTW - Hit The Best Help The Worst
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  The GameRule Logic works on the scoreKill Method. It gives
//  malus to player who kill the worst player and bonus to player
//  who kill the best player.
//  Malus and Bonus are for now hardCoded in the defaultproperties and have the
//  following values (An UIScene Mutator Configuration could be added):
//	- m_bonus = 2;
//	- m_malus = 2;
//  Each time a scoreKill is performed, the best and worst player are updated
//  They can be recognise into the game by a Green Halo for best player and
//  Red Halo for worst player.
//  This GameRule intends to equilibrate match facing skills player and rookie
//-----------------------------------------------------------
class EA_HTBHTW_Mutator extends UTMutator;

var class<GameRules> GRClass;

function InitMutator(string Options, out string ErrorMessage)
{
	WorldInfo.Game.AddGameRules(GRClass);

	Super.InitMutator(Options, ErrorMessage);
}

DefaultProperties
{
	GRClass=class'MWLight.EA_HTBHTW_Rules'
	name="Hit The Best Help the Worst"
}


The GameRule
//-----------------------------------------------------------
//
//  - HTBHTW - Hit The Best Help The Worst
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//-----------------------------------------------------------
class EA_HTBHTW_Rules extends GameRules;

var Controller m_bestPlayer;
var Controller m_worstPlayer;

var PointLightComponent m_bestPlayerLight;
var PointLightComponent m_worstPlayerLight;

var int m_bonus;
var int m_malus;

var color redColor;
var color greenColor;

function ScoreKill(Controller Killer, Controller Killed)
{

	local int killerId, killedId, bestPlayerId, worstPlayerId;

	killerId = Killer.playerReplicationInfo.PlayerId;
	killedId = Killed.playerReplicationInfo.PlayerId;
	bestPlayerId = getBestPlayerId();
	worstPlayerId = getWorstPlayerId();

	//check if the killed player is the worst player => malus
	if(killedId == worstPlayerId)
		setMalus(killer);

	//check if the killed player is the best player = >bonus
	if(killedId == bestPlayerId)
		setBonus(killer);

	//check if the killer was the worst player => bonus
	if(killerId == bestPlayerId)
		setBonus(killer);

	//update status best and worst player
	updateControllersStatus(killedId);
}

/**
* The best player is the player who has the maximum score and minimum death
*/
function int getBestPlayerId()
{
	local int i;
	local PlayerReplicationInfo bestPlayer, currentPlayer;
	for(i=0;i<worldInfo.GRI.PRIArray.length;i++)
	{
		currentPlayer = worldInfo.GRI.PRIArray[i];
		if(i==0)
			bestPlayer = currentPlayer;

		if(bestPlayer!=none && bestPlayer.score < currentPlayer.score)
			bestPlayer = currentPlayer;

		else if(bestPlayer!=none && bestPlayer.score == currentPlayer.score)
		{
		   if(bestPlayer.deaths > currentPlayer.deaths)
			 bestPlayer = currentPlayer;
		}

	}
	return bestPlayer.playerId;
}

/**
* The worst player is the player who has the minimum score and the maximum deaths
*/
function int getWorstPlayerId()
{
	local int i;
	local PlayerReplicationInfo worstPlayer, currentPlayer;
	for(i=0;i<worldInfo.GRI.PRIArray.length;i++)
	{
		currentPlayer = worldInfo.GRI.PRIArray[i];
		if(i==0)
			worstPlayer = currentPlayer;

		if(worstPlayer!=none && worstPlayer.score > currentPlayer.score )
			worstPlayer = currentPlayer;

		else if(worstPlayer!=none && worstPlayer.score == currentPlayer.score)
		{
		   if(worstPlayer.deaths < currentPlayer.deaths)
			 worstPlayer = currentPlayer;
		}
	}
	return worstPlayer.playerId;
}

/**
* update PointLightComponent which tells other players who is the worst and
* the best
*/
function updateControllersStatus(int killedId)
{
	local Controller controller;
	local int bestPlayerId, worstPlayerId, currentPlayerId;


	bestPlayerId = getBestPlayerId();
	worstPlayerId = getWorstPlayerId();

	if(bestPlayerId == worstPlayerId)
	   return;

	//detach previous light component
	if(m_bestPlayer!=None && m_bestPlayer.pawn != None)
	   m_bestPlayer.pawn.detachComponent(m_bestPlayerLight);

	if(m_worstPlayer!=None && m_worstPlayer.Pawn != None)
	   m_worstPlayer.pawn.detachComponent(m_worstPlayerLight);

	m_bestPlayer = None;
	m_worstPlayer = None;

	//create the point light
	if(m_bestPlayerLight == None)
	   m_bestPlayerLight = createPointLight(false);

	if(m_worstPlayerLight == None)
	   m_worstPlayerLight = createPointLight(true);

	//retrieve best and worst controller
	ForEach DynamicActors(class'Controller', controller)
	{
		currentPlayerId = controller.PlayerReplicationInfo.PlayerId;

		if(m_bestPlayer != None && m_worstPlayer != None) //if best and worst found break
			break;

		if(currentPlayerId == bestPlayerId && currentPlayerId != killedId)
			m_bestPlayer = controller;

		if(currentPlayerId == worstPlayerId && currentPlayerId != killedId)
			m_worstPlayer = controller;
	}

	//attach the light ccmponent
	if(m_bestPlayer!=none && m_bestPlayer.Pawn != None)
	  m_bestPlayer.pawn.attachComponent(m_bestPlayerLight);

	if(m_worstPlayer!=none && m_worstPlayer.pawn!=None)
	  m_worstPlayer.pawn.attachComponent(m_worstPlayerLight);
}


function setBonus(Controller c)
{
	c.PlayerReplicationInfo.score += m_bonus;
	c.PlayerReplicationInfo.bForceNetUpdate = true;
	c.PlayerReplicationInfo.Kills+= m_bonus;
}

function setMalus(Controller c)
{
	c.PlayerReplicationInfo.score -= m_malus;
	c.PlayerReplicationInfo.bForceNetUpdate = true;
	c.PlayerReplicationInfo.Kills -= m_malus;
}

/**
 *create the PointLightComponent that will be attached to the pawn's controller
 *@param red: whether the pointLight is red <true> or green <false>
 */
function PointLightComponent createPointLight(bool red)
{
  local PointLightComponent plc;
  local class<PointLightComponent> plcClass;


  plcClass = class'Engine.PointLightComponent';
  plc = new (self)plcClass;

  plc.Radius=250;
  plc.SetEnabled(true);
  if(red)
	  plc.SetLightProperties(1000, redColor);
  else
	  plc.SetLightProperties(1000, greenColor);
  return plc;
}


defaultproperties
{
	m_bonus = 2
	m_malus = 2

	redColor =  (R=255,G=0,B=0,A=255);
	greenColor = (R=0,G=255,B=0,A=255);
}

As soon as Luke told me about defaultproperties brackets, the bonus/malus stuff works perfectly.
The hardest part was "How do I tell the other that this controller is the best or the worst ?"
I was thinking about a light ball over player head. So I use a derivate of ActorComponent (PointLightComponent) and use attach and detachComponent from actor class of worst and best controller pawn. But I was not able to add a relative location (above head) so I increase the radius of the light.

There are few times where I'm facing some problem with detachComponent on dead pawn as it is no longer possessed by the controller.

A mutator configuration menu could be added in order to specify the malus and bonus (Luke's tutorial ? :p).

I'll upload files tonight. In the mean time, if you see something I can modify

Erwan

#31 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 27 February 2008 - 09:45 AM

Looking pretty good, I'll have to give it a spin at lunch. You could potentially cut down the red and green values a bit since UE3 uses floating points between 1 and 0 to define parameters - 255 is pretty overkill, since this is red * 255, rather than just pure red :shiftee:

#32 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 27 February 2008 - 10:41 AM

Oh I didn't know, I see how color was made in different classes, it was integer between 0-255, I 'll try.

In fact, I didn't manage to create the effect I was looking for. I tried making a light ball above the pawn which does not enlight too much the pawn (like a simple Indicator in fact) because, for now, the players with those LightBall see life in Green or Red :shiftee: not really what I want.

I look to Projectile stuff suck as LinkProjectile or UTProj_ShockBall but I was not able to correctly attached them to the pawn

#33 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 27 February 2008 - 11:21 AM

What about the Warfare orb? That's a pretty close approximation, as it attaches to and sits a little above and behind the player?

Edit: I see what you mean now. It would appear that light uses Color and not LinearColor, which is unusual, since LinearColor would do the same thing, and is used everywhere else. In which case, values of 255 may be meaningful after all if we're talking lights.

Edited by ambershee, 27 February 2008 - 01:01 PM.


#34 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 27 February 2008 - 12:54 PM

I'll check that, as I wrote in previous posts, I'm a complete noob player. In Ut2004, I didn't know what vehicle was a HellBender but I knew what was an ONSPRV :shiftee:

#35 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 27 February 2008 - 02:07 PM

//-----------------------------------------------------------
//
//  LP_Flashlight - Headlamp
//  Written by Luke 'ambershee' Parkes-Haskell (ambershee@gmail.com)
//
//	Mutator Week One: Light
//	Attaches a dynamic spotlight to the player.
//	Added to pad the release package.
//-----------------------------------------------------------

class LP_Mutator_Flashlight extends UTMutator;

function ModifyPlayer(Pawn Other)
{
	local SkeletalMeshSocket SMS;
	local name HeadShotSocketName;
	local SpotLightComponent LightAttachment;
	local Color LightColour;
	
	if (Other.IsA('UTPawn'))
	{
		HeadShotSocketName = UTPawn(Other).GetFamilyInfo().default.HeadShotGoreSocketName;
		
		SMS = UTPawn(Other).Mesh.GetSocketByName( HeadShotSocketName );

		if( SMS != none )
		{
			LightAttachment = new(self) class'SpotLightComponent';
			
			//LightAttachment.Brightness = 1.5;
			//LightAttachment.LightColor = (R = 255, G = 255, B = 255);
			//LightAttachment.bEnabled = true;
			
			if (UTPawn(Other).Controller.PlayerReplicationInfo.Team.TeamIndex == 0)
			{
				LightColour.R = 255;
				LightColour.G = 25;
				LightColour.B = 25;
			}
			else if (UTPawn(Other).Controller.PlayerReplicationInfo.Team.TeamIndex == 1)
			{
				LightColour.R = 25;
				LightColour.G = 25;
				LightColour.B = 255;
			}
			else
			{
				LightColour.R = 255;
				LightColour.G = 255;
				LightColour.B = 255;
			}
			
			LightAttachment.SetLightProperties(100, LightColour);
			
			LightAttachment.CastDynamicShadows = true;
			LightAttachment.SetEnabled(true);
			
			//UTPawn(Other).Mesh.AttachComponentToSocket( LightAttachment, HeadShotSocketName );
			UTPawn(Other).AttachComponent(LightAttachment);
			
		}
	}
}

DefaultProperties
{
}

And there's the one I was working on to pad out the package. It's getting there. I'm going to have the light only come up under certain circumstances that I haven't decided yet. Making it player optional should be good - but that involves intercepting a key bind, which I don't want to do. Perhaps if the player has certain weapons up instead.

Also, I noticed something interesting with the team-indexes on this one - if you try the code, you still get a red torch in free for all. I was under the impression that in FFA (DM), the player had no team, and thus the teamindex should be 255 by default like it was in 2k4. I'm going to have to take a look at that and check for the right values! The brightness is also up too high, but I needed to make it obvious for testing :shiftee:

Edited by ambershee, 27 February 2008 - 02:07 PM.


#36 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 27 February 2008 - 03:39 PM

Nice !
It gives me a new idea "Threat Cone"!! something like Commandos maybe for next mutator :shiftee:

#37 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 28 February 2008 - 08:34 AM

Double post
Thanks Luke for svn, I won't be able to make any modification today. If you intend to release the package, consider mine as finish (Even if I have extra thing to test and try will be for next mutator :alien: )

#38 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 28 February 2008 - 11:48 AM

Ok, no worries. I'll be knocking it together and making a public release later :alien:

Edit: Doing the final bugfixin's now.

I changed your ScoreKill function as it was clashing with other mutators - I appended the following:

if ( NextGameRules != None )
	{
		NextGameRules.ScoreKill(Killer,Killed);
	}

This means that if there is another GameRules being used (such as my Flare mutator), it will also call the ScoreKill function in that rules - so that classes both derived from the same parent can call the same function properly. I'm adding similar code to the other mutators to revolve conflicts too.

Edited by ambershee, 28 February 2008 - 02:32 PM.


#39 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 28 February 2008 - 09:24 PM

yeah you 're right, I check other GameRules. That'a weird behavior however

Edited by xiongmao, 28 February 2008 - 09:25 PM.


#40 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 28 February 2008 - 11:13 PM

Well, it's not very often that you have two subclass functions of that all need to happen at the same time - ScoreKill however is one of them - both events needs to happen, and both have the same parent. In this instance, we check to see if there are any other GameRules ScoreKill functions remaining to be called, and execute them. Otherwise, we'd call ScoreKill, and every time we'd also call the parent function in GameRules - which must only happen once!

Catch the drift ;)?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users