From: <pat...@us...> - 2015-02-06 04:28:47
|
Revision: 385 http://sourceforge.net/p/simspark/svn/385 Author: patmac369 Date: 2015-02-06 04:28:44 +0000 (Fri, 06 Feb 2015) Log Message: ----------- Adding penalty shootout mode where a goal is awarded to the left team (penalty kicker) if the right team's player (penalty goalie) leaves the penalty area. Modified Paths: -------------- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h trunk/rcssserver3d/rcssserver3d/naosoccersim.rb Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2014-07-06 05:21:04 UTC (rev 384) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.cpp 2015-02-06 04:28:44 UTC (rev 385) @@ -75,7 +75,8 @@ mMaxTouchGroupSize(1000), mMaxFoulTime(0.0), // maximum time allowed for a player to commit a positional foul before being repositioned mLastKickOffKickTime(0), - mCheckKickOffKickerFoul(false) + mCheckKickOffKickerFoul(false), + mPenaltyShootout(false) { mFreeKickPos = Vector3f(0.0,0.0,mBallRadius); } @@ -120,6 +121,28 @@ // Reset touch groups ResetTouchGroups(TI_LEFT); ResetTouchGroups(TI_RIGHT); + + // If in penalty shootout mode check that the goalie remains in the penalty area + if (mPenaltyShootout) + { + SoccerBase::TAgentStateList agent_states; + if (! SoccerBase::GetAgentStates(*mBallState.get(), agent_states, TI_RIGHT)) + return; + boost::shared_ptr<oxygen::Transform> agent_aspect; + SoccerBase::TAgentStateList::const_iterator i; + for (i = agent_states.begin(); i != agent_states.end(); ++i) + { + SoccerBase::GetTransformParent(**i, agent_aspect); + Vector3f agentPos = agent_aspect->GetWorldTransform().Pos(); + if (agentPos.x() < mRightPenaltyArea.minVec[0] || agentPos.y() < mRightPenaltyArea.minVec[1] || agentPos.y() > mRightPenaltyArea.maxVec[1]) + { + // Penalty shootout goalie has left penalty area so award goal + mPenaltyShootout = false; + mGameState->ScoreTeam(TI_LEFT); + mGameState->SetPlayMode(PM_Goal_Left); + } + } + } } } @@ -1717,6 +1740,7 @@ SoccerBase::GetSoccerVar(*this,"GoalKickDist",mGoalKickDist); SoccerBase::GetSoccerVar(*this,"AutomaticKickOff",mAutomaticKickOff); SoccerBase::GetSoccerVar(*this,"WaitBeforeKickOff",mWaitBeforeKickOff); + SoccerBase::GetSoccerVar(*this,"PenaltyShootout",mPenaltyShootout); SoccerBase::GetSoccerVar(*this,"SingleHalfTime",mSingleHalfTime); SoccerBase::GetSoccerVar(*this,"AutomaticQuit",mAutomaticQuit); SoccerBase::GetSoccerVar(*this,"ChangeSidesInSecondHalf",mChangeSidesInSecondHalf); Modified: trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h =================================================================== --- trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2014-07-06 05:21:04 UTC (rev 384) +++ trunk/rcssserver3d/plugin/soccer/soccerruleaspect/soccerruleaspect.h 2015-02-06 04:28:44 UTC (rev 385) @@ -448,6 +448,8 @@ boost::shared_ptr<oxygen::AgentAspect> mLastKickOffTaker; /** if kickoff taker should be checked for single kick rule */ bool mCheckKickOffKickerFoul; + /** if in penalty shootout mode */ + bool mPenaltyShootout; /** complete foul history */ std::vector<Foul> mFouls; Modified: trunk/rcssserver3d/rcssserver3d/naosoccersim.rb =================================================================== --- trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2014-07-06 05:21:04 UTC (rev 384) +++ trunk/rcssserver3d/rcssserver3d/naosoccersim.rb 2015-02-06 04:28:44 UTC (rev 385) @@ -54,6 +54,7 @@ addSoccerVar('AutomaticKickOff', false) addSoccerVar('WaitBeforeKickOff', 30.0) addSoccerVar('CoinTossForKickOff', false) +addSoccerVar('PenaltyShootout', false) addSoccerVar('AutomaticQuit', false) addSoccerVar('ChangeSidesInSecondHalf', false) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |