There is no spoon

Difference between revisions of "Unreal Wiki:Scratchpad"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
Line 7: Line 7:
  
 
<uscript>
 
<uscript>
//=============================================================================
 
// Copyright 2008-Now Josh Lee a.k.a. Pendragon @ Hedstem.com
 
// All rights Reserved.
 
// This was created to add a make the game rock.
 
//=============================================================================
 
 
class H3D_TagMutator extends UTMutator config(H3D_TagMutator);
 
 
var() config array<string> H3D_Inventories;
 
var() config float SpawnIntervalMin, SpawnIntervalMax;
 
 
var int LastUsedNode;
 
 
var array<PathNode> found_nodes;
 
var array<vector> used_nodes;
 
 
 
Function MatchStarting() {
 
local PathNode FoundNode;
 
`log("ASSHAT: Start");
 
if( H3D_Inventories.Length == -1 ) {
 
LogInternal( "SHIT! We are out of beer!!!", Name );
 
`log( "ASSHAT: SHIT! We are out of beer!!!");
 
Destroy();
 
}
 
 
Super.MatchStarting();
 
ForEach WorldInfo.AllNavigationPoints( Class'PathNode', FoundNode ) { // Create a list of nodes.
 
found_nodes[found_nodes.Length] = FoundNode;
 
}
 
if( found_nodes.Length != 1 ) {
 
SetTimer( RandRange( SpawnIntervalMin, SpawnIntervalMax ),, 'RandomSpawn' );
 
`log( "ASSHAT: Timer Set");
 
} else {
 
LogInternal( "No NavigationPoints found in this map!", Name );
 
`log( "ASSHAT: No NavigationPoints found in this map!");
 
Destroy();
 
}
 
}
 
function remNode(vector Loc) {
 
local int i;
 
local array<vector> new_array;
 
for(i=0;i<used_nodes.Length;i++) {
 
if(used_nodes[i] != Loc) {
 
new_array[new_array.Length] = used_nodes[i];
 
}
 
}
 
used_nodes = new_array;
 
}
 
function addNode(vector Loc) {
 
if(!nodeUsed(loc)) {
 
used_nodes[used_nodes.Length] = Loc;
 
}
 
}
 
function bool nodeUsed(vector Loc) {
 
local int i;
 
for(i=0;i<used_nodes.Length;i++) {
 
if(used_nodes[i] == Loc) {
 
return True;
 
}
 
}
 
return False;
 
}
 
 
Function RandomSpawn() {
 
local int CurrentNode, RandInvNum;
 
local PickupFactory Spawned_HItem;
 
local vector tempLoc;
 
local byte SpawnAttempts;
 
 
GetNode:
 
if( SpawnAttempts > 2 ) {
 
return;
 
}
 
CurrentNode = Rand( found_nodes.Length );
 
if( LastUsedNode == CurrentNode ) { // Don''t spawn a present at same spot.
 
Goto'GetNode'; // Try another.
 
}
 
LastUsedNode = CurrentNode;
 
tempLoc = found_nodes[CurrentNode].Location;
 
if(nodeUsed(tempLoc)) {
 
if(SpawnAttempts > 2) {
 
SetTimer( RandRange( SpawnIntervalMin, SpawnIntervalMax ),, 'RandomSpawn' );
 
}
 
Goto'GetNode';
 
}
 
Spawned_HItem = Spawn( Class'H3D_PickupFactory', Self,, tempLoc );
 
 
if( Spawned_HItem == None ) { // Get another node and try to spawn again.
 
SpawnAttempts ++;
 
Goto'GetNode';
 
}
 
 
RandInvNum = Rand( H3D_Inventories.Length );
 
 
if( H3D_Inventories[RandInvNum] != "" ) {
 
Spawned_HItem.InventoryType = Class<Inventory>( DynamicLoadObject( H3D_Inventories[RandInvNum], Class'Class', True ) );
 
Spawned_HItem.remNode = remNode;
 
addNode(tempLoc);
 
} else {
 
LogInternal( "Spawned_HItem"@RandInvNum@"is empty!", Name );
 
}
 
SetTimer( RandRange( SpawnIntervalMin, SpawnIntervalMax ),, 'RandomSpawn' ); // Prepare the next Spawned_HItem.
 
}
 
 
defaultproperties {
 
  H3D_Inventories(0)="InsaneMOFO.UTBerserkMOFO"
 
  H3D_Inventories(1)="InvisibleR.UTInvisibilityR"
 
  H3D_Inventories(2)="Speed.UTSpeed"
 
  H3D_Inventories(3)="InsaneMOFO.UTBerserkMOFO"
 
  H3D_Inventories(4)="InvisibleR.UTInvisibilityR"
 
  H3D_Inventories(5)="Speed.UTSpeed"
 
  H3D_Inventories(6)="UTGameContent.UTJumpBoots"
 
  H3D_Inventories(7)="UTGameContent.UTInvisibility"
 
  H3D_Inventories(8)="UTGameContent.UTDeployableEMPMine"
 
  H3D_Inventories(9)="UTGameContent.UTDeployableEnergyShield"
 
  H3D_Inventories(10)="UTGameContent.UTDeployableShapedCharge"
 
  H3D_Inventories(11)="UTGameContent.UTDeployableSlowVolume"
 
  H3D_Inventories(12)="SwarmAvril.UTWeap_SwarmAvril_Content"
 
  H3D_Inventories(13)="UTGameContent.UTDeployableSpiderMineTrap"
 
  H3D_Inventories(14)="UTGameContent.UTUDamage"
 
  H3D_Inventories(15)="UTGameContent.UTJumpBoots"
 
  H3D_Inventories(16)="UTGameContent.UTInvisibility"
 
  H3D_Inventories(17)="UTGameContent.UTDeployableEMPMine"
 
  H3D_Inventories(18)="UTGameContent.UTDeployableEnergyShield"
 
  H3D_Inventories(19)="UTGameContent.UTDeployableShapedCharge"
 
  H3D_Inventories(20)="UTGameContent.UTDeployableSlowVolume"
 
  H3D_Inventories(21)="UTGameContent.UTDeployableSpiderMineTrap"
 
  H3D_Inventories(22)="UTGameContent.UTUDamage"
 
  H3D_Inventories(23)="PPC.UTWeap_PPC"
 
  H3D_Inventories(24)="H3D_Healer.H3D_Deployable_Healer"
 
 
 
  SpawnIntervalMin=10.000000
 
  SpawnIntervalMax=30.000000
 
  // PickupSound=SoundCue'H3D_Tag.Sounds.OmegaCue'
 
  GroupNames(0)="H3D_Inventories"
 
  Begin Object SpriteComponent Name=Sprite ObjName=Sprite Archetype=SpriteComponent'UTGame.Default__UTMutator:Sprite'
 
      ObjectArchetype=SpriteComponent'UTGame.Default__UTMutator:Sprite'
 
  End Object
 
  Components(0)=Sprite
 
  Name="Default__H3D_TagMutator"
 
  ObjectArchetype=UTMutator'UTGame.Default__UTMutator'
 
}
 
 
</uscript>
 
 
<uscript>
 
