void UpdateAI(const uint32 uiDiff) override { if (m_uiIntroTimer) { if (m_uiIntroTimer <= uiDiff) { DoScriptText(SAY_DOROTHEE_AGGRO, m_creature); m_uiIntroTimer = 0; } else m_uiIntroTimer -= uiDiff; } if (m_uiAggroTimer) { if (m_uiAggroTimer <= uiDiff) { m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PLAYER); SetReactState(REACT_AGGRESSIVE); m_creature->SetInCombatWithZone(); m_uiAggroTimer = 0; } else m_uiAggroTimer -= uiDiff; } if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; for (uint32 i = 0; i < DOROTHEE_ACTION_MAX; ++i) { if (!m_actionReadyStatus[i]) { if (m_actionTimers[i] <= uiDiff) { m_actionTimers[i] = 0; m_actionReadyStatus[i] = true; } else m_actionTimers[i] -= uiDiff; } } ExecuteActions(); DoMeleeAttackIfReady(); }
void UpdateAI(const uint32 uiDiff) override { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; for (uint32 i = 0; i < KIGGLER_ACTION_MAX; ++i) { if (!m_actionReadyStatus[i]) { if (m_actionTimers[i] <= uiDiff) { m_actionTimers[i] = 0; m_actionReadyStatus[i] = true; } else m_actionTimers[i] -= uiDiff; } } ExecuteActions(); DoMeleeAttackIfReady(); }
void GameEngine::Action() { // alle OldPos erst mal setzen! data.E("Ball.Gui.OldPos",data.E("Ball.Pos")); for(MyML& player:data.E("Team1.Player")){ player.E("Gui.OldPos",player.E("Pos")); } for(MyML& player:data.E("Team2.Player")){ player.E("Gui.OldPos",player.E("Pos")); } // old positions gesetzt; nun aktion MyML ref=this->data; MyML PosActions; for(int h=0;h<GE_HEIGHT;h++){ for(int w=0;w<GE_WIDTH;w++){ stringstream name; name<<w<<","<<h; MyML action("Pos.x;Pos.y"); action.AddArray("Actions"); PosActions.AddE(name.str(),action); } } for(MyML& player:data.E("Team1.Player")){ MyML ge=ref;//this->data; MyML a=Action(ge,player,"Team1",false); stringstream pos; pos<<a.A("OnPos.x")<<","<<a.A("OnPos.y"); MyMLArray mymlarray(PosActions.E(pos.str()).E("Actions")); mymlarray.Add(a); } for(MyML& player:data.E("Team2.Player")){ MyML ge=ref;//this->data; MyML a=Action(ge,player,"Team2",true); stringstream pos; pos<<a.A("OnPos.x")<<","<<a.A("OnPos.y"); MyMLArray mymlarray(PosActions.E(pos.str()).E("Actions")); mymlarray.Add(a); } // cout<<"##################ACTIONS#######################"<<endl; // for(pair<string,MyML> e:PosActions.Elements()){ // if(e.second.E("Actions").Elements().size()>1){ // cout<<"-----------------------------------------------"<<endl; // cout<<"Name: "<<e.first<<endl; // for(MyML action:e.second.E("Actions")){ // cout<<"Item"<<" -> "<<endl<<action.Info()<<endl; // } // } // } // cout<<"################################################"<<endl; //hier erst mal alle möglichen Actions in die richtige reihenfolge bringen (prio) MyML possible_actions_sorted; possible_actions_sorted.AddArray("SortedActions"); for(pair<string,MyML> aaa:data.E("Config.Actions").Elements()){ string name =aaa.first; MyMLArray mymlarray(possible_actions_sorted.E("SortedActions")); mymlarray.Add(aaa.second); } (MyMLArray(possible_actions_sorted.E("SortedActions"))).Sort("prio"); (MyMLArray(possible_actions_sorted.E("SortedActions"))).Invert(); for(pair<string,MyML> e:PosActions.Elements()){ for(MyML& current_action: possible_actions_sorted.E("SortedActions")){ MyML same_actions("type=array;size=0"); MyML& all_actions_on_this_field=e.second.E("Actions"); //hier sind alle actions in beliebiger reihenfolge drin. for(MyML action:all_actions_on_this_field){ if(!action.ExistsA("Action.action")){ cout<<LOG<<"Action does not exist! "<<action.Info()<<endl; } if(action.A("Action.action")==current_action.A("action")){ MyMLArray(same_actions).Add(action); } } // HIER KÖNNEN WIR ENDLICH WAS MACHEN if(same_actions.A("size")!="0"){ // cout<<"Field: "<<e.first<<" action: "<<current_action.A("action"); // for(MyML a:same_actions){ // cout<<" "<<a.A("id")<<","; // if(a.A("Action.action")=="move"){ // MyML& player=GetPlayer(a.A("id")); // player.SetE("Pos",a.E("Action.Pos")); // } // } // cout<<endl; ExecuteActions(current_action.A("action"),same_actions,e.second.E("Actions")); } } } }