This whole idea sounds like a combination of single and multi target I believe. Could be nice to try.
This is what I mean: Selecting a Group of friendly infantry and using A and creating a box would do this: But I guess this might put targets spamming back to the game.
Yes, the closest enemy wouldn't always be the same one. That's why I was wondering if this is worthy for dev to spend time on. Designating a random target might not be drastically inferior than this.
yep, thats why we need Jephir to consider this Its for sure not worth doing, if it isnt easy (lets say 1 hour of work max)
For each player selected, check the distance between the given player and every enemy in the targeting box. Then set the target to the one with the lowest distance. Depending on how complicated the code that actually sets the target and the code that selects entities is, this could be either very hard or very easy.
Problem is that you often give targets to more than 1 player. Different targets out of those will be closer to different players. That's where it starts getting a little messy code-side.
Thats what I was thinking in that case. Otherwise it could be done on some averages. Yeah, Check distance for each friendly player to every enemy target. And then the calculations would have to come and thats why I didnt liked this idea. So I made that one with individual single unit targets where no calculations are necessary.
I'm not an active Empires developer at the moment, but if I'm reading what you guys want correctly, then it's just a matter of getting the distance between each potential target and the ordered unit, and getting the minimum one out of that. If I'm active again in the future I could probably do this, but at the moment I'm taking a bit of a break from Empires development.
That it wasn't coded this way before 2.4 was released just goes to show how little the devs care about the most definitive role in the game, the commander.
Here FN, since it's so easy, if you want this feature, you implement it. Code: //we're done drawing a selection box, get all entities and see if they're within the box, if yes, then add them to the selection array int numentities; numentities = ClientEntityList().NumberOfEntities(); C_BaseEntity *pEnt; C_BaseEntityIterator iterator; Vector vecMins, vecMaxs, vecOrigin; int vOrigin[2]; bool bSelectNone; //bool bFirstIteration = true; C_BaseEntity *pTargets[256]; int numTargets = 0; while ((pEnt = iterator.Next()) != NULL ) { bSelectNone = true; if (pEnt->GetTeamNumber() == pSDKPlayer->GetTeamNumber() && !pEnt->IsDormant() && !m_bForceAttack) { if (pEnt->IsPlayer() || pEnt->IsBuilding() || pEnt->IsVehicle() ) { pEnt->GetRenderBounds(vecMins, vecMaxs); vecOrigin = pEnt->GetAbsOrigin(); //set custom bounds for a player if (pEnt->IsPlayer()) { vecMins.x = -16; vecMins.y = -16; vecMaxs.x = 16; vecMaxs.y = 16; vecOrigin.z += 30; } GetVectorInScreenSpace(vecOrigin, vOrigin[0], vOrigin[1], NULL); if (vOrigin[0] > x[0] && vOrigin[0] < x[1] && vOrigin[1] > y[0] && vOrigin[1] < y[1]) { //if we have other things selected and we're holding shift, we're going to deselect things that were selected and are now in our box if (iSelectionSize > 0 && m_bMultipleSelect) { for (int i=0;i<iSelectionSize;i++) { if (pSelection[i] == pEnt) { //this is the unit we clicked, set them to null and shift down all units above in the array /*pSelection[i] = NULL; for (int i2=i;i2<iSelectionSize-1;i2++) { if (iSelectionSize > i2+1) pSelection[i2] = pSelection[i2 + 1]; } pSelection[iSelectionSize-1] = NULL; iSelectionSize--; */ bSelectNone = false; break; //m_iClick = -1; //return; } } } if (bSelectNone) { pSelection[iSelectionSize] = pEnt; iSelectionSize++; } } } } // Select units from the attack box. else if (pEnt->IsAlive() && pEnt->GetTeamNumber() != pSDKPlayer->GetTeamNumber() && !pEnt->IsDormant() && m_bForceAttack && r_mousex > -1 && r_mousey > -1) { if (pEnt->IsPlayer() || pEnt->IsBuilding() || pEnt->IsVehicle() ) { // Don't target players in a vehicle if (pEnt->IsPlayer()) { auto pPlayer = ToSDKPlayer(pEnt); if (pPlayer && pPlayer->IsInAVehicle()) { continue; } } pEnt->GetRenderBounds(vecMins, vecMaxs); vecOrigin = pEnt->GetAbsOrigin(); //set custom bounds for a player vecMins.x = -16; vecMins.y = -16; vecMaxs.x = 16; vecMaxs.y = 16; vecOrigin.z += 30; GetVectorInScreenSpace(vecOrigin, vOrigin[0], vOrigin[1], NULL); if (vOrigin[0] > x[0] && vOrigin[0] < x[1] && vOrigin[1] > y[0] && vOrigin[1] < y[1]) { if (iSelectionSize > 0) { pTargets[numTargets++] = pEnt; } } } } } //send the list of targets to attack to our selected units if (numTargets > 0) { char command[256]; // Prioritize infantry and vehicles before buildings int index = 0; for (int i=0;i<numTargets;i++) // Target infantry first if there are any { if (pTargets[i]->IsPlayer()) { index = pTargets[i]->index; break; } } if (!index) { for (int i=0;i<numTargets;i++) // Target vehicles next if there are any { if (pTargets[i]->IsVehicle()) { index = pTargets[i]->index; break; } } if (!index) // Target anything { index = pTargets[0]->index; } } Q_snprintf( command,sizeof(command), "orders"); int orderSelectionSize = 0; for (int i=0;i<iSelectionSize && orderSelectionSize < 32;i++) { if (pSelection[i].Get() && (pSelection[i].Get()->IsPlayer() || pSelection[i].Get()->IsVehicle())) { orderSelectionSize++; Q_snprintf( command,sizeof(command), "%s %i", command, pSelection[i].Get()->index); } } engine->ServerCmd( const_cast<char *>( command ) ); Q_snprintf( command,sizeof(command), "order %i %i", EMP_ORDER_ATTACK_ENTITY, index); engine->ServerCmd( const_cast<char *>( command ) ); }
Yes, huge part of the code is just a pile of shit. No one wants to touch it. There's no personal gain whatsoever in improving the situation, no one gets paid for doing so so it just stays as is. If anyone were to refactor/clean this up, it'd lead to regressions and general hate from "community".
That code doesn't look as shit as I thought it is. :D But I can't imagine debugging them, which is the point. Also, comm isn't the most definitive guy on the field, in pubber it's the team, in scrim/pug it's the battle commander and squad leaders.
is the increased runtime for iterating over the array and comparing the the player->target distance to the last closest player->target distance in compairison to just picking the first occurance of a player as index and break - which is quite a lot less - bearable? targets will get issued often and cpu is already busy doing a lot of stuff in empires isnt it? i dont mean to say the idea is bad - its not bad at all, more like the contrary - i just wonder if its good to do it. edit: ohohoho tarp - the above code ofc only is for all players on the team, so if this should give individual targets you would need to iterate over all the players on your team aswell. thats not only a lot more, that a whole lot more then it is now. but to avoid that you could take the center of mass of a convex shape - or even just the center of a AABB - containing all your selected players and compair to this instead. it wouldnt be perfect either but at least somewhat predictable for the commander aka "just dont issue the whole map as targets for everyone and you should be set". edit2: i should think before i post, the above ofc would still require you to look at each player selected on your team too or how would you get the shape for the center. so its no shortcut - compairing all selected players with all selected enemy players simply wont get even close to "get first occurance of player in array and issue to everyone" - in the worst case youd have to go through the loop 1024 times while atm its only 32 times if you only consider players - if you add other entities like vehicles and buildings it could get way more too (n*m where n is players who get targets and m is possible targeted entities). imagine 32 players in a turret farm and some empty vehicles - you could maybe reach 60entites*32players and we are close to 2000 iterations ...
It's not the point, it's the amount and copy & paste programming. Refactoring this is tedious and it's easy to make errors when doing so. There are 10000+ lines like that.
Why are u even suggesting an idea when u are punching devs to the face... They can just not care at all, they are doing service to you and its not like they are payed for it.. All they recieve for their hard work is more bitching and thats why this game is short on devs... - respect FN Iam disappointed.
come on man, you just called me out on a friday night. Code: //send the list of targets to attack to our selected units if (numTargets > 0) { char command[256]; // Assign the closest target to the selected units int index = 0; vec_t minDistance = pTargets[0]->DisToSqr(pSelection[0]); for (int i=0;i<numTargets;i++) { for (int j=0;j<iSelectionSize;j++) { if (pTargets[i]->DisToSqr(pSelection[j]) < minDistance) { minDistance = pTargets[i]->DisToSqr(pSelection[j]); index = pTargets[i]->index; } } } Q_snprintf( command,sizeof(command), "orders"); int orderSelectionSize = 0; for (int i=0;i<iSelectionSize && orderSelectionSize < 32;i++) { if (pSelection[i].Get() && (pSelection[i].Get()->IsPlayer() || pSelection[i].Get()->IsVehicle())) { orderSelectionSize++; Q_snprintf( command,sizeof(command), "%s %i", command, pSelection[i].Get()->index); } } engine->ServerCmd( const_cast<char *>( command ) ); Q_snprintf( command,sizeof(command), "order %i %i", EMP_ORDER_ATTACK_ENTITY, index); engine->ServerCmd( const_cast<char *>( command ) ); } go easy on me guys this is my first time coding