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.
DGun probs
Moderators: hoijui, Moderators
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.
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.
I think I found the problem in NTAI's code:
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:
This should solve the problem, because I used to have the same one.
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;
}
}
}
}
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;