Change mover KeyPos[] at runtime

Discussions about Coding and Scripting
User avatar
Barbie
Godlike
Posts: 2805
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Change mover KeyPos[] at runtime

Post by Barbie »

I tried to fix a mover by code when the map is loaded by M.KeyPos[1] = vect(0, -6, 0); but mover first moves to old KeyNum[1] and then jumps to my fixed location.
T3d of original mover

Code: Select all

Begin Map
Begin Actor Class=Mover Name=Mover2
     MoveTime=0.500000
     StayOpenTime=0.500000
     KeyPos(1)=(X=-0.091980,Y=8.368240)
     BasePos=(X=2244.007812,Y=-3553.972656,Z=-764.000000)
     SavedPos=(X=-12345.000000,Y=-12345.000000,Z=-12345.000000)
     BaseRot=(Yaw=-16384)
     SavedRot=(Pitch=123,Yaw=456,Roll=789)
     MainScale=(SheerAxis=SHEER_ZX)
     PostScale=(SheerAxis=SHEER_ZX)
     Level=LevelInfo'MyLevel.LevelInfo0'
     Tag="Mover"
     Region=(Zone=LevelInfo'MyLevel.LevelInfo0',iLeaf=-1)
     Location=(X=2244.007812,Y=-3553.972656,Z=-764.000000)
     Rotation=(Yaw=-16384)
     OldLocation=(X=-608.000000,Y=-256.000000,Z=-32.000000)
     bSelected=True
    Begin Brush Name=Model848
       Begin PolyList
          Begin Polygon Link=0
             Origin   -00004.000000,-00004.000000,-00004.000000
             Normal   -00001.000000,+00000.000000,+00000.000000
             TextureU +00000.000000,+00001.000000,+00000.000000
             TextureV +00000.000000,+00000.000000,-00001.000000
             Vertex   -00004.000000,-00004.000000,-00004.000000
             Vertex   -00004.000000,-00004.000000,+00004.000000
             Vertex   -00004.000000,+00004.000000,+00004.000000
             Vertex   -00004.000000,+00004.000000,-00004.000000
          End Polygon
          Begin Polygon Link=1
             Origin   -00004.000000,+00004.000000,-00004.000000
             Normal   +00000.000000,+00001.000000,+00000.000000
             TextureU +00001.000000,-00000.000000,+00000.000000
             TextureV +00000.000000,+00000.000000,-00001.000000
             Vertex   -00004.000000,+00004.000000,-00004.000000
             Vertex   -00004.000000,+00004.000000,+00004.000000
             Vertex   +00004.000000,+00004.000000,+00004.000000
             Vertex   +00004.000000,+00004.000000,-00004.000000
          End Polygon
          Begin Polygon Link=2
             Origin   +00004.000000,+00004.000000,-00004.000000
             Normal   +00001.000000,+00000.000000,+00000.000000
             TextureU -00000.000000,-00001.000000,+00000.000000
             TextureV +00000.000000,+00000.000000,-00001.000000
             Vertex   +00004.000000,+00004.000000,-00004.000000
             Vertex   +00004.000000,+00004.000000,+00004.000000
             Vertex   +00004.000000,-00004.000000,+00004.000000
             Vertex   +00004.000000,-00004.000000,-00004.000000
          End Polygon
          Begin Polygon Link=3
             Origin   +00004.000000,-00004.000000,-00004.000000
             Normal   +00000.000000,-00001.000000,+00000.000000
             TextureU -00001.000000,+00000.000000,+00000.000000
             TextureV +00000.000000,+00000.000000,-00001.000000
             Vertex   +00004.000000,-00004.000000,-00004.000000
             Vertex   +00004.000000,-00004.000000,+00004.000000
             Vertex   -00004.000000,-00004.000000,+00004.000000
             Vertex   -00004.000000,-00004.000000,-00004.000000
          End Polygon
          Begin Polygon Link=4
             Origin   -00004.000000,+00004.000000,+00004.000000
             Normal   +00000.000000,+00000.000000,+00001.000000
             TextureU +00001.000000,-00000.000000,+00000.000000
             TextureV +00000.000000,+00001.000000,+00000.000000
             Vertex   -00004.000000,+00004.000000,+00004.000000
             Vertex   -00004.000000,-00004.000000,+00004.000000
             Vertex   +00004.000000,-00004.000000,+00004.000000
             Vertex   +00004.000000,+00004.000000,+00004.000000
          End Polygon
          Begin Polygon Link=5
             Origin   -00004.000000,-00004.000000,-00004.000000
             Normal   +00000.000000,+00000.000000,-00001.000000
             TextureU +00001.000000,-00000.000000,+00000.000000
             TextureV -00000.000000,-00001.000000,+00000.000000
             Vertex   -00004.000000,-00004.000000,-00004.000000
             Vertex   -00004.000000,+00004.000000,-00004.000000
             Vertex   +00004.000000,+00004.000000,-00004.000000
             Vertex   +00004.000000,-00004.000000,-00004.000000
          End Polygon
       End PolyList
    End Brush
     Brush=Model'MyLevel.Model848'
     PrePivot=(X=3.101318,Y=0.083435,Z=-4.000000)
     Name="Mover2"
