| | 178 | == WaypointPatrolController == |
| | 179 | |
| | 180 | An advanced version of the WaypointController is the WaypointPatrolController. Spaceships controlled by a simple WaypointController will never shoot at you, however if you replace the WaypointController by a WaypointPatrolController they do if you get close enough to them. Try it by setting the "alertnessradius" and "attackradius" attributes properly. |
| | 181 | |
| | 182 | == Templates == |
| | 183 | |
| | 184 | Let's expand the above example a little: |
| | 185 | {{{ |
| | 186 | #!xml |
| | 187 | <SpaceShip position="300,0,0" lookat="0,0,0" team=3> |
| | 188 | <templates> |
| | 189 | <Template link=spaceshipescort /> |
| | 190 | </templates> |
| | 191 | <controller> |
| | 192 | <WaypointController accuracy=10 team=3> |
| | 193 | <waypoints> |
| | 194 | <StaticEntity position="300,0,0" /> |
| | 195 | <StaticEntity position="300,500,0" /> |
| | 196 | <StaticEntity position="0,500,0" /> |
| | 197 | <StaticEntity position="0,0,0" /> |
| | 198 | </waypoints> |
| | 199 | </WaypointController> |
| | 200 | </controller> |
| | 201 | </SpaceShip> |
| | 202 | |
| | 203 | <SpaceShip position="300,500,0" lookat="0,0,0" team=3> |
| | 204 | <templates> |
| | 205 | <Template link=spaceshipassff2 /> |
| | 206 | </templates> |
| | 207 | <controller> |
| | 208 | <WaypointController accuracy=10 team=3> |
| | 209 | <waypoints> |
| | 210 | <StaticEntity position="300,0,0" /> |
| | 211 | <StaticEntity position="300,500,0" /> |
| | 212 | <StaticEntity position="0,500,0" /> |
| | 213 | <StaticEntity position="0,0,0" /> |
| | 214 | </waypoints> |
| | 215 | </WaypointController> |
| | 216 | </controller> |
| | 217 | </SpaceShip> |
| | 218 | |
| | 219 | <SpaceShip position="0,500,0" lookat="0,0,0" team=3> |
| | 220 | <templates> |
| | 221 | <Template link=spaceshippirate /> |
| | 222 | </templates> |
| | 223 | <controller> |
| | 224 | <WaypointController accuracy=10 team=3> |
| | 225 | <waypoints> |
| | 226 | <StaticEntity position="300,0,0" /> |
| | 227 | <StaticEntity position="300,500,0" /> |
| | 228 | <StaticEntity position="0,500,0" /> |
| | 229 | <StaticEntity position="0,0,0" /> |
| | 230 | </waypoints> |
| | 231 | </WaypointController> |
| | 232 | </controller> |
| | 233 | </SpaceShip> |
| | 234 | }}} |
| | 235 | There are now three different spaceships all following the same route. If you want to modify a single waypoint for all spaceships you have to change it at three different place in the XML code. A better approach is the use of templates: |
| | 236 | {{{ |
| | 237 | #!xml |
| | 238 | <Template name=waypointstemplate> |
| | 239 | <WaypointController> |
| | 240 | <waypoints> |
| | 241 | <StaticEntity position="300,0,0" /> |
| | 242 | <StaticEntity position="300,500,0" /> |
| | 243 | <StaticEntity position="0,500,0" /> |
| | 244 | <StaticEntity position="0,0,0" /> |
| | 245 | </waypoints> |
| | 246 | </WaypointController> |
| | 247 | </Template> |
| | 248 | |
| | 249 | <SpaceShip position="300,0,0" lookat="0,0,0" team=3> |
| | 250 | <templates> |
| | 251 | <Template link=spaceshipescort /> |
| | 252 | </templates> |
| | 253 | <controller> |
| | 254 | <WaypointController accuracy=10 team=3> |
| | 255 | <templates> |
| | 256 | <Template link=waypointstemplate /> |
| | 257 | </templates> |
| | 258 | </WaypointController> |
| | 259 | </controller> |
| | 260 | </SpaceShip> |
| | 261 | |
| | 262 | <SpaceShip position="300,500,0" lookat="0,0,0" team=3> |
| | 263 | <templates> |
| | 264 | <Template link=spaceshipassff2 /> |
| | 265 | </templates> |
| | 266 | <controller> |
| | 267 | <WaypointController accuracy=10 team=3> |
| | 268 | <templates> |
| | 269 | <Template link=waypointstemplate /> |
| | 270 | </templates> |
| | 271 | </WaypointController> |
| | 272 | </controller> |
| | 273 | </SpaceShip> |
| | 274 | |
| | 275 | <SpaceShip position="0,500,0" lookat="0,0,0" team=3> |
| | 276 | <templates> |
| | 277 | <Template link=spaceshippirate /> |
| | 278 | </templates> |
| | 279 | <controller> |
| | 280 | <WaypointController accuracy=10 team=3> |
| | 281 | <templates> |
| | 282 | <Template link=waypointstemplate /> |
| | 283 | </templates> |
| | 284 | </WaypointController> |
| | 285 | </controller> |
| | 286 | </SpaceShip> |
| | 287 | }}} |
| | 288 | |