Page 2 of 3

nope

Posted: Wed Sep 01, 2004 1:09 pm
by tltrude
No, it is the same.

Posted: Wed Sep 01, 2004 2:46 pm
by jv_map
Try this:

Code: Select all


pole_prep:

local.POLE_SEPERATION = 3680 // distance between poles
local.SPEED = 1536.0 // terrain speed (3 X 512)

local.poles = $pole1::$pole2::$pole3::$pole4

local.basepoint = $polewayA.origin
local.movevec = $polewayB2.origin - local.basepoint
local.trackdist = vector_length local.movevec
local.dirvec = (1.0 / local.trackdist) * local.movevec // unit vector
local.poles[1].origin = $polewayA.origin
local.dist = 0.0 // distance travelled

//pole movement loop

while(1)
{
   // space the poles along the track
   for(local.i = 1; local.i <= local.poles.size; local.i++)
   {
      local.pole = local.poles[local.i]
      local.pole show
      local.dist_on_track = local.dist + local.POLE_SEPERATION * (local.i - 1)
      if(local.dist_on_track > local.trackdist)
      {
         // move back to the beginning
         local.dist_on_track -= local.trackdist
         local.pole hide
      }
      local.pole.origin = local.basepoint + local.dist_on_track * local.dirvec
   }
   waitframe
   local.dist += local.SPEED * 0.05
   
   // this is only to prevent the dist variable from getting too large
   if(local.dist > local.trackdist)
      local.dist -= local.trackdist
}
 
end 
I only added a local.pole show and a local.pole hide line... no idea if it makes a difference :?

nope

Posted: Thu Sep 02, 2004 12:55 am
by tltrude
Does not work. The poles that have returned stay hidden untill all four poles have returned. Then they all show at the same time and it starts all over again. Also the "hide" does not happen fast enough, so the returning poles still flicker on there way back to the start point.

Posted: Thu Sep 02, 2004 3:07 pm
by Shuriken1
Please excuse my stupidity but whats wrong with:

Code: Select all

local.poles[1] hide
local.poles[1] time .005 
local.poles[1] moveto $polewayA 
local.poles[1] waitmove
local.poles[1] show

moveto

Posted: Thu Sep 02, 2004 5:16 pm
by tltrude
Nothing, but that is originally how I had it and the poles got out of sync with each other.

I tryed this, but it seems to ignore the moveto lines.

Code: Select all

      if(local.dist_on_track > local.trackdist) 
      { 
         // move back to the beginning
         local.pole time .001
         local.pole moveto $polewayC
         waitmove
         local.pole moveto $polewayD
         waitmove
         local.dist_on_track -= local.trackdist 
      } 

Posted: Thu Sep 02, 2004 6:03 pm
by Shuriken1
Could you have something that is in infinitely looping round waiting for something to enter the final position, ie. the final waypoint of the loop and move it back to the starting position. I'm not sure how you would code that, I just can't help thinking there is a much more simple method :?

array

Posted: Fri Sep 03, 2004 2:13 am
by tltrude
I think the problem is that it uses a "Constant array" rather than a "Targetname array" for the poles. Would it be better to just name all the poles "pole" and then index them with a for loop?

Re: array

Posted: Fri Sep 03, 2004 6:56 am
by jv_map
tltrude wrote:I think the problem is that it uses a "Constant array" rather than a "Targetname array" for the poles. Would it be better to just name all the poles "pole" and then index them with a for loop?
I can't see why that would matter :?

SO?

Posted: Fri Sep 03, 2004 9:47 pm
by tltrude
So, how do I fix it?
I don't really understand how your thread moves the poles.
Is it changing the poles origin by one unit 14720 times?
What does (-=) and (+=) mean?
Can I replace "local.basepoint" with "$polewayA.origin"?
I'm guessing that to get the pole to go back, the vector direction is reversed from ( 0 -14720 0) to ( 0 14720 0).
Am I right?

Re: SO?

Posted: Sat Sep 04, 2004 8:19 am
by jv_map
tltrude wrote:So, how do I fix it?
I don't really understand how your thread moves the poles.
Is it changing the poles origin by one unit 14720 times?
What does (-=) and (+=) mean?
local.a -= local.b means local.a = local.a - local.b, and similar for +=. Hence the origin of the poles does not increase with 1 unit but with 0.05 * local.SPEED each frame :)
Can I replace "local.basepoint" with "$polewayA.origin"?
Yes... I personally hate to use targetnames all throughout a script because they may be subject to change... hence I usually store them in some universal variable somewhere at the top of the script... it's only personal preference though so you can change it as you like.
I'm guessing that to get the pole to go back, the vector direction is reversed from ( 0 -14720 0) to ( 0 14720 0).
Am I right?
No not at all ;) .. the pole doesn't actually move back...

Quote:

Code: Select all

      if(local.dist_on_track > local.trackdist)
      {
         // move back to the beginning
         local.dist_on_track -= local.trackdist
      } 
      local.pole.origin = local.basepoint + local.dist_on_track * local.dirvec 
This little bit of code checks if a pole has exceeded the length of the track, and if it is the distance of the track is subtracted from its current distance from the startpoint. Hence, say a pole has passed the last waypoint by 10 units, it's dist_on_track would be trackdist + 10, and the if block would change that to trackdist + 10 - trackdist = 10 so the pole is placed at 10 units from the start waypoint.

Hope this clears it up somehow :?

ok

Posted: Sun Sep 05, 2004 9:31 am
by tltrude
Thanks, that helped a lot! But, I still don't understand why I can't get the retuning pole to loop underground. Below is the script with all the know value variables removed. It worked the same as before until I added an offset. Now, all four poles stay underground until they get to polewayB. Then they all pop up together and start sending the poles back one by one to be assembled underground again.

So basically, I don't know why the four poles act as one. Nor do I understand why they pop up 3680 units before they reach polewayB2 (the endpoint) and not one by one at polewayA.

Code: Select all

// Test poles
// ARCHITECTURE: ATOMIC
// SCRIPTING: ATOMIC & TLTRUDE

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "test poles!"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" ""

	level waittill prespawn
 
	//***Precache Dm Stuff
	exec global/DMprecache.scr
	level.script = maps/dm/test_jpoles.scr
	exec global/ambient.scr m6l3a // for background sound

	spawn info_waypoint targetname "polewayB2"
	$polewayB2.origin = ($polewayB.origin + ( -3680 0 0 ))

	thread pole_prep

	level waittill spawn 

end

//------------------------------>
// Pole Thread
//------------------------------>

pole_prep: 

local.poles = $pole1::$pole2::$pole3::$pole4 

local.poles[1].origin = $polewayA.origin 
local.dist = 0.0

//pole movement loop 

while(1) 
{ 
   for(local.i = 1; local.i <= local.poles.size; local.i++) 
   { 
      local.poles[local.i].offset = ( 0 0 0 ) 
      local.pole = local.poles[local.i] 
      local.dist_on_track = local.dist + 3680 * (local.i - 1) 
      if( local.dist_on_track > 14720 ) 
      { 
         local.dist_on_track = ( local.dist_on_track - 14720 ) 
         local.poles[local.i].offset = ( 0 0 -1000 ) 
      } 
      local.pole.origin = $polewayA.origin + ((local.dist_on_track * ( -1 0 0 )) + local.poles[local.i].offset )
   } 
   waitframe 
   local.dist = ( local.dist + 76.8 ) 
   if( local.dist > 14720 ) 
      local.dist = ( local.dist - 14720 ) 
} 
  
end
There are two waypoints underground ($polewayC and $polewayD) which are not being used, and $polewayB is only being used as a reference to spawn $polewayB2. I can add a fifth pole, if needed.
I am sorry to be such a pest about this, but your thread is unuseable if the poles return above ground.

Posted: Sun Sep 05, 2004 5:48 pm
by jv_map
Hmm :? well here's some things you could still try:

- Use plain Entities instead of ScriptSlaves.
- Instead of local.pole.origin = (x y z) use local.pole origin (x y z)
- Try the below commands:
local.pole stationary
local.pole effects "+antisbjuice"

Here's a convenient method for turning a script_object into an Entity:

Code: Select all

local.script_object_poles = $pole1::$pole2::$pole3::$pole4
for(local.i = 1; local.i <= local.script_object_poles.size; local.i++)
{
  local.poles[local.i] = waitthread reclassobject local.script_object_poles[local.i] Entity
}

// (...)

// -------------------
// spawns a new object with same brushmodel and removes old object
reclassobject local.object local.newclass:
  local.newobj = spawn local.newclass origin local.object.origin angles local.object.angles model local.object.brushmodel
  local.object remove
end local.newobj

strange

Posted: Sun Sep 05, 2004 9:43 pm
by tltrude
A strange thing happened. I increased the distance between wayponts to 18400 units and added a fifth pole. Now I can not see the returning poles! It still needs to be tested on the full map.

It might be that the map just has a little more or less fps and that what fixed it. I have been testing terrain brushes on the test map too, and they may have caused the change.

I tried the "entity" thing and it works, but it does not seem to do anything different for the 5 poles version. I did not try it with 4 poles. I don't know how, or where, to use those other two new lines.

Code: Select all

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "test poles!"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" ""

	level waittill prespawn
 
	//***Precache Dm Stuff
	exec global/DMprecache.scr
	level.script = maps/dm/test_jpoles.scr
	exec global/ambient.scr m6l3a // for background sound

	spawn info_waypoint targetname "polewayB2"
	$polewayB2.origin = ($polewayB.origin + ( -3760 0 0 ))
	spawn info_waypoint targetname "polewayA2"
	$polewayA2.origin = ($polewayA.origin + ( 3600 0 0 ))

	thread pole_prep

	level waittill spawn 

end

//------------------------------>
// Pole Thread
//------------------------------>

pole_prep: 

local.poles = $pole1::$pole2::$pole3::$pole4::$pole5 

local.poles[1].origin = $polewayA2.origin
local.dist = 0.0

//poles movement loop 

while(1) 
{  
   for(local.i = 1; local.i <= local.poles.size; local.i++) 
   { 
      local.pole = local.poles[local.i] 
      local.dist_on_track = local.dist + 3680 * (local.i - 1) 
      if( local.dist_on_track > 18400 ) 
      { 
         local.dist_on_track = ( local.dist_on_track - 18400 ) 
      } 
      local.pole.origin = $polewayA2.origin + (local.dist_on_track * ( -1 0 0 ))
   } 
   waitframe 
   local.dist = ( local.dist + 76.8 ) 
   if( local.dist > 18400 ) 
      local.dist = ( local.dist - 18400 )
} 
  
end

test

Posted: Sat Sep 11, 2004 7:19 am
by tltrude
I tested it in the full size map and all is well. so, a big thanks to you jv_map!!!!!!!!!!!

Posted: Sat Sep 11, 2004 8:13 am
by At0miC
Yay! 8-), thanks m8