mirror of https://github.com/dirtbags/moth.git
67 lines
3.7 KiB
Plaintext
67 lines
3.7 KiB
Plaintext
|
( todo: Set treads to turn relative to tank position, not turret position. It )
|
||
|
( works okay now since the treads help turn the turret faster, but I think )
|
||
|
( it could be better. )
|
||
|
( sensors: )
|
||
|
( 0: firing sensor )
|
||
|
( 1: fore collision sensor )
|
||
|
( 2: starboard fore long-range turret-mounted sensor )
|
||
|
( 3: fore short-range sensor )
|
||
|
( 4: port fore long-range turret-mounted sensor )
|
||
|
( 5: starboard mid-range turrent-mounted sensor )
|
||
|
( 6: port mid-range turrent-mounted sensor )
|
||
|
( 7: fore long-range turret-mounted sensor )
|
||
|
( 8: starboard long-range turret-mounted sensor )
|
||
|
( 9: port long-range turret-mounted sensor )
|
||
|
|
||
|
fire-ready? { 1 set-led! } ( Turn on led if cannon is ready. )
|
||
|
{ 0 set-led!
|
||
|
3 sensor? { -100 -100 set-speed! } if
|
||
|
} ifelse
|
||
|
|
||
|
0 sensor? { fire! } if
|
||
|
|
||
|
1 sensor? { -100 -100 set-speed! }
|
||
|
{
|
||
|
7 sensor? ( If there is an enemy dead ahead )
|
||
|
{ fire-ready? ( and the cannon is ready, speed )
|
||
|
{ 0 sensor? { fire! } ( up to catch it and fire when in )
|
||
|
{ 1 sensor? { } ( range. if cannon is not ready, )
|
||
|
{ 100 100 set-speed! } ifelse ( pursue at a safe distance. if )
|
||
|
} ifelse ( the enemy gets too close, back )
|
||
|
} ( off. )
|
||
|
{ 1 sensor? { }
|
||
|
{ 3 sensor? { -100 -100 set-speed! }
|
||
|
{ 100 100 set-speed! } ifelse
|
||
|
} ifelse
|
||
|
} ifelse
|
||
|
}
|
||
|
{ 8 sensor? ( If there is an enemy on right, )
|
||
|
{ 6 sensor? ( turn right, but if there is a )
|
||
|
{ get-turret 20 - set-turret! ( closer enemy on left, turn left. )
|
||
|
1 sensor? { } ( To avoid collisions, flee if an )
|
||
|
{ 3 sensor? { -100 -80 set-speed! } ( an enemy gets too close. )
|
||
|
{ -100 100 set-speed! } ifelse
|
||
|
} ifelse
|
||
|
}
|
||
|
{ 2 sensor?
|
||
|
{ get-turret 5 + set-turret! 100 50 set-speed! }
|
||
|
{ get-turret 20 + set-turret! 100 -100 set-speed! } ifelse
|
||
|
} ifelse
|
||
|
}
|
||
|
{ 9 sensor? ( If there is an enemy on left, )
|
||
|
{ 5 sensor? ( turn left, but if there is a )
|
||
|
{ get-turret 20 + set-turret! ( closer enemy on right, turn )
|
||
|
1 sensor? { } ( right. To avoid collisions, flee )
|
||
|
{ 3 sensor? { -80 -100 set-speed! } ( if an enemy gets too close. )
|
||
|
{ 100 -100 set-speed! } ifelse
|
||
|
} ifelse
|
||
|
}
|
||
|
{ 4 sensor?
|
||
|
{ get-turret 5 - set-turret! 50 100 set-speed! }
|
||
|
{ get-turret 20 - set-turret! -100 100 set-speed! } ifelse
|
||
|
} ifelse
|
||
|
}
|
||
|
{ 100 100 set-speed! 0 set-turret! } ifelse ( if there are no nearby tanks, )
|
||
|
} ifelse ( maintain cruising speed and )
|
||
|
} ifelse ( reset turret to face forward. )
|
||
|
} ifelse
|