Mostly Harmless

Legacy:Highlander/Gravitypack

From Unreal Wiki, The Unreal Engine Documentation Site
< Legacy:Highlander
Revision as of 04:41, 20 July 2003 by Foxpaw (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Well Tarquin said to paste the code... So here it is in its n00b glory.

//Written by Robin Murray Nov 2001 (]Bs[Highlander)
//unfhighlander@hotmail.com
//for use in UNF-OF-dome
//Is a gravitational point source.
//ie: a point in space that effects all the pawns in its radius of effect (collision radius)
 
class blackhole extends effects;
 
var() float force; //multiplier that u can use to change the force exerted.
var vector me2target;
var bool bEnabled;
var pawn target;
var float temp;
var float temp2;
 
simulated function prebeginplay()
		{
		//disabled to start <- fix me... ah well jus use timed trigger to disable it
		disable('tick');
		bEnabled = false;
		}
 
simulated function tick(float deltatime)
		{
		//log("in tick");
		foreach TouchingActors(class 'pawn',target){ //go through pawns
			//log("in foreach");
			if ((Target != None) && (Target.Region.Zone != None)) {//if there is a target there...
			me2target=(self.Location-target.Location);
			me2target=Normal(me2target)*1500*DeltaTime;
			Target.SetPhysics(PHYS_Falling);
			Target.Velocity -=force*((Target.Region.Zone.ZoneGravity*DeltaTime)-me2target);	//change velocity
			}
		}//of foreach
		}
 
simulated function trigger(actor Other, pawn EventInstigator)//toggle it on or off
		{
		if (bEnabled)
			{
			disable('tick');
			benabled = false;
			log("blackhole disabled");
			}
			else
			{
			enable('tick');
			benabled = true;
			log("blackhole enabled");
			}
 
		}
//Written by Robin Murray Nov 2001 (]Bs[Highlander)
//unfhighlander@hotmail.com
//for use in UNF-OF-dome
//Is a gravitational area that is not a zone.
class gravityactor extends effects;
 
var() float force; //multiplier that u can use to change the force exerted.
var() vector direction;
var bool bEnabled;
var pawn target;
var float temp;
var float temp2;
 
simulated function prebeginplay()
		{
		//disabled to start <- fix me... ah well jus use timed trigger to disable it
		disable('tick');
		bEnabled = false;
		}
simulated function tick(float deltatime)
		{
		//log("in tick");
		foreach TouchingActors(class 'pawn',target){ //go through pawns
			//log("in foreach");
			if ((Target != None) && (Target.Region.Zone != None)) {//if there is a target there...
			Target.SetPhysics(PHYS_Falling);
			Target.Velocity -=force*((Target.Region.Zone.ZoneGravity*DeltaTime)-direction);	//change velocity
			}
		}//of foreach
		}
simulated function trigger(actor Other, pawn EventInstigator)//toggle it on or off
		{
		if (bEnabled)
			{
			disable('tick');
			benabled = false;
			log("blackhole disabled");
			}
			else
			{
			enable('tick');
			benabled = true;
			log("blackhole enabled");
			}
 
		}
//=============================================================================
// GravityZoneInfo.
//=============================================================================
//Written By Robin Murray Nov 2001 (]Bs[Highlander)
// unfhighlander@hotmail.com
//For use in UNF-OF-dome
//Will toggle zone gravity and velocity between two sets of values on trigger
class GravityZoneInfo expands ZoneInfo;
 
var() vector NewZoneGrav;
var vector OldZoneGrav;
var() vector NewZoneVelocity;
var vector OldZoneVelocity;
function Trigger ( Actor Other, pawn EventInstigator )
{
	OldZoneGrav = ZoneGravity;
	ZoneGravity=NewZoneGrav;
	NewZoneGrav = OldZonegrav;
	OldZoneVelocity = ZoneVelocity;
	ZoneVelocity = NewZoneVelocity;
	NewZoneVelocity = OldZoneVelocity;	
}
//Written by Robin Murray Nov 2001 (]Bs[Highlander)
//unfhighlander@hotmail.com
//for use in UNF-OF-dome
//is a whirlwind effect.
 
class whirlwind extends effects;
var() float force; //multiplier that u can use to change the force exerted.
var() int zcomponent; //move up or down?
var() bool bClockwise;
var vector me2target;
var vector tempvector;
var bool bEnabled;
var pawn target;
var float temp;
var float temp2;
 
simulated function prepare()
		{
		//disabled to start <- fix me... ah well jus use timed trigger to disable it
		disable('tick');
		bEnabled = false;
		}
 
simulated function tick(float deltatime)
		{
		//log("in tick");
		foreach TouchingActors(class 'pawn',target){ //go through pawns
			//log("in foreach");
			if ((Target != None) && (Target.Region.Zone != None)) {//if there is a target there...
			me2target=(self.Location-target.Location);
			//ok  now need to get vector at right angles to this 1...
			me2target.z = zcomponent; //up or down movement
			tempvector.x = 0;
			tempvector.y = 0;
			tempvector.z = 1; //going up
			if (bClockwise) {
			tempvector = me2target cross tempvector;
				}
				else
				{
				tempvector = tempvector cross me2target;
				}
			//now i have vector at right angles to vertical line in middle
			tempvector = tempvector + me2target;
 
			Target.SetPhysics(PHYS_Falling);
			Target.Velocity -=force*((Target.Region.Zone.ZoneGravity*DeltaTime)-tempvector);	//change velocity
			}
		}//of foreach
		}
 
simulated function trigger(actor Other, pawn EventInstigator)//toggle it on or off
		{
		if (bEnabled)
			{
			disable('tick');
			benabled = false;
			log("blackhole disabled");
			}
			else
			{
			enable('tick');
			benabled = true;
			log("blackhole enabled");
			}
 
		}

Foxpaw: Did this work as you expected? I haven't been able to apply PHYS_Falling to something that is PHYS_Walking. It always just reverts instantly back to PHYS_Walking because it's touching the ground so it things it just landed. Maybe I'm just doing it wrong. Also, would you mind if I cleaned up the above a bit? There's some variables declared that don't get used at all, and some stray log statements and whatnot. It's your personal page though so it's up to you.