Modding moving objects in Legions, possible?

Jello

Contributor
This is a question that's mostly for a dev.

Is it possible to implement a moving object in legions(yea the players move... :rolleyes:), like for instance the clouds, lets say I wanted to put, I don't know a bird and I wanted it to move here and there and show up like a certain number of times, and actually make it look like its flying, would that be possible?

It's just a question, I am making a couple 3D "stuff" in Blender and I just wanted to know.
 

Jello

Contributor
Thank You whoever edited and moved my thread, guess it wasn't in the right section

I think it's possible. Don't take my word for it though.

I'm not a coder so I don't really know but from the sound of it id say its really difficult, hell might not need coding at all who knows...
 

Stubbsy

Contributor
Thank You whoever edited and moved my thread, guess it wasn't in the right section



I'm not a coder so I don't really know but from the sound of it id say its really difficult, hell might not need coding at all who knows...
What I'd do is ask Defender in the mean time. He's helped me with a lot of coding.
 

Defender

Member
To make it look kinda realistic, maybe try to make a flock of birds, create a big .dts model and animate it some how like the devs, did for some of the cores, and stuff.. If you look close at one them, there are a bunch of little ball effects bouncing around inside one of them...
Scale it big, and place it high up in the sky, make it visible for a long distance in the map datablock. Hope I was a little help...
 

Jello

Contributor
To make it look kinda realistic, maybe try to make a flock of birds, create a big .dts model and animate it some how like the devs, did for some of the cores, and stuff.. If you look close at one them, there are a bunch of little ball effects bouncing around inside one of them...
Scale it big, and place it high up in the sky, make it visible for a long distance in the map datablock. Hope I was a little help...

You were, I will try to make that flock, as a starter but I was thinking of something else but I guess once I make that flock I will be able to implement the same thing from them to what I was thinking of..
 

Defender

Member
I would research this and see how they do it in today's modern computer games.
In FARCRY, I remember seeing flocks of birds in the sky, it looked like some sort of low detailed model animation, that randomly appeared in the sky..
 

Jello

Contributor
I did a little research but this is in Unity so I dont know if this will work for legions, but here are a couple codes they used to make an object from from point A to point B

Code:
///////////////CODE 1

var pointB : Vector3;
function Start () {
    var pointA = transform.position;
    while (true) {
        yield MoveObject(transform, pointA, pointB, 3.0);
        yield MoveObject(transform, pointB, pointA, 3.0);
    }
}
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
    var i = 0.0;
    var rate = 1.0/time;
    while (i < 1.0) {
        i += Time.deltaTime * rate;
        thisTransform.position = Vector3.Lerp(startPos, endPos, i);
        yield;
    }
}

/////////////CODE 2

var pointB : Transform;
private var pointA : Vector3;
var speed = 1.0;
function Start () {
    pointA = transform.position;
    while (true) {
        var i = Mathf.PingPong(Time.time * speed, 1);
        transform.position = Vector3.Lerp(pointA, pointB.position, i);
        yield;
    }
}

////////////CODE 3

public Vector3 pointB;
IEnumerator Start () {
    Vector3 pointA = transform.position;
    while (true) {
        yield MoveObject(transform, pointA, pointB, 3.0);
        yield MoveObject(transform, pointB, pointA, 3.0);
    }
}
IEnumerator MoveObject (Transform thisTransform, Vector3 startPos, Vector3 endPos, float time) {
    float i = 0.0f;
    float rate = 1.0f / time;
    while (i < 1.0f) {
        i += Time.deltaTime * rate;
        thisTransform.position = Vector3.Lerp(startPos, endPos, i);
        yield;
    }
}

/////////CODE 4

public Vector3 pointB;
IEnumerator Start () {
    Vector3 pointA = transform.position;
    while (true) {
        yield return StartCoroutine(MoveObject(transform, pointA, pointB, 3.0));
        yield return StartCoroutine(MoveObject(transform, pointB, pointA, 3.0));
    }
}
IEnumerator MoveObject (Transform thisTransform, Vector3 startPos, Vector3 endPos, float time) {
    float i = 0.0f;
    float rate = 1.0f / time;
    while (i < 1.0f) {
        i += Time.deltaTime * rate;
        thisTransform.position = Vector3.Lerp(startPos, endPos, i);
        yield return null;
    }
}

I'd post more but I feel like they're all the same thing..., so would the same code work for legions just written differently?

I have absolutely zero clue in coding besides java and html...
 

Defender

Member
Sure it could work, if rewritten differently...
Here is some code I ported from tribes2, for my "Asteroid Belt" map that works.
It moves my asteroids across the map from point A to point B, and back to point A...
The movement is slow, and can be adjusted....


You need to add markers in the map editor...
If you look in my map-pack, see my Asteroid Belt, map for how i setup the movement markers..

This goes at the bottom of your map...

Code:
//********************************************************************
// Coded by Defender
//********************************************************************
package PingPongPackage
{
function ClientManager::endClientMissions( )
{
  parent::endClientMissions( );
  if($PingPongActive){
  echo("<>>>>> Deactivate PingPong Package <<<<<>");
  CancelPingPongEvents();
  }
}
};
ActivatePackage(PingPongPackage);


Code:
//--- OBJECT WRITE END ---
PingPongInit( NameToID(Rock1), NameToID(MoveMarker1), 30000, 5, 5000);  //%time, %smoothness, %delay
PingPongInit( NameToID(Rock2), NameToID(MoveMarker2), 30000, 5, 7000);  //%time, %smoothness, %delay
PingPongInit( NameToID(Rock3), NameToID(MoveMarker3), 30000, 5, 9000);  //%time, %smoothness, %delay
PingPongInit( NameToID(Rock4), NameToID(MoveMarker4), 30000, 5, 11000);  //%time, %smoothness, %delay
PingPongInit( NameToID(Rock5), NameToID(MoveMarker5), 30000, 5, 13000);  //%time, %smoothness, %delay



PingPong.cs, past this at the bottom of your map or make a new file place it in the gameObjects
Code:
//********************************************************************
//PingPong.cs - Allows dynamic movement of objects such as buildings
//By - EvilCheese
//
//Usage: PingPongInit(%obj, %marker, %time, %smoothness, %delay)
//
//%obj = Object to move
//%marker = Destination position marker
//%time = time in milliseconds for one half of the ping-pong
//%smoothness = Number of movement updates per second, more = smoother = more CPU taxing.
//%delay = time delay in ms at each end of the path
//********************************************************************

//********************************************************************
// 3-21-2013
// Updates to code and additions by Defender, for use in my maps for Legions Overdrive.
//********************************************************************


//********************************************************************
function CancelPingPongEvents(){
if ( isEventPending($PingPongMoveEvent))
cancel($PingPongMoveEvent);// delete the event
echo("<>>>>> cancel $PingPongMoveEvent <<<<<>");
$PingPongActive = 0;
DeactivatePackage(PingPongPackage);
}

//********************************************************************
function posFromTransform(%transform) // Tribes2, function
{
  // the first three words of an object's transform are the object's position
  %position = getWord(%transform, 0) SPC getWord(%transform, 1) SPC getWord(%transform, 2);
  return %position;
}

function rotFromTransform(%transform)  // Tribes2, function
{
  // the last four words of an object's transform are the object's rotation
  %rotation = getWord(%transform, 3) SPC getWord(%transform, 4) SPC getWord(%transform, 5) SPC getWord(%transform, 6);
  return %rotation;
}

//********************************************************************
function PingPongInit(%obj , %marker, %time, %smoothness, %delay)
{
  $PingPongActive = 1;
  //This will move object (%obj) to the position marker specified, and then back again, in a ping-pong loop

  if(!isObject(%obj)) //If it isnt an object, error
  {
    echo("Unable to set movement on non-object classes, First parameter invalid");
  }

  if(!isObject(%marker)) //no marker
  {
    echo("Unable to set movement, marker object not found / invalid");
  }

  //Some maffs wizardry now, figure out the size of step required etc to make this work
  %startpos = posFromTransform(%obj.getTransform());
  %endpos = posFromTransform(%marker.getTransForm());

  //Find a vector from one to the other
  %Longvec = VectorSub(%endpos, %startpos);

  //How many steps is the movement going to take for the smoothness level?
  //%numsteps = (%time/1000) * %smoothness;
  //%interval = 1000 / %smoothness;
  %numsteps = (%time/250) * %smoothness;
  %interval = 250 / %smoothness;


  //Chop the big vector into that many parts to work out each step size.
  %stepvec = VectorScale(%Longvec, (1/%numsteps));

  %numstepsleft = %numsteps;

  %currpos = %startpos;
  //Start the movement
  PingPongMove(%obj, %startpos, %endpos, %numsteps, %numstepsleft, %stepvec, %currpos, %interval, %delay);

}

function PingPongMove(%obj, %startpos, %endpos, %numsteps, %numstepsleft, %stepvec, %currpos, %interval, %delay)
{

  %rot = rotFromTransform(%obj.getTransform());
  //echo("OldPos:" @ %currpos);

  %currpos = VectorAdd(%currpos, %stepvec);
  //echo ("NewPos:" @ %currpos);
  //echo ("Steps Remaining :" @ %numstepsleft);
  %obj.setTransForm(%currpos SPC %rot);
  //Movement Done, setup for next one
  %numstepsleft--;
  if(%numstepsleft < 1)
  {
    //Loop backwards after %delay ms
    %stepvec = VectorScale(%stepvec, -1);
    %numstepsleft = %numsteps;
    %currpos = %endpos;
    $PingPongMoveEvent = schedule( (%interval + %delay) , %obj, "PingPongMove", %obj, %endpos, %startpos, %numsteps, %numstepsleft, %stepvec, %currpos, %interval, %delay);
  }
  else
  {
    //Schedule another move
    $PingPongMoveEvent = schedule(%interval, %obj, "PingPongMove", %obj, %startpos, %endpos, %numsteps, %numstepsleft, %stepvec, %currpos, %interval, %delay);
  }

}
 
Last edited:

Defender

Member
Here are my rocks and markers...
You place a rock in the map, and place a movement marker for each rock across the map where you want it to move too, and then it moves back to its original position in a set time... This should work with .dts shapes too..

Code:
  new InteriorInstance(Rock1) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "1260.46 972.353 7767.67";
  rotation = "-0.424049 -0.671347 0.607845 65.2368";
  scale = "8 12 11";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  interiorFile = "legions/data/interiors/misc/rock2.dif";
  showTerrainInside = "0";
  TypeBool locked = "true";
  };
  new InteriorInstance(Rock2) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "1419.46 154.511 8027.63";
  rotation = "-0.784261 0.115615 -0.609563 75.9681";
  scale = "6 6 16";
  doDistanceFade = "1";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  interiorFile = "legions/data/interiors/misc/rock2.dif";
  showTerrainInside = "0";
  TypeBool locked = "true";
  };
  new InteriorInstance(Rock3) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "1092.94 -593.211 7909.93";
  rotation = "0.27119 -0.791739 0.547363 64.0745";
  scale = "7 4 9";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  interiorFile = "legions/data/interiors/misc/rock2.dif";
  showTerrainInside = "0";
  TypeBool locked = "true";
  };
  new InteriorInstance(Rock4) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "723.109 -1126.06 7299.36";
  rotation = "0.27119 -0.791739 0.547363 64.0745";
  scale = "7 4 9";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  interiorFile = "legions/data/interiors/misc/rock2.dif";
  showTerrainInside = "0";
  TypeBool locked = "true";
  };
  new InteriorInstance(Rock5) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "96.0555 -1092.27 7952.43";
  rotation = "0.27119 -0.791739 0.547363 64.0745";
  scale = "7 4 9";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  interiorFile = "legions/data/interiors/misc/rock2.dif";
  showTerrainInside = "0";
  TypeBool locked = "true";
  };
  new Marker(MoveMarker1) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "-746.888 283.779 7820.46";
  rotation = "1 0 0 0";
  scale = "1 1 1";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  seqNum = "256";
  type = "Normal";
  msToNext = "1000";
  smoothingType = "Spline";
  TypeBool locked = "true";
  };
  new Marker(MoveMarker2) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "-541.799 607.228 7820.46";
  rotation = "1 0 0 0";
  scale = "1 1 1";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  seqNum = "257";
  type = "Normal";
  msToNext = "1000";
  smoothingType = "Spline";
  locked = "true";
  };
  new Marker(MoveMarker3) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "-495.397 -4.95149 7798.11";
  rotation = "1 0 0 0";
  scale = "1 1 1";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  seqNum = "258";
  type = "Normal";
  msToNext = "1000";
  smoothingType = "Spline";
  TypeBool locked = "true";
  };
  new Marker(MoveMarker4) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "-333.353 -322.575 7792.82";
  rotation = "1 0 0 0";
  scale = "1 1 1";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  seqNum = "261";
  type = "Normal";
  msToNext = "1000";
  smoothingType = "Spline";
  TypeBool locked = "true";
  };
  new Marker(MoveMarker5) {
  canSaveDynamicFields = "1";
  Enabled = "1";
  position = "288.061 736.161 7813.07";
  rotation = "1 0 0 0";
  scale = "1 1 1";
  doDistanceFade = "0";
  startFadeDistance = "10";
  endFadeDistance = "500";
  blockExplosionDamage = "1";
  teamIndex = "-1";
  seqNum = "262";
  type = "Normal";
  msToNext = "1000";
  smoothingType = "Spline";
  TypeBool locked = "true";
  };
 
Last edited:
Top