Page 3 of 6

Posted: Thu Apr 08, 2004 8:24 pm
by raiser
Well at first I did'nt know what bdbodger trying to say, but after reading the message 7,8 times I finally understand. Its hard to understand staff like this unless u have done scripes before.

And its really crash the game after adding "spawn info_pathnode" in .scr file.(To think that after spending 1 hrs on it) :x

Now I'm trying bdbodger method. :wink:


Imageraiser_land.......

Posted: Thu Apr 08, 2004 8:33 pm
by M&M
congrats cheech ,u have made jv_map interested in the bot project again (yay) .maybe we can c something cool like this tool soon
My first attemp at making such a tool You can create nodes by simply pressing the fire button, now making a function to remove faulty nodes as well
btw where is it?
i hope u can complete the next version of bots soon (just anxious)

btw cheech,i pmed u about some problem im having with the bot stuff,check ur pm inbox :wink:

Posted: Thu Apr 08, 2004 8:42 pm
by jv_map
Oh well I didn't know you where interested in the actual script :P

Here it is:

Code: Select all

// bot test script
// by jv_map

main:
	waitthread makepathnodes

	level waittill spawn
	
	thread nodes
end

makepathnodes:	
	// copy & paste output log here
	// so you can load the existing paths
	// if you want to make a change :)
end

nodes:
	wait 5
	
	level.nodeID = 0
	
	waitthread makebeams 512 // makes # beams
	
	// init commands
	level.cmdlist = "writescript"::"removenode"
	for(local.i = 1; local.i <= level.cmdlist.size; local.i++)
		setcvar ("ne_" + level.cmdlist[local.i]) "0"
	
	// add existing nodes
	for(local.i = 1; local.i <= level.botnodes.size; local.i++)
	{
		waitthread addnode level.botnodes[local.i].origin
	}
	
	while(1)
	{
		local.cmd = NULL
		while (!($player.fireheld) && local.cmd == NULL)
		{
			waitframe
			local.cmd = waitthread processcommands
		}
		
		if(local.cmd != NULL)
		{
			switch(local.cmd)
			{
				writescript:
					waitthread writescript
					break
				removenode:
					waitthread removenode
					break
				default:
					println "unknow cmd " local.cmd "... bug bug bug! :("
			}
			waitframe
		}
		else
		{
			waitthread addnode $player.origin
		
			while ($player.fireheld)
				waitframe
		}
	}
end

processcommands:
	for(local.i = 1; local.i <= level.cmdlist.size; local.i++)
	{
		local.cvar = "ne_" + level.cmdlist[local.i]
		local.str = getcvar local.cvar
		if(local.str != "0")
		{
			setcvar local.cvar "0"
			end level.cmdlist[local.i]
		}
	}
end NULL

makebeams local.num:
	for(local.i = 1; local.i <= local.num; local.i++)
	{
		level.beams[local.i] = spawn func_beam
		level.beams[local.i] maxoffset 0.0
		level.beams[local.i] persist 1
		level.beams[local.i].inuse = 0	
	}
end

getbeam:
	for(local.i = 1; local.i <= level.beams.size; local.i++)
	{
		local.beam = level.beams[local.i]
		if(local.beam.inuse == 0)
		{
			local.beam.inuse = 1
			end local.beam
		}
	}
	println "WARNING: no more beams in stack :("
	// create a new beam
	//local.beam = spawn func_beam
	//local.beam.notstacked = 1
end local.beam

releasebeam local.beam:
	if(local.beam)
	{
		local.beam deactivate
		local.beam.inuse = 0
	}
end

addnode local.origin:
	local.node = spawn script_model model models/fx/corona_red.tik origin (local.origin + (0 0 32)) scale 3.0
	local.node notsolid
	local.node.numinbeams = 0
	local.node thread nodescale
	
	// make beams from this node to connecting nodes
	waitthread makenodebeams local.node
	
	level.nodeID++
	level.nodes[level.nodeID] = local.node
end

