Changeset 10838
- Timestamp:
- Nov 23, 2015, 3:50:59 PM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10834 r10838 32 32 33 33 <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"/> 34 < SpawnPoint team=0position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />35 >34 <TeamSpawnPoint team=1 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff /> 35 36 36 <!-- 37 37 <?lua … … 52 52 53 53 54 <SpaceShip position="4000, 1500, -1000" lookat="0,0,0" >54 <SpaceShip position="4000, 1500, -1000" lookat="0,0,0" team=0> 55 55 <templates> 56 56 <Template link=spaceshipassff /> 57 57 </templates> 58 58 <controller> 59 <DivisionController team=1 formationMode="wall" action="FIGHT">59 <DivisionController formationMode="wall" action="PROTECT" protect="FUCK" team=0> 60 60 </DivisionController> 61 61 </controller> 62 62 </SpaceShip> 63 <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0" >63 <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0" team=0> 64 64 <templates> 65 65 <Template link=spaceshipassff /> 66 66 </templates> 67 67 <controller> 68 <WingmanController team=1>68 <WingmanController > 69 69 </WingmanController> 70 70 </controller> 71 71 </SpaceShip> 72 <SpaceShip position="4000, 1500, -2200" lookat="0,0,0" >72 <SpaceShip position="4000, 1500, -2200" lookat="0,0,0" team=0> 73 73 <templates> 74 74 <Template link=spaceshipassff /> 75 75 </templates> 76 76 <controller> 77 <WingmanController team=1>77 <WingmanController > 78 78 </WingmanController> 79 79 </controller> 80 80 </SpaceShip> 81 <SpaceShip position="4000, 1500, -2800 " lookat="0,0,0" >81 <SpaceShip position="4000, 1500, -2800 " lookat="0,0,0" team=0> 82 82 <templates> 83 83 <Template link=spaceshipassff /> 84 84 </templates> 85 85 <controller> 86 <SectionController team=1> 86 <SectionController > 87 </SectionController> 88 </controller> 89 </SpaceShip> 90 <SpaceShip position="-4000, 1500, -2800 " lookat="0,0,0" team=0 name="FUCK"> 91 <templates> 92 <Template link=spaceshipassff /> 93 </templates> 94 <controller> 95 <SectionController> 87 96 </SectionController> 88 97 </controller> 89 98 </SpaceShip> 90 99 91 < SpaceShip position="-4000, 1500, -5000" lookat="0,0,0">100 <!-- <SpaceShip position="-4000, 1500, -5000" lookat="0,0,0"> 92 101 <templates> 93 102 <Template link=spaceshipassff /> … … 124 133 </SectionController> 125 134 </controller> 126 </SpaceShip> 135 </SpaceShip> --> 127 136 128 137 -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
r10834 r10838 38 38 39 39 #include "Scene.h" 40 #include <OgreRay.h> 41 #include <OgreSceneQuery.h> 42 #include <OgreCamera.h> 43 #include <OgreSceneManager.h> 40 41 #include "worldentities/pawns/TeamBaseMatchBase.h" 42 #include "gametypes/TeamDeathmatch.h" 43 #include "gametypes/Dynamicmatch.h" 44 #include "gametypes/Mission.h" 45 #include "gametypes/Gametype.h" 46 #include "controllers/WaypointPatrolController.h" 47 #include "controllers/NewHumanController.h" 48 #include "controllers/DroneController.h" 49 50 44 51 namespace orxonox 45 52 { … … 51 58 CommonController::CommonController( Context* context ): Controller( context ) 52 59 { 53 54 55 60 this->action_ = Action::FLY; 56 61 this->stopLookingAtTarget(); … … 70 75 XMLPortParam( CommonController, "formationMode", setFormationModeXML, getFormationModeXML, xmlelement, mode ); 71 76 XMLPortParam( CommonController, "action", setActionXML, getActionXML, xmlelement, mode ); 72 77 XMLPortParam ( CommonController, "protect", setProtectXML, getProtectXML, xmlelement, mode ); 78 //XMLPortParam ( CommonController, "enemy", setEnemyXML, getEnemyXML, xmlelement, mode ); 79 } 80 void CommonController::setProtectXML( std::string val ) 81 { 82 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 83 { 84 if ((*itP)->getName() == val) 85 { 86 this->setProtect (static_cast<ControllableEntity*>(*itP)); 87 } 88 } 89 } 90 std::string CommonController::getProtectXML () 91 { 92 if (!this->getProtect()) 93 return "noProtectWasSet"; 94 return this->getProtect()->getName(); 95 } 96 97 void CommonController::setProtect (ControllableEntity* protect) 98 { 99 this->protect_ = protect; 100 } 101 ControllableEntity* CommonController::getProtect () 102 { 103 return this->protect_; 73 104 } 74 105 void CommonController::setActionXML( std::string val) … … 205 236 Pawn* closestTarget = 0; 206 237 float minDistance = std::numeric_limits<float>::infinity(); 207 238 Gametype* gt = this->getGametype(); 208 239 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 209 240 { 210 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP) ) )241 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) ) 211 242 continue; 212 243 … … 669 700 return ( entity1->getPosition() - entity2->getPosition() ).length(); 670 701 } 671 bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2 )672 { 673 if (!entity1 || !entity2)702 bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 703 { 704 /*if (!entity1 || !entity2) 674 705 return false; 675 return entity1->getTeam() == entity2->getTeam(); 706 return entity1->getTeam() == entity2->getTeam();*/ 707 if (entity1 == entity2) 708 return true; 709 710 int team1 = entity1->getTeam(); 711 int team2 = entity2->getTeam(); 712 713 Controller* controller = 0; 714 if (entity1->getController()) 715 controller = entity1->getController(); 716 else 717 controller = entity1->getXMLController(); 718 if (controller) 719 { 720 CommonController* ac = orxonox_cast<CommonController*>(controller); 721 if (ac) 722 team1 = ac->getTeam(); 723 } 724 725 if (entity2->getController()) 726 controller = entity2->getController(); 727 else 728 controller = entity2->getXMLController(); 729 if (controller) 730 { 731 CommonController* ac = orxonox_cast<CommonController*>(controller); 732 if (ac) 733 team2 = ac->getTeam(); 734 } 735 736 TeamGametype* tdm = orxonox_cast<TeamGametype*>(gametype); 737 if (tdm) 738 { 739 if (entity1->getPlayer()) 740 team1 = tdm->getTeam(entity1->getPlayer()); 741 742 if (entity2->getPlayer()) 743 team2 = tdm->getTeam(entity2->getPlayer()); 744 } 745 746 TeamBaseMatchBase* base = 0; 747 base = orxonox_cast<TeamBaseMatchBase*>(entity1); 748 if (base) 749 { 750 switch (base->getState()) 751 { 752 case BaseState::ControlTeam1: 753 team1 = 0; 754 break; 755 case BaseState::ControlTeam2: 756 team1 = 1; 757 break; 758 case BaseState::Uncontrolled: 759 default: 760 team1 = -1; 761 } 762 } 763 base = orxonox_cast<TeamBaseMatchBase*>(entity2); 764 if (base) 765 { 766 switch (base->getState()) 767 { 768 case BaseState::ControlTeam1: 769 team2 = 0; 770 break; 771 case BaseState::ControlTeam2: 772 team2 = 1; 773 break; 774 case BaseState::Uncontrolled: 775 default: 776 team2 = -1; 777 } 778 } 779 780 DroneController* droneController = 0; 781 droneController = orxonox_cast<DroneController*>(entity1->getController()); 782 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2) 783 return true; 784 droneController = orxonox_cast<DroneController*>(entity2->getController()); 785 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1) 786 return true; 787 DroneController* droneController1 = orxonox_cast<DroneController*>(entity1->getController()); 788 DroneController* droneController2 = orxonox_cast<DroneController*>(entity2->getController()); 789 if (droneController1 && droneController2 && droneController1->getOwner() == droneController2->getOwner()) 790 return true; 791 792 Dynamicmatch* dynamic = orxonox_cast<Dynamicmatch*>(gametype); 793 if (dynamic) 794 { 795 if (dynamic->notEnoughPigs||dynamic->notEnoughKillers||dynamic->notEnoughChasers) {return false;} 796 797 if (entity1->getPlayer()) 798 team1 = dynamic->getParty(entity1->getPlayer()); 799 800 if (entity2->getPlayer()) 801 team2 = dynamic->getParty(entity2->getPlayer()); 802 803 if (team1 ==-1 ||team2 ==-1 ) {return false;} 804 else if (team1 == dynamic->chaser && team2 != dynamic->chaser) {return false;} 805 else if (team1 == dynamic->piggy && team2 == dynamic->chaser) {return false;} 806 else if (team1 == dynamic->killer && team2 == dynamic->chaser) {return false;} 807 else return true; 808 } 809 810 return (team1 == team2 && team1 != -1); 676 811 } 677 812 void CommonController::doFire() -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
r10834 r10838 103 103 { return this->rank_; } 104 104 //----[/Rank data]---- 105 //----[Protect data]---- 106 void setProtectXML( std::string val ); 107 std::string getProtectXML (); 108 void setProtect (ControllableEntity* protect); 109 ControllableEntity* getProtect (); 110 //----[/Protect data]---- 105 111 //----[/XML data]---- 106 112 … … 124 130 float randomInRange(float a, float b); 125 131 static float distance(ControllableEntity* entity1, ControllableEntity* entity2); 126 static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2 );132 static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt); 127 133 static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ; 128 134 … … 168 174 bool bHasTargetOrientation_; 169 175 Quaternion targetOrientation_; 170 // Vector3 destination_; 171 // bool bHasDestination; 176 177 Vector3 destination_; 178 bool bHasDestination; 172 179 //----[/where-to-fly information]---- 173 180 //----[protect information]---- 181 WeakPtr<ControllableEntity> protect_; 182 //----[/protect information]---- 174 183 //----[who-to-kill information]---- 175 184 WeakPtr<ControllableEntity> target_; 176 //WeakPtr<ControllableEntity> objectiveTarget_;185 WeakPtr<ControllableEntity> enemy_; 177 186 178 187 bool bHasPositionOfTarget_; -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10834 r10838 133 133 else if (this->action_ == Action::PROTECT) 134 134 { 135 135 if (this->getProtect()) 136 { 137 orxout(internal_error) << "PROTECT FOUND" << endl; 138 } 136 139 } 137 140 -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10834 r10838 168 168 //----new target should be close to division's target---- 169 169 Vector3 divisionTargetPosition = this->myDivisionLeader_->getTarget()->getWorldPosition(); 170 170 Gametype* gt = this->getGametype(); 171 171 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 172 172 { 173 173 //----is enemy?---- 174 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP) ) )174 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) ) 175 175 continue; 176 176 //----in range?---- -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10834 r10838 135 135 CommonController* closestLeader = 0; 136 136 float minDistance = std::numeric_limits<float>::infinity(); 137 137 Gametype* gt = this->getGametype(); 138 138 for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it) 139 139 { … … 145 145 146 146 //----same team?---- 147 if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity() ) )147 if ( !CommonController::sameTeam (this->getControllableEntity(), (it)->getControllableEntity(), gt) ) 148 148 continue; 149 149 -
code/branches/campaignHS15/src/orxonox/worldentities/SpawnPoint.h
r9667 r10838 55 55 { return this->template_; } 56 56 57 Pawn* spawn();57 virtual Pawn* spawn(); 58 58 void spawn(ControllableEntity* entity); 59 59 -
code/branches/campaignHS15/src/orxonox/worldentities/TeamSpawnPoint.cc
r9667 r10838 49 49 XMLPortParam(TeamSpawnPoint, "team", setTeamNumber, getTeamNumber, xmlelement, mode).defaultValues(0); 50 50 } 51 Pawn* TeamSpawnPoint::spawn() 52 { 53 Pawn* entity = SpawnPoint::spawn(); 54 static_cast<ControllableEntity*>(entity)->setTeam (this->teamNumber_); 55 return entity; 56 } 51 57 } -
code/branches/campaignHS15/src/orxonox/worldentities/TeamSpawnPoint.h
r9667 r10838 49 49 unsigned int getTeamNumber() const 50 50 { return this->teamNumber_; } 51 virtual Pawn* spawn(); 51 52 52 53 private: 53 unsignedint teamNumber_;54 int teamNumber_; 54 55 }; 55 56 }
Note: See TracChangeset
for help on using the changeset viewer.