Jump to content


Photo

Theme: Surprise


  • Please log in to reply
34 replies to this topic

#1 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 01 March 2008 - 06:00 PM

The second theme is out - this week, it's Surprise!

Hand in date is Sunday the 9th of March.

#2 Bob Chatman

Bob Chatman
  • New Members
  • 4 posts

Posted 01 March 2008 - 06:10 PM

Im on it!

Are we sharing ideas? I have 6 already on paper.

#3 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 01 March 2008 - 06:14 PM

You can share anything you like. I had plenty, so I've already started a couple that have some partial code on Subversion, haha.

#4 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 01 March 2008 - 10:04 PM

That's unfair Luke must have pieces of code for the next 2000 Mutator Week :p
Surprise ? Hmm let's see what can I find :thumbsdownsmiley:

#5 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 01 March 2008 - 10:07 PM

Haha, I only wrote a few snippets, and only a few hours ago :thumbsdownsmiley:

I'll try and get them done tommorow, but I always have trouble finding time.

#6 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 02 March 2008 - 10:44 PM

Hi All, I found some hours this sunday evening to release something.
The mutator is quite simple, It consists in reinitialising randomly all WeaponPickup and ammopickup. The purpose was to use new feature of UT3 such as interface.

Here is the code.

Mutator

//-----------------------------------------------------------
//
//  - Surprise Weapon Factory -  EA_SurpriseFactory_Mutator
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  When the game starts, All WeaponPickup factory are reinitialised
//  randomly. Each new weaponPickup initialised are stored in an array
//  used to initialise randomly AmmoPickup.
//
//  The mutator aims to show how to use, array and interface
//-----------------------------------------------------------
class EA_SurpriseFactory_Mutator extends UTMutator;

var array<class<UTWeapon> > allWeaponClasses[9];
var array<class<UTAmmoPickupFactory> > allAmmoPickupFactory[8];
var EA_SurpriseFactory_MapInterface mapWeaponAmmoClass;

//array filled during WeaponPickupFactory reinitialisation (checkReplacement)
var array<class<UTWeapon> > spawnedWeaponClasses;

event PostBeginPlay()
{
  super.PostBeginPlay();

  initWeaponArray();
  initAmmoArray();
}

/*
 *fill array with weapon class known
 */
function initWeaponArray()
{
	allWeaponClasses[0] = class'UTGameContent.UTWeap_Avril_Content';
	allWeaponClasses[1] = class'UTGameContent.UTWeap_BioRifle_Content';
	allWeaponClasses[2] = class'UTGame.UTWeap_FlakCannon';
	allWeaponClasses[3] = class'UTGame.UTWeap_LinkGun';
	allWeaponClasses[4] = class'UTGame.UTWeap_RocketLauncher';
	allWeaponClasses[5] = class'UTGame.UTWeap_ShockRifle';
	allWeaponClasses[6] = class'UTGame.UTWeap_SniperRifle';
	allWeaponClasses[7] = class'UTGame.UTWeap_Stinger';
	  allWeaponClasses[8] = class'UTGameContent.UTWeap_Redeemer_Content';
}

/*
 *fill array with ammo class known and also linked weapon class to ammo class
 */
function initAmmoArray()
{
	allAmmoPickupFactory[0] = class'UTGameContent.UTAmmo_Avril';
	allAmmoPickupFactory[1] = class'UTGameContent.UTAmmo_BioRifle_Content';
	allAmmoPickupFactory[2] = class'UTGame.UTAmmo_FlakCannon';
	allAmmoPickupFactory[3] = class'UTGame.UTAmmo_LinkGun';
	allAmmoPickupFactory[4] = class'UTGame.UTAmmo_RocketLauncher';
	allAmmoPickupFactory[5] = class'UTGame.UTAmmo_ShockRifle';
	allAmmoPickupFactory[6] = class'UTGame.UTAmmo_SniperRifle';
	allAmmoPickupFactory[7] = class'UTGame.UTAmmo_Stinger';

	mapWeaponAmmoClass = new(self)class'EA_SurpriseFactory_StandardMap';

	mapWeaponAmmoClass.put(allWeaponClasses[0], allAmmoPickupFactory[0]);
	mapWeaponAmmoClass.put(allWeaponClasses[1], allAmmoPickupFactory[1]);
	mapWeaponAmmoClass.put(allWeaponClasses[2], allAmmoPickupFactory[2]);
	mapWeaponAmmoClass.put(allWeaponClasses[3], allAmmoPickupFactory[3]);
	mapWeaponAmmoClass.put(allWeaponClasses[4], allAmmoPickupFactory[4]);
	mapWeaponAmmoClass.put(allWeaponClasses[5], allAmmoPickupFactory[5]);
	mapWeaponAmmoClass.put(allWeaponClasses[6], allAmmoPickupFactory[6]);
	mapWeaponAmmoClass.put(allWeaponClasses[7], allAmmoPickupFactory[7]);
}

