Page 1 of 1

DGun probs

Posted: 13 Dec 2005, 03:27
by Snipawolf
Hey on the latest Ntai it says an error has occured when the commander fires his DGun.

When this happened i was playing pick on the commander, my banshee was shooting at it then ducking behind the airfield (maybe it has its own AI?!?), the commander shot his dgun and blew up the airfield then it glitched, please fix in later versions.

Posted: 13 Dec 2005, 18:18
by AF
NTAI is not at fault. The code for d-gunning is identical for the last 7 versions and yet this error only occurs in the latest versions of springs and doesnt give an AI error btu an engine error.

This is nto soemthignw e can fix, it is an engien bug not an AI bug, and this bgu affects all AI's that d-gun, that includes NTAI and OTAI.

Posted: 13 Dec 2005, 19:46
by Veylon
I think I found the problem in NTAI's code:

Code: Select all

void Chaser::UnitDamaged(int damaged,int attacker,float damage,float3 dir){
	const UnitDef* ud = G->cb->GetUnitDef(damaged);
	if(ud == 0) return;
	Command Cmd;
	if(ud->weapons.empty() == false){
		for(vector<UnitDef::UnitDefWeapon>::const_iterator wu = ud->weapons.begin();wu !=ud->weapons.end();++wu){
			if(wu->def->manualfire == true){
				/*for(vector<Tunit*>::iterator uwad = G->Fa->builders.begin();uwad != G->Fa->builders.end();++uwad){
					Tunit* uwa = *uwad;
					if(uwa->uid == damaged){
						uwa->DGUNNING = true;
						uwa->current = G->cb->GetCurrentUnitCommands(damaged)->front();
						break;
					}
				}*/
				/*If a unit needs to fire a special weapon and its building soemthing then it is likely to either die or its next building
				project has a high chance of dieing, or being destroyed by the special weapon. It isnt worth continuing the task fi you
				encounter a new set of circumstances, that would be unflexible, and that is not what i want for my AI
				I keep this code here for those who can make use of it*/
				Cmd.id = CMD_DGUN;
				Cmd.timeOut = 200;
				Cmd.params.push_back(attacker);
				G->cb->GiveOrder(damaged, &Cmd);
				break;
			}
		}
	}
}
You can see that no check is made if there is no attacker (e.g. Damage from unit exploding, etc.), which is sent as -1.

There should have been a couple lines at the beginning like this:

Code: Select all

// No Attacker because of unit exploding damage or whatever
if(attacker < 0)
     return;
// Don't kill my own units because of mistake
if(G->cb->GetUnitTeam(attacker) == G->myTeam)
     return;
This should solve the problem, because I used to have the same one.

Posted: 13 Dec 2005, 20:06
by AF
yay! cookie for veylon!

Posted: 13 Dec 2005, 22:43
by Snipawolf
Well now that i have tested more, i found that any building destroyed near the commander will glitch it up.

Posted: 13 Dec 2005, 22:46
by AF
hmm well I'm applying a few patches to get my offline build to compile udner GCC and do veylons patch then test it out.

But there are still engine bugs present that could do with fixing and that have cropepd up in the recent versions.