defenses fire at each other [message #466586] |
Tue, 24 April 2012 16:27 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma:
|
Recruit |
|
|
i remade JFW_Base_Defence
and i works perfect however (using a guardtower and a turret) i added that it shouldnt attack if their target has no moveable physics.
but stil the guardtower and turret attack eachother
the code wich i forgot :
Toggle Spoiler
void KB_Base_Defence::Enemy_Seen(GameObject *obj,GameObject *enemy)
{
if(!Is_Script_Attached(enemy,"KB_Friendly_Zone_Generated") && Commands->Is_A_Star(enemy)||Is_Harvester(enemy))
{
bool attack = true;
GameObject *o = Get_Vehicle(enemy);
if (o)
{
enemy = o;
}
if(Is_Vehicle(enemy))
{
MoveablePhysClass* moveable = enemy->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass();
if(!moveable)
{
attack = false;
}
}
if(attack)
{
ActionParamsStruct params;
Vector3 pos,pos2;
float distance;
float minattack,maxattack;
float attacktimer;
pos = Commands->Get_Position(obj);
pos2 = Commands->Get_Position(enemy);
distance = Commands->Get_Distance(pos2,pos);
minattack = Get_Float_Parameter("MinAttackDistance");
if (distance >= minattack)
{
maxattack = Get_Float_Parameter("MaxAttackDistance");
params.Set_Basic(this,100,2);
params.Set_Attack(enemy,maxattack,0.0,true);
params.AttackCheckBlocked = false;
params.AttackForceFire = true;
Commands->Action_Attack(obj,params);
attacktimer = Get_Float_Parameter("AttackTimer");
Commands->Start_Timer(obj,this,attacktimer,2);
}
}
}
}
Owner of kambot TT server
kambot.freeforums.org
[Updated on: Wed, 25 April 2012 00:50] Report message to a moderator
|
|
|