function bool CheckReplacement(Actor Other)
{
	local class<UTWeapon> UTNewWeaponClass;
	local class<UTAmmoPickupFactory>  UTNewAmmoPickupFactory;

	if(Other.IsA('UTWeaponPickupFactory'))
	{

	   //reinitialise the weapon class
	   UTNewWeaponClass = allWeaponClasses[Rand(9)];
	   UTWeaponPickupFactory(Other).WeaponPickupClass = UTNewWeaponClass;
	   UTWeaponPickupFactory(Other).InitializePickup();

	   //store the new weapon class
	   if( spawnedWeaponClasses.find(UTNewWeaponClass) == -1)
		spawnedWeaponClasses.addItem(UTNewWeaponClass);
	}
	else if ( Other.IsA('UTAmmoPickupFactory'))
	{
	   /* if new weapon classes exist, get randomly one of this weaponclass
		* then in the map<class<UTWeapon>, class<UTAmmoPickupFactory>> retrieve
		* the UTAmmoPickupFactory associated to the current weaponclass
		*/
	   if(spawnedWeaponClasses.length > 0)
		 UTNewAmmoPickupFactory = class<UTAmmoPickupFactory>(mapWeaponAmmoClass.getValue(spawnedWeaponClasses[Rand(spawnedWeaponClasses.Length)]));

	   else
		 UTNewAmmoPickupFactory =  allAmmoPickupFactory[Rand(8)];

	   UTAmmoPickupFactory(Other).TransformAmmoType(UTNewAmmoPickupFactory);
	}

	return true;
}
defaultproperties
{
}
Interface

//-----------------------------------------------------------
//
//  - Surprise Weapon Factory -  EA_SurpriseFactory_MapInterface
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  This is the interface of all map
//-----------------------------------------------------------
interface EA_SurpriseFactory_MapInterface;

function Object getValue(Object key);

function put(Object key, Object value);

function int getObjectCount();

function bool containsKey(Object key);

function bool containsValue(Object value);

function dump();

Implementation of Interface

//-----------------------------------------------------------
//
//  - Surprise Weapon Factory -  EA_SurpriseFactory_StandardMap
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  This is the standard implementation of EA_SurpriseFactory_MapInterface
//  It is used to store data which is a pair of key and value
//-----------------------------------------------------------
class EA_SurpriseFactory_StandardMap extends Object
			  implements ( EA_SurpriseFactory_MapInterface );

var array<Object> keys;
var array<Object> values;

function Object getValue(Object key)
{
  local int i;
  local int indexFound;

  indexFound = -1;
  for(i=0;i<keys.length;i++)
  {
	 if( keys[i] == key)
	 {
		indexFound = i;
		break;
	 }
  }

  if(indexFound > -1)
	return values[indexFound];

  return none;
}

function put(Object key, Object value)
{
  if(key != None)
  {
	keys.addItem(key);
	values.addItem(value);
  }
}

function int getObjectCount()
{
  return keys.length;
}

function bool containsKey(Object key)
{
   if(keys.find(key) > -1)
	 return true;

   return false;
}

function bool containsValue(Object value)
{
   if(values.find(value) > -1)
	 return true;

   return false;
}

function dump()
{
  local int i;
  for(i=0;i<keys.length;i++)
	LogInternal("Row "@i@" key: "@keys[i]@" value: "@values[i]);
}


someone can tell me:
- is there a way to get weapon list such as Class'CacheManager'.static.getWeaponlist in UT2004
- How can i set a friendly name and a description to the mutator as i didn't see anymore these fields

Any comment is appreciated :popcorn:

#7 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 03 March 2008 - 10:43 AM

Take a look at the weapon replacement mutator, that should go through all the weapons. Friendly name and description are generally set in the ini config file, although you can still enter the same fields into the mutator class itself, I believe. I'm not sure what the interface is for?

