// Ability to alter the objective: // DOBJ_ACTION_OPEN: Opens the objective door and starts spawning creeps (if round has started) // DOBJ_ACTION_CLOSE: Closes the objective door and stops spawning creeps (if this is the last door, the round will end) int DotaObjective::TakeAction( int dobjAction ) { // Issue #24: AMP - 2013-10-04 - Lane manipulation if (dobjAction & DOBJ_ACTION_CLOSE) { PropSetAnim( "Close" ); // Issue #35: JMS - 2013-10-27 - fire event to clients IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_close" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); gameeventmanager->FireEvent( pEvent ); } m_bMet = true; //turn off the maker CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); if( maker ) maker->m_enabled = false; //see if I'm the last one, if so, game over bool foundOne = false; for ( CBaseEntity *pEntity = gEntList.FirstEnt(); pEntity != NULL; pEntity = gEntList.NextEnt(pEntity) ) { DotaObjective * obj = dynamic_cast<DotaObjective*>( pEntity ); if ( obj && obj->GetTeamNumber() == this->GetTeamNumber() && !obj->m_bMet ) foundOne = true; } if ( !foundOne ) { CHL2MPRules *rules = (CHL2MPRules*)g_pGameRules; if ( rules && !rules->IsIntermission() ) { rules->EndMultiplayerGame(); } } return true; } else if (dobjAction & DOBJ_ACTION_OPEN) { // Issue #35: JMS - 2013-10-27 - fire event to clients IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_open" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); gameeventmanager->FireEvent( pEvent ); } m_timesHit = 0; m_bMet = false; CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); maker->m_enabled = true; PropSetAnim( "Open" ); return true; } return false; }
int OperationNode::Evaluate(const mtlChars &dst, mtlString &out, int lane, int depth) { int ldepth = left->Evaluate(dst, out, lane, depth); int rdepth = right->IsLeaf() ? 0 : right->Evaluate(dst, out, lane, depth+1); int mdepth = 0; mtlString addr_str; if (depth > 0 || dst.GetSize() == 0) { out.Append('['); addr_str.FromInt(depth); out.Append(addr_str); out.Append(']'); mdepth = depth; } else { mtlString temp; GetLane(dst, lane, temp); out.Append(temp); //out.Append(dst); } AppendValue(out); out.Append('='); if (right->IsLeaf()) { right->AppendValue(out); } else { addr_str.FromInt(depth+1); out.Append('['); out.Append(addr_str); out.Append(']'); } out.Append(';'); return mmlMax(ldepth, mdepth, rdepth); }
int DotaObjective::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { if ( m_bMet ) return 0; if ( !(inputInfo.GetDamageType() & DMG_BULLET) ) { CHL2MP_Player * playerAttacker = ToHL2MPPlayer( inputInfo.GetAttacker() ); CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); if ( !maker ) AssertMsg( false, "Objective can't find its creepmaker!\n" ); CAI_BaseNPC * guardian = (CAI_BaseNPC*)gEntList.FindEntityByName( NULL, m_guardianName ); if( guardian && guardian->IsAlive() ) { if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("The guradian is alive in this lane, you can't hurt the gate.\n") ); } else { m_timesHit++; m_timesHit = min(m_timesHit, OBJECTIVE_HEALTHI); // make sure times hit never goes above the maximum times an objective can be hit! CRecipientFilter user; user.AddRecipientsByTeam( this->GetTeam() ); user.MakeReliable(); char szText[200]; Q_snprintf( szText, sizeof(szText), "Your ally gate is under attack from an enemy!" ); UTIL_ClientPrintFilter( user, HUD_PRINTCENTER, szText ); if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("Gate has %i health left.\n", OBJECTIVE_HEALTHI - m_timesHit) ); if (m_timesHit >= OBJECTIVE_HEALTHI) { TakeAction(DOBJ_ACTION_CLOSE); } else { IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_attacked" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); pEvent->SetFloat( "health", (OBJECTIVE_HEALTHF - m_timesHit)/OBJECTIVE_HEALTHF ); gameeventmanager->FireEvent( pEvent ); } } } } return 0; }
int ValueNode::Evaluate(const mtlChars &dst, mtlString &out, int lane, int depth) { int out_depth = 0; mtlString temp; if (depth > 0 || dst.GetSize() == 0) { out.Append('['); temp.FromInt(depth); out.Append(temp); out.Append(']'); out_depth = depth; } else { //out.Append(dst); GetLane(dst, lane, temp); out.Append(temp); out_depth = 0; } out.Append("="); //AppendValue(out); GetLane(term, lane, temp); out.Append(temp); out.Append(';'); return out_depth; }