Following light AI... PLEASE HELP

Topics regarding Scripting with Reality Factory
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Following light AI... PLEASE HELP

Post 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 :)
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post 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");
	} ]

}
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Post 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?
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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...
Pain is only psychological.
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

It seems that you can't attach a foglight to any entity
The MorphingField entity is a dynamic foglight effect.
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Post by psYco »

Wow thanks alot guys! This sounds very promising! Ill give it a try and post back tommorow! :D
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Post 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
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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'.
Pain is only psychological.
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Post 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!
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Post 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
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post 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.
*GD*
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Post 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
User avatar
psYco
Posts: 782
Joined: Wed Mar 15, 2006 10:55 am
Location: England

Post 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:
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas »

please explain your problem with animation a little more. Is it the virgil model?
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
GD1
Posts: 413
Joined: Tue Jul 05, 2005 2:33 pm

Post 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.
Check out my band
Tougher Than Fort Knox
Image
Post Reply