#8 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 03 March 2008 - 11:12 AM

Yeah I already check this mutator it uses "Game.DefaultInventory". I didn't test yet but I 'm pretty sure this weapon list is non exhaustive.
Thanks for the IniFile suggest, I never touch config file stuff in UT3 for now.

I admit interface is quite useless in this case as there is only one implementation :popcorn: but you were talking about "experimental and cool code" so I try :popcorn:

It was just a Sunday Test Evening, I'll try to release something else for next weekend

#9 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 03 March 2008 - 12:24 PM

Game.DefaultInventory is what the players start with in that game mode (the "default weapons") - it's not what you're looking for. In the check replacement function however, it uses this sort of thing:
NewAmmoClass = class<UTAmmoPickupFactory>(DynamicLoadObject(AmmoToReplace[Index].NewClassPath, class'Class'));

This is read in from a config variable - notably, the WeaponReplacement mutator has all the weapons chosen by a configuration scene - so it also has a menu class. Look in the menu class, and you'll find how this list is generated. You could then write an algorithm that randomly generates these lists instead of having them controlled by a configuration scene :popcorn:

#10 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 03 March 2008 - 12:40 PM

thanks, I'll check that tonight

I have extra questions on UIScene.

In UT2004, you can open a menu with the methode ClientOpenMenu (or somethig like this) in PlayerController

I didn't find this in UT3, I found OpenScene in Engine.UISceneClient (not sure if it is the right direction) The question is where is the instance of this class ? I precise that I'm at work so I only use Uncodex to search :popcorn:

#11 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 03 March 2008 - 12:53 PM

My advice is to stop looking at and referring UT2004 code. A lot of UT3 has changed - the UI system is completely different. OpenScene is the correct function - but UIScenes are editor objects. If you followed my second tutorial, you'd see a mutator config example :popcorn:

Edit: Here's the first one I'm working on, and easy one to make sure I have something by Sunday:

class LP_Mutator_Disguise extends UTMutator;

var StaticMesh playerBox, playerBoxRed, playerBoxBlue;
var() Vector BoxScale;

function ModifyPlayer(Pawn Other)
{
	local StaticMeshComponent BoxAttachment;
	
	if (Other.IsA('UTPawn'))
	{
			BoxAttachment = new(self) class'StaticMeshComponent';
			
			if (WorldInfo.Game.bTeamGame == true)
			{
				if (UTPawn(Other).Controller.PlayerReplicationInfo.Team.TeamIndex == 0)
				{
					BoxAttachment.SetStaticMesh( playerBoxRed );
				}
				else if (UTPawn(Other).Controller.PlayerReplicationInfo.Team.TeamIndex == 1)
				{
					BoxAttachment.SetStaticMesh( playerBoxBlue );
				}
			}
			else
			{
				BoxAttachment.SetStaticMesh( playerBox );
			}
			
			UTPawn(Other).AttachComponent(BoxAttachment);
			
			BoxAttachment.SetScale3D(boxScale);
	}
	
	super.ModifyPlayer(Other);
}

DefaultProperties
{
	playerBox = StaticMesh'LP_Disguise_Assets.Box'
	playerBoxRed = StaticMesh'LP_Disguise_Assets.Box_Red'
	playerBoxBlue = StaticMesh'LP_Disguise_Assets.Box_Blue'
	boxScale=(X=1.000000,Y=1.000000,Z=1.000000)
}

Should be real easy - attach a static mesh component to the player, so he's disguised as a box. Play in maps full of said boxes, and things get interesting. Mesh isn't showing in game however, and no logged errors. Doh.

Edited by ambershee, 03 March 2008 - 02:04 PM.


#12 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 03 March 2008 - 07:35 PM

Ahah interesting ^^. You should add a pic .

I take a look at UIScene and manage to open one when I want ("Open Scene" remember ? :dry:) I may release an extra mutator :xcahik_:

I have an extra question about UIScene: Is there a way to use Timer in those classes? as they don't inherit from Actor

Edited by xiongmao, 04 March 2008 - 12:16 AM.


#13 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 04 March 2008 - 01:59 PM

I believe the UTUIWidgets have internal tick functions. This is very similar - it depends what you want to do though. If you want proper timing functions, you'd need to tie the scene to Kismet, which is nasty.

#14 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 04 March 2008 - 02:12 PM

I want to display a countdown and update a label text each timer period

setTImer(1, true);

function Timer()
{
  if( counter > -1)
	updateLabel(counter --);

  else
  {
	settimer(0, false);
	closeScene(self)
  }
}
Something like this in fact.

Indeed I can use AnimTick() to simulate timer.

I may change to an Action to close Scene

Edited by xiongmao, 04 March 2008 - 02:12 PM.


#15 knighteyes

knighteyes
  • Members
  • 21 posts

Posted 04 March 2008 - 05:21 PM

My idea is something like the vampire mod for ut2k4 (when you hit someone, you steal his health). The difference is that I want to give the stolen health to a randomly choosen player (but the one who's hurt).
After hours of digging the script reference, I still can't override the function that takes health from one player and make it give the health to another.
Last attempt was oncausedamage, but didn't work, it doesn't even write to the log.

My class extends mutator, maybe I should try other approach?

I've read of a mod with some rpg characteristics, that has a vampirish power up, so maybe I'll look that code to find something.

Help appreciated :xcahik_:

#16 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 04 March 2008 - 05:36 PM

Extend mutator and include a game rules - some of the 'Light' mutators will show you how to do that. You can then over-ride the damage functions from there.

#17 knighteyes

knighteyes
  • Members
  • 21 posts

Posted 05 March 2008 - 03:13 AM

Thanks!!
I tried to extend GameRules before but couldn't make it work (but with each hour struggling I'm understanding a little more, or so I wish),
I'm sure I was trying to over-ride the wrong function.
The vampire mod is working (no network test), I'm going to do the random part and then add to svn to get some comments from you all.

#18 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 05 March 2008 - 09:08 AM

In the previous MutatorWeek, you can find everything you need to get the Random controller
key words (GameReplicationInfo, ForEach and Rand) :rolleyes:

Another question about UIScene, mine is fullScreen, how can I set dimension to my UIScene ?

Edited by xiongmao, 05 March 2008 - 09:11 AM.


#19 ambershee

ambershee

    Nimbusfish Rawks

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

Posted 05 March 2008 - 09:26 AM

It's always full screen - just don't draw over the bits you don't want to show menus - leave it blank.

#20 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 05 March 2008 - 10:54 PM

Hi All,
I release a new one called "Surprise Gift". The aim of this mutator was to touch the UIScene part of Unrealscript.
Basically, the mutator logic is contained in the scorekill method of a new gamerule. It displays randomly to the killer an UIScene. The killer just need to wait the countdown to finish and receives its gift between weapons ammo and death !!!

As the UIScene doesn't extend Actor, I implemented an "heavy" listener mechanism. It is composed of an actor "counterActor" which has an array of listeners (such as the UIScene) it starts a timer and send notification to all listeners. The counterActor can be itself a listener.
In my gamerule, 2 counterActor are used one to update the countdown label and one to update the giftlabel

Another thing required, the UIScene must have this field in its defaultproperties bPauseGameWhileActive=false, if not the counters won't never start as the UIScene pause the game.

Posted Image


and here is the code:

Mutator

//-----------------------------------------------------------
//
//  - Surprise Gift Factory -  EA_SurpriseGift_Mutator
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  Each time a PlayerController kills someone, there is a chance
//  that a popup appears. This popup is displayed during the countDownInSecond
//  After that a gift is given randomly. the gifts provided are:
//	 - FlakCannon
//	 - Reedeemer
//	 - RocketLauncher
//	 - AllAmmo
//	 - Death !!!
//  The mutator aims to show how to use, array and interface and UIScene
//-----------------------------------------------------------
class EA_SurpriseGift_Mutator extends UTMutator
	  config(SurpriseGift);

var class<GameRules> GRClass;

var config int countDownInSecond;
var config float counterRateTimer;
var config float giftRateTimer;


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

	super.InitMutator(Options, ErrorMessage);
}

DefaultProperties
{
	GRClass=class'MWSurprise.EA_SurpriseGift_Rules'
	countDownInSecond = 2
	counterRateTimer = 1.0
	giftRateTimer = 0.2
}

Gamerule

//-----------------------------------------------------------
//
//  - Surprise Gift Factory -  EA_SurpriseGift_Rules
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  The GameRules opens the UIScene and initialises counters
//-----------------------------------------------------------
class EA_SurpriseGift_Rules extends GameRules;


