|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Mon Apr 19, 2010 1:58 am
Pathfinding |
What would be the best way to restrict rooms of certain color from being used to find a path from point a to b without having to mark over half a zone as do not enter?
For example, say a given map has 4 different types of rooms colored Red, Green, Blue, and Yellow.
At any given time one color of room is safe to walk in
The others hurt you to varying degrees.
The amount they hurt could change, from day to day.
If the relative safeness for the 4 room types was known and ranked..
how could i calculate the safest path and or the quickest path with a given acceptable risk? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Mon Apr 19, 2010 1:44 pm |
You can go in and programically assign a cost to each room based on color. And then the built in path finding routine would work for you.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Mon Apr 19, 2010 9:39 pm |
An example would help.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Tue Apr 20, 2010 12:19 am |
This is off the top of my head so I haven't had a chance to test it. But it should at least get you going.
Code: |
#call %maplocked( 0)
#SAY Changes to map permitted...
#LOOP %numrooms( )
{
#IF (%roomcol( %mapvnum( %i)) = "536870911") { // use color # for specified color
#ECHO Changing Room cost
#call %roomcost( %mapvnum( %i), #) // Replace # with cost of room
}
|
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Tue Apr 20, 2010 2:22 am |
this is what i came up with...
Code: |
alias name="mapsetter" id="128">
<value>$thismap=CTF
$safe=%colorname(green)
$slow=%colorname(yellow)
$pain=%colorname(red)
$kill=%colorname(black)
#CALL %mapfilter( %concat( "ZoneID = ", %zonenum( $thisMap)))
#CALL %maplocked( 0)
#LOOP %numrooms {
#SWITCH (%roomcol(%roomvnum(%i)))
($safe) {#CALL %roomcost(%roomvnum(%i), 5)}
($slow) {#CALL %roomcost(%roomvnum(%i), 10)}
($pain) {#CALL %roomcost(%roomvnum(%i), 50)}
($death) {#CALL %roomcost(%roomvnum(%i), -1)}
}
#CALL %maplocked( 1)
#CALL %mapfilter("")</value>
</alias> |
This does in fact work, but in a zone with over 1000 rooms it took near 4 minutes to finish. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Tue Apr 20, 2010 1:15 pm |
Someone with a little more database knowledge might be able to speed up the script. The good news, is that once you do this you will never have to do it again. :) Just create any new rooms now that are colored with the roomcost.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Tue Apr 20, 2010 7:28 pm |
Actually it was for a zone where the roomcosts change at given intervals... so i will have to run it at least once a day.. but i suppose i can spare a few minutes.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|