Author Topic: Need help with AI teams  (Read 1333 times)

Recently, I've been making two AIs for a project of mine. The AIs are a Martian and a Heavy Martian. The Martian is equipped with a Alien Blaster and the Heavy Martian with a Flash Cannon. The problem is; They shoot eachother. I'm confused as to how to make them not shoot each other. I've attempted changing the
Code: [Select]
ZombieTeam =Line but with no success. They disappear from the in-game spawn list when I do this.

Anyway, if you can help I'd really love it. You can find the codes right here;

Heavy Martian
Code: [Select]
datablock PlayerData(MartiancannonZombie : PlayerStandardArmor)
{
//category = "Vehicles";
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;
maxItems   = 0; //total number of bricks you can carry
maxWeapons = 0; //this will be controlled by mini-game code
maxTools = 0;
runforce = 100 * 90;
maxForwardSpeed = 6;
maxBackwardSpeed = 6;
maxSideSpeed = 6;
attackpower = 15;
//jumpsound = "ZombieJumpSound";
cameradefaultFOV = 90;
cameraMaxFov = 120;
cameraMinFov = 10;
//minlookangle = -1;
//maxlookangle = -1;
minlookangle = -1.5708;
maxlookangle = 1.5708;
BrickDestroyMaxVolume = 250;
BrickMaxJumpHeight = 10;
uiName = "Heavy Martian";
rideable = true;
canRide = true;
BrickKillRadius = 2;
skinColor = "1 0.79 0.57 1";
FollowAnim = "ArmReadyright";
randomwalk = 1;
aimatplayer = 1;
SpecialAttack = 1;
NoBloodyHands = 1;
DoNotZombify = 1;
chance = 90;
ZombieTeam = "Martiancannon";
};
function MartiancannonZombie::SpecialAttack(%this,%onshot)
{
%ran = getrandom(-1,1);
%ran2 = getrandom(-1,1);
%this.setmovex(%ran);
%this.setmovey(%ran);
schedule(0,0,MartiancannonShootMode,%this);
schedule(500,0,MartiancannonShootMode,%this);
schedule(1000,0,MartiancannonShootMode,%this);
schedule(1500,0,MartiancannonShootMode,%this);
%this.schedule(2000,clearmovex);
}
function MartiancannonShootMode(%this)
{
if(isobject(%this) && %this.getstate() !$= "Dead")
{
%this.setimagetrigger(0,1);
%this.setimagetrigger(0,0);
}
}
function MartiancannonZombie::ondisabled(%this,%obj)
{
parent::ondisabled(%this,%obj);
ZombieDefault::ondisabled(%this,%obj);
}
function MartiancannonZombie::onCollision(%this, %obj, %col, %fade, %pos, %norm)
{
parent::oncollision(%this, %obj, %col, %fade, %pos, %norm);
ZombieDefault::onCollision(%this, %obj, %col, %fade, %pos, %norm);
}
function MartiancannonZombie::onMount(%a,%player,%vehicle,%d,%e,%f)
{
ZombieDefault::onMount(%a,%player,%vehicle,%d,%e,%f);
parent::onMount(%a,%player,%vehicle,%d,%e,%f);
}
function MartiancannonZombie::onUnMount(%a,%player,%vehicle,%d,%e,%f)
{
ZombieDefault::onUnMount(%a,%player,%vehicle,%d,%e,%f);
parent::onUnMount(%a,%player,%vehicle,%d,%e,%f);
}
function MartiancannonZombie::onAdd(%this,%obj)
{
parent::onAdd(%this,%obj);
ZombieDefault::onAdd(%this,%obj);
//schedule(10,0,Martiancannonfy,%obj);
schedule(15,0,Martiancannonfy,%obj);
//schedule(20,0,ghostifybot,%obj);
//%obj.playthread(2,armreadyright);
//%obj.setarmthread(crouch);
%obj.mountimage(FlashCannonimage,0);
}