nodescale:
	while(self)
	{
		local.dist = vector_length (self.origin - $player.origin)
		
		if(local.dist <= 512)
			self.scale = 6.0
		else
			self.scale = 3.0
			
		wait 0.5	
	}
end

makenodebeams local.node:
	local.node.numoutbeams = 0
	for(local.i = 1; local.i <= level.nodeID; local.i++)
	{
		local.othernode = level.nodes[local.i]
		if(local.othernode)
		{
			local.dist = vector_length (local.othernode.origin - local.node.origin)	
			if(local.dist <= 512)
			{
				if(sighttrace local.othernode local.node 128)
				{
					local.beam = waitthread getbeam
					local.beam origin local.node.origin
					local.beam endpoint local.othernode.origin
					//local.beam updateendpoint
					local.beam color (0.0 1.0 0.0)
					local.beam doActivate
					
					local.beam thread beamvisibility
					
					local.node.numoutbeams++
					local.node.outbeams[local.node.numoutbeams] = local.beam
					
					local.othernode.numinbeams++
					local.othernode.inbeams[local.othernode.numinbeams] = local.beam
				}
			}
		}
	}
end

beamvisibility:	
	while(self && self.inuse == 1)
	{
		local.dist = vector_length (self.origin - $player.origin)
		
		if(local.dist <= 1024)
			self show
		else
			self hide
			
		wait 1.0	
	}
end

removenode:
	println "--- removenode ---"
	// find nearest node
	for(local.i = 1; local.i <= level.nodeID; local.i++)
	{
		local.node = level.nodes[local.i]
		if(local.node)
		{
			local.dist = vector_length($player.origin - local.node.origin)
			
			if(local.smallestdist == NIL || local.dist < local.smallestdist)
			{
				local.smallestdist = local.dist
				local.nearestnode = local.node
			}
		}
	}
	if(local.nearestnode)
	{
		// first remove any beams to and from this node
		for(local.i = 1; local.i <= local.nearestnode.numoutbeams; local.i++)
		{
			local.beam = local.nearestnode.outbeams[local.i]
			waitthread releasebeam local.beam	
		}
		for(local.i = 1; local.i <= local.nearestnode.numinbeams; local.i++)
		{
			local.beam = local.nearestnode.inbeams[local.i]
			waitthread releasebeam local.beam	
		}
		local.nearestnode remove	
	}
end

writescript:
	// write out the script
	println "--- writescript ---"
	
	level.loop_protection = 0
	
	setcvar "logfile" "1"
	
	println "8< ------------"
	local.j = 0
	for(local.i = 1; local.i <= level.nodeID; local.i++)
	{
		local.node = level.nodes[local.i]
		if(local.node)
		{
			local.j++
			waitthread writeblock local.node local.j
		}
	}
	println "-------------- >8"
	setcvar "logfile" "0"
	
	level.loop_protection = 1
	
	println "--- " local.j " nodes written to main/qconsole.log ---"
end

writeblock local.node local.num:
	local.vec = "( " + local.node.origin[0] + " " + local.node.origin[1] + " " + local.node.origin[2] + " )"
	println "level.botnodes[" local.num "] = spawn info_pathnode origin " local.vec " spawnflags 4"
end
You can use the console commands ne_removenode 1 and ne_writescript 1 to remove a node or to write the nodes made to the log.

You can then simply copy & paste the node code from qconsole.log into the makepathnodes thread. Make sure to delete the .pth first (if there is one).

8-)

Posted: Thu Apr 08, 2004 11:02 pm
by blue60007
So you just stick that into your script file for the map?

Posted: Fri Apr 09, 2004 12:07 am
by M&M
hmm :? this needs a tutorial by itself ,or am i 2 slow?
maybe because im not much of a scripter.
i would 've prefered a pk3 addon but .....
anyways i guess this script (part after makepathnodes)should be added into ur .scr file at the end and

Code: Select all

