// Set Physics to all actors with designed Tag

class ACTION_SetPhysicsOther extends ScriptedAction;

var(Action) class<Actor> BaseClass;
var(Action) name OtherTag;
var(Action) Actor.EPhysics NewPhysicsMode;
var(Action) float NewNetUpdateFrequency; // in cases we need to force replication to clients, e.g. dropping down pickup

function bool InitActionFor(ScriptedController C)
{
	local Actor Other;
	local Pickup Pickup;
	
	foreach C.AllActors(BaseClass, Other, OtherTag) {
		Other.SetPhysics(NewPhysicsMode);
		
		if ( Other.Level.NetMode != NM_StandAlone && NewPhysicsMode != PHYS_None ) {
			if ( Other.NetUpdateFrequency < NewNetUpdateFrequency ) {
				Other.NetUpdateFrequency = NewNetUpdateFrequency;
				Other.NetUpdateTime = Other.Level.TimeSeconds - 1;
			}
			if ( NewPhysicsMode == PHYS_Falling) {
				Pickup = Pickup(Other);
				if ( Pickup != none ) {
					// copied from Pickup.InitDroppedPickupFor()
					Pickup.bOnlyReplicateHidden = false;
					Pickup.bUpdateSimulatedPosition = true;
					Pickup.bIgnoreEncroachers = false;
					Pickup.NetUpdateFrequency = 8;
				}
			}
		}
	}
	return false;	
}

function string GetActionString()
{
	return ActionString@NewPhysicsMode;
}

defaultproperties
{
     baseClass=Class'Engine.Actor'
     ActionString="change physics to "
}