function Martiancannonfy(%obj)
{
%obj.name = "Martiancannon";
%obj.chestcolor = "0.200 0.200 0.200 1.000";
//%obj.hatcolor = "0.72  0.53 0.29 1";
%obj.rarmcolor = "0.200 0.200 0.200 1.000";
%obj.larmcolor = "0.200 0.200 0.200 1.000";
%obj.hipcolor = "0.200 0.200 0.200 1.000";
%obj.llegcolor = "0.200 0.200 0.200 1.000";
%obj.rlegcolor = "0.200 0.200 0.200 1.000";
%obj.secondpackcolor = "0.0784314 0.0784314 0.0784314 1";
%obj.packcolor = "0.0784314 0.0784314 0.0784314 1";
%obj.lhandColor = "0.000 1.000 1.000 1.000";
%obj.rhandColor = "0.000 1.000 1.000 1.000";
%obj.headskinColor = "0.000 1.000 1.000 1.000";

%obj.chest = "0";
%obj.lhand = "0";
%obj.rhand = "0";
%obj.larm = "0";
%obj.rarm = "0";
%obj.hat = "0";
%obj.accent = "0";
%obj.pack = "6";
%obj.secondpack = "6";
%obj.lleg = "0";
%obj.rleg = "0";
%obj.hip = "0";

GameConnection::ApplyBodyParts(%obj);
GameConnection::ApplyBodyColors(%obj);
%obj.setfacename(Orc);
%obj.setdecalname("Space-Old");
%color = %obj.getdatablock().skincolor;
servercmdupdatebodyparts(%obj,6);
%obj.setNodecolor("headskin", %obj.lhandcolor);
}
function servercmdsigheil(%client)
{
%client.player.playthread(1,armreadyright);
%client.player.setarmthread(armattack);
}
function servercmdunsigheil(%client)
{
%client.player.setarmthread(look);
}
package MartiancannonAttackPackage
{
function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(isobject(%obj.sourceobject) && %obj.sourceobject.getdatablock().getname() $= "MartiancannonZombie")
{
//schedule(0,0,PropaneTankDamageF,%this,%obj,%col);
%source = %obj.sourceobject;
%obj.client = %obj.sourceobject;

//echo(%source.getclassname());
//echo(IsInMiniGame(%source));
//echo(IsInSameMinigame(%col,%source));
if(isobject(%obj.sourceobject) && %obj.sourceobject.getclassname() $= "AiPlayer" && IsInMinigame(%obj.sourceobject) && IsInSameMinigame(%col,%source))
{
if(%col.client != 0)
{
%source.cols = %col.client;
}
//%col.damage(%obj,%obj.sourceobject,%obj.getdatablock().directDamage/2,$DamageType::zombiebite);
}
}
if(%col.getclassname() $= "AiPlayer" && %col.getdatablock().getname() $= "MartiancannonZombie" && %obj.sourceobject.getdatablock().getname() $= "MartiancannonZombie")return;

parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
};
activatepackage(MartiancannonAttackPackage);
//thatwouldbeyourmother
Martian
Code: [Select]
datablock PlayerData(MartianZombie : PlayerStandardArmor)
{
//category = "Vehicles";
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;
maxItems   = 0; //total number of bricks you can carry
maxWeapons = 0; //this will be controlled by mini-game code
maxTools = 0;
runforce = 100 * 90;
maxForwardSpeed = 8;
maxBackwardSpeed = 8;
maxSideSpeed = 8;
attackpower = 10;
//jumpsound = "ZombieJumpSound";
cameradefaultFOV = 90;
cameraMaxFov = 120;
cameraMinFov = 10;
//minlookangle = -1;
//maxlookangle = -1;
minlookangle = -1.5708;
maxlookangle = 1.5708;
BrickDestroyMaxVolume = 250;
BrickMaxJumpHeight = 20;
uiName = "Martian";
rideable = true;
canRide = true;
BrickKillRadius = 2;
skinColor = "1 0.79 0.57 1";
FollowAnim = "ArmReadyright";
randomwalk = 1;
aimatplayer = 1;
SpecialAttack = 1;
NoBloodyHands = 1;
DoNotZombify = 1;
chance = 90;
ZombieTeam = "Martian";
};
function MartianZombie::SpecialAttack(%this,%onshot)
{
%ran = getrandom(-1,1);
%ran2 = getrandom(-1,1);
%this.setmovex(%ran);
%this.setmovey(%ran);
schedule(0,0,MartianShootMode,%this);
schedule(500,0,MartianShootMode,%this);
schedule(1000,0,MartianShootMode,%this);
schedule(1500,0,MartianShootMode,%this);
%this.schedule(2000,clearmovex);
}
function MartianShootMode(%this)
{
if(isobject(%this) && %this.getstate() !$= "Dead")
{
%this.setimagetrigger(0,1);
%this.setimagetrigger(0,0);
}
}
function MartianZombie::ondisabled(%this,%obj)
{
parent::ondisabled(%this,%obj);
ZombieDefault::ondisabled(%this,%obj);
}
function MartianZombie::onCollision(%this, %obj, %col, %fade, %pos, %norm)
{
parent::oncollision(%this, %obj, %col, %fade, %pos, %norm);
ZombieDefault::onCollision(%this, %obj, %col, %fade, %pos, %norm);
}
function MartianZombie::onMount(%a,%player,%vehicle,%d,%e,%f)
{
ZombieDefault::onMount(%a,%player,%vehicle,%d,%e,%f);
parent::onMount(%a,%player,%vehicle,%d,%e,%f);
}
function MartianZombie::onUnMount(%a,%player,%vehicle,%d,%e,%f)
{
ZombieDefault::onUnMount(%a,%player,%vehicle,%d,%e,%f);
parent::onUnMount(%a,%player,%vehicle,%d,%e,%f);
}
function MartianZombie::onAdd(%this,%obj)
{
parent::onAdd(%this,%obj);
ZombieDefault::onAdd(%this,%obj);
//schedule(10,0,Martianfy,%obj);
schedule(15,0,Martianfy,%obj);
//schedule(20,0,ghostifybot,%obj);
//%obj.playthread(2,armreadyright);
//%obj.setarmthread(crouch);
%obj.mountimage(AlienBlasterimage,0);
}

