Page 1 of 2

Following light AI... PLEASE HELP

Posted: Mon Nov 13, 2006 10:03 am
by psYco
Well for my latest project I want for this alien/spirit/soul to follow the player it will basically be a floating light that pretty much assists the player, but since this is a short term project that i intend to finish before I have done learning scripting, I was wondering if there is a script somewhere that allows for a pawn to follow the player? then i could just edit this pawn to carry a fog light and a regular light around and make its animation float and drift around... and then If some one could then tell me how to make the light to special tricks like just basic stuff like darting away from danger and moving towards trapped miners.

Thanks again for the help :)

Posted: Mon Nov 13, 2006 2:27 pm
by QuestOfDreams
This is from an older RF release:

follow.s

Code: Select all

{
	SCALE				[1]
	BOXWIDTH			[10]
	WALK		 		[Walk]		// walking animation
	WALKSPEED		  [70]		  // average walking speed
	FORCEUP 			[30]		  // obstacle avoidance jump speed
	FORCEFORWARD	  [30]		  // obstacle avoidance forward speed
	FORCESIDE		  [30]		  // obstacle avoidance sideways speed
	FOV				  [180]		 // field of view in degrees
	YAWSPEED			[120]		 // speed of rotation in deg/sec

	Start[ ()
	{
		Console(true);
		AvoidOrder("Avoidance");
		PlayAnimation("Idle", false, "");
		HostilePlayer(true);
		if(BOXWIDTH > 0)
		{
			BoxWidth(BOXWIDTH*SCALE);			// set bounding box width/depth
		}
		SetFOV(FOV);
		FindTargetOrder(100, "Follow", "health");
		NewOrder("DoNothing");
	} ]

	Avoidance[ ()
	{
		if(random(1,10)<3)	// backup and move sideways sometimes
		{
			MoveBackward(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
			MoveRight(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
		}
		else
		{
			Jump(WALK, FORCEUP*SCALE, true, "");
			if(random(1,10)<6)
			{
				Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, 90, 0, "");
			}
			else
			{
				Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, -90, 0, "");
			}
		}
		Return();
	} ]

	DoNothing[ ()
	{
		RestartOrder();
	} ]

	Follow[ ()
	{
		AddDistanceOrder(1, 60, "Wait");
		RotateMoveToTarget("Walk", YAWSPEED, WALKSPEED*SCALE, false, "");
		MoveToTarget("Walk", WALKSPEED*SCALE, "");
		NewOrder("Wait");
	} ]

	Wait[ ()
	{
		RotateToTarget("Idle", YAWSPEED, false, "");
		AddDistanceOrder(1, -80, "Follow");
		PlayAnimation("Idle", false, "");
		NewOrder("DoNothing");
	} ]

}

Posted: Mon Nov 13, 2006 2:48 pm
by psYco
W :shock: W! This is perfect! Thanks QoD! :D

Now Im just stuck on getting a light and foglight attached to the pawn any body know how?

Posted: Mon Nov 13, 2006 3:10 pm
by Juutis
It seems that you can't attach a foglight to any entity. The normal light entity doesn't have this feature either. So you'll need to use DynamicLight.

Name the pawn something like 'LighterPawn' and enter that name in the DynamicLight's field 'EntityName'. In the 'BoneName' field enter the name of the bone you want the light to attach to.
That should do it...

Posted: Mon Nov 13, 2006 3:15 pm
by QuestOfDreams
It seems that you can't attach a foglight to any entity
The MorphingField entity is a dynamic foglight effect.

Posted: Mon Nov 13, 2006 5:25 pm
by psYco
Wow thanks alot guys! This sounds very promising! Ill give it a try and post back tommorow! :D