//this represent the fraction of chance to get the surprise  1/nbChance
var int chanceForSurprise;

function ScoreKill(Controller Killer, Controller Killed)
{
 local  UTGameUISceneClient SC;
 local UIScene giftUIscene, outGiftUIScene;
 local EA_SurpriseGift_CounterActor counterTimerActor, updateGiftTimerActor;
 local EA_SurpriseGift_CounterEventObject updateCountDownAction, updateGiftLabelAction;
 local int countDown;
 local float countDownRate, updategiftLabelRate;

 if( PlayerController(killer) != None && killer.PlayerReplicationInfo.PlayerID != killed.PlayerReplicationInfo.PlayerID && Rand(chanceForSurprise) == 0)
 {
	SC = UTGameUISceneClient(class'UIRoot'.static.GetSceneClient());
	if(SC != None)
	{

	  //open the scene and retrieve it by the Out Parameter
	  giftUIscene = UIScene(DynamicLoadObject("EA_SurpriseGift_Package.EA_SurpriseGift_UIScene", class'Engine.UIScene'));
	  SC.OpenScene(giftUIscene, LocalPlayer(PlayerController(killer).Player), outGiftUIScene);

	  //set controller
	  EA_SurpriseGift_Menu(outGiftUIScene).setPlayerController(PlayerController(killer));

	  //initialise rate and countdown
	  countDown = class'MWSurprise.EA_SurpriseGift_Mutator'.default.countDownInSecond;
	  countDownRate = class'MWSurprise.EA_SurpriseGift_Mutator'.default.counterRateTimer;
	  updategiftLabelRate = class'MWSurprise.EA_SurpriseGift_Mutator'.default.giftRateTimer;

	  //create the two timers actors
	  counterTimerActor = spawn(class'EA_SurpriseGift_CounterActor');
	  updateGiftTimerActor  = spawn(class'EA_SurpriseGift_CounterActor');

	  //register UIScene and updateLabelCounterTimerActor to the counterTimerActor
	  counterTimerActor.addListener(EA_SurpriseGift_CounterEventListener(outGiftUIScene));
	  counterTimerActor.addListener(EA_SurpriseGift_CounterEventListener(updateGiftTimerActor));

	  //register UIScene to the second timer
	  updateGiftTimerActor.addListener(EA_SurpriseGift_CounterEventListener(outGiftUIScene));

	  //create the event that will be send through the notify method
	  //@see EA_SurpriseGift_CounterEventListener interface
	  updateCountDownAction = new(self)class'MWSurprise.EA_SurpriseGift_CounterEventObject';
	  updateCountDownAction.eventName="updateCountdown";

	  updateGiftLabelAction = new(self)class'MWSurprise.EA_SurpriseGift_CounterEventObject';
	  updateGiftLabelAction.eventName="updateGift";

	  //launch both timers
	  counterTimerActor.initCounter(countDownRate, countDown, updateCountDownAction);
	  updateGiftTimerActor.initCounter(updategiftLabelRate, -1, updateGiftLabelAction);

	}
 }

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

}

defaultproperties
{
  chanceForSurprise = 3;
}

UIScene

//-----------------------------------------------------------
//
//  - Surprise Gift Factory -  EA_SurpriseGift_Menu
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  This is the UIScene displayed. It receives notification by
//  counters and update its labels value.
//  It finally gives a gift to the player according to the last
//  gift selection.
//-----------------------------------------------------------
class EA_SurpriseGift_Menu extends UIScene
	implements(EA_SurpriseGift_CounterEventListener);

var UILabel countDownLabel;
var UILabel giftLabel;
var PlayerController pController;

var array<String> giftsLabel[5];

var int selectedGiftIndex;

event SceneActivated(bool bInitialActivation)
{
   super.SceneActivated(bInitialActivation);

   if (bInitialActivation)
   {
	 countDownLabel = UILabel(FindChild('EA_SurpriseGift_RemainingTimeLabel_Change', true));
	 giftLabel = UILabel(FindChild('EA_SurpriseGift_GiftLabel_Change', true));
   }
}

function setPlayerController(PlayerController PC )
{
  pController = PC;
}

function updateCountDownLabel(String counter)
{
  countDownLabel.setValue(counter);
}

//call every 0.5s to change the gift name
function updateGiftLabel ()
{
  selectedGiftIndex = Rand(5);
  giftLabel.SetValue(giftsLabel[selectedGiftIndex]);
}

