[Orxonox-commit 6176] r10834 - in code/branches/campaignHS15: . data/levels src/libraries/util src/modules/docking src/modules/overlays/hud src/orxonox/controllers src/orxonox/worldentities/pawns test/util
maxima at orxonox.net
maxima at orxonox.net
Mon Nov 23 13:24:51 CET 2015
Author: maxima
Date: 2015-11-23 13:24:51 +0100 (Mon, 23 Nov 2015)
New Revision: 10834
Added:
code/branches/campaignHS15/DivisionBrit.png
code/branches/campaignHS15/Four_Finger_Squadron.PNG
code/branches/campaignHS15/data/levels/AITest.oxw
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
Modified:
code/branches/campaignHS15/
code/branches/campaignHS15/src/libraries/util/Math.cc
code/branches/campaignHS15/src/libraries/util/Math.h
code/branches/campaignHS15/src/modules/docking/DockingController.cc
code/branches/campaignHS15/src/modules/overlays/hud/HUDRadar.cc
code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt
code/branches/campaignHS15/src/orxonox/controllers/FormationController.cc
code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/campaignHS15/test/util/MathTest.cc
Log:
AI_HS15 merged into campaignHS15
Property changes on: code/branches/campaignHS15
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/ParticleEffectsFS15:10309-10612
/code/branches/Racingbot:9388-9513
/code/branches/SciptableControllerFS15:10308-10613
/code/branches/ScriptableController:9999-10075
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/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/clangenb:10385-10609
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/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/core6:9552-9666
/code/branches/core7:10328-10623
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/formationFS15:10320-10610
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/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/hud:8883-8986
/code/branches/hudHS14:10083-10241
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/keckslevelHS14:10082-10222
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/leveljoemeHS14:10087-10223
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/minigame4DHS14:10081-10230
/code/branches/miniprojects:2754-2824
/code/branches/modularships:9994-10071
/code/branches/multiplayerFS15:10324-10611
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/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/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/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/pickupsFS14:10000-10259
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationFS14:10069-10215
/code/branches/presentationFS15:10499
/code/branches/presentationFS15merge:10595-10621
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/presentationHS14merge:10222-10257
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/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/sfxThilo:9691-9917
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/storymodeHS14:10085-10254
/code/branches/surfaceRace:9028-9199
/code/branches/surfaceraceHS14:10080-10236
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/towerdefenseFS15:10283-10614
/code/branches/towerdefenseHS14:10086-10247
/code/branches/turret:9380-9501
/code/branches/turretFS14:9998-10070
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weaponFS15:10302-10615
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
/code/branches/weaponupdateHS14:10084-10237
+ /code/branches/AI_HS15:10640-10832
/code/branches/ParticleEffectsFS15:10309-10612
/code/branches/Racingbot:9388-9513
/code/branches/SciptableControllerFS15:10308-10613
/code/branches/ScriptableController:9999-10075
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/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/clangenb:10385-10609
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/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/core6:9552-9666
/code/branches/core7:10328-10623
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/formationFS15:10320-10610
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/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/hud:8883-8986
/code/branches/hudHS14:10083-10241
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/keckslevelHS14:10082-10222
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/leveljoemeHS14:10087-10223
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/minigame4DHS14:10081-10230
/code/branches/miniprojects:2754-2824
/code/branches/modularships:9994-10071
/code/branches/multiplayerFS15:10324-10611
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/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/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/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/pickupsFS14:10000-10259
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationFS14:10069-10215
/code/branches/presentationFS15:10499
/code/branches/presentationFS15merge:10595-10621
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/presentationHS14merge:10222-10257
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/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/sfxThilo:9691-9917
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/storymodeHS14:10085-10254
/code/branches/surfaceRace:9028-9199
/code/branches/surfaceraceHS14:10080-10236
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/towerdefenseFS15:10283-10614
/code/branches/towerdefenseHS14:10086-10247
/code/branches/turret:9380-9501
/code/branches/turretFS14:9998-10070
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weaponFS15:10302-10615
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
/code/branches/weaponupdateHS14:10084-10237
/code/trunk:10639
Copied: code/branches/campaignHS15/DivisionBrit.png (from rev 10832, code/branches/AI_HS15/DivisionBrit.png)
===================================================================
(Binary files differ)
Copied: code/branches/campaignHS15/Four_Finger_Squadron.PNG (from rev 10832, code/branches/AI_HS15/Four_Finger_Squadron.PNG)
===================================================================
(Binary files differ)
Copied: code/branches/campaignHS15/data/levels/AITest.oxw (from rev 10832, code/branches/AI_HS15/data/levels/AITest.oxw)
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw (rev 0)
+++ code/branches/campaignHS15/data/levels/AITest.oxw 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,133 @@
+<LevelInfo
+ name = "New AI testing level"
+ description = "A level with two opposing new AI teams"
+ tags = "test"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipAssff.oxt")
+ include("templates/spaceshipPirate.oxt")
+ include("templates/spaceshipEscort.oxt")
+ include("templates/spaceshipRing.oxt")
+ include("templates/spaceshipSwallow.oxt")
+?>
+
+<Level>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <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 team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ >
+<!--
+ <?lua
+ for i = 0, 5, 1 do
+ ?>
+
+
+ <SpaceShip position="<?lua print(-1600+i*200) ?>,<?lua print(-3000-i*500) ?>, -1500 ?>" lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <AIController accuracy=10 team=2>
+ </AIController>
+ </controller>
+ </SpaceShip>
+ <?lua end ?> -->
+
+
+ <SpaceShip position="4000, 1500, -1000" lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <DivisionController team=1 formationMode="wall" action="FIGHT">
+ </DivisionController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=1>
+ </WingmanController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="4000, 1500, -2200" lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=1>
+ </WingmanController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="4000, 1500, -2800 " lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <SectionController team=1>
+ </SectionController>
+ </controller>
+ </SpaceShip>
+
+ <SpaceShip position="-4000, 1500, -5000" lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <DivisionController team=2 formationMode="wall" action="FIGHT">
+ </DivisionController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="-4000 , 1500, -5600" lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=2>
+ </WingmanController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="-4000, 1500, -6200" lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <WingmanController team=2>
+ </WingmanController>
+ </controller>
+ </SpaceShip>
+ <SpaceShip position="-4000, 1500, -6800 " lookat="0,0,0">
+ <templates>
+ <Template link=spaceshipassff />
+ </templates>
+ <controller>
+ <SectionController team=2>
+ </SectionController>
+ </controller>
+ </SpaceShip>
+
+
+
+
+ </Scene>
+</Level>
+
Modified: code/branches/campaignHS15/src/libraries/util/Math.cc
===================================================================
--- code/branches/campaignHS15/src/libraries/util/Math.cc 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/src/libraries/util/Math.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -160,7 +160,7 @@
- If the other object is only a bit at my right, the function still returns <tt>Vector2(0.01, 0)</tt>.
- If the other object is exactly above me, the function returns <tt>Vector2(0, 0.5)</tt>.
*/
- orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
+ orxonox::Vector2 get2DViewCoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
{
orxonox::Vector3 distance = otherposition - myposition;
Modified: code/branches/campaignHS15/src/libraries/util/Math.h
===================================================================
--- code/branches/campaignHS15/src/libraries/util/Math.h 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/src/libraries/util/Math.h 2015-11-23 12:24:51 UTC (rev 10834)
@@ -90,7 +90,7 @@
_UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
_UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
- _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
+ _UtilExport orxonox::Vector2 get2DViewCoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
_UtilExport orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit);
_UtilExport bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle);
_UtilExport int determineMap3DZOrder(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float detectionlimit);
Modified: code/branches/campaignHS15/src/modules/docking/DockingController.cc
===================================================================
--- code/branches/campaignHS15/src/modules/docking/DockingController.cc 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/src/modules/docking/DockingController.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -60,7 +60,7 @@
return;
float distance = (this->dock_->getWorldPosition() - entity->getPosition()).length();
- Vector2 coord = get2DViewcoordinates( // I don't understand this too
+ Vector2 coord = get2DViewCoordinates( // I don't understand this too
entity->getPosition(),
entity->getOrientation() * WorldEntity::FRONT,
entity->getOrientation() * WorldEntity::UP,
Modified: code/branches/campaignHS15/src/modules/overlays/hud/HUDRadar.cc
===================================================================
--- code/branches/campaignHS15/src/modules/overlays/hud/HUDRadar.cc 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/src/modules/overlays/hud/HUDRadar.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -239,7 +239,7 @@
it->second->_notifyZOrder(this->overlay_->getZOrder() * 100 + 70 + zOrder);
}
else
- coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
+ coord = get2DViewCoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
Modified: code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt 2015-11-23 12:24:51 UTC (rev 10834)
@@ -10,4 +10,9 @@
DroneController.cc
FormationController.cc
ControllerDirector.cc
+ DivisionController.cc
+ LeaderController.cc
+ WingmanController.cc
+ SectionController.cc
+ CommonController.cc
)
Copied: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,694 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Dominik Solenicki
+ *
+ */
+//bug or feature? Press 4 control keys from {Q,W,E,A,S,D,C} at the same time or 3 keys from {Q,E,A,D}, spaceship goes in free fly mode
+#include "controllers/CommonController.h"
+#include "core/XMLPort.h"
+
+#include "weaponsystem/WeaponMode.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponSlot.h"
+#include "weaponsystem/WeaponSlot.h"
+#include "worldentities/pawns/SpaceShip.h"
+
+#include "Scene.h"
+#include <OgreRay.h>
+#include <OgreSceneQuery.h>
+#include <OgreCamera.h>
+#include <OgreSceneManager.h>
+namespace orxonox
+{
+
+ RegisterClass( CommonController );
+ const float SPEED = 0.9f/0.02f;
+ const float ROTATEFACTOR = 1.0f/0.02f;
+
+ CommonController::CommonController( Context* context ): Controller( context )
+ {
+
+
+ this->action_ = Action::FLY;
+ this->stopLookingAtTarget();
+
+ RegisterObject( CommonController );
+ }
+
+
+ CommonController::~CommonController()
+ {
+ //orxout(internal_error) << "I died, my Rank is " << rank_ << endl;
+ }
+
+ void CommonController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
+ {
+ SUPER( CommonController, XMLPort, xmlelement, mode );
+ XMLPortParam( CommonController, "formationMode", setFormationModeXML, getFormationModeXML, xmlelement, mode );
+ XMLPortParam( CommonController, "action", setActionXML, getActionXML, xmlelement, mode );
+
+ }
+ void CommonController::setActionXML( std::string val)
+ {
+ const std::string valUpper = getUppercase( val );
+ Action::Value value;
+
+ if ( valUpper == "FIGHT" )
+ value = Action::FIGHT;
+ else if ( valUpper == "FLY" )
+ value = Action::FLY;
+ else if ( valUpper == "PROTECT" )
+ value = Action::PROTECT;
+ else
+ ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ val + "'." );
+ this->setAction( value );
+ }
+ std::string CommonController::getActionXML()
+ {
+ switch ( this->action_ )
+ {
+ case Action::FIGHT:
+ {
+ return "FIGHT";
+ break;
+ }
+ case Action::FLY:
+ {
+ return "FLY";
+ break;
+ }
+ case Action::PROTECT:
+ {
+ return "PROTECT";
+ break;
+ }
+ default:
+ return "FIGHT";
+ break;
+ }
+ }
+ void CommonController::setFormationModeXML( std::string val )
+ {
+ const std::string valUpper = getUppercase( val );
+ FormationMode::Value value;
+
+ if ( valUpper == "WALL" )
+ value = FormationMode::WALL;
+ else if ( valUpper == "FINGER4" )
+ value = FormationMode::FINGER4;
+ else if ( valUpper == "DIAMOND" )
+ value = FormationMode::DIAMOND;
+ else
+ ThrowException( ParseError, std::string( "Attempting to set an unknown FormationMode: '" )+ val + "'." );
+ this->setFormationMode( value );
+
+ }
+ std::string CommonController::getFormationModeXML()
+ {
+ switch ( this->formationMode_ )
+ {
+ case FormationMode::WALL:
+ {
+ return "WALL";
+ break;
+ }
+ case FormationMode::FINGER4:
+ {
+ return "FINGER4";
+ break;
+ }
+ case FormationMode::DIAMOND:
+ {
+ return "DIAMOND";
+ break;
+ }
+ default:
+ return "DIAMOND";
+ break;
+
+ }
+ }
+ Action::Value CommonController::getAction ()
+ {
+ return this->action_;
+ }
+ void CommonController::setAction (Action::Value action)
+ {
+ this->action_ = action;
+ }
+
+ void CommonController::setAction (Action::Value action, ControllableEntity* target)
+ {
+ this->action_ = action;
+ if (action == Action::FIGHT)
+ {
+ if (target)
+ this->setTarget (target);
+ }
+ else if (action == Action::PROTECT)
+ {
+ }
+ }
+ void CommonController::setAction (Action::Value action, const Vector3& target)
+ {
+ this->action_ = action;
+ if (action == Action::FLY)
+ {
+ this->setTargetPosition (target);
+ }
+ else if (action == Action::PROTECT)
+ {
+
+ }
+ }
+ void CommonController::setAction (Action::Value action, const Vector3& target, const Quaternion& orient )
+ {
+ this->action_ = action;
+ if (action == Action::FLY)
+ {
+ this->setTargetPosition (target);
+ this->setTargetOrientation (orient);
+ }
+ else if (action == Action::PROTECT)
+ {
+
+ }
+ }
+ void CommonController::setClosestTarget()
+ {
+ if (!this->getControllableEntity())
+ return;
+
+ Pawn* closestTarget = 0;
+ float minDistance = std::numeric_limits<float>::infinity();
+
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
+ continue;
+
+ float distance = CommonController::distance (*itP, this->getControllableEntity());
+ if (distance < minDistance)
+ {
+ closestTarget = *itP;
+ minDistance = distance;
+ }
+ }
+ if (closestTarget)
+ {
+ (this)->setTarget(static_cast<ControllableEntity*>(closestTarget));
+ }
+ }
+ void CommonController::maneuver()
+ {
+ maneuverCounter_++;
+
+ if (maneuverCounter_ > 5)
+ maneuverCounter_ = 0;
+ if ( this->target_ && this->getControllableEntity())
+ {
+ Vector3 thisPosition = this->getControllableEntity()->getWorldPosition();
+ //Quaternion thisOrientation = this->getControllableEntity()->getOrientation();
+
+ this->setPositionOfTarget( getPredictedPosition(
+ thisPosition,
+ hardcoded_projectile_speed,
+ this->target_->getWorldPosition() ,
+ this->target_->getVelocity()
+ ) );
+ this->setOrientationOfTarget( this->target_->getOrientation() );
+
+
+ Vector3 diffVector = this->positionOfTarget_ - thisPosition;
+ float diffLength = diffVector.length();
+ Vector3 diffUnit = diffVector/diffLength;
+
+
+
+ //bool bThisIsLookingAtTarget = this->isLooking ( getControllableEntity(), this->target_, math::pi/4 );
+ bool bTargetIsLookingAtThis = this->isLooking ( this->target_, getControllableEntity(), math::pi/10.0f );
+
+
+
+ //too far? well, come closer then
+ if ( diffLength > 3000 )
+ {
+ if (diffLength < 6000)
+ {
+
+ }
+ else
+ {
+ }
+ this->setTargetPosition( this->positionOfTarget_ );
+ }
+ //too close? How do u expect to dodge anything? Just attack!
+ else if ( diffLength < 500 )
+ {
+ //at this point, just look and shoot
+ if ( diffLength < 250 )
+ {
+ this->stopMoving();
+ this->startLookingAtTarget();
+ }
+ else
+ {
+ this->setTargetPosition( this->positionOfTarget_ );
+ }
+ }
+ //Good distance? Check if target looks at us. It doesn't? Go hunt!
+ else if ( !bTargetIsLookingAtThis )
+ {
+ this->setTargetPosition( this->positionOfTarget_ );
+ /* if (maneuverCounter_ == 0)
+ {
+ this->setTargetPosition( this->positionOfTarget_ );
+ return;
+ }
+ else
+ {
+ dodge( thisPosition, diffUnit );
+ }*/
+ }
+ //That's unfortunate, he is looking and probably shooting... try to dodge what we can...
+ else
+ {
+
+ if (maneuverCounter_ == 0)
+ {
+ this->setTargetPosition( this->positionOfTarget_ );
+ return;
+ }
+ dodge( thisPosition, diffUnit );
+
+ }
+ }
+
+ //orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl;
+ }
+ ControllableEntity* CommonController::getTarget()
+ {
+ return this->target_;
+ }
+ void CommonController::dodge(Vector3& thisPosition, Vector3& diffUnit)
+ {
+ float factorX = 0, factorY = 0, factorZ = 0;
+ float rand = randomInRange (0, 1);
+ if (rand <= 0.5)
+ {
+ factorX = 1;
+ }
+ else
+ {
+ factorX = -1;
+ }
+ rand = randomInRange (0, 1);
+ if (rand <= 0.5)
+ {
+ factorY = 1;
+ }
+ else
+ {
+ factorY = -1;
+ }
+ rand = randomInRange (0, 1);
+ if (rand <= 0.5)
+ {
+ factorZ = 1;
+ }
+ else
+ {
+ factorZ = -1;
+ }
+ Vector3 target = ( diffUnit )* 8000.0f;
+ Vector3* randVector = new Vector3(
+ factorX * randomInRange( 10000, 40000 ),
+ factorY * randomInRange( 10000, 40000 ),
+ factorZ * randomInRange( 10000, 40000 )
+ );
+ Vector3 projection = randVector->dotProduct( diffUnit )* diffUnit;
+ *randVector -= projection;
+ target += *randVector;
+ this->setTargetPosition( thisPosition + target );
+ }
+ void CommonController::stopMoving()
+ {
+ this->bHasTargetPosition_ = false;
+ }
+ void CommonController::startLookingAtTarget()
+ {
+ this->bLookAtTarget_ = true;
+ }
+ void CommonController::stopLookingAtTarget()
+ {
+ this->bLookAtTarget_ = false;
+ }
+ void CommonController::lookAtTarget(float dt)
+ {
+
+
+ ControllableEntity* entity = this->getControllableEntity();
+ if ( !entity )
+ return;
+ Vector2 coord = get2DViewCoordinates
+ ( entity->getPosition() ,
+ entity->getOrientation() * WorldEntity::FRONT,
+ entity->getOrientation() * WorldEntity::UP,
+ positionOfTarget_ );
+
+ //rotates should be in range [-1,+1], clamp cuts off all that is not
+ float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
+ float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
+
+
+
+ //Yaw and Pitch are enough to start facing the target
+ this->getControllableEntity() ->rotateYaw( ROTATEFACTOR * rotateX * dt );
+ this->getControllableEntity() ->rotatePitch( ROTATEFACTOR * rotateY * dt );
+
+
+ }
+
+ bool CommonController::setWingman ( CommonController* wingman )
+ {
+ return false;
+ }
+
+ bool CommonController::hasWingman()
+ {
+ return true;
+ }
+ void CommonController::setTarget( ControllableEntity* target )
+ {
+ this->target_ = target;
+ //orxout ( internal_error ) << " TARGET SET " << endl;
+
+ if ( this->target_ )
+ {
+ this->setPositionOfTarget( target_->getWorldPosition() );
+
+ }
+ }
+ bool CommonController::hasTarget()
+ {
+ if ( this->target_ )
+ return true;
+ return false;
+ }
+ void CommonController::setPositionOfTarget( const Vector3& target )
+ {
+ this->positionOfTarget_ = target;
+ this->bHasPositionOfTarget_ = true;
+ }
+ void CommonController::setOrientationOfTarget( const Quaternion& orient )
+ {
+ this->orientationOfTarget_=orient;
+ this->bHasOrientationOfTarget_=true;
+ }
+
+ void CommonController::setTargetPosition( const Vector3& target )
+ {
+ this->targetPosition_ = target;
+ this->bHasTargetPosition_ = true;
+ }
+
+ void CommonController::setTargetOrientation( const Quaternion& orient )
+ {
+ this->targetOrientation_=orient;
+ this->bHasTargetOrientation_=true;
+ }
+
+ void CommonController::setTargetOrientation( ControllableEntity* target )
+ {
+ if ( target )
+ setTargetOrientation( target->getOrientation() );
+ }
+
+
+
+ //copy the Roll orientation of given Quaternion.
+ void CommonController::copyOrientation( const Quaternion& orient, float dt )
+ {
+ //roll angle difference in radian
+ float diff=orient.getRoll( false ).valueRadians() -( this->getControllableEntity() ->getOrientation() .getRoll( false ).valueRadians() );
+ while( diff>math::twoPi )diff-=math::twoPi;
+ while( diff<-math::twoPi )diff+=math::twoPi;
+ this->getControllableEntity() ->rotateRoll( diff*ROTATEFACTOR * dt );
+ }
+ void CommonController::copyTargetOrientation( float dt )
+ {
+ if ( bHasTargetOrientation_ )
+ {
+ copyOrientation( targetOrientation_, dt );
+ }
+ }
+
+
+
+
+ void CommonController::moveToTargetPosition( float dt )
+ {
+ this->moveToPosition( this->targetPosition_, dt );
+ }
+ void CommonController::moveToPosition( const Vector3& target, float dt )
+ {
+
+
+ //100 is ( so far )the smallest tolerance ( empirically found )that can be reached,
+ //with smaller distance spaceships can't reach position and go circles around it instead
+ int tolerance = 65;
+
+ ControllableEntity* entity = this->getControllableEntity();
+ Vector2 coord = get2DViewCoordinates
+ ( entity->getPosition() ,
+ entity->getOrientation() * WorldEntity::FRONT,
+ entity->getOrientation() * WorldEntity::UP,
+ target );
+
+ float distance = ( target - this->getControllableEntity() ->getPosition() ).length();
+
+ //rotates should be in range [-1,+1], clamp cuts off all that is not
+ float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
+ float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
+
+
+ if ( distance > tolerance )
+ {
+ //Yaw and Pitch are enough to start facing the target
+ this->getControllableEntity() ->rotateYaw( ROTATEFACTOR * rotateX * dt );
+ this->getControllableEntity() ->rotatePitch( ROTATEFACTOR * rotateY * dt );
+
+ //300 works, maybe less is better
+ if ( distance < 400 )
+ {
+ //Change roll when close. When Spaceship faces target, roll doesn't affect it's trajectory
+ //It's important that roll is not changed in the process of changing yaw and pitch
+ //Wingmen won't face same direction as Leaders, but when Leaders start moving
+ //Yaw and Pitch will adapt.
+ if ( bHasTargetOrientation_ )
+ {
+ copyTargetOrientation( dt );
+ }
+ }
+
+ this->getControllableEntity() ->moveFrontBack( SPEED * dt );
+ }
+ else
+ {
+ bHasTargetPosition_ = false;
+ bHasTargetOrientation_ = false;
+ }
+ }
+ float CommonController::randomInRange( float a, float b )
+ {
+ float random = rnd( 1.0f );
+ float diff = b - a;
+ float r = random * diff;
+ return a + r;
+ }
+
+
+ //to be called in action
+ //PRE: relativeTargetPosition is desired position relative to the spaceship,
+ //angleRoll is the angle in degrees of Roll that should be applied by the end of the movement
+ //POST: target orientation and position are set, so that it can be used by MoveAndRoll()
+ void CommonController::moveToPoint( const Vector3& relativeTargetPosition, float angleRoll )
+ {
+ ControllableEntity* entity = this->getControllableEntity();
+ if ( !entity )
+ return;
+ Quaternion orient = entity->getWorldOrientation();
+ Quaternion rotation = Quaternion( Degree( angleRoll ), Vector3::UNIT_Z );
+
+ Vector3 target = orient * relativeTargetPosition + entity->getWorldPosition();
+ setTargetPosition( target );
+ orient = orient * rotation;
+ this->setTargetOrientation( orient );
+
+ }
+ //to be called in tick
+ //PRE: MoveToPoint was called
+ //POST: spaceship changes its yaw and pitch to point towards targetPosition_,
+ //moves towards targetPosition_ by amount depending on dt and its speed,
+ //rolls by amount depending on the difference between angleRoll_ and angleRolled_, dt, and
+ //angular speed
+ //if position reached with a certain tolerance, and angleRolled_ = angleRoll_, returns false,
+ //otherwise returns true
+ //dt is normally around 0.02f, which makes it 1/0.02 = 50 frames/sec
+ bool CommonController::moveAndRoll( float dt )
+ {
+ float factor = 1;
+ if ( !this->getControllableEntity() )
+ return false;
+ if ( this->rank_ == Rank::DIVISIONLEADER )
+ factor = 0.8;
+ if ( this->rank_ == Rank::SECTIONLEADER )
+ factor = 0.9;
+ int tolerance = 60;
+
+ ControllableEntity* entity = this->getControllableEntity();
+ if ( !entity )
+ return true;
+ Vector2 coord = get2DViewCoordinates
+ ( entity->getPosition() ,
+ entity->getOrientation() * WorldEntity::FRONT,
+ entity->getOrientation() * WorldEntity::UP,
+ targetPosition_ );
+
+ float distance = ( targetPosition_ - this->getControllableEntity() ->getPosition() ).length();
+
+ //rotates should be in range [-1,+1], clamp cuts off all that is not
+ float rotateX = clamp( coord.x * 10, -1.0f, 1.0f );
+ float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
+
+
+ if ( distance > tolerance )
+ {
+ //Yaw and Pitch are enough to start facing the target
+ this->getControllableEntity() ->rotateYaw( -2.0f * ROTATEFACTOR * rotateX * dt );
+ this->getControllableEntity() ->rotatePitch( 2.0f * ROTATEFACTOR * rotateY * dt );
+
+ //Roll
+ if ( bHasTargetOrientation_ )
+ {
+ copyTargetOrientation( dt );
+ }
+
+ //Move
+ this->getControllableEntity() ->moveFrontBack( 1.2f * SPEED * factor * dt );
+ //if still moving, return false
+ return false;
+ }
+ else
+ {
+
+ //if finished, return true;
+ return true;
+ }
+ }
+
+ float CommonController::squaredDistanceToTarget() const
+ {
+ if ( !this->getControllableEntity() )
+ return 0;
+ if ( !this->target_ || !this->getControllableEntity() )
+ return ( this->getControllableEntity() ->getPosition() .squaredDistance( this->targetPosition_ ) );
+ else
+ return ( this->getControllableEntity() ->getPosition() .squaredDistance( this->positionOfTarget_ ) );
+ }
+
+ bool CommonController::isLookingAtTarget( float angle )const
+ {
+ if ( !this->getControllableEntity() || !this->target_ )
+ return false;
+
+ return ( getAngle( this->getControllableEntity() ->getPosition() ,
+ this->getControllableEntity() ->getOrientation() * WorldEntity::FRONT, this->positionOfTarget_ ) < angle );
+ }
+ bool CommonController::isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle )
+ {
+ if ( !entityThatLooks || !entityBeingLookedAt )
+ return false;
+ return ( getAngle( entityThatLooks ->getPosition() ,
+ entityThatLooks->getOrientation() * WorldEntity::FRONT,
+ entityBeingLookedAt->getWorldPosition() ) < angle );
+ }
+
+ bool CommonController::canFire()
+ {
+
+ //no target? why fire?
+ if ( !this->target_ )
+ return false;
+
+ Vector3 newPositionOfTarget = getPredictedPosition( this->getControllableEntity() ->getWorldPosition() ,
+ hardcoded_projectile_speed, this->target_->getWorldPosition() , this->target_->getVelocity() );
+ if ( newPositionOfTarget != Vector3::ZERO )
+ {
+ this->setPositionOfTarget( newPositionOfTarget );
+ }
+
+ float squaredDistance = squaredDistanceToTarget();
+
+ if ( squaredDistance < 9000000.0f && this->isLookingAtTarget( math::pi / 20.0f)) {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+ float CommonController::distance (ControllableEntity* entity1, ControllableEntity* entity2)
+ {
+ if (!entity1 || !entity2)
+ return std::numeric_limits<float>::infinity();
+ return ( entity1->getPosition() - entity2->getPosition() ).length();
+ }
+ bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2)
+ {
+ if (!entity1 || !entity2)
+ return false;
+ return entity1->getTeam() == entity2->getTeam();
+ }
+ void CommonController::doFire()
+ {
+ if ( !this->target_ || !this->getControllableEntity() )
+ {
+ return;
+ }
+
+ Pawn* pawn = orxonox_cast<Pawn*>( this->getControllableEntity() );
+
+ if ( pawn )
+ //pawn->setAimPosition( this->getControllableEntity() ->getWorldPosition() + 4000*( this->getControllableEntity() ->getOrientation() * WorldEntity::FRONT ));
+ pawn->setAimPosition( this->positionOfTarget_ );
+
+ this->getControllableEntity() ->fire( 0 );
+ }
+
+
+}
Copied: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/CommonController.h)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.h (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.h 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,192 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _CommonController_H__
+#define _CommonController_H__
+
+
+#include "controllers/Controller.h"
+#include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/Pawn.h"
+#include "util/Math.h"
+
+#include "tools/Timer.h"
+#include "tools/interfaces/Tickable.h"
+#include <limits>
+
+
+namespace orxonox
+{
+
+ namespace FormationMode
+ {
+ enum Value
+ {
+ FINGER4, DIAMOND, WALL
+ };
+ }
+ namespace Rank
+ {
+ enum Value
+ {
+ NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN
+ };
+
+ }
+ namespace Action
+ {
+ enum Value
+ {
+ FLY, FIGHT, PROTECT
+ };
+ }
+
+
+ class _OrxonoxExport CommonController : public Controller
+ {
+
+ public:
+ static const float hardcoded_projectile_speed = 750;
+ static const float ACTION_INTERVAL = 1.0f;
+
+ CommonController(Context* context);
+ virtual ~CommonController();
+
+ //----[XML data]----
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ //----[Action data]----
+ Action::Value getAction ();
+ void setAction (Action::Value action);
+ void setAction (Action::Value action, ControllableEntity* target);
+ void setAction (Action::Value action, const Vector3& target);
+ void setAction (Action::Value action, const Vector3& target, const Quaternion& orient );
+ void setActionXML( std::string val);
+ std::string getActionXML();
+ //----[/Action data]----
+ //----[Formation data]----
+ virtual void setFormationModeXML(std::string val);
+ virtual std::string getFormationModeXML();
+ virtual void setFormationMode(FormationMode::Value val)
+ { this->formationMode_ = val; }
+ inline FormationMode::Value getFormationMode() const
+ { return this->formationMode_; }
+ //----[/Formation data]----
+ //----[Rank data]----
+ virtual void setRank(Rank::Value val)
+ { this->rank_ = val; }
+ inline Rank::Value getRank() const
+ { return this->rank_; }
+ //----[/Rank data]----
+ //----[/XML data]----
+
+ //----[Interaction with other Controllers]----
+ virtual bool setWingman(CommonController* wingman);
+ virtual bool hasWingman();
+
+ void setPositionOfTarget(const Vector3& target);
+ void setOrientationOfTarget(const Quaternion& orient);
+
+ void setTarget(ControllableEntity* target);
+ ControllableEntity* getTarget();
+ bool hasTarget();
+
+ void setTargetPosition(const Vector3& target);
+ void setTargetOrientation(const Quaternion& orient);
+ void setTargetOrientation(ControllableEntity* target);
+ //----[/Interaction with other Controllers]----
+
+ //----[Helper functions]----
+ float randomInRange(float a, float b);
+ static float distance(ControllableEntity* entity1, ControllableEntity* entity2);
+ static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2);
+ static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ;
+
+ float squaredDistanceToTarget() const;
+ bool isLookingAtTarget(float angle) const;
+ //----[/Helper functions]----
+
+ protected:
+ //----[Flying functionality]----
+ void stopMoving();
+
+ void moveToPoint(const Vector3& relativeTargetPosition, float angleRoll);
+ bool moveAndRoll(float dt);
+
+ void moveToPosition(const Vector3& target, float dt);
+ void moveToTargetPosition(float dt);
+
+ void copyOrientation(const Quaternion& orient, float dt);
+ void copyTargetOrientation(float dt);
+
+ void lookAtTarget(float dt);
+ void stopLookingAtTarget();
+ void startLookingAtTarget();
+
+ bool bLookAtTarget_;
+ //----[/Flying functionality]----
+
+ //----[Fighting functionality]----
+ void maneuver();
+ void dodge(Vector3& thisPosition, Vector3& diffUnit);
+ void aimAtTarget();
+ bool canFire();
+ void doFire();
+ void setClosestTarget();
+
+ bool bShooting_;
+ int maneuverCounter_;
+ //----[/Fighting functionality]----
+
+ //----[where-to-fly information]----
+ bool bHasTargetPosition_;
+ Vector3 targetPosition_;
+ bool bHasTargetOrientation_;
+ Quaternion targetOrientation_;
+ // Vector3 destination_;
+ // bool bHasDestination;
+ //----[/where-to-fly information]----
+
+ //----[who-to-kill information]----
+ WeakPtr<ControllableEntity> target_;
+ //WeakPtr<ControllableEntity> objectiveTarget_;
+
+ bool bHasPositionOfTarget_;
+ Vector3 positionOfTarget_;
+ bool bHasOrientationOfTarget_;
+ Quaternion orientationOfTarget_;
+ //----[/who-to-kill information]----
+
+ //----["Private" variables]----
+ FormationMode::Value formationMode_;
+ Rank::Value rank_;
+ Action::Value action_;
+ //----[/"Private" variables]----
+ };
+}
+
+#endif /* _CommonController_H__ */
Copied: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,253 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Dominik Solenicki
+ *
+ */
+
+#include "DivisionController.h"
+
+
+namespace orxonox
+{
+
+ RegisterClass(DivisionController);
+
+ //Leaders share the fact that they have Wingmans
+ DivisionController::DivisionController(Context* context) : LeaderController(context)
+ {
+ RegisterObject(DivisionController);
+
+ this->setFormationMode(FormationMode::DIAMOND);
+ this->target_ = 0;
+ this->myFollower_ = 0;
+ this->myWingman_ = 0;
+ this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
+ this->rank_ = Rank::DIVISIONLEADER;
+
+
+ }
+
+ DivisionController::~DivisionController()
+ {
+ }
+
+ void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(DivisionController, XMLPort, xmlelement, mode);
+
+ //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
+ }
+
+
+ void DivisionController::tick(float dt)
+ {
+ if (!this->isActive())
+ return;
+ if (this->bHasTargetPosition_)
+ {
+ this->moveToTargetPosition(dt);
+ }
+ else if (this->bLookAtTarget_)
+ {
+ this->lookAtTarget(dt);
+ }
+ if (bShooting_)
+ {
+ this->doFire();
+ }
+
+ SUPER(DivisionController, tick, dt);
+
+ }
+ void DivisionController::action()
+ {
+
+
+ if (this->action_ == Action::FIGHT)
+ {
+ if (!this->hasTarget())
+ {
+ //----find a target----
+ this->setClosestTarget();
+ }
+ else
+ {
+ //----fly in formation if far enough----
+ Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();
+ if (diffVector.length() > 3000)
+ {
+ this->setTargetPositionOfWingman();
+ this->setTargetPositionOfFollower();
+ }
+ else
+ {
+ //----wingmans shall support the fire of their leaders----
+ if (this->myWingman_)
+ {
+ this->myWingman_->setAction (Action::FIGHT, this->target_);
+ }
+ if (this->myFollower_)
+ {
+ this->myFollower_->setAction (Action::FIGHT);
+ }
+
+ }
+
+ }
+ if (this->hasTarget())
+ {
+ //----choose where to go----
+ this->maneuver();
+ //----fire if you can----
+ this->bShooting_ = this->canFire();
+ }
+
+ }
+ else if (this->action_ == Action::FLY)
+ {
+ this->setTargetPositionOfWingman();
+ this->setTargetPositionOfFollower();
+ }
+ else if (this->action_ == Action::PROTECT)
+ {
+
+ }
+
+ }
+
+
+
+ void DivisionController::setTargetPositionOfWingman()
+ {
+ if (!this->myWingman_)
+ return;
+ Vector3* targetRelativePositionOfWingman;
+ switch (this->formationMode_){
+ case FormationMode::WALL:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, 0, 0);
+ break;
+ }
+ case FormationMode::FINGER4:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, 0, 200);
+ break;
+ }
+
+ case FormationMode::DIAMOND:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, 0, 200);
+ break;
+ }
+ }
+ Quaternion orient = this->getControllableEntity()->getWorldOrientation();
+
+ Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) +
+ (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
+
+ myWingman_->setAction( Action::FLY, targetAbsolutePositionOfWingman, orient);
+
+ }
+ void DivisionController::setTargetPositionOfFollower()
+ {
+ if (!this->myFollower_)
+ return;
+ this->myFollower_->setFormationMode(this->formationMode_);
+
+ Vector3* targetRelativePositionOfFollower;
+ switch (this->formationMode_){
+ case FormationMode::WALL:
+ {
+ targetRelativePositionOfFollower = new Vector3 (-400, 0, 0);
+ break;
+ }
+ case FormationMode::FINGER4:
+ {
+ targetRelativePositionOfFollower = new Vector3 (-400, 0, 200);
+ break;
+ }
+
+ case FormationMode::DIAMOND:
+ {
+ targetRelativePositionOfFollower = new Vector3 (-400, 0, 200);
+ break;
+ }
+ }
+ Quaternion orient = this->getControllableEntity()->getWorldOrientation();
+
+ Vector3 targetAbsolutePositionOfFollower = ((this->getControllableEntity()->getWorldPosition()) +
+ (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfFollower)));
+
+ myFollower_->setAction ( Action::FLY, targetAbsolutePositionOfFollower, orient );
+ }
+
+
+ bool DivisionController::setWingman(CommonController* cwingman)
+ {
+
+ WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
+ if (!this->myWingman_)
+ {
+ this->myWingman_ = wingman;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+ bool DivisionController::setFollower(LeaderController* myFollower)
+ {
+ if (!this->myFollower_)
+ {
+ this->myFollower_ = myFollower;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ bool DivisionController::hasWingman()
+ {
+ if (this->myWingman_)
+ return true;
+ else
+ return false;
+ }
+ bool DivisionController::hasFollower()
+ {
+ if (this->myFollower_)
+ return true;
+ else
+ return false;
+ }
+
+
+
+
+
+}
Copied: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,74 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Dominik Solenicki
+ *
+ */
+
+#ifndef _DivisionController_H__
+#define _DivisionController_H__
+
+#include "controllers/LeaderController.h"
+
+
+
+namespace orxonox
+{
+ class _OrxonoxExport DivisionController : public LeaderController, public Tickable
+ {
+ public:
+ //----[language demanded functions]----
+ DivisionController(Context* context);
+
+ virtual ~DivisionController();
+ //----[/language demanded functions]----
+
+ //----[orxonox demanded functions]----
+ virtual void tick(float dt);
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ //----[orxonox demanded functions]----
+
+ //----[own functions]----
+ virtual bool setFollower(LeaderController* myFollower);
+ virtual bool setWingman(CommonController* cwingman);
+ virtual bool hasWingman();
+ virtual bool hasFollower();
+
+ void setTargetPositionOfWingman();
+ void setTargetPositionOfFollower();
+ //----[/own functions]----
+
+ protected:
+ //----action must only be managed by this----
+ virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
+
+ private:
+ //----private variables-----
+ Timer actionTimer_; //<! Regularly calls action().
+
+ };
+}
+
+#endif /* _DivisionController_H__ */
Modified: code/branches/campaignHS15/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FormationController.cc 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/src/orxonox/controllers/FormationController.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -276,7 +276,7 @@
// return;
}
- Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
+ Vector2 coord = get2DViewCoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
float distance = (target - this->getControllableEntity()->getPosition()).length();
float rotateX = clamp(coord.x * 10, -1.0f, 1.0f);
float rotateY = clamp(coord.y * 10, -1.0f, 1.0f);
@@ -1068,7 +1068,7 @@
if (!this->getControllableEntity())
return;
- Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
+ Vector2 coord = get2DViewCoordinates(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 > minDistance)
Copied: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,51 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Dominik Solenicki
+ *
+ */
+
+#include "LeaderController.h"
+
+
+namespace orxonox
+{
+
+ RegisterClass(LeaderController);
+
+ //CommonController contains all common functionality of AI Controllers
+ LeaderController::LeaderController(Context* context) : CommonController(context)
+ {
+
+ RegisterObject(LeaderController);
+
+ }
+
+
+ LeaderController::~LeaderController()
+ {
+ }
+
+
+}
Copied: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,69 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _LeaderController_H__
+#define _LeaderController_H__
+
+#include "controllers/CommonController.h"
+#include "controllers/WingmanController.h"
+
+
+
+
+namespace orxonox
+{
+ class _OrxonoxExport LeaderController : public CommonController
+ {
+ public:
+ //----[language demanded functions]----
+ LeaderController(Context* context);
+ virtual ~LeaderController();
+ //----[language demanded functions]----
+
+ //----[pseudo virtual methods]----
+ virtual bool setFollower(LeaderController* myFollower)
+ { return false; }
+ virtual bool hasFollower()
+ { return true; }
+ //----[/pseudo virtual methods]----
+
+
+
+ protected:
+ //----private variables-----
+ WeakPtr<WingmanController> myWingman_;
+ WeakPtr<LeaderController> myFollower_;
+ WeakPtr<LeaderController> myDivisionLeader_;
+
+
+ private:
+
+ };
+}
+
+#endif /* _LeaderController_H__ */
Copied: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,305 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Dominik Solenicki
+ *
+ */
+
+#include "SectionController.h"
+
+namespace orxonox
+{
+
+ RegisterClass(SectionController);
+
+ //Leaders share the fact that they have Wingmans
+ SectionController::SectionController(Context* context) : LeaderController(context)
+ {
+ RegisterObject(SectionController);
+ this->setFormationMode(FormationMode::FINGER4);
+
+ this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
+ this->myWingman_ = 0;
+ this->myDivisionLeader_ = 0;
+ this->rank_ = Rank::SECTIONLEADER;
+
+ //orxout(internal_error) << this << "Was created" << endl;
+
+ }
+
+ SectionController::~SectionController()
+ {
+
+ }
+ void SectionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SectionController, XMLPort, xmlelement, mode);
+
+ //XMLPortParam(SectionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
+ }
+
+ //----in tick, move (or look) and shoot----
+ void SectionController::tick(float dt)
+ {
+ if (!this->isActive())
+ return;
+ if (this->bHasTargetPosition_)
+ {
+ this->moveToTargetPosition(dt);
+ }
+ else if (this->bLookAtTarget_)
+ {
+ this->lookAtTarget(dt);
+ }
+ if (bShooting_)
+ {
+ this->doFire();
+ }
+
+ SUPER(SectionController, tick, dt);
+ }
+
+ void SectionController::action()
+ {
+ //----If no leader, find one----
+ if (!myDivisionLeader_)
+ {
+ LeaderController* newDivisionLeader = findNewDivisionLeader();
+ this->myDivisionLeader_ = newDivisionLeader;
+
+ }
+ //----If have leader----
+ else
+ {
+ }
+
+ //----action was set to fight----
+ if (this->action_ == Action::FIGHT)
+ {
+ if (!this->hasTarget())
+ {
+ if (this->myDivisionLeader_)
+ {
+ this->chooseTarget();
+ }
+ else
+ {
+ this->setClosestTarget();
+ }
+ }
+ else
+ {
+
+ //----fly in formation if far enough----
+ Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();
+ if (diffVector.length() > 3000)
+ {
+ this->setTargetPositionOfWingman();
+ }
+ else
+ {
+ //----wingmans shall support the fire of their leaders----
+ if (this->myWingman_)
+ {
+ this->myWingman_->setAction (Action::FIGHT, this->target_);
+ }
+ }
+ }
+ if (this->hasTarget())
+ {
+ //----choose where to go----
+ this->maneuver();
+ //----fire if you can----
+ this->bShooting_ = this->canFire();
+ }
+ }
+
+ //----action was set to fly----
+ else if (this->action_ == Action::FLY)
+ {
+ this->setTargetPositionOfWingman();
+ }
+
+ //----action was set to protect----
+ else if (this->action_ == Action::PROTECT)
+ {
+
+ }
+
+
+ }
+ //PRE: myDivisionLeader_ != 0 && myDivisionLeader_->action_ == Action::FIGHT
+ //POST: this->target_ is set unless division leader doesn't have one
+ void SectionController::chooseTarget()
+ {
+ //----If division leader fights, cover him by fighting emenies close to his target----
+ if (this->myDivisionLeader_->getAction() == Action::FIGHT)
+ {
+ //----if he has a target----
+ if (this->myDivisionLeader_->hasTarget())
+ {
+ //----try to find a new target if division leader has wingman (doing fine) and no good target already set----
+ if ( this->myDivisionLeader_->hasWingman() &&
+ !( this->hasTarget() && this->getTarget() != this->myDivisionLeader_->getTarget() ) )
+ {
+
+ bool foundTarget = false;
+ //----new target should be close to division's target----
+ Vector3 divisionTargetPosition = this->myDivisionLeader_->getTarget()->getWorldPosition();
+
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ //----is enemy?----
+ if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )
+ continue;
+ //----in range?----
+ if (((*itP)->getWorldPosition() - divisionTargetPosition).length() < 3000 &&
+ (*itP) != this->myDivisionLeader_->getTarget())
+ {
+ foundTarget = true;
+ this->setAction(Action::FIGHT, (*itP));
+ //orxout(internal_error) << "Found target" << endl;
+ break;
+ }
+ }
+ //----no target? then attack same target as division leader----
+ if (!foundTarget)
+ {
+ this->setAction(Action::FIGHT, this->myDivisionLeader_->getTarget());
+ }
+ }
+ //----if division leader doesn't have a wingman, support his fire----
+ else
+ {
+ this->setAction(Action::FIGHT, this->myDivisionLeader_->getTarget());
+ }
+ }
+ //----If he fights but doesn't have a target, wait for him to get one----
+ else
+ {
+
+ }
+ }
+ }
+
+ //----stay in formation----
+ //gani-TODO: sum targetAbso... and this->predicted position
+ void SectionController::setTargetPositionOfWingman()
+ {
+ if (!this->myWingman_)
+ return;
+ Vector3* targetRelativePositionOfWingman;
+ switch (this->formationMode_){
+ case FormationMode::WALL:
+ {
+ targetRelativePositionOfWingman = new Vector3 (-400, 0, 0);
+ break;
+ }
+ case FormationMode::FINGER4:
+ {
+ targetRelativePositionOfWingman = new Vector3 (-400, 0, 200);
+ break;
+ }
+ case FormationMode::DIAMOND:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, -200, 0);
+ break;
+ }
+ }
+ Quaternion orient = this->getControllableEntity()->getWorldOrientation();
+
+ Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) +
+ (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
+
+ myWingman_->setAction (Action::FLY, targetAbsolutePositionOfWingman, orient);
+
+ }
+
+ LeaderController* SectionController::findNewDivisionLeader()
+ {
+
+ if (!this->getControllableEntity())
+ return 0;
+
+ LeaderController* closestLeader = 0;
+ float minDistance = std::numeric_limits<float>::infinity();
+ //go through all pawns
+ for (ObjectList<LeaderController>::iterator it = ObjectList<LeaderController>::begin(); it; ++it)
+ {
+ //0ptr or not DivisionController?
+ if (!(it) || !((it)->getRank() == Rank::DIVISIONLEADER) || !(it->getControllableEntity()))
+ continue;
+ //same team?
+ if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()))
+ continue;
+
+ //is equal to this?
+ if (orxonox_cast<ControllableEntity*>(*it) == this->getControllableEntity())
+ continue;
+
+ float distance = CommonController::distance (it->getControllableEntity(), this->getControllableEntity());
+
+ if (distance < minDistance && !(it->hasFollower()))
+ {
+ closestLeader = *it;
+ minDistance = distance;
+ }
+
+ }
+ if (closestLeader)
+ {
+ if (closestLeader->setFollower(this))
+ return closestLeader;
+ }
+ return 0;
+
+ }
+ bool SectionController::setWingman(CommonController* cwingman)
+ {
+ WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
+
+ if (!this->myWingman_)
+ {
+ this->myWingman_ = wingman;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ bool SectionController::hasWingman()
+ {
+ if (this->myWingman_)
+ return true;
+ else
+ return false;
+ }
+
+
+
+
+
+}
Copied: code/branches/campaignHS15/src/orxonox/controllers/SectionController.h (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/SectionController.h)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.h (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,74 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Dominik Solenicki
+ *
+ */
+
+#ifndef _SectionController_H__
+#define _SectionController_H__
+
+#include "controllers/LeaderController.h"
+
+
+namespace orxonox
+{
+ class _OrxonoxExport SectionController : public LeaderController, public Tickable
+ {
+ public:
+ //----[language demanded functions]----
+ SectionController(Context* context);
+
+ virtual ~SectionController();
+ //----[/language demanded functions]----
+
+ //----[orxonox demanded functions]----
+ virtual void tick(float dt);
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ //----[/orxonox demanded functions]----
+
+ //----[own functions]----
+ LeaderController* findNewDivisionLeader();
+ void setTargetPositionOfWingman();
+
+ virtual bool setWingman(CommonController* cwingman);
+ virtual bool hasWingman();
+
+ void chooseTarget();
+ //----[/own functions]----
+
+ protected:
+ //----action must only be managed by this----
+ virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
+
+ private:
+ //----private variables-----
+ Timer actionTimer_; //<! Regularly calls action().
+
+
+ };
+}
+
+#endif /* _SectionController_H__ */
Copied: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,171 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Dominik Solenicki
+ *
+ */
+
+#include "WingmanController.h"
+
+
+namespace orxonox
+{
+
+ RegisterClass(WingmanController);
+
+ //CommonController contains all common functionality of AI Controllers
+ WingmanController::WingmanController(Context* context) : CommonController(context)
+ {
+ RegisterObject(WingmanController);
+ this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
+ this->myLeader_ = 0;
+ this->rank_ = Rank::WINGMAN;
+ }
+
+ WingmanController::~WingmanController()
+ {
+
+ }
+
+ void WingmanController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(WingmanController, XMLPort, xmlelement, mode);
+
+ //XMLPortParam(SectionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
+ }
+
+ //----in tick, move (or look) and shoot----
+ void WingmanController::tick(float dt)
+ {
+ if (!this->isActive())
+ return;
+ if (this->bHasTargetPosition_)
+ {
+ this->moveToTargetPosition(dt);
+ }
+ else if (this->bLookAtTarget_)
+ {
+ this->lookAtTarget(dt);
+ }
+ if (bShooting_)
+ {
+ this->doFire();
+ }
+
+ SUPER(WingmanController, tick, dt);
+ }
+
+ //----action for hard calculations----
+ void WingmanController::action()
+ {
+ //----If no leader, find one----
+ if (!this->myLeader_)
+ {
+ CommonController* newLeader = findNewLeader();
+ this->myLeader_ = newLeader;
+
+ }
+ //----If have leader, he will deal with logic----
+ else
+ {
+ this->action_ = this->myLeader_->getAction();
+ }
+
+
+ //----action was set to fight----
+ if (this->action_ == Action::FIGHT)
+ {
+ //----If no leader found, attack someone----
+ if (!this->hasTarget() && !this->myLeader_)
+ {
+ this->setClosestTarget();
+ }
+ if (this->hasTarget())
+ {
+ //----choose where to go----
+ this->maneuver();
+ //----fire if you can----
+ this->bShooting_ = this->canFire();
+ }
+ }
+ //----action was set to fly, leader handles the logic----
+ else if (this->action_ == Action::FLY)
+ {
+
+ }
+ //----gani-TODO: implement protect----
+ else if (this->action_ == Action::PROTECT)
+ {
+
+ }
+
+ }
+
+
+
+ //----POST: closest leader that is ready to take a new wingman is returned----
+ CommonController* WingmanController::findNewLeader()
+ {
+
+ if (!this->getControllableEntity())
+ return 0;
+
+ //----vars for finding the closest leader----
+ CommonController* closestLeader = 0;
+ float minDistance = std::numeric_limits<float>::infinity();
+
+ for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
+ {
+ //----0ptr or not a leader or dead?----
+ if (!it ||
+ (it->getRank() != Rank::SECTIONLEADER && it->getRank() != Rank::DIVISIONLEADER) ||
+ !(it->getControllableEntity()))
+ continue;
+
+ //----same team?----
+ if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity()) )
+ continue;
+
+ //----check distance----
+ float distance = CommonController::distance (it->getControllableEntity(), this->getControllableEntity());
+ if (distance < minDistance && !(it->hasWingman()))
+ {
+ closestLeader = *it;
+ minDistance = distance;
+ }
+
+ }
+ if (closestLeader)
+ {
+ //----Racing conditions----
+ if (closestLeader->setWingman(this))
+ return closestLeader;
+ }
+ return 0;
+ }
+
+
+
+
+}
Copied: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h (from rev 10832, code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h)
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-11-23 12:24:51 UTC (rev 10834)
@@ -0,0 +1,69 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _WingmanController_H__
+#define _WingmanController_H__
+
+
+#include "controllers/CommonController.h"
+
+
+namespace orxonox
+{
+ class _OrxonoxExport WingmanController : public CommonController, public Tickable
+ {
+ public:
+ //----[language demanded functions]----
+ WingmanController(Context* context);
+
+ virtual ~WingmanController();
+ //----[/language demanded functions]----
+
+ //----[orxonox demanded functions]----
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ virtual void tick(float dt);
+ //----[/orxonox demanded functions]----
+
+ //----[own functions]----
+ CommonController* findNewLeader();
+ //----[/own functions]----
+
+ protected:
+ //----action must only be managed by this----
+ virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
+
+ private:
+ //----private variables-----
+ WeakPtr<CommonController> myLeader_;
+ Timer actionTimer_; //<! Regularly calls action().
+
+ };
+}
+
+#endif /* _WingmanController_H__ */
Modified: code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.cc 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/src/orxonox/worldentities/pawns/Pawn.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -298,7 +298,6 @@
}
}
-
void Pawn::kill()
{
this->damage(this->health_);
@@ -319,7 +318,6 @@
}
}
-
void Pawn::death()
{
this->setHealth(1);
@@ -471,6 +469,10 @@
}
}
+ /**
+ @brief
+ Check whether the Pawn has a @ref Orxonox::WeaponSystem and fire it with the specified firemode if it has one.
+ */
void Pawn::fired(unsigned int firemode)
{
if (this->weaponSystem_)
Modified: code/branches/campaignHS15/test/util/MathTest.cc
===================================================================
--- code/branches/campaignHS15/test/util/MathTest.cc 2015-11-23 12:15:36 UTC (rev 10833)
+++ code/branches/campaignHS15/test/util/MathTest.cc 2015-11-23 12:24:51 UTC (rev 10834)
@@ -336,7 +336,7 @@
/*
getAngle
get2DViewdirection
- get2DViewcoordinates
+ get2DViewCoordinates
getPredictedPosition
*/
}
More information about the Orxonox-commit
mailing list