waitthread makepathnodes 
should be added right after main
then u would theoritically be able 2 remove and add nodes.and via the script editor or notepad in mohaa u can open the qconsole and take the stuff out and copy it into the thread jv mentioned am i right in the previous stuff i mentioned ?.
.and y do i have to del the .pth file ,what does it do anyways?
. I delete the .pth file since the .scr file have include the details of nodepaths and everythings. AND IT WORKS WITHOUT THE .pth FILE
seems like nothing,sry if im being a noob ,its just my 1st experience with bot stuff

Posted: Fri Apr 09, 2004 4:14 am
by blue60007
yeah, it looks great jv, but can you fill us in on how to use it?

Posted: Fri Apr 09, 2004 4:15 am
by blue60007
yeah, it looks great jv, but can you fill us in on how to use it? I understand how it works (sort of) but no clue on how to use it. :? Thanks!

Posted: Fri Apr 09, 2004 5:39 am
by bdbodger
well I made my own script for doing the nodes no beams like in JV's script but works good for me . You can get it here

to use it just put it in the global directory in main and then make an empty script for a map such as mohdm2.scr and put exec global/bodger_nodes.scr in it then save it in the dm directory for a dm map or obj directoy for a obj map . Remember name the script the same as the original script. Next run the map and you should see Pathnode system by Bdbodger in the middle of the screen and Pathnode system off below that . To activate it just hold the firebutton for a second then let it go you should then see Pathnode system on . Now as you run around the map you will see red coronas where you have been . Keep running around the map until you have it covered . when you are ready to make the .pth file type writescript 1 into the console and it will write to the log . If you don't have your log running type logfile 1 into the console first . That will give you output like this

Code: Select all

 <----------- Botpath node writeout--------------->
local.botnodes[0] = spawn info_pathnode origin ( -121.803 -413.253 5.287 ) spawnflags 4
local.botnodes[1] = spawn info_pathnode origin ( 3.615 -412.875 1.447 ) spawnflags 4
local.botnodes[2] = spawn info_pathnode origin ( 129.267 -415.558 -2.686 ) spawnflags 4
local.botnodes[3] = spawn info_pathnode origin ( 254.536 -418.561 -16.998 ) spawnflags 4
local.botnodes[4] = spawn info_pathnode origin ( 378.467 -421.532 -25.331 ) spawnflags 4
local.botnodes[5] = spawn info_pathnode origin ( 501.819 -424.639 -30.525 ) spawnflags 4
local.botnodes[6] = spawn info_pathnode origin ( 626.391 -428.654 -35.797 ) spawnflags 4
local.botnodes[7] = spawn info_pathnode origin ( 740.726 -474.060 -39.875 ) spawnflags 4
local.botnodes[8] = spawn info_pathnode origin ( 827.841 -563.355 -39.875 ) spawnflags 4
local.botnodes[9] = spawn info_pathnode origin ( 904.262 -661.888 -39.875 ) spawnflags 4
local.botnodes[10] = spawn info_pathnode origin ( 953.139 -788.332 -39.875 ) spawnflags 4
local.botnodes[11] = spawn info_pathnode origin ( 987.910 -911.777 -39.875 ) spawnflags 4
local.botnodes[12] = spawn info_pathnode origin ( 1022.407 -1045.394 -39.875 ) spawnflags 4
local.botnodes[13] = spawn info_pathnode origin ( 1053.025 -1166.837 -39.479 ) spawnflags 4
local.botnodes[14] = spawn info_pathnode origin ( 1086.252 -1298.629 -34.710 ) spawnflags 4
local.botnodes[15] = spawn info_pathnode origin ( 1116.976 -1420.488 -30.300 ) spawnflags 4
local.botnodes[16] = spawn info_pathnode origin ( 1150.000 -1551.476 -23.765 ) spawnflags 4
local.botnodes[17] = spawn info_pathnode origin ( 1181.056 -1674.077 -17.179 ) spawnflags 4
local.botnodes[18] = spawn info_pathnode origin ( 1217.649 -1807.122 -5.274 ) spawnflags 4
local.botnodes[19] = spawn info_pathnode origin ( 1254.088 -1938.307 9.010 ) spawnflags 4
local.botnodes[20] = spawn info_pathnode origin ( 1290.374 -2068.939 22.524 ) spawnflags 4
local.botnodes[21] = spawn info_pathnode origin ( 1322.028 -2192.403 35.398 ) spawnflags 4 
now just copy that into the empty script and comment out the exec global/bodger_nodes.scr and at the end of the script put