//=============================================================================
 
// Copyright 2008-Now Josh Lee a.k.a. Pendragon @ Hedstem.com
 
// All rights Reserved.
 
// This was created to add a make the game rock.
 
//=============================================================================
 
 
class H3D_PickupFactory extends UTPowerupPickupFactory;
 
var SoundCue PickupSound;
 
 
Function PickedUpBy( Pawn P ) {
 
TriggerEventClass(class'SeqEvent_PickupStatusChange', P, 1);
 
P.PlaySound( PickupSound );
 
if (P.Controller != None && P.Controller.MoveTarget == self) {
 
P.SetAnchor(self);
 
P.Controller.MoveTimer = -1.0;
 
}
 
remNode(Location);
 
Destroy();
 
}
 
delegate remNode(vector MyLocation);
 
 
defaultproperties
 
{
 
  PickupSound=SoundCue'H3D_Tag.Sound.OmegaCue'
 
  Begin Object Class=SkeletalMeshComponent Name=VisualMesh ObjName=VisualMesh Archetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent'
 
      SkeletalMesh=SkeletalMesh'H3D_Tag.SkMesh.TheTag'
 
      bUpdateSkelWhenNotRendered=False
 
      bUseAsOccluder=False
 
      bForceDirectLightMap=True
 
      bCastDynamicShadow=False
 
      CollideActors=False
 
      BlockRigidBody=False
 
      Translation=(X=0.000000,Y=0.000000,Z=5.000000)
 
      Name="VisualMesh"
 
      ObjectArchetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent'
 
  End Object
 
  PickupMesh=VisualMesh
 
 
  Begin Object Name=StaticMeshComponent1 ObjName=StaticMeshComponent1 Archetype=StaticMeshComponent'UTGame.Default__UTPowerupPickupFactory:StaticMeshComponent1'
 
      ObjectArchetype=StaticMeshComponent'UTGame.Default__UTPowerupPickupFactory:StaticMeshComponent1'
 
  End Object
 
 
 
  Spinner=StaticMeshComponent1
 
  InventoryType=Class'H3D_TagMutator.H3D_Inventory'
 
  Begin Object Name=CollisionCylinder ObjName=CollisionCylinder Archetype=CylinderComponent'UTGame.Default__UTPowerupPickupFactory:CollisionCylinder'
 
      ObjectArchetype=CylinderComponent'UTGame.Default__UTPowerupPickupFactory:CollisionCylinder'
 
  End Object
 
  CylinderComponent=CollisionCylinder
 
  Components(0)=CollisionCylinder
 
  Begin Object Name=PathRenderer ObjName=PathRenderer Archetype=PathRenderingComponent'UTGame.Default__UTPowerupPickupFactory:PathRenderer'
 
      ObjectArchetype=PathRenderingComponent'UTGame.Default__UTPowerupPickupFactory:PathRenderer'
 
  End Object
 
  Components(1)=PathRenderer
 
  Components(2)=PickupLightEnvironment
 
  Components(3)=VisualMesh
 
  Components(4)=None
 
  CollisionComponent=CollisionCylinder
 
    RemoteRole=ROLE_SimulatedProxy
 
    bStatic=False
 
    bHidden=False
 
    bNoDelete=False
 
    bNetInitialRotation=True
 
 
 
  Name="Default__H3D_PickupFactory"
 
  ObjectArchetype=UTPowerupPickupFactory'UTGame.Default__UTPowerupPickupFactory'
 
}
 
  
 
</uscript>
 
</uscript>

Revision as of 05:47, 20 February 2009

This page is for pasting code you want to show someone as an example or to get assistance with. This allows you to easily collaborate with someone to solve a problem, and allows easy comparisons of the edits.

You are free to remove any existing code from below, and paste your code between the <uscript> </uscript> tags. If the page hasn't been edited in the last few hours (the last edit timestamp is 2009-02-20 05:47:45), you can assume it isn't needed anymore and can be removed. A full edit history will be available, so don't worry about losing anything you removed.

Clean up after you're done!