function Martianfy(%obj)
{
%obj.name = "Martian";
%obj.chestcolor = "0.200 0.200 0.200 1.000";
//%obj.hatcolor = "0.72  0.53 0.29 1";
%obj.rarmcolor = "0.200 0.200 0.200 1.000";
%obj.larmcolor = "0.200 0.200 0.200 1.000";
%obj.hipcolor = "0.200 0.200 0.200 1.000";
%obj.llegcolor = "0.200 0.200 0.200 1.000";
%obj.rlegcolor = "0.200 0.200 0.200 1.000";
%obj.secondpackcolor = "0.0784314 0.0784314 0.0784314 1";
%obj.packcolor = "0.0784314 0.0784314 0.0784314 1";
%obj.lhandColor = "0.000 1.000 0.000 1.000";
%obj.rhandColor = "0.000 1.000 0.000 1.000";
%obj.headskinColor = "0.000 1.000 0.000 1.000";

%obj.chest = "0";
%obj.lhand = "0";
%obj.rhand = "0";
%obj.larm = "0";
%obj.rarm = "0";
%obj.hat = "0";
%obj.accent = "0";
%obj.pack = "6";
%obj.secondpack = "6";
%obj.lleg = "0";
%obj.rleg = "0";
%obj.hip = "0";

GameConnection::ApplyBodyParts(%obj);
GameConnection::ApplyBodyColors(%obj);
%obj.setfacename(Orc);
%obj.setdecalname("Space-Old");
%color = %obj.getdatablock().skincolor;
servercmdupdatebodyparts(%obj,6);
%obj.setNodecolor("headskin", %obj.lhandcolor);
}
function servercmdsigheil(%client)
{
%client.player.playthread(1,armreadyright);
%client.player.setarmthread(armattack);
}
function servercmdunsigheil(%client)
{
%client.player.setarmthread(look);
}
package MartianAttackPackage
{
function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(isobject(%obj.sourceobject) && %obj.sourceobject.getdatablock().getname() $= "MartianZombie")
{
//schedule(0,0,PropaneTankDamageF,%this,%obj,%col);
%source = %obj.sourceobject;
%obj.client = %obj.sourceobject;

//echo(%source.getclassname());
//echo(IsInMiniGame(%source));
//echo(IsInSameMinigame(%col,%source));
if(isobject(%obj.sourceobject) && %obj.sourceobject.getclassname() $= "AiPlayer" && IsInMinigame(%obj.sourceobject) && IsInSameMinigame(%col,%source))
{
if(%col.client != 0)
{
%source.cols = %col.client;
}
//%col.damage(%obj,%obj.sourceobject,%obj.getdatablock().directDamage/2,$DamageType::zombiebite);
}
}
if(%col.getclassname() $= "AiPlayer" && %col.getdatablock().getname() $= "MartianZombie" && %obj.sourceobject.getdatablock().getname() $= "MartianZombie")return;

parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
};
activatepackage(MartianAttackPackage);

I'd really love it if you could help out :D

Martian Cannon:
Code: [Select]
ZombieTeam = "Martiancannon";
Martain
Code: [Select]
ZombieTeam = "Martian";They are on different teams so they shoot each other. Change it to "Martian" like how all the national socialist AI types are on the "national socialist" team.

I tried this several times but they won't spawn. I'll try again and see what happens.

I tried this several times but they won't spawn. I'll try again and see what happens.
Sorry to get off topic but you can use isgoodguy = 1; Thay wont attack you.

Sorry to get off topic but you can use isgoodguy = 1; Thay wont attack you.

He wants the AIs to be teams vs the HUMANS. Not Ai and Humans vs other Ai.