function giveGiftToPlayer()
{
   pController.ClientMessage("Player receives the gift: "@giftLabel.getValue());
   switch(selectedGiftIndex)
   {
	 case 0: pController.CheatManager.AllAmmo;
			 break;
	 case 1: pController.CheatManager.GiveWeapon("UTGame.UTWeap_FlakCannon");
			 break;
	 case 2: pController.CheatManager.GiveWeapon("UTGameContent.UTWeap_Redeemer_Content");
			 break;
	 case 3: pController.Suicide();
			 break;
	 case 4: pController.CheatManager.GiveWeapon("UTGame.UTWeap_RocketLauncher");
			 break;
   }
   CloseScene(self);
}

//Interface method
function notifyCount(EA_SurpriseGift_CounterEventObject counterEvent)
{
  if(counterEvent.eventName == "updateCountdown")
	 updateCountDownLabel(""@counterEvent.countdown@"");

  else if(counterEvent.eventName == "updateGift")
	 updateGiftLabel();

  else if(counterEvent.eventName == "stop")
	 giveGiftToPlayer();
}


DefaultProperties
{
   giftsLabel[0] = "All Ammo";
   giftsLabel[1] = "Flak Cannon";
   giftsLabel[2] = "Redeemer";
   giftsLabel[3] = "Death";
   giftsLabel[4] = "Rocket Launcher";

   //require if not the window is modal and the counter can't start
   bPauseGameWhileActive=false
}

interface listener

//-----------------------------------------------------------
//
//  - Surprise Gift Factory -  EA_SurpriseGift_CounterEventListener
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  Classes which want to receive notification from counterActor must
//  implemented this interface
//-----------------------------------------------------------
interface EA_SurpriseGift_CounterEventListener;

function notifyCount(EA_SurpriseGift_CounterEventObject counterEvent);

Event Sent

//-----------------------------------------------------------
//
//  - Surprise Gift Factory -  EA_SurpriseGift_CounterEventObject
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  The object passed in parameter when notify counterActor listener
//-----------------------------------------------------------
class EA_SurpriseGift_CounterEventObject extends Object;

var String eventName;
var int countdown;

CounterActor

//-----------------------------------------------------------
//
//  - Surprise Gift Factory -  EA_SurpriseGift_CounterActor
//  Written/tested by Erwan Allain (zall1@hotmail.com)
//
//  Coded for Mutator Week/Shee Labs
//
//  This class uses the mechanism of Listener. It starts a Timer when
//  calling initTimer() then it sends notification to each listeners
//-----------------------------------------------------------
class EA_SurpriseGift_CounterActor extends Actor
   implements (EA_SurpriseGift_CounterEventListener);

var int counter;
var array<EA_SurpriseGift_CounterEventListener>  eventListeners;
var EA_SurpriseGift_CounterEventObject action;

var EA_SurpriseGift_CounterEventObject stopAction;
var bool alwaysLoop;

function postBeginPlay()
{
  super.PostBeginPlay();
  stopAction = new(self)class'MWSurprise.EA_SurpriseGift_CounterEventObject';
  stopAction.eventName="stop";
}

function initCounter(float rate, int nbLoop, EA_SurpriseGift_CounterEventObject act)
{
  counter = nbLoop;
  if(nbLoop == -1)
   alwaysLoop = true;
  else
   alwaysLoop = false;
  action = act;
  setTimer(rate, true);
}

function addListener(EA_SurpriseGift_CounterEventListener listener)
{
  eventListeners.addItem(listener);
}


function Timer()
{
  local int i;
  action.countdown = counter;
  if(counter > -1 || alwaysLoop)
  {
	  for(i=0;i<eventListeners.length;i++)
	  {
		  if( eventListeners[i] != None)
		   eventListeners[i].notifyCount(action);
	  }
  }
  else
  {
	  for(i=0;i<eventListeners.length;i++)
	  {
		  if( eventListeners[i] != None)
			eventListeners[i].notifyCount(stopAction);
	  }
	   setTimer(0,false);
  }
  counter --;
}

function notifyCount(EA_SurpriseGift_CounterEventObject counterEvent)
{
  if(counterEvent.eventName == "stop")
	 setTimer(0, false);
}

defaultproperties
{
}

That's all :rolleyes:

Edited by xiongmao, 05 March 2008 - 11:07 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users