I needed to make a healing arua script for cnc_reborn, but I thought the renegaders might find it useful too.
I have hard coded all the values to make it heal your own teams infantry only if they are withing 15 feet of the objects with the script attached. it heals there health only at a rate of +2 per second.
It might be nice for veteran players or perhaps as a crate, i dunno :-/
If people like it but only want to use it in level edit and change some of the values themselves then I will re-write it for that purpose and send it to Jonathan/SaberHawk/Jerad (whoever is writing the new one ).
I have another reason for posting it here, it's the first time i've dealt with the GenericSLNode * type and NodeData, it seems to me that It returns allot of objects and I have to filter most of them out, so if anyone sees some flaws in this or thinks they can make it more efficient then please post and correct me
void reb_healing_aura::Created(GameObject *obj){
Commands->Start_Timer(obj,this,1.0f,1);
}
void reb_healing_aura::Timer_Expired(GameObject *obj,int number){
if (number == 1){
int team = Get_Object_Type(obj);
Vector3 CurPosition = Commands->Get_Position(obj);
GenericSLNode *x = BaseGameObjList->HeadNode;
while (x){
GameObject *o = (GameObject *)x->NodeData;
if (o && As_ScriptableGameObj(o) && Is_Soldier(o)){
if ((Get_Object_Type(o) == team)){
Vector3 CurPositiono = Commands->Get_Position(o);
float Dist = Commands->Get_Distance(CurPosition,CurPositiono);
if(Dist <= 15.0f){
float armour = Commands->Get_Health(o);
armour += 2.0f;
if (armour > Commands->Get_Max_Health(o))
{
armour = Commands->Get_Max_Health(o);
}
Commands->Set_Health(o,armour);
}
}
}
x = x->NodeNext;
}
Commands->Start_Timer(obj,this,1.0f,1);
}
}
ScriptRegistrant<reb_healing_aura> reb_healing_aura_Registrant("reb_healing_aura","");
class reb_healing_aura : public ScriptImpClass {
void Created(GameObject *obj);
void Timer_Expired(GameObject *obj,int number);
};
[Updated on: Fri, 30 January 2009 14:18] by Moderator
Report message to a moderator