End Actor
End Map
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Change mover KeyPos[] at runtime

Post by sektor2111 »

I did such changes but I used to do it in both server and client and then... The code snippet is like this - "BasePos" also it's in account...

Code: Select all

simulated function AlterActors() //This is a Package mapped only when said map is loaded.
{
...
...
		if (string(A.Name) ~= "Mover3") // Position 673
		{
			Mover(A).BasePos = vect(240,-23680,-5632);
			Mover(A).KeyPos[0] = vect(0,0,0);
			Mover(A).KeyPos[1] = vect(0,0,-968); //Just open properly - Same as above
			log("Mover has"@Mover(A).BasePos,'SuperTomokov2');
			continue;
		}
...
}
User avatar
Barbie
Godlike
Posts: 2805
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Change mover KeyPos[] at runtime

Post by Barbie »

Thanks. At which stage (PreBeginPlay() ... Auto State reached) runs your code?   
Auto merged new post submitted 1 hour 41 minutes later
sektor2111 wrote: Tue Apr 02, 2024 10:40 pm "BasePos" also it's in account...
Isn't BasePos usually the same as Location?   
Auto merged new post submitted 39 minutes later
I've now reduced the problem to a 2-brushes-map:
UnfixableButton.unr.jpg
It works fine on local play but not online. :? Adding "simulated" to ButtonFixer.Trigger() does not change behaviour.
You do not have the required permissions to view the files attached to this post.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Change mover KeyPos[] at runtime

Post by sektor2111 »

I set the task concerning Movers - different said a sort of "destruction", means to operate in both server and client for best results, I prefer to setup these very early (PreBeginPlay) because some Movers will do some jobs later in PostBeginPlay, I wanted to step into alternate movement options before their initialization (any potential LiftCenter, etc). Such sort of task I already posted for that CTF-Niven map where mutator can destroy doors at user's desire (daily or weekly). Movers actually are going into void at once with disabling trigger and altering even number of keys when is really needed. Client will have a notifier which will run the same code only in that environment, server has it's own similar task or else some bad movement timing can be seen in client. Code is fully operational if is done correctly but... plain compiler claims constants that are really stupid in this definition. If a Mover is bad, a patch file can get rid of it and everything will be normal.

The second point - making a static mover to open. I also did this in MH-Purgatorium, MH-BirdBrainedResearch and elsewhere - the same dual execution concerning keys changed in run-time + making sure about two keys, adding tags according to events and such. In second map I mapped even additional paths in that area... since the way could be open. These patch plugin type files for NavAdder mutator are old and not very optimized but... I was happy to improve things this way and then... I did not recreate them in a different format. In other maps I did not touch movers like that but creating random situations in order to gain a dynamic map not the same all the time.

Edit: Attachment check...

Code: Select all

Warning: Failed loading package: Can't find file for package 'FM][Tex'
Warning: Failed loading package: Can't find file for package 'FM][Tex'
Why not simply using stock files ?