Code: Select all
function bool FindActor(name ActorName, out Actor A) {
local Actor A4loop;
foreach AllActors(class 'Actor', A4loop)
if (A4loop.Name == ActorName)
{
A = A4loop;
return true;
}
return false;
}
Code: Select all
function bool FindActor(name ActorName, out Actor A) {
local Actor A4loop;
foreach AllActors(class 'Actor', A4loop)
if (A4loop.Name == ActorName)
{
A = A4loop;
return true;
}
return false;
}
Code: Select all
final function Actor FindActor(name ActorName, out Actor A, optional name ActorTag)
{
local Actor A;
foreach AllActors( class 'Actor', A, ActorTag)
if (A4loop.Name == ActorName)
{
A = A4loop;
return A4loop;
}
}
Code: Select all
void AActor::execAllActors( FFrame& Stack, RESULT_DECL )
{
P_GET_OBJECT(UClass,ActorClass);
P_GET_ACTOR_REF(OutActor);
P_GET_NAME_OPTX(ActorTag,NAME_None);
P_FINISH;
BaseClass = ActorClass ? ActorClass : AActor::StaticClass();
INT i=0;
PRE_ITERATOR;
*OutActor = NULL;
while( (i < XLevel->Actors.Num()) && *OutActor==NULL )
{
AActor* TestActor = XLevel->Actors(i++);
//Tag check is done at native level, therefore faster
if ( TestActor && TestActor->IsA(ActorClass) && (ActorTag==NAME_None || TestActor->Tag==ActorTag) )
*OutActor = TestActor;
}
if( *OutActor == NULL )
{
Stack.Code = &Stack.Node->Script(wEndOffset + 1);
break;
}
POST_ITERATOR;
}
Code: Select all
if ( Level.Title == "Map 6: Gore Mine Crossing " && (Trigger(Other).Name == 'Trigger60') )
{
Trigger(Other).InitialState = 'NormalTrigger';
Trigger(Other).bInitiallyActive = True;
}
Code: Select all
if(InStr ( Level.Title, "Andromeda" ) == -1) //Stupid hack to let the people play with the everlasting jump boots
{
ReplaceWith(Other,"HitmanModv8.HittyJumpBoots");
return false;
}
}
That looks like something coming straight ouf ot IsRelevant()JackGriffin wrote:If you know the actor's name in a specific map you can do fixes like this:I do a ton of these in my coop controller. There's well over a thousand lines of just map fixes for various this-n-that.Code: Select all
if ( Level.Title == "Map 6: Gore Mine Crossing " && (Trigger(Other).Name == 'Trigger60') ) { Trigger(Other).InitialState = 'NormalTrigger'; Trigger(Other).bInitiallyActive = True; }
Code: Select all
local string LevelName;
LevelName = string(self);
LevelName = Left( LevelName, InStr(LevelName,".") );
//Evaluate levels here.
//We only need to fix level once, so no matter if map name changes if loaded from savegame
if ( LevelName ~= "Bluff" )
FixBluff();
else if ( LevelName ~= "ExtremeDGen" )
FixDGen();
else....
Code: Select all
function FixBluff()
{
//Spam Barbie's FindActor to find specific actors and apply changes (my edit).
//Also spawn your actors here if you wish.
}
Code: Select all
function postbeginplay()
{
FixMaps();
Code: Select all
function FixMaps()
{
if (outer.name == '00Intro')
FixMap_00Intro();
else if (outer.name == '01Escape')
FixMap_01Escape();
else if (outer.name == '02Village')
FixMap_02Village();
else if (outer.name == '03Temple')
FixMap_03Temple();
else if (outer.name == '04Mountains')
FixMap_04Mountains();
Code: Select all
function FixMap_00Intro()
{
SetSpecialEventMessage("SpecialEvent1", "In the 21st century tension between world powers was rising...");
SetSpecialEventMessage("SpecialEvent2", "Until the outbursts of hatred got out of control.");
SetSpecialEventMessage("SpecialEvent3", "In 2048 the 3rd World War broke out.");
That was my first thought (because of other), too. Then the only-once-applied-map-changing-stuff is called on nearly every spawned item...Higor wrote:That looks like something coming straight ouf ot IsRelevant()
Code: Select all
function bool FixTeleporterWithURL(Teleporter T) {
/*******************************************************************************
Returns TRUE if *T* has a travelling URL.
Todo: if an URL is given it may direct to the map itself.
*******************************************************************************/
local MonsterEnd MonsterEnd;
if (InStr(T.URL, "#") >= 0) // URL=LevelName#TeleporterName: Teleports to a different level. Found in MH-FissionSmelter, MH-NP04Hyperion.
{
log(T @ "has travelling URL '" $ T.URL $ "', disabling teleporter");
T.URL = "";
T.SetCollision(False, False, False);// don't replace to avoid error messages "destination not found" ingame
T.bHidden = True;
// put a MHEnd also at the same place:
//ExMHEnd = Spawn(class'exmhend',,,T.location + vect(-1,-1,-1));
MonsterEnd = Spawn(class'MonsterEnd',,,T.location);
//MonsterEnd = MonsterEnd(SpawnAndPasteActor(T, "MonsterHunt.MonsterEnd"));
if (MonsterEnd != None)
{
MonsterEnd.SetCollisionSize(FMax(t.CollisionRadius, MonsterEnd.CollisionRadius), FMax(t.CollisionHeight, MonsterEnd.CollisionHeight));
MonsterEnd.bHidden = False;
}
else
warn("MonsterEnd could not be spawned");
Return True;
}
else
Return False;
}
Code: Select all
class MyMutator expands Mutator;
...
auto state WhatEverYouNamedIt {
Begin:
MonsterReplicationInfoSB(Level.Game.GameReplicationInfo).MaxAmmoScale = MaxAmmoScale;
FixCTFFlags();
MapSpecificFixes();
if(bFixTeleportersWithURL)
FixTeleportersWithURL();
}
Higor wrote:EDIT3: False return is automatic, let's shrink the function by 2 bytes by removing it.
Code: Select all
Function WhatEver(string s) {
local int i;
// <- if some code is added here and changes i, the next line keeps the functionality
i = 0; // not necessary because compiler sets intial value of 0
While (i < len(s))
DoSomething(s, i++);
}
Also my coding style: I prefer functions with error code as result and eventually return values as parameter. Then such a function can smoothly be used asHigor wrote:EDIT4: Turn this into a major utilitary function by changing return type (return NONE automatic return).
Code: Select all
if (FunctionNameLikeAQuestion(MyActor)) DoSomeThingWith(MyActor)
Few people seem to realize that actors are always directly contained in the map package itself. As a result you can extract the package name without any explicit string manipulation operations:Higor wrote:Code: Select all
local string LevelName; LevelName = string(self); LevelName = Left( LevelName, InStr(LevelName,".") );
Code: Select all
local string LevelName;
LevelName = string(Outer); // assuming code is in an actor subclass, otherwise access Outer through an actor reference
Code: Select all
// in PreBeginPlay() of a Mutator-like class (UT200x differentiates between Mutator and GameRules)
// SetInitialState will later pick up the InitialState value set here
// we opted for Locs() (opposite of Caps()) to prevent polluting the name table and ensure the actual string representation matches
switch (Locs(Level.Outer.Name)) {
case "jb-arlon-gold": InitialState = 'Arlon'; break;
case "jb-aswan-v2": InitialState = 'Aswan'; break;
case "jb-atlantis-gold": InitialState = 'Atlantis'; break;
case "jb-babylontemple-gold": InitialState = 'BabylonTemple'; break;
case "jb-collateral": InitialState = 'Collateral'; break;
case "jb-cosmos": InitialState = 'Cosmos'; break;
case "jb-frostbite": InitialState = 'Frostbite'; break;
case "jb-heights-gold-v2": InitialState = 'Heights'; break;
case "jb-indusrage2-gold": InitialState = 'IndusRage'; break;
case "jb-poseidon-gold": InitialState = 'Poseidon'; break;
case "jb-thedecks": InitialState = 'TheDecks'; break;
}
Code: Select all
switch (Locs(A.StaticMesh.Name))
{
case "idomatakkenmid":
case "idomatakkenend":
SpawnEmitter(A, class'ChristmasTreeLightsEmitterF');
break;
case "miscstatue01ba": // for some reason myLevel'd in ONS-Crossfire
SpawnDecoHat(A, vect(-4,0,111), rot(0,16384,-2048), 0.47, vect(1,1,2));
SpawnDecoBag(A, vect(24,16,60), rot(0,-16384,3072), 2.0, vect(1,1,1));
break;
case "colWallFirePot2AR": // face deco on Bridge of Fate
SpawnDecoHat(A, vect(0,3,-4), rot(0,0,0), 0.25, vect(1.5,0.5,1.05));
break;
case "bannersconce": // myLevel'd in BR-Serenity, but also in sc_volcano_m package
SpawnDecoHat(A, vect(0,2,144), rot(0,32768,3072), 0.225, vect(1,1,1));
break;
case "hourekandelaarkemtelelcitilicht": // myLevel'd
case "kandelaarkemtelelcitilicht": // from HourmeshstuffX3, but possibly also myLevel'd
SpawnDecoHat(A, vect(456.4,48.95,94), rot(0,0,0), 0.2, vect(1,1,1));
break;
case "phonepole": // don't want spiffingrad left out
SpawnDecoHat(A, vect(-89,11,-12), rot(0,32768,0), 0.46, vect(1,1,1.5));
break;
case "StatueCon1":
SpawnDecoHat(A, vect(-56,-64,536), rot(0,16384,-1024), 0.8, vect(0.85,1,1));
SpawnDecoBag(A, vect(-16,-64,480), rot(0,-16384,0), 2.0, vect(0.9,1,1.5));
break;
}