level waittill prespawn

Run the map again and you will get a .pth file for the map . Then delete the empty script you don't need it anymore . Now you have a .pth file for the map . If you want it to be a bot map you still have to add the nodes needed for bots like cheech did but hey at least you now have most of the pathnodes done . I don't think you can give the nodes targetnames so you will have to spawn nodes that need targetnames for bot stuff in the script for your map .

Posted: Fri Apr 09, 2004 7:08 am
by jv_map
Cool bdbodger... I like it the new botpioneers now have a choice :)

I'd like you to change one thing however, if that's ok with you... could you make it so that it writes level.botnodes[] instead of local.botnodes[] ? I'd love to be able to access the nodes in the bots scripts later on 8-)

Now onto my own version :)

Simply replace the map script with the script I posted and you should be able to place those damn nodes 8-). You can see when you are close enough to another node to make a path.. i.e this node will appear much larger than the others - that are too far away. I think however that I gotta use 384 instead of 512 as the distance value :?

Be aware it's only a very early version (only spent a few hours making it).. probably the neatest feature by now is that you can easily remove nodes by standing right at em and typing ne_removenode 1 in console (bind a key to it! ;)).

When you're done, type ne_writescript 1 and it should write the paths to the logfile (note there is a small bug here :oops: you gotta do writescript twice to get the full log mostly... I think it can be fixed though :))

Then copy + paste the nodes from the logfile into the makepathnodes thread, delete the .pth file (otherwise mohaa will crash) and type devmap mymap... you now should see the same nodes and paths as when you made the nodes... and when you type ai_showroutes 1 in console you should also see the actual paths the game made :)

Note that the actual paths are not always exactly the same as the paths shown in the 'editor'... that's because my editor only does a quick approximation (distance and line-of-sight) to see if a path is possible. The game uses a much more sophisticated algorithm and does some optimization.

Posted: Fri Apr 09, 2004 7:43 am
by bdbodger
Well JV my script is not ment to be used instead of yours just as a way of makeing a basic .pth file . I tried your script but had some problems with it I forget the error max poly or something . Also arn't pathnodes suppose to be 360 units or less away from each other ? I just set it up to make script_model coronas where you run as long as there are no others withing 128 units of you . I used 128 so that there were enough to get your ai around tight corners . I have no way to remove any except for editing the output of the log . I know you will have a better script for us soon I am sure . The .pth file I made for my test of mohdm1 was not too bad I made a ai and had him chase me to see if it was working well enough and it was . Like i said in my post after the .pth file was made I just discarded the temp script for the map with all the origins of the nodes in it but if it will make you happy I will change it to level.botnodes[] anything you want my friend is ok with me . here is what it looks like .

Image
Image

Posted: Fri Apr 09, 2004 9:55 am
by bdbodger
I was thinking JV what if you could lets say make some of the special bot type nodes by crouching or something or maybe if you have a pistol in your hand it makes a campnode and a different weapon make another type of node . Maybe if you type campnode 1 into the console then fire a weapon to make the node . Just some ideas for you to think about .

Posted: Fri Apr 09, 2004 10:09 am
by jv_map
Indeed there are great possibilities now 8-)

Posted: Fri Apr 09, 2004 11:13 am
by Mr. Pig

Code: Select all

 writeing script
 writeing script
made node
made node
 writeing script
made node
made node
 writeing script
made node
 writeing script

Disconnected from server
----- Server Shutdown -----
---------------------------
------- S_StopAllSounds (stop music) -------
------- S_StopAllSounds Complete-------
This is what I get from log file, I cannt see the origin location like bdbodger. Pls help.

Posted: Fri Apr 09, 2004 12:02 pm
by jv_map
Did you set developer at 1?

Posted: Fri Apr 09, 2004 12:20 pm
by Mr. Pig
Thks Jv_maps, its work :wink: