Teletrasporto gruppo

« Older   Newer »
 
  Share  
.
  1.     +1   -1
     
    .
    Avatar

    Contadino

    Group
    Member
    Posts
    45
    Reputation
    0

    Status
    Offline
    Ciao a tutti. Esiste un codice per far teletrasportare un gruppo mantenendone le relative distanze? Intendo ad esempio facendo in modo che un eroe con le sue truppe mantenga la formazione.
    Grazie in anticipo
     
    .
  2.     +1   -1
     
    .
    Avatar

    Ricky

    Group
    Eroi
    Posts
    4,930
    Reputation
    +197
    Location
    Tourin (Italy)

    Status
    Anonymous
    Non esiste una singola istruzione ma potresti provare a calcolare, per ogni unitą che č assegnata all'eroe, un offset dal punto di spostamento in cui finirą l'eroe. Dovrebbe funzionare :)
     
    .
  3.     +1   -1
     
    .
    Avatar

    Contadino

    Group
    Member
    Posts
    45
    Reputation
    0

    Status
    Offline
    Grazie mille di aver risposto. Pił concretamente mi potresti spiegare come potrei farlo?
    Grazie in anticipo
     
    .
  4.     +1   -1
     
    .
    Avatar

    Guerriero

    Group
    Eroi
    Posts
    1,674
    Reputation
    +193
    Location
    Giza

    Status
    Anonymous
    Cpyy6ta
     
    .
  5.     +1   -1
     
    .
    Avatar

    Ricky

    Group
    Eroi
    Posts
    4,930
    Reputation
    +197
    Location
    Tourin (Italy)

    Status
    Anonymous
    Penso che lo schema di Razor sia sufficiente.
    In ogni caso, una possibile implementazione (con le opportune modifiche per i nomi di eroe e area!) potrebbe essere:

    CODE
    int uCounter;
    Hero h;

    /* Spostamento gruppo con formazione */
    h = NO_Eroe.obj.AsHero();
    for(uCounter = 0; uCounter < h.army().count(); uCounter += 1)
    {
           Unit u;
           u = h.army()[uCounter].AsUnit();
           if(u.IsValid() == true && h.IsValid() == true && h.IsAlive() == true && u.IsAlive() == true)
           {
                   int xOffset, yOffset;
                   xOffset = (u.pos().x() - h.pos().x());
                   yOffset = (u.pos().y() - h.pos().y());
                   u.SetPos(AreaCenter("A_TeletrasportoEroe") + Point(xOffset, yOffset));
                   //oppure, se vuoi seplicemente usare un punto (x,y) e non un'area:
                   //u.SetPos(Point(1006 + xOffset, 3134 + yOffset));
           }
    }
    h.SetPos(AreaCenter("A_TeletrasportoEroe"));

    Se vuoi cambiare l'orientamento delle truppe, bisogna modificare la formula dell'offset per introdurre eventuali rotazioni :)
     
    .
  6.     +1   -1
     
    .
    Avatar

    Contadino

    Group
    Member
    Posts
    45
    Reputation
    0

    Status
    Offline
    Grazie mille a tutti, ha funzionato perfettamente!
     
    .
  7.     +1   -1
     
    .
    Avatar

    Ricky

    Group
    Eroi
    Posts
    4,930
    Reputation
    +197
    Location
    Tourin (Italy)

    Status
    Anonymous
    Prego! Chiudo! :closed:
     
    .
6 replies since 14/6/2020, 08:55   103 views
  Share  
.