[Orxonox-commit 2319] r7034 - in code/branches/presentation3: . data/levels data/levels/templates src/modules/pickup src/modules/pickup/items src/orxonox src/orxonox/controllers src/orxonox/interfaces src/orxonox/worldentities
landauf at orxonox.net
landauf at orxonox.net
Mon May 31 05:31:50 CEST 2010
Author: landauf
Date: 2010-05-31 05:31:50 +0200 (Mon, 31 May 2010)
New Revision: 7034
Added:
code/branches/presentation3/src/modules/pickup/items/DronePickup.cc
code/branches/presentation3/src/modules/pickup/items/DronePickup.h
code/branches/presentation3/src/orxonox/controllers/DroneController.cc
code/branches/presentation3/src/orxonox/controllers/DroneController.h
code/branches/presentation3/src/orxonox/worldentities/Drone.cc
code/branches/presentation3/src/orxonox/worldentities/Drone.h
Modified:
code/branches/presentation3/
code/branches/presentation3/data/levels/pickups.oxw
code/branches/presentation3/data/levels/templates/pickup_representation_templates.oxt
code/branches/presentation3/data/levels/templates/spaceship_pirate.oxt
code/branches/presentation3/src/modules/pickup/PickupPrereqs.h
code/branches/presentation3/src/modules/pickup/items/CMakeLists.txt
code/branches/presentation3/src/orxonox/OrxonoxPrereqs.h
code/branches/presentation3/src/orxonox/controllers/AIController.cc
code/branches/presentation3/src/orxonox/controllers/ArtificialController.cc
code/branches/presentation3/src/orxonox/controllers/ArtificialController.h
code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt
code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.cc
code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.h
code/branches/presentation3/src/orxonox/interfaces/PickupCarrier.h
code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt
Log:
merged ai branch to presentation3
Property changes on: code/branches/presentation3
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/dynamicmatch:6584-7030
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
+ /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/dynamicmatch:6584-7030
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
Modified: code/branches/presentation3/data/levels/pickups.oxw
===================================================================
--- code/branches/presentation3/data/levels/pickups.oxw 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/data/levels/pickups.oxw 2010-05-31 03:31:50 UTC (rev 7034)
@@ -25,6 +25,14 @@
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
<SpawnPoint position="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ <!-- Drone pickup -->
+
+ <PickupSpawner position="-100,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <DronePickup droneTemplate=droneTemplate />
+ </pickup>
+ </PickupSpawner>
+
<!-- Shield pickups -->
<PickupSpawner position="-25,-25,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10">
Modified: code/branches/presentation3/data/levels/templates/pickup_representation_templates.oxt
===================================================================
--- code/branches/presentation3/data/levels/templates/pickup_representation_templates.oxt 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/data/levels/templates/pickup_representation_templates.oxt 2010-05-31 03:31:50 UTC (rev 7034)
@@ -1,428 +1,459 @@
-<!-- Shield pickups: -->
-
-<Template name=smallshieldpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="1,1,1" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="1,1,1" material="Shield" scale=0.3 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=smallshieldpickup>
- <ShieldPickup
- duration = 10
- shieldabsorption = 0.7
- shieldhealth = 300
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-
-<Template name=mediumshieldpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="1,1,1" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="1,1,1" material="Shield" scale=0.5 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=mediumshieldpickup>
- <ShieldPickup
- duration = 30
- shieldabsorption = 0.8
- shieldhealth = 500
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-
-<Template name=hugeshieldpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="1,1,1" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="1,1,1" material="Shield" scale=0.7 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=hugeshieldpickup>
- <ShieldPickup
- duration = 60
- shieldabsorption = 0.95
- shieldhealth = 700
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<!-- Health pickups: -->
-
-<Template name=smallhealthpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.3 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=smallhealthpickup>
- <HealthPickup
- health = 10
- healthType = "limited"
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=mediumhealthpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.5 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=mediumhealthpickup>
- <HealthPickup
- health = 50
- healthType = "limited"
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=hugehealthpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.7 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=hugehealthpickup>
- <HealthPickup
- health = 100
- healthType = "limited"
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=crazyhealthpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=1.2 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=crazyhealthpickup>
- <HealthPickup
- health = 1000
- healthType = "permanent"
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<!-- Meta pickups: -->
-
-<Template name=usepickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.60,0.97,0.23" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.40,0.81,0.10" material="Arrow" scale=0.65 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=droppickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.95,0.10,0.05" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.95,0.20,0.10" material="Arrow" scale=0.65 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<!-- Speed pickups -->
-
-<Template name=smallspeedpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.3 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=smallspeedpickup>
- <SpeedPickup
- duration = 10.0
- speedAdd = 0.0
- SpeedMultiply = 10.0
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=mediumspeedpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.5 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=mediumspeedpickup>
- <SpeedPickup
- duration = 10.0
- speedAdd = 0.0
- SpeedMultiply = 25.0
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=hugespeedpickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.7 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=hugespeedpickup>
- <SpeedPickup
- duration = 10.0
- speedAdd = 0.0
- SpeedMultiply = 50.0
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=smalljumppickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="1,0,0" material="3arrowsup" scale=0.3 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=smalljumppickup>
- <SpeedPickup
- duration = 0.7
- speedAdd = 5000.0
- SpeedMultiply = 1.0
- activationType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<!-- Invisible pickups -->
-
-<Template name=smallinvisiblepickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.22,0.32,0.86" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.06,0.14,0.63" material="Eye" scale=0.5 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=smallinvisiblepickup>
- <InvisiblePickup
- duration = 5.0
- activaionType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=mediuminvisiblepickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.22,0.32,0.86" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.06,0.14,0.63" material="Eye" scale=0.7 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=mediuminvisiblepickup>
- <InvisiblePickup
- duration = 10.0
- activaionType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<Template name=hugeinvisiblepickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.22,0.32,0.86" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,0,0" colour="0.06,0.14,0.63" material="Eye" scale=0.9 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=hugeinvisiblepickup>
- <InvisiblePickup
- duration = 20.0
- activaionType = "immediate"
- durationType = "once"
- />
-</Template>
-
-<!-- Pickup Collection pickups -->
-
-<Template name=triplehealthspeedinvisibilitypickupRepresentation>
- <PickupRepresentation>
- <spawner-representation>
- <StaticEntity>
- <attached>
- <Billboard position="0,0,0" colour="0.95,0.85,0.27" material="Sphere2" scale=0.1>
- <attached>
- <Billboard position="0,20,0" colour="0.36,0.81,0.10" material="Cross" scale=0.25 />
- <Billboard position="-20,-10,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.25 />
- <Billboard position="20,-10,0" colour="0.06,0.14,0.63" material="Eye" scale=0.35 />
- </attached>
- </Billboard>
- </attached>
- </StaticEntity>
- </spawner-representation>
- </PickupRepresentation>
-</Template>
-
-<Template name=triplehealthspeedinvisibilitypickup>
- <PickupCollection>
- <pickupables>
- <HealthPickup template=mediumhealthpickup />
- <SpeedPickup template=mediumspeedpickup />
- <InvisiblePickup template=mediuminvisiblepickup />
- </pickupables>
- </PickupCollection>
-</Template>
-
+<!-- Shield pickups: -->
+
+<Template name=smallshieldpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="1,1,1" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="1,1,1" material="Shield" scale=0.3 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=smallshieldpickup>
+ <ShieldPickup
+ duration = 10
+ shieldabsorption = 0.7
+ shieldhealth = 300
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+
+<Template name=mediumshieldpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="1,1,1" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="1,1,1" material="Shield" scale=0.5 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=mediumshieldpickup>
+ <ShieldPickup
+ duration = 30
+ shieldabsorption = 0.8
+ shieldhealth = 500
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+
+<Template name=hugeshieldpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="1,1,1" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="1,1,1" material="Shield" scale=0.7 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=hugeshieldpickup>
+ <ShieldPickup
+ duration = 60
+ shieldabsorption = 0.95
+ shieldhealth = 700
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<!-- Health pickups: -->
+
+<Template name=smallhealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.3 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=smallhealthpickup>
+ <HealthPickup
+ health = 10
+ healthType = "limited"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=mediumhealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.5 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=mediumhealthpickup>
+ <HealthPickup
+ health = 50
+ healthType = "limited"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=hugehealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.7 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=hugehealthpickup>
+ <HealthPickup
+ health = 100
+ healthType = "limited"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=crazyhealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=1.2 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=crazyhealthpickup>
+ <HealthPickup
+ health = 1000
+ healthType = "permanent"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<!-- Meta pickups: -->
+
+<Template name=usepickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.60,0.97,0.23" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.40,0.81,0.10" material="Arrow" scale=0.65 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=droppickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.95,0.10,0.05" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.95,0.20,0.10" material="Arrow" scale=0.65 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<!-- Speed pickups -->
+
+<Template name=smallspeedpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.3 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=smallspeedpickup>
+ <SpeedPickup
+ duration = 10.0
+ speedAdd = 0.0
+ SpeedMultiply = 10.0
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=mediumspeedpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.5 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=mediumspeedpickup>
+ <SpeedPickup
+ duration = 10.0
+ speedAdd = 0.0
+ SpeedMultiply = 25.0
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=hugespeedpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.7 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=hugespeedpickup>
+ <SpeedPickup
+ duration = 10.0
+ speedAdd = 0.0
+ SpeedMultiply = 50.0
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=smalljumppickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.99,0.96,0.52" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="1,0,0" material="3arrowsup" scale=0.3 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=smalljumppickup>
+ <SpeedPickup
+ duration = 0.7
+ speedAdd = 5000.0
+ SpeedMultiply = 1.0
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<!-- Invisible pickups -->
+
+<Template name=smallinvisiblepickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.22,0.32,0.86" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.06,0.14,0.63" material="Eye" scale=0.5 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=smallinvisiblepickup>
+ <InvisiblePickup
+ duration = 5.0
+ activaionType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=mediuminvisiblepickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.22,0.32,0.86" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.06,0.14,0.63" material="Eye" scale=0.7 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=mediuminvisiblepickup>
+ <InvisiblePickup
+ duration = 10.0
+ activaionType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=hugeinvisiblepickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.22,0.32,0.86" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.06,0.14,0.63" material="Eye" scale=0.9 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=hugeinvisiblepickup>
+ <InvisiblePickup
+ duration = 20.0
+ activaionType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<!-- Pickup Collection pickups -->
+
+<Template name=triplehealthspeedinvisibilitypickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.95,0.85,0.27" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,20,0" colour="0.36,0.81,0.10" material="Cross" scale=0.25 />
+ <Billboard position="-20,-10,0" colour="0.98,0.94,0.22" material="3arrowsup" scale=0.25 />
+ <Billboard position="20,-10,0" colour="0.06,0.14,0.63" material="Eye" scale=0.35 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=triplehealthspeedinvisibilitypickup>
+ <PickupCollection>
+ <pickupables>
+ <HealthPickup template=mediumhealthpickup />
+ <SpeedPickup template=mediumspeedpickup />
+ <InvisiblePickup template=mediuminvisiblepickup />
+ </pickupables>
+ </PickupCollection>
+</Template>
+
+<Template name=droneTemplate>
+ <Drone name="meineDrohne" mass= "50" linearDamping = "0.7" angularDamping = "0.99999" maxDistanceToOwner_=150 minDistanceToOwner_=50 primaryThrust_=250 auxilaryThrust_=250 rotationThrust_=50>
+ <attached>
+ <Model scale="1" mesh="drone.mesh"/>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="1, 1, 1" />
+ </collisionShapes>
+ <weaponslots>
+ <WeaponSlot position=" 0, 0,0" />
+ </weaponslots>
+ <weaponsets>
+ <WeaponSet firemode=0 />
+ </weaponsets>
+ <weapons>
+ <WeaponPack>
+ <links>
+ <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+ </links>
+ <Weapon>
+ <attached>
+ <Model mesh="hs-w01.mesh" roll="195" position="0,1,0" scale=2 />
+ <Model mesh="hs-w01s.mesh" roll="195" position="0.1,0.5,0" scale=2 />
+ </attached>
+ <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5,-4" />
+ <HsW01 mode=0 munitionpershot=0 delay=0 material="Flares/point_lensflare" muzzleoffset="-0.9, 1.1,-4" />
+ </Weapon>
+ </WeaponPack>
+ </weapons>
+ </Drone>
+</Template>
Modified: code/branches/presentation3/data/levels/templates/spaceship_pirate.oxt
===================================================================
--- code/branches/presentation3/data/levels/templates/spaceship_pirate.oxt 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/data/levels/templates/spaceship_pirate.oxt 2010-05-31 03:31:50 UTC (rev 7034)
@@ -68,21 +68,21 @@
accelerationleftright = 125
accelerationupdown = 125
>
- <active>
+ <EffectContainer condition="not idle">
<FadingBillboard mainstate=activity active=false scale=0.02 position=" 1.3, -4, -15" colour="1.0, 0.65, 0.2, 1.0" material="Examples/FlareZwei" turnontime=0.5 turnofftime=0.5 />
<FadingBillboard mainstate=activity active=false scale=0.02 position=" 0, -4, -15" colour="1.0, 0.65, 0.2, 1.0" material="Examples/FlareZwei" turnontime=0.5 turnofftime=0.5 />
<FadingBillboard mainstate=activity active=false scale=0.02 position="-1.3, -4, -15" colour="1.0, 0.65, 0.2, 1.0" material="Examples/FlareZwei" turnontime=0.5 turnofftime=0.5 />
- </active>
- <forward>
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
<Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 13, -4, 9.5" colour="1.0, 0.65, 0.2, 1.0" width=8 length=800 lifetime=1 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
<Backlight mainstate=activity active=false scale=0.4 name=bltest position="-13, -4, 9.5" colour="1.0, 0.65, 0.2, 1.0" width=8 length=800 lifetime=1 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- </forward>
- <boost>
+ </EffectContainer>
+ <EffectContainer condition="boost">
<Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 0, 5, 15.5" colour="1.0, 0.65, 0.2, 1.0" width=16 length=1600 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
- </boost>
- <brake>
+ </EffectContainer>
+ <EffectContainer condition="brake">
<FadingBillboard mainstate=activity active=false scale=0.1 position=" 4.4, -5.5, 5" colour="0.8, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
<FadingBillboard mainstate=activity active=false scale=0.1 position="-4.4, -5.5, 5" colour="0.8, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
- </brake>
+ </EffectContainer>
</MultiStateEngine>
</Template>
Modified: code/branches/presentation3/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/presentation3/src/modules/pickup/PickupPrereqs.h 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/modules/pickup/PickupPrereqs.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -74,6 +74,7 @@
class PickupSpawner;
//items
+ class DronePickup;
class HealthPickup;
class InvisiblePickup;
class MetaPickup;
Modified: code/branches/presentation3/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/modules/pickup/items/CMakeLists.txt 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/modules/pickup/items/CMakeLists.txt 2010-05-31 03:31:50 UTC (rev 7034)
@@ -2,6 +2,7 @@
HealthPickup.cc
InvisiblePickup.cc
MetaPickup.cc
+ DronePickup.cc
SpeedPickup.cc
ShieldPickup.cc
)
Copied: code/branches/presentation3/src/modules/pickup/items/DronePickup.cc (from rev 7033, code/branches/ai/src/modules/pickup/items/DronePickup.cc)
===================================================================
--- code/branches/presentation3/src/modules/pickup/items/DronePickup.cc (rev 0)
+++ code/branches/presentation3/src/modules/pickup/items/DronePickup.cc 2010-05-31 03:31:50 UTC (rev 7034)
@@ -0,0 +1,199 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Lukas Gasser
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DronePickup.cc
+ @brief Implementation of the DronePickup class.
+*/
+
+#include "DronePickup.h"
+#include "worldentities/Drone.h"
+#include "controllers/DroneController.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/StringUtils.h"
+
+#include "worldentities/pawns/Pawn.h"
+#include "pickup/PickupIdentifier.h"
+
+#include <sstream>
+
+namespace orxonox
+{
+
+ CreateFactory(DronePickup);
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes the member variables.
+ */
+ DronePickup::DronePickup(BaseObject* creator) : Pickup(creator)
+ {
+ RegisterObject(DronePickup);
+
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ DronePickup::~DronePickup()
+ {
+
+ }
+
+ /**
+ @brief
+ Initializes the member variables.
+ */
+ void DronePickup::initialize(void)
+ {
+ this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
+ this->setDurationTypeDirect(pickupDurationType::once);
+ this->droneTemplate_ = "";
+ }
+
+ /**
+ @brief
+ Initializes the PickupIdentifier of this pickup.
+ */
+ void DronePickup::initializeIdentifier(void)
+ {
+ std::string val = this->getDroneTemplate();
+ std::string type = "droneTemplate";
+ this->pickupIdentifier_->addParameter(type, val);
+ }
+
+ /**
+ @brief
+ Method for creating a DronePickup object through XML.
+ */
+ void DronePickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+ {
+ SUPER(DronePickup, XMLPort, xmlelement, mode);
+ XMLPortParam(DronePickup, "droneTemplate", setDroneTemplate, getDroneTemplate, xmlelement, mode);
+
+ this->initializeIdentifier();
+ }
+
+ void DronePickup::setDroneTemplate(std::string templatename){
+ droneTemplate_ = templatename;
+ }
+
+ const std::string& DronePickup::getDroneTemplate() const
+ {
+ return droneTemplate_;
+ }
+
+ /**
+ @brief
+ Is called when the pickup has transited from used to unused or the other way around.
+ */
+ void DronePickup::changedUsed(void)
+ {
+ SUPER(DronePickup, changedUsed);
+
+ //! If the pickup is not picked up nothing must be done.
+ if(!this->isPickedUp())
+ return;
+
+ //! If the pickup has transited to used.
+ if(this->isUsed())
+ {
+
+ Pawn* pawn = this->carrierToPawnHelper();
+ if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ this->destroy();
+
+ //Attach to pawn
+ Drone* drone = new Drone(pawn->getCreator()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
+ drone->addTemplate(this->getDroneTemplate());
+
+ Controller* controller = drone->getController();
+ DroneController* droneController = dynamic_cast<DroneController*>(controller);
+ if(droneController != NULL)
+ {
+ droneController->setOwner(pawn);
+ }
+
+ Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(30,0,-30);
+ drone->setPosition(spawnPosition);
+
+ //! The pickup has been used up.
+ this->setUsed(false);
+ }
+ else
+ {
+ //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
+ if(this->isOnce() || (this->isContinuous() ))
+ {
+ this->destroy();
+ }
+ }
+ }
+
+ /**
+ @brief
+ Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+ @return
+ A pointer to the Pawn, or NULL if the conversion failed.
+ */
+ Pawn* DronePickup::carrierToPawnHelper(void)
+ {
+ PickupCarrier* carrier = this->getCarrier();
+ Pawn* pawn = dynamic_cast<Pawn*>(carrier);
+
+ if(pawn == NULL)
+ {
+ COUT(1) << "Invalid PickupCarrier in DronePickup." << std::endl;
+ }
+
+ return pawn;
+ }
+
+ /**
+ @brief
+ Creates a duplicate of the input OrxonoxClass.
+ @param item
+ A pointer to the Orxonox class.
+ */
+ void DronePickup::clone(OrxonoxClass*& item)
+ {
+ if(item == NULL)
+ item = new DronePickup(this);
+
+ SUPER(DronePickup, clone, item);
+
+ DronePickup* pickup = dynamic_cast<DronePickup*>(item);
+ pickup->setDroneTemplate(this->getDroneTemplate());
+
+ pickup->initializeIdentifier();
+ }
+}
Property changes on: code/branches/presentation3/src/modules/pickup/items/DronePickup.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Copied: code/branches/presentation3/src/modules/pickup/items/DronePickup.h (from rev 7033, code/branches/ai/src/modules/pickup/items/DronePickup.h)
===================================================================
--- code/branches/presentation3/src/modules/pickup/items/DronePickup.h (rev 0)
+++ code/branches/presentation3/src/modules/pickup/items/DronePickup.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -0,0 +1,79 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Lukas Gasser
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DronePickup.h
+ @brief Declaration of the DronePickup class.
+*/
+
+#ifndef _DronePickup_H__
+#define _DronePickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+#include <worldentities/pawns/Pawn.h>
+#include <worldentities/Drone.h>
+
+#include "worldentities/StaticEntity.h"
+
+#include "pickup/Pickup.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox {
+
+
+ class _PickupExport DronePickup : public Pickup, public Tickable
+ {
+ public:
+
+ DronePickup(BaseObject* creator); //!< Constructor.
+ virtual ~DronePickup(); //!< Destructor.
+
+ virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a DronePickup object through XML.
+
+ virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
+ virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
+
+ void setDroneTemplate(std::string templatename);
+ const std::string& getDroneTemplate() const;
+
+ protected:
+ void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+
+ private:
+ void initialize(void); //!< Initializes the member variables.
+ std::string droneTemplate_;
+ Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+
+
+
+ };
+}
+
+#endif // _DronePickup_H__
Property changes on: code/branches/presentation3/src/modules/pickup/items/DronePickup.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/presentation3/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/presentation3/src/orxonox/OrxonoxPrereqs.h 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/OrxonoxPrereqs.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -81,6 +81,7 @@
class AIController;
class ArtificialController;
class Controller;
+ class DroneController;
class HumanController;
class ScriptController;
class WaypointController;
@@ -161,6 +162,7 @@
class BigExplosion;
class CameraPosition;
class ControllableEntity;
+ class Drone;
class EffectContainer;
class ExplosionChunk;
class MobileEntity;
Modified: code/branches/presentation3/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/AIController.cc 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/controllers/AIController.cc 2010-05-31 03:31:50 UTC (rev 7034)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Dominik Solenicki
*
*/
@@ -55,45 +55,154 @@
float random;
float maxrand = 100.0f / ACTION_INTERVAL;
- // search enemy
- random = rnd(maxrand);
- if (random < 15 && (!this->target_))
- this->searchNewTarget();
+ if (this->state_ == FREE)
+ {
- // forget enemy
- random = rnd(maxrand);
- if (random < 5 && (this->target_))
- this->forgetTarget();
+ if (this->formationFlight_)
+ {
+ // return to Master after being forced free
+ if (this->freedomCount_ == 1)
+ {
+ this->state_ = SLAVE;
+ this->freedomCount_ = 0;
+ }
- // next enemy
- random = rnd(maxrand);
- if (random < 10 && (this->target_))
- this->searchNewTarget();
+ random = rnd(maxrand);
+ if (random < 90 && (((!this->target_) || (random < 50 && this->target_)) && !this->forcedFree()))
+ this->searchNewMaster();
+ }
- // fly somewhere
- random = rnd(maxrand);
- if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
- this->searchRandomTargetPosition();
+ // search enemy
+ random = rnd(maxrand);
+ if (random < 15 && (!this->target_))
+ this->searchNewTarget();
- // stop flying
- random = rnd(maxrand);
- if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
- this->bHasTargetPosition_ = false;
+ // forget enemy
+ random = rnd(maxrand);
+ if (random < 5 && (this->target_))
+ this->forgetTarget();
- // fly somewhere else
- random = rnd(maxrand);
- if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
- this->searchRandomTargetPosition();
+ // next enemy
+ random = rnd(maxrand);
+ if (random < 10 && (this->target_))
+ this->searchNewTarget();
- // shoot
- random = rnd(maxrand);
- if (random < 75 && (this->target_ && !this->bShooting_))
- this->bShooting_ = true;
+ // fly somewhere
+ random = rnd(maxrand);
+ if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
+ this->searchRandomTargetPosition();
- // stop shooting
- random = rnd(maxrand);
- if (random < 25 && (this->bShooting_))
- this->bShooting_ = false;
+ // stop flying
+ random = rnd(maxrand);
+ if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
+ this->bHasTargetPosition_ = false;
+
+ // fly somewhere else
+ random = rnd(maxrand);
+ if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
+ this->searchRandomTargetPosition();
+
+ // shoot
+ random = rnd(maxrand);
+ if (!(this->passive_) && random < 75 && (this->target_ && !this->bShooting_))
+ this->bShooting_ = true;
+
+ // stop shooting
+ random = rnd(maxrand);
+ if (random < 25 && (this->bShooting_))
+ this->bShooting_ = false;
+
+ }
+
+ if (this->state_ == SLAVE)
+ {
+
+ }
+
+ if (this->state_ == MASTER)
+ {
+
+
+ this->commandSlaves();
+
+ if (this->specificMasterAction_ != NONE)
+ {
+ this->specificMasterActionHold();
+
+// if (this->specificMasterAction_ == TURN180)
+// this->turn180Init();
+
+// if (this->specificMasterAction_ == SPIN)
+// this->spinInit();
+
+// if (this->specificMasterAction_ == FOLLOWHUMAN)
+// this->followHuman(this->HumanToFollow_, false);
+ }
+
+ else {
+
+ // make 180 degree turn - a specific Master Action
+ random = rnd(1000.0f);
+ if (random < 5)
+ this->turn180Init();
+
+ // spin around - a specific Master Action
+ random = rnd(1000.0f);
+ if (random < 5)
+ this->spinInit();
+
+ // lose master status (only if less than 4 slaves in formation)
+ random = rnd(maxrand);
+ if(random < 15/(this->slaves_.size()+1) && this->slaves_.size() < 4 )
+ this->loseMasterState();
+
+ // look out for outher masters if formation is small
+ random = rnd(maxrand);
+ if(this->slaves_.size() < 3 && random < 20)
+ this->searchNewMaster();
+
+ // search enemy
+ random = rnd(maxrand);
+ if (random < 15 && (!this->target_))
+ this->searchNewTarget();
+
+ // forget enemy
+ random = rnd(maxrand);
+ if (random < 5 && (this->target_))
+ this->forgetTarget();
+
+ // next enemy
+ random = rnd(maxrand);
+ if (random < 10 && (this->target_))
+ this->searchNewTarget();
+
+ // fly somewhere
+ random = rnd(maxrand);
+ if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
+ this->searchRandomTargetPosition();
+
+
+ // fly somewhere else
+ random = rnd(maxrand);
+ if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
+ this->searchRandomTargetPosition();
+
+ // shoot
+ random = rnd(maxrand);
+ if (!(this->passive_) && random < 9 && (this->target_ && !this->bShooting_))
+ {
+ this->bShooting_ = true;
+ this->forceFreeSlaves();
+ }
+
+ // stop shooting
+ random = rnd(maxrand);
+ if (random < 25 && (this->bShooting_))
+ this->bShooting_ = false;
+
+ }
+ }
+
}
void AIController::tick(float dt)
@@ -101,15 +210,49 @@
if (!this->isActive())
return;
- if (this->target_)
- this->aimAtTarget();
+ if (this->state_ == MASTER)
+ {
+ if (this->specificMasterAction_ == NONE)
+ {
+ if (this->target_)
+ this->aimAtTarget();
- if (this->bHasTargetPosition_)
- this->moveToTargetPosition();
+ if (this->bHasTargetPosition_)
+ this->moveToTargetPosition();
- if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
- this->getControllableEntity()->fire(0);
+ if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
+ this->getControllableEntity()->fire(0);
+ }
+ if (this->specificMasterAction_ == TURN180)
+ this->turn180();
+
+ if (this->specificMasterAction_ == SPIN)
+ this->spin();
+ if (this->specificMasterAction_ == FOLLOWHUMAN)
+ this->follow();
+ }
+
+ if (this->state_ == SLAVE)
+ {
+
+ if (this->bHasTargetPosition_)
+ this->moveToTargetPosition();
+
+ }
+
+ if (this->state_ == FREE)
+ {
+ if (this->target_)
+ this->aimAtTarget();
+
+ if (this->bHasTargetPosition_)
+ this->moveToTargetPosition();
+
+ if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
+ this->getControllableEntity()->fire(0);
+ }
+
SUPER(AIController, tick, dt);
}
Modified: code/branches/presentation3/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/ArtificialController.cc 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/controllers/ArtificialController.cc 2010-05-31 03:31:50 UTC (rev 7034)
@@ -22,30 +22,62 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Dominik Solenicki
*
*/
#include "ArtificialController.h"
+#include <vector>
#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
#include "worldentities/ControllableEntity.h"
#include "worldentities/pawns/Pawn.h"
#include "worldentities/pawns/TeamBaseMatchBase.h"
#include "gametypes/TeamDeathmatch.h"
#include "gametypes/Dynamicmatch.h"
#include "controllers/WaypointPatrolController.h"
+#include "controllers/NewHumanController.h"
+#include "controllers/DroneController.h"
+#include "util/Math.h"
+#include "core/ConsoleCommand.h"
namespace orxonox
{
+ SetConsoleCommand(ArtificialController, formationflight, true);
+ SetConsoleCommand(ArtificialController, masteraction, true);
+ SetConsoleCommand(ArtificialController, followme, true);
+ SetConsoleCommand(ArtificialController, passivebehaviour, true);
+ SetConsoleCommand(ArtificialController, formationsize, true);
+
+ static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7;
+ static const int FORMATION_LENGTH = 130;
+ static const int FORMATION_WIDTH = 110;
+ static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
+ static const float SPEED_MASTER = 0.6f;
+ static const float ROTATEFACTOR_MASTER = 0.2f;
+ static const float SPEED_FREE = 0.8f;
+ static const float ROTATEFACTOR_FREE = 0.8f;
+ static const int SECONDS_TO_FOLLOW_HUMAN = 100;
+
ArtificialController::ArtificialController(BaseObject* creator) : Controller(creator)
{
RegisterObject(ArtificialController);
this->target_ = 0;
+ this->formationFlight_ = true;
+ this->passive_ = false;
+ this->maxFormationSize_ = STANDARD_MAX_FORMATION_SIZE;
+ this->myMaster_ = 0;
+ this->freedomCount_ = 0;
+ this->team_ = -1;
+ this->state_ = FREE;
+ this->specificMasterAction_ = NONE;
+ this->specificMasterActionHoldCount_ = 0;
this->bShooting_ = false;
this->bHasTargetPosition_ = false;
this->targetPosition_ = Vector3::ZERO;
+ this->humanToFollow_ = NULL;
this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this));
}
@@ -54,6 +86,167 @@
{
}
+ void ArtificialController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(ArtificialController, XMLPort, xmlelement, mode);
+
+ XMLPortParam(ArtificialController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(-1);
+ XMLPortParam(ArtificialController, "formationflight", setFormationFlight, getFormationFlight, xmlelement, mode).defaultValues(true);
+ XMLPortParam(ArtificialController, "formation_size", setFormationSize, getFormationSize, xmlelement, mode).defaultValues(STANDARD_MAX_FORMATION_SIZE);
+ }
+
+// Documentation only here to get a faster overview for creating a useful documentation...
+
+ /**
+ @brief Activates / deactivates formationflight behaviour
+ @param form activate formflight if form is true
+ */
+ void ArtificialController::formationflight(bool form)
+ {
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
+ {
+ if (!it->getController())
+ continue;
+
+ ArtificialController *aiController = orxonox_cast<ArtificialController*>(it->getController());
+
+ if(aiController)
+ {
+ aiController->formationFlight_ = form;
+ if(!form)
+ {
+ if(aiController->state_ == MASTER) aiController->freeSlaves();
+ aiController->state_ = FREE;
+ }
+ }
+ }
+ }
+
+ /**
+ @brief Get all masters to do a "specific master action"
+ @param action which action to perform (integer, so it can be called with a console command (tmp solution))
+ */
+ void ArtificialController::masteraction(int action)
+ {
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
+ {
+ if (!it->getController())
+ continue;
+
+ ArtificialController *aiController = orxonox_cast<ArtificialController*>(it->getController());
+
+ if(aiController && aiController->state_ == MASTER)
+ {
+ if (action == 1)
+ aiController->spinInit();
+ if (action == 2)
+ aiController->turn180Init();
+ }
+ }
+ }
+
+ /**
+ @brief A human player gets followed by its nearest master. Initiated by console command, intended for demonstration puproses. Does not work at the moment.
+ */
+ void ArtificialController::followme()
+ {
+
+ Pawn *humanPawn = NULL;
+ NewHumanController *currentHumanController = NULL;
+ std::vector<ArtificialController*> allMasters;
+
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
+ {
+ if (!it->getController())
+ continue;
+
+ currentHumanController = orxonox_cast<NewHumanController*>(it->getController());
+
+ if(currentHumanController) humanPawn = *it;
+
+ ArtificialController *aiController = orxonox_cast<ArtificialController*>(it->getController());
+
+ if(aiController || aiController->state_ == MASTER)
+ allMasters.push_back(aiController);
+
+ }
+
+ if((humanPawn != NULL) && (allMasters.size() != 0))
+ {
+ float posHuman = humanPawn->getPosition().length();
+ float distance = 0.0f;
+ float minDistance = FLT_MAX;
+ int index = 0;
+ int i = 0;
+
+ for(std::vector<ArtificialController*>::iterator it = allMasters.begin(); it != allMasters.end(); it++)
+ {
+ distance = posHuman - (*it)->getControllableEntity()->getPosition().length();
+ if(distance < minDistance) index = i;
+ }
+ allMasters[index]->humanToFollow_ = humanPawn;
+// allMasters[index]->followHuman(humanPawn, false);
+ }
+
+ }
+
+ /**
+ @brief Sets shooting behaviour of pawns.
+ @param passive if true, bots won't shoot.
+ */
+ void ArtificialController::passivebehaviour(bool passive)
+ {
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
+ {
+ if (!it->getController())
+ continue;
+
+ ArtificialController *aiController = orxonox_cast<ArtificialController*>(it->getController());
+
+ if(aiController)
+ {
+ aiController->passive_ = passive;
+ }
+ }
+ }
+
+
+ /**
+ @brief Sets maximal formation size
+ @param size maximal formation size.
+ */
+ void ArtificialController::formationsize(int size)
+ {
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
+ {
+ if (!it->getController())
+ continue;
+
+ ArtificialController *aiController = orxonox_cast<ArtificialController*>(it->getController());
+
+ if(aiController)
+ {
+ aiController->maxFormationSize_ = size;
+ }
+ }
+ }
+
+ /**
+ @brief Gets called when ControllableEntity is being changed. Resets the bot when it dies.
+ */
+ void ArtificialController::changedControllableEntity()
+ {
+ if(!getControllableEntity())
+ {
+ if (this->state_ == SLAVE) unregisterSlave();
+ if (this->state_ == MASTER) setNewMasterWithinFormation();
+ this->slaves_.clear();
+ this->state_ = FREE;
+
+ }
+ }
+
+
void ArtificialController::moveToPosition(const Vector3& target)
{
if (!this->getControllableEntity())
@@ -62,17 +255,57 @@
Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
float distance = (target - this->getControllableEntity()->getPosition()).length();
- if (this->target_ || distance > 10)
+
+ if(this->state_ == FREE)
{
- // Multiply with 0.8 to make them a bit slower
- this->getControllableEntity()->rotateYaw(-0.8f * sgn(coord.x) * coord.x*coord.x);
- this->getControllableEntity()->rotatePitch(0.8f * sgn(coord.y) * coord.y*coord.y);
+ if (this->target_ || distance > 10)
+ {
+ // Multiply with 0.8 to make them a bit slower
+ this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_FREE * sgn(coord.x) * coord.x*coord.x);
+ this->getControllableEntity()->rotatePitch(ROTATEFACTOR_FREE * sgn(coord.y) * coord.y*coord.y);
+ }
+
+ if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
+ {
+ this->getControllableEntity()->moveFrontBack(-0.05f); // They don't brake with full power to give the player a chance
+ } else this->getControllableEntity()->moveFrontBack(SPEED_FREE);
}
- if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
- this->getControllableEntity()->moveFrontBack(-0.5f); // They don't brake with full power to give the player a chance
- else
- this->getControllableEntity()->moveFrontBack(0.8f);
+
+
+ if(this->state_ == MASTER)
+ {
+ if (this->target_ || distance > 10)
+ {
+ this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);
+ this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);
+ }
+
+ if (this->target_ && distance < 200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
+ {
+ this->getControllableEntity()->moveFrontBack(-0.05f);
+ } else this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
+ }
+
+
+
+ if(this->state_ == SLAVE)
+ {
+
+ this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);
+ this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);
+
+ if (distance < 300)
+ {
+ if (distance < 40)
+ {
+ this->getControllableEntity()->moveFrontBack(0.8f*SPEED_MASTER);
+ } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER);
+
+ } else {
+ this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
+ }
+ }
}
void ArtificialController::moveToTargetPosition()
@@ -80,6 +313,304 @@
this->moveToPosition(this->targetPosition_);
}
+ int ArtificialController::getState()
+ {
+ return this->state_;
+ }
+
+ /**
+ @brief Unregisters a slave from its master. Called by a slave.
+ */
+ void ArtificialController::unregisterSlave() {
+ if(myMaster_)
+ {
+ std::vector<ArtificialController*>::iterator it = std::find(myMaster_->slaves_.begin(), myMaster_->slaves_.end(), this);
+ if( it != myMaster_->slaves_.end() )
+ myMaster_->slaves_.erase(it);
+ }
+ }
+
+ void ArtificialController::searchNewMaster()
+ {
+
+ if (!this->getControllableEntity())
+ return;
+
+ this->targetPosition_ = this->getControllableEntity()->getPosition();
+ this->forgetTarget();
+ int teamSize = 0;
+ //go through all pawns
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
+ {
+
+ //same team?
+ if (!ArtificialController::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it), this->getGametype()))
+ continue;
+
+ //has it an ArtificialController?
+ if (!it->getController())
+ continue;
+
+ //is pawn oneself?
+ if (orxonox_cast<ControllableEntity*>(*it) == this->getControllableEntity())
+ continue;
+
+ teamSize++;
+
+ ArtificialController *newMaster = orxonox_cast<ArtificialController*>(it->getController());
+
+ //is it a master?
+ if (!newMaster || newMaster->getState() != MASTER)
+ continue;
+
+ float distance = (it->getPosition() - this->getControllableEntity()->getPosition()).length();
+
+ // is pawn in range?
+ if (distance < 5000)
+ {
+ if(newMaster->slaves_.size() > this->maxFormationSize_) continue;
+
+ for(std::vector<ArtificialController*>::iterator itSlave = this->slaves_.begin(); itSlave != this->slaves_.end(); itSlave++)
+ {
+ (*itSlave)->myMaster_ = newMaster;
+ newMaster->slaves_.push_back(*itSlave);
+ }
+ this->slaves_.clear();
+ this->state_ = SLAVE;
+
+ this->myMaster_ = newMaster;
+ newMaster->slaves_.push_back(this);
+
+ break;
+ }
+ }
+
+ if (state_ != SLAVE && teamSize != 0) state_ = MASTER;
+
+ }
+
+ /**
+ @brief Commands the slaves of a master into a formation. Called by a master.
+ */
+ void ArtificialController::commandSlaves()
+ {
+ if(this->state_ != MASTER) return;
+
+ Quaternion orient = this->getControllableEntity()->getOrientation();
+ Vector3 dest = this->getControllableEntity()->getPosition();
+
+ // 1 slave: follow
+ if (this->slaves_.size() == 1)
+ {
+ dest += 4*orient*WorldEntity::BACK;
+ this->slaves_.front()->setTargetPosition(dest);
+ }
+ else
+ {
+ dest += 1.0f*orient*WorldEntity::BACK;
+ Vector3 pos = Vector3::ZERO;
+ int i = 1;
+
+ for(std::vector<ArtificialController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ {
+ pos = Vector3::ZERO;
+ if (i <= 1) pos += dest + FORMATION_WIDTH*(orient*WorldEntity::LEFT);
+ if (i == 2) pos += dest + FORMATION_WIDTH*(orient*WorldEntity::RIGHT);
+ if (i == 3) pos += dest + FORMATION_WIDTH*(orient*WorldEntity::UP);
+ if (i >= 4)
+ {
+ pos += dest + FORMATION_WIDTH*(orient*WorldEntity::DOWN);
+ i = 1;
+ dest += FORMATION_LENGTH*(orient*WorldEntity::BACK);
+ (*it)->setTargetPosition(pos);
+ continue;
+ }
+ i++;
+ (*it)->setTargetPosition(pos);
+ }
+ }
+ }
+
+ /**
+ @brief Sets a new master within the formation. Called by a master.
+ */
+ void ArtificialController::setNewMasterWithinFormation()
+ {
+ if(this->state_ != MASTER) return;
+
+ if (this->slaves_.empty())
+ return;
+
+ ArtificialController *newMaster = this->slaves_.back();
+ this->slaves_.pop_back();
+
+ if(!newMaster) return;
+ newMaster->state_ = MASTER;
+ newMaster->slaves_ = this->slaves_;
+
+ this->slaves_.clear();
+ this->state_ = SLAVE;
+ this->myMaster_ = newMaster;
+
+ for(std::vector<ArtificialController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++)
+ {
+ (*it)->myMaster_ = newMaster;
+ }
+
+ }
+
+ /**
+ @brief Frees all slaves form a master. Called by a master.
+ */
+ void ArtificialController::freeSlaves()
+ {
+ if(this->state_ != MASTER) return;
+
+ for(std::vector<ArtificialController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ {
+ (*it)->state_ = FREE;
+ }
+ this->slaves_.clear();
+ }
+
+ /**
+ @brief Master sets its slaves free for @var FREEDOM_COUNT seconds.
+ */
+ void ArtificialController::forceFreeSlaves()
+ {
+ if(this->state_ != MASTER) return;
+
+ for(std::vector<ArtificialController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+ {
+ (*it)->state_ = FREE;
+ (*it)->forceFreedom();
+ (*it)->targetPosition_ = this->targetPosition_;
+ (*it)->bShooting_ = true;
+// (*it)->getControllableEntity()->fire(0);// fire once for fun
+ }
+ }
+
+ void ArtificialController::loseMasterState()
+ {
+ this->freeSlaves();
+ this->state_ = FREE;
+ }
+
+
+ void ArtificialController::forceFreedom()
+ {
+ this->freedomCount_ = FREEDOM_COUNT;
+ }
+
+ /**
+ @brief Checks wether caller has been forced free, decrements time to stay forced free.
+ @return true if forced free.
+ */
+ bool ArtificialController::forcedFree()
+ {
+ if(this->freedomCount_ > 0)
+ {
+ this->freedomCount_--;
+ return true;
+ } else return false;
+ }
+
+ /**
+ @brief Used to continue a "specific master action" for a certain time and resuming normal behaviour after.
+ */
+ void ArtificialController::specificMasterActionHold()
+ {
+ if(this->state_ != MASTER) return;
+
+ if (specificMasterActionHoldCount_ == 0)
+ {
+ this->specificMasterAction_ = NONE;
+ this->searchNewTarget();
+ }
+ else specificMasterActionHoldCount_--;
+ }
+
+ /**
+ @brief Master initializes a 180 degree turn. Leads to a "specific master action".
+ */
+ void ArtificialController::turn180Init()
+ {
+ COUT(0) << "~turnInit" << std::endl;
+ if(this->state_ != MASTER) return;
+
+ Quaternion orient = this->getControllableEntity()->getOrientation();
+
+ this->setTargetPosition(this->getControllableEntity()->getPosition() + 1000.0f*orient*WorldEntity::BACK);
+
+ this->specificMasterActionHoldCount_ = 4;
+
+ this->specificMasterAction_ = TURN180;
+ }
+
+ /**
+ @brief Execute the 180 degree turn. Called within tick.
+ */
+ void ArtificialController::turn180()
+ {
+ Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
+
+ this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
+ this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
+
+ this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
+ }
+
+ /**
+ @brief Master initializes a spin around its looking direction axis. Leads to a "specific master action". Not yet implemented.
+ */
+ void ArtificialController::spinInit()
+ {
+ COUT(0) << "~spinInit" << std::endl;
+ if(this->state_ != MASTER) return;
+ this->specificMasterAction_ = SPIN;
+ this->specificMasterActionHoldCount_ = 10;
+ }
+
+ /**
+ @brief Execute the spin. Called within tick.
+ */
+ void ArtificialController::spin()
+ {
+ this->moveToTargetPosition();
+ this->getControllableEntity()->rotateRoll(0.8f);
+ }
+
+ /**
+ @brief Master begins to follow a human player. Is a "specific master action".
+ @param humanController human to follow.
+ @param alaways follows human forever if true, else it follows it for @var SECONDS_TO_FOLLOW_HUMAN seconds.
+ */
+ void ArtificialController::followHumanInit(Pawn* human, bool always)
+ {
+ COUT(0) << "~followInit" << std::endl;
+ if (human == NULL || this->state_ != MASTER)
+ return;
+
+ this->specificMasterAction_ = FOLLOWHUMAN;
+
+ this->setTarget(human);
+ if (!always)
+ this->specificMasterActionHoldCount_ = SECONDS_TO_FOLLOW_HUMAN;
+ else
+ this->specificMasterActionHoldCount_ = INT_MAX; //for now...
+
+ }
+
+ /**
+ @brief Follows target with adjusted speed. Called within tick.
+ */
+ void ArtificialController::follow()
+ {
+ this->moveToTargetPosition(); //standard position apprach for now.
+ }
+
+
+
void ArtificialController::setTargetPosition(const Vector3& target)
{
this->targetPosition_ = target;
@@ -144,7 +675,7 @@
this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity());
this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
- Pawn* pawn = dynamic_cast<Pawn*>(this->getControllableEntity());
+ Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
if (pawn)
pawn->setAimPosition(this->targetPosition_);
}
@@ -188,17 +719,27 @@
int team1 = -1;
int team2 = -1;
- if (entity1->getXMLController())
+ Controller* controller = 0;
+ if (entity1->getController())
+ controller = entity1->getController();
+ else
+ controller = entity1->getXMLController();
+ if (controller)
{
- WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController*>(entity1->getXMLController());
- if (wpc)
- team1 = wpc->getTeam();
+ ArtificialController* ac = orxonox_cast<ArtificialController*>(controller);
+ if (ac)
+ team1 = ac->getTeam();
}
- if (entity2->getXMLController())
+
+ if (entity1->getController())
+ controller = entity1->getController();
+ else
+ controller = entity1->getXMLController();
+ if (controller)
{
- WaypointPatrolController* wpc = orxonox_cast<WaypointPatrolController*>(entity2->getXMLController());
- if (wpc)
- team2 = wpc->getTeam();
+ ArtificialController* ac = orxonox_cast<ArtificialController*>(controller);
+ if (ac)
+ team2 = ac->getTeam();
}
TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);
@@ -245,6 +786,18 @@
}
}
+ DroneController* droneController = 0;
+ droneController = orxonox_cast<DroneController*>(entity1->getController());
+ if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2)
+ return true;
+ droneController = orxonox_cast<DroneController*>(entity2->getController());
+ if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1)
+ return true;
+ DroneController* droneController1 = orxonox_cast<DroneController*>(entity1->getController());
+ DroneController* droneController2 = orxonox_cast<DroneController*>(entity2->getController());
+ if (droneController1 && droneController2 && droneController1->getOwner() == droneController2->getOwner())
+ return true;
+
Dynamicmatch* dynamic = orxonox_cast<Dynamicmatch*>(gametype);
if (dynamic)
{
Modified: code/branches/presentation3/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/ArtificialController.h 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/controllers/ArtificialController.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Dominik Solenicki
*
*/
@@ -31,8 +31,11 @@
#include "OrxonoxPrereqs.h"
+#include <vector>
+
#include "util/Math.h"
#include "Controller.h"
+#include "controllers/NewHumanController.h"
namespace orxonox
{
@@ -42,14 +45,72 @@
ArtificialController(BaseObject* creator);
virtual ~ArtificialController();
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
void abandonTarget(Pawn* target);
+ inline void setTeam(int team)
+ { this->team_ = team; }
+ inline int getTeam() const
+ { return this->team_; }
+ inline void setFormationFlight(bool formation)
+ { this->formationFlight_ = formation; }
+ inline bool getFormationFlight() const
+ { return this->formationFlight_; }
+ inline void setFormationSize(int size)
+ { this->maxFormationSize_ = size; }
+ inline int getFormationSize() const
+ { return this->maxFormationSize_; }
+ virtual void changedControllableEntity();
+
+ static void formationflight(bool form);
+ static void masteraction(int action);
+ static void followme();
+ static void passivebehaviour(bool passive);
+ static void formationsize(int size);
+
protected:
+
+ int team_;
+ bool formationFlight_;
+ bool passive_;
+ unsigned int maxFormationSize_;
+ int freedomCount_;
+ enum State {SLAVE, MASTER, FREE};
+ State state_;
+ std::vector<ArtificialController*> slaves_;
+ ArtificialController *myMaster_;
+ enum SpecificMasterAction {NONE, HOLD, SPIN, TURN180, FOLLOWHUMAN};
+ SpecificMasterAction specificMasterAction_;
+ int specificMasterActionHoldCount_;
+ Pawn* humanToFollow_;
+
void targetDied();
void moveToPosition(const Vector3& target);
void moveToTargetPosition();
+ int getState();
+
+ void unregisterSlave();
+ void searchNewMaster();
+ void commandSlaves();
+ void setNewMasterWithinFormation();
+
+ void freeSlaves();
+ void forceFreeSlaves();
+ void loseMasterState();
+ void forceFreedom();
+ bool forcedFree();
+
+ void specificMasterActionHold();
+ void turn180Init();
+ void turn180();
+ void spinInit();
+ void spin();
+ void followHumanInit(Pawn* human, bool always);
+ void follow();
+
void setTargetPosition(const Vector3& target);
void searchRandomTargetPosition();
Modified: code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/controllers/CMakeLists.txt 2010-05-31 03:31:50 UTC (rev 7034)
@@ -7,4 +7,5 @@
ScriptController.cc
WaypointController.cc
WaypointPatrolController.cc
+ DroneController.cc
)
Copied: code/branches/presentation3/src/orxonox/controllers/DroneController.cc (from rev 7033, code/branches/ai/src/orxonox/controllers/DroneController.cc)
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/DroneController.cc (rev 0)
+++ code/branches/presentation3/src/orxonox/controllers/DroneController.cc 2010-05-31 03:31:50 UTC (rev 7034)
@@ -0,0 +1,139 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "DroneController.h"
+#include "worldentities/Drone.h"
+#include "util/Math.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "worldentities/ControllableEntity.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ Constructor.
+ */
+ CreateFactory(DroneController);
+
+ static const float ACTION_INTERVAL = 1.0f;
+
+ DroneController::DroneController(BaseObject* creator) : ArtificialController(creator)
+ {
+ RegisterObject(DroneController);
+
+ this->owner_ = 0;
+ this->drone_ = 0;
+
+ this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DroneController::action, this)));
+
+ this->owner_.setCallback(createFunctor(&DroneController::ownerDied, this));
+ }
+
+ DroneController::~DroneController()
+ {
+ }
+
+ void DroneController::setOwner(Pawn* owner){
+ this->owner_ = owner;
+ }
+
+ void DroneController::setDrone(Drone* drone)
+ {
+ this->drone_ = drone;
+ this->setControllableEntity(drone);
+ }
+
+ void DroneController::action()
+ {
+ float random;
+ float maxrand = 100.0f / ACTION_INTERVAL;
+
+ const Vector3& ownerPosition = getOwner()->getWorldPosition();
+ const Vector3& dronePosition = getDrone()->getWorldPosition();
+
+ const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system
+
+ random = rnd(maxrand);
+ if ( random < 30 && (!this->target_))
+ this->searchNewTarget();
+
+ if (random < 50 && this->target_)
+ {
+ this->isShooting_ = true;
+ this->aimAtTarget();
+ drone_->rotateYaw(targetPosition_.x); //face target
+ drone_->rotatePitch(targetPosition_.y);
+ drone_->fire(0);
+ this->isShooting_ = false;
+ }
+
+ }
+
+ /*
+ @brief
+ The controlling happens here. This method defines what the controller has to do each tick.
+ @param dt
+ The duration of the tick.
+ */
+ void DroneController::tick(float dt)
+ {
+
+
+ Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
+ float maxDistanceSquared = this->getDrone()->getMaxDistanceToOwner()*this->getDrone()->getMaxDistanceToOwner();
+ float minDistanceSquared = this->getDrone()->getMinDistanceToOwner()*this->getDrone()->getMinDistanceToOwner();
+ if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() > maxDistanceSquared) {
+ this->moveToPosition(this->getOwner()->getWorldPosition());
+ }
+ else if((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() < minDistanceSquared) {
+ this->moveToPosition(-this->getOwner()->getWorldPosition());
+ }
+ else if(!isShooting_) {
+ float random = rnd(2.0f);
+ float randomSelection = rnd(6.0f);
+ if((int)randomSelection==0) drone_->moveUpDown(random);
+ else if((int)randomSelection==1) drone_->moveRightLeft(random);
+ else if((int)randomSelection==2) drone_->moveFrontBack(random);
+ else if((int)randomSelection==3) drone_->rotateYaw(random);
+ else if((int)randomSelection==4) drone_->rotatePitch(random);
+ else if((int)randomSelection==5) drone_->rotateRoll(random);
+ }
+ SUPER(AIController, tick, dt);
+
+ }
+
+ void DroneController::ownerDied()
+ {
+ if (this->drone_)
+ this->drone_->destroy();
+ else
+ this->destroy();
+ }
+}
Property changes on: code/branches/presentation3/src/orxonox/controllers/DroneController.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Copied: code/branches/presentation3/src/orxonox/controllers/DroneController.h (from rev 7033, code/branches/ai/src/orxonox/controllers/DroneController.h)
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/DroneController.h (rev 0)
+++ code/branches/presentation3/src/orxonox/controllers/DroneController.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -0,0 +1,77 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _DroneController_H__
+#define _DroneController_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "AIController.h"
+#include "core/WeakPtr.h"
+#include "tools/interfaces/Tickable.h"
+
+#include "tools/Timer.h"
+
+
+namespace orxonox
+{
+ /**
+ @brief
+ Controller for the Drone of the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport DroneController : public ArtificialController, public Tickable
+ {
+ public:
+ DroneController(BaseObject* creator);
+ virtual ~DroneController();
+
+ virtual void tick(float dt); //!< The controlling happens here. This method defines what the controller has to do each tick.
+
+ void setOwner(Pawn* owner);
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+
+ void setDrone(Drone* drone);
+ inline Drone* getDrone() const
+ { return this->drone_; }
+
+ protected:
+ virtual void action();
+ void ownerDied();
+ bool isShooting_;
+
+ private:
+ Timer actionTimer_;
+ WeakPtr<Pawn> owner_;
+ Drone* drone_;
+ };
+}
+
+#endif /* _DroneController_H__ */
Property changes on: code/branches/presentation3/src/orxonox/controllers/DroneController.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.cc
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.cc 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.cc 2010-05-31 03:31:50 UTC (rev 7034)
@@ -41,7 +41,7 @@
{
RegisterObject(WaypointPatrolController);
- this->team_ = 0;
+ //this->team_ = 0;
this->alertnessradius_ = 500;
this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy, this)));
@@ -52,7 +52,7 @@
SUPER(WaypointPatrolController, XMLPort, xmlelement, mode);
XMLPortParam(WaypointPatrolController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
- XMLPortParam(WaypointPatrolController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
+// XMLPortParam(WaypointPatrolController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(0);
}
void WaypointPatrolController::tick(float dt)
Modified: code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.h
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.h 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/controllers/WaypointPatrolController.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -45,10 +45,10 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void tick(float dt);
- inline void setTeam(int team)
+ /* inline void setTeam(int team)
{ this->team_ = team; }
inline int getTeam() const
- { return this->team_; }
+ { return this->team_; } */
inline void setAlertnessRadius(float radius)
{ this->alertnessradius_ = radius; }
@@ -58,7 +58,7 @@
protected:
void searchEnemy();
- int team_;
+ //int team_;
float alertnessradius_;
Timer patrolTimer_;
};
Modified: code/branches/presentation3/src/orxonox/interfaces/PickupCarrier.h
===================================================================
--- code/branches/presentation3/src/orxonox/interfaces/PickupCarrier.h 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/interfaces/PickupCarrier.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -53,6 +53,7 @@
class HealthPickup;
class InvisiblePickup;
class MetaPickup;
+ class DronePickup;
class SpeedPickup;
/**
@@ -71,6 +72,7 @@
friend class HealthPickup;
friend class InvisiblePickup;
friend class MetaPickup;
+ friend class DronePickup;
friend class SpeedPickup;
public:
Modified: code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt 2010-05-31 03:01:31 UTC (rev 7033)
+++ code/branches/presentation3/src/orxonox/worldentities/CMakeLists.txt 2010-05-31 03:31:50 UTC (rev 7034)
@@ -4,7 +4,7 @@
MovableEntity.cc
MobileEntity.cc
ControllableEntity.cc
-
+ Drone.cc
BigExplosion.cc
EffectContainer.cc
ExplosionChunk.cc
Copied: code/branches/presentation3/src/orxonox/worldentities/Drone.cc (from rev 7033, code/branches/ai/src/orxonox/worldentities/Drone.cc)
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/Drone.cc (rev 0)
+++ code/branches/presentation3/src/orxonox/worldentities/Drone.cc 2010-05-31 03:31:50 UTC (rev 7034)
@@ -0,0 +1,183 @@
+
+
+
+
+
+
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ */
+
+
+#include "Drone.h"
+
+#include "core/XMLPort.h"
+#include "BulletDynamics/Dynamics/btRigidBody.h"
+
+namespace orxonox
+{
+ CreateFactory(Drone);
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ */
+ Drone::Drone(BaseObject* creator) : Pawn(creator)
+ {
+ RegisterObject(Drone);
+
+ this->myController_ = 0;
+
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ this->setRadarVisibility(false);
+ this->setCollisionType(WorldEntity::Dynamic);
+
+ myController_ = new DroneController(static_cast<BaseObject*>(this)); //!< Creates a new controller and passes our this pointer to it as creator.
+ myController_->setDrone(this);
+
+ this->setController(myController_);
+ }
+
+ /**
+ @brief
+ Destructor. Destroys controller, if present.
+ */
+ Drone::~Drone()
+ {
+ if( this->isInitialized() && this->myController_ )
+ delete this->myController_;
+ }
+
+ /**
+ @brief
+ Method for creating a Drone through XML.
+ */
+ void Drone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Drone, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Drone, "primaryThrust_", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
+ XMLPortParam(Drone, "auxilaryThrust_", setAuxilaryThrust, getAuxilaryThrust, xmlelement, mode);
+ XMLPortParam(Drone, "rotationThrust_", setRotationThrust, getRotationThrust, xmlelement, mode);
+ XMLPortParam(Drone, "maxDistanceToOwner_", setMaxDistanceToOwner, getMaxDistanceToOwner, xmlelement, mode);
+ XMLPortParam(Drone, "minDistanceToOwner_", setMinDistanceToOwner, getMinDistanceToOwner, xmlelement, mode);
+ }
+
+
+ /**
+ @brief
+ Defines which actions the Drone has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
+ void Drone::tick(float dt)
+ {
+ SUPER(Drone, tick, dt);
+
+ //if (this->hasLocalController())
+ //{
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
+ else
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
+ this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+
+ this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
+ this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
+ //}
+ }
+
+ /**
+ @brief
+ Moves the Drone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void Drone::moveFrontBack(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
+ }
+
+ /**
+ @brief
+ Moves the Drone in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void Drone::moveRightLeft(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Moves the Drone in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
+ void Drone::moveUpDown(const Vector2& value)
+ {
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Drone::rotateYaw(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Drone::rotatePitch(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
+ }
+
+ /**
+ @brief
+ Rotates the Drone around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
+ void Drone::rotateRoll(const Vector2& value)
+ {
+ this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
+ }
+
+}
Property changes on: code/branches/presentation3/src/orxonox/worldentities/Drone.cc
___________________________________________________________________
Added: svn:eol-style
+ native
Copied: code/branches/presentation3/src/orxonox/worldentities/Drone.h (from rev 7033, code/branches/ai/src/orxonox/worldentities/Drone.h)
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/Drone.h (rev 0)
+++ code/branches/presentation3/src/orxonox/worldentities/Drone.h 2010-05-31 03:31:50 UTC (rev 7034)
@@ -0,0 +1,147 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Oli Scheuss
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _Drone_H__
+#define _Drone_H__
+
+#include "OrxonoxPrereqs.h"
+#include "worldentities/pawns/Pawn.h"
+#include "controllers/DroneController.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Drone, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
+ class _OrxonoxExport Drone : public Pawn
+ {
+ public:
+ Drone(BaseObject* creator);
+ virtual ~Drone();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Drone through XML.
+ virtual void tick(float dt); //!< Defines which actions the Drone has to take in each tick.
+
+
+ virtual void moveFrontBack(const Vector2& value);
+ virtual void moveRightLeft(const Vector2& value);
+ virtual void moveUpDown(const Vector2& value);
+
+ virtual void rotateYaw(const Vector2& value);
+ virtual void rotatePitch(const Vector2& value);
+ virtual void rotateRoll(const Vector2& value);
+
+ /**
+ @brief Moves the Drone in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveFrontBack(float value)
+ { this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveRightLeft(float value)
+ { this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
+ inline void moveUpDown(float value)
+ { this->moveUpDown(Vector2(value, 0)); }
+
+ /**
+ @brief Rotates the Drone around the y-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateYaw(float value)
+ { this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the x-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotatePitch(float value)
+ { this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the z-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
+ inline void rotateRoll(float value)
+ { this->rotateRoll(Vector2(value, 0)); }
+
+ /**
+ @brief Sets the primary thrust to the input amount.
+ @param thrust The amount of thrust.
+ */
+ inline void setPrimaryThrust( float thrust )
+ { this->primaryThrust_=thrust; }
+ inline void setAuxilaryThrust( float thrust )
+ { this->auxilaryThrust_=thrust; }
+ inline void setRotationThrust( float thrust )
+ { this->rotationThrust_=thrust; }
+ inline void setMaxDistanceToOwner( float distance)
+ { this->maxDistanceToOwner_=distance; }
+ inline void setMinDistanceToOwner( float distance)
+ { this->minDistanceToOwner_=distance; }
+
+
+ /**
+ @brief Gets the primary thrust to the input amount.
+ @preturn The amount of thrust.
+ */
+ inline float getPrimaryThrust()
+ { return this->primaryThrust_; }
+ inline float getAuxilaryThrust()
+ { return this->auxilaryThrust_; }
+ inline float getRotationThrust()
+ { return this->rotationThrust_; }
+ inline float getMaxDistanceToOwner()
+ { return this->maxDistanceToOwner_; }
+ inline float getMinDistanceToOwner()
+ { return this->minDistanceToOwner_; }
+
+ private:
+ DroneController *myController_; //!< The controller of the Drone.
+
+ btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the Drone the next tick.
+ btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the Drone the next tick.
+ float primaryThrust_; //!< The amount of primary thrust. This is just used, when moving forward.
+ float auxilaryThrust_; //!< The amount of auxilary thrust. Used for all other movements (except for rotations).
+ float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.
+ float maxDistanceToOwner_; //Maximum Distance to owner
+ float minDistanceToOwner_; //Minimum Distance to owner
+ };
+
+}
+
+#endif /* _Drone_H__ */
Property changes on: code/branches/presentation3/src/orxonox/worldentities/Drone.h
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Orxonox-commit
mailing list