Posted: Sun Nov 19, 2006 2:47 pm
by psYco
i have made my pawn and given it its basic 'idle' animation (witch it should use for everything since its just a floating ball of light) and well the problem is that it seems to 'spawn' when the level starts but it then doesnt play an animation and it also doesent 'follow' the player! :(

here is the script (i made a few changes did i mess it up????)

Code: Select all

{ 
   SCALE            [1] 
   BOXWIDTH         [10] 
   WALK             [idle]      // walking animation 
   WALKSPEED        [70]        // average walking speed 
   FORCEUP          [30]        // obstacle avoidance jump speed 
   FORCEFORWARD     [30]        // obstacle avoidance forward speed 
   FORCESIDE        [30]        // obstacle avoidance sideways speed 
   FOV              [180]       // field of view in degrees 
   YAWSPEED         [120]       // speed of rotation in deg/sec 

   Start[ () 
   { 
      Console(true); 
      AvoidOrder("Avoidance"); 
      PlayAnimation("Idle", false, ""); 
      HostilePlayer(true); 
      if(BOXWIDTH > 0) 
      { 
         BoxWidth(BOXWIDTH*SCALE);         // set bounding box width/depth 
      } 
      SetFOV(FOV); 
      FindTargetOrder(100, "Follow", "health"); 
      NewOrder("DoNothing"); 
   } ] 

   Avoidance[ () 
   { 
      if(random(1,10)<3)   // backup and move sideways sometimes 
      { 
         MoveBackward(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, ""); 
         MoveRight(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, ""); 
      } 
      else 
      { 
         Jump(WALK, FORCEUP*SCALE, true, ""); 
         if(random(1,10)<6) 
         { 
            Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, 90, 0, ""); 
         } 
         else 
         { 
            Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, -90, 0, ""); 
         } 
      } 
      Return(); 
   } ] 

   DoNothing[ () 
   { 
      RestartOrder(); 
   } ] 

   Follow[ () 
   { 
      AddDistanceOrder(1, 60, "Wait"); 
      RotateMoveToTarget("Walk", YAWSPEED, WALKSPEED*SCALE, false, ""); 
      MoveToTarget("Walk", WALKSPEED*SCALE, ""); 
      NewOrder("Wait"); 
   } ] 

   Wait[ () 
   { 
      RotateToTarget("Idle", YAWSPEED, false, ""); 
      AddDistanceOrder(1, -80, "Follow"); 
      PlayAnimation("Idle", false, ""); 
      NewOrder("DoNothing"); 
   } ] 

}

and here is the entry for it in the pawn INI:

Code: Select all

 [lightball]
actorname = lightball.act
actorrotation = 0 180 0
actorscale = 1
fillcolor = 255 255 255
ambientcolor = 255 255 255
subjecttogravity = false
boundingboxanimation = Idle
shadowsize = 30 

Image

What am i doing wrong??

Thans for all the help! :D

Posted: Sun Nov 19, 2006 4:55 pm
by Juutis
In the script the first order is called 'Start' but in the pawn properties in the editor you have set 'Spawn' as the 'SpawnOrder'. So change it to 'Start'.

Posted: Sun Nov 19, 2006 6:14 pm
by psYco
Okay that was just me being stupid! Thanks for the help! :D

Okay now it follows the player but it still doesnt play its 'idle' animation! i named the one animation idle and in the field for the walk animation (as you seen in my last post) I put idle... why wont it work?

Oh and also how do I make the lightball 'no clip' so that it can go through walls and also so the player doesnt get 'stuck' on it...

Thanks again!

Posted: Sun Nov 19, 2006 6:36 pm
by psYco
Sorry for all the questions but I have another problem, In milk shape I made the balls texture plain white and i made the specular adn diffuse maps white aswell so basically the ball was COMPLETELY white, but now in the engien the ball looks quite grey how can i correct this?

Image

Please dont let this post distract from the questions in the last post cause i still havent worked that out either. :)

Oh and as you can see I have attached the dynamic light and fog light... :D

Posted: Mon Nov 20, 2006 3:30 pm
by scott
this what i found hard, if you put a 16x16 wite texture on it, that will osrt your problem out, its because things like specular mpas and stuff are artificaly added to that group, it doest have a source of light to get a 'shine' from or what ever effect you are after. at least thats what i think but putting a white textyure will work.

Posted: Mon Nov 20, 2006 8:27 pm
by psYco
WOW scott thanks that really worked (i cant seem to figure out why but making the textue 16x16 worked?) Thanks man!

The animation is still not playing tho can anyone see why??

Thanks again I really am greatfull! Ounce I work out this ai then i can start perfecting the destructable terrain and then ill be able to start the game! :D :D

Posted: Mon Nov 20, 2006 8:56 pm
by psYco
I really want this thing to look like a rip in time and space at the moment it just looks like a ball, witch is not so great...

Here is how it looks now (a big improvement thanks to scott) but still not really like it looks in milkshape... any suggestions??

Image

:EDIT: The animation is still not playing tho can anyone see why??

Thanks again I really am greatfull! Ounce I work out this ai then i can start perfecting the destructable terrain and then ill be able to start the game! :D :D :EDIT:

Posted: Tue Nov 21, 2006 5:57 pm
by jonas
please explain your problem with animation a little more. Is it the virgil model?

Posted: Tue Nov 21, 2006 10:15 pm
by GD1
the specular effects in milkshape do not translate to RF. the only thing MS3D does material wise is add in the diffuse texture you specify. But, you can get this look in RF using EMBM (the BMS_ map is a lightmap/specular map that can be used for glow effects). Or you could use a smaller actor like Proj.act and attach a corona or flipbook entity to it.