Home » Renegade Discussions » Mod Release Forum » Base defence source (Base defence source)
() 2 Votes
Base defence source [message #419055] |
Tue, 02 February 2010 06:54 |
|
Hex
Messages: 858 Registered: March 2004
Karma: 0
|
Colonel |
|
|
Clearing out unused source that I have, see no point in it being wasted, allows you to rebuild/spawn defences ect ect, just attach BaseDefenceScript to the defence
Will post more later if and when I find it
//.h
class PickUpScript : public ScriptImpClass, public GroupLink
{
void Custom(GameObject *obj, int message, int param, GameObject *sender);
};
class BaseDefenceRebuy : public ScriptImpClass, public GroupLink
{
int total;
void Created(GameObject *obj);
void Custom(GameObject *obj, int message, int param, GameObject *sender);
void Timer_Expired(GameObject *obj, int number);
};
class BaseDefenceScript : public ScriptImpClass, public GroupLink
{
int InvisObjCont;
void Killed(GameObject *obj, GameObject *shooter);
};
class Hardden : public ScriptImpClass, public GroupLink
{
void Created(GameObject *obj);
void Timer_Expired(GameObject *obj,int number);
};
//.cpp
void PickUpScript::Custom(GameObject *obj, int message, int param, GameObject *sender)
{
if(message == 1000000025)
{
if((stricmp(Get_Definition_Name(Get_Int_Parameter("preset")), "Nod_Turret_MP") == 0) || (stricmp(Get_Definition_Name(Get_Int_Parameter("preset")), "Nod_Turret_MP_Improved") == 0))
{
if(Get_Team(Get_Player_ID(sender)) == 0)
{
GameObject *TurretPickupObj = Commands->Find_Object(Get_Int_Parameter("ID"));
if(TurretPickupObj)
{
Commands->Send_Custom_Event(sender, TurretPickupObj, 100, 0, 0);
}
Commands->Destroy_Object(obj);
}
else
{
GameObject *TurretPickupObj = Commands->Find_Object(Get_Int_Parameter("ID"));
if(TurretPickupObj)
{
Commands->Send_Custom_Event(sender, TurretPickupObj, 101, 0, 0);
}
Commands->Destroy_Object(obj);
}
}
else if(stricmp(Get_Definition_Name(Get_Int_Parameter("preset")), "GDI_Guard_Tower") == 0)
{
if(Get_Team(Get_Player_ID(sender)) == 1)
{
GameObject *GDITowerPickupObj = Commands->Find_Object(Get_Int_Parameter("ID"));
if(GDITowerPickupObj)
{
Commands->Send_Custom_Event(sender, GDITowerPickupObj, 100, 0, 0);
}
Commands->Destroy_Object(obj);
}
else
{
GameObject *GDITowerPickupObj = Commands->Find_Object(Get_Int_Parameter("ID"));
if(GDITowerPickupObj)
{
Commands->Send_Custom_Event(sender, GDITowerPickupObj, 101, 0, 0);
}
Commands->Destroy_Object(obj);
}
}
}
}
void BaseDefenceRebuy::Created(GameObject *obj)
{
total = 0;
Commands->Start_Timer(obj, this, 1.0f, 1);
}
void BaseDefenceRebuy::Custom(GameObject *obj, int message, int param, GameObject *sender)
{
if(message == 100)
{
int cost = 100;
int power = 1;
int ID = Get_Player_ID(sender);
if(!Is_Base_Powered(Get_Team(Get_Player_ID(sender))))
{
power = 2;
}
if(!Purchase_Item(sender, cost))
{
Functions::PPage(ID,"You don't have enough money to add to the pool");
}
else
{
total += cost;
if((stricmp(Get_Definition_Name(Get_Int_Parameter("preset")), "Nod_turret_MP") == 0) || (stricmp(Get_Definition_Name(Get_Int_Parameter("preset")), "Nod_turret_MP_Improved") == 0))
{
if(total >= (1000*power))
{
GameObject *NodTurretRebuild = Commands->Create_Object("Nod_turret_MP_Improved", Commands->Get_Position(obj));
if(NodTurretRebuild)
{
Commands->Disable_Physical_Collisions(NodTurretRebuild);
Attach_Script_Once(NodTurretRebuild, "BaseDefenceScript", "");
Attach_Script_Once(NodTurretRebuild, "Hardden", "");
Functions::Console("msg %ls just bought back a Turret for %s",Get_Wide_Player_Name(sender), Functions::GetTeamName(Get_Team(Get_Player_ID(sender))));
Commands->Destroy_Object(obj);
}
}
else
{
Functions::PPage(ID,"You have added credits to the Turret rebuild fund, %d more credits required.", (1000*power)-total);
}
}
else if(stricmp(Get_Definition_Name(Get_Int_Parameter("preset")), "GDI_Guard_Tower") == 0)
{
if(total >= (1600*power))
{
GameObject *GdiTowerRebuild = Commands->Create_Object("GDI_Guard_Tower", Commands->Get_Position(obj));
if(GdiTowerRebuild)
{
Commands->Disable_Physical_Collisions(GdiTowerRebuild);
Attach_Script_Once(GdiTowerRebuild, "BaseDefenceScript", "");
Attach_Script_Once(GdiTowerRebuild, "Hardden", "");
Functions::Console("msg %ls just bought back a Guard Tower for %s",Get_Wide_Player_Name(sender), Functions::GetTeamName(Get_Team(Get_Player_ID(sender))));
Commands->Destroy_Object(obj);
}
}
else
{
Functions::PPage(ID,"You have added credits to the Guard Tower rebuild fund, %d more credits required.", (1600*power)-total);
}
}
}
Commands->Start_Timer(obj, this, 3.0f, 1);
}
if(message == 101)
{
int ID = Get_Player_ID(sender);
int cost = 100;
if (total >= cost)
{
total -= cost;
Set_Money(ID, Get_Money(ID)+cost);
Functions::PPage(ID, "You just stole %d credits from the enemy defense pool.", cost);
}
Commands->Start_Timer(obj, this, 3.0f, 1);
}
}
void BaseDefenceRebuy::Timer_Expired(GameObject *obj, int number)
{
GameObject *powerup = Commands->Create_Object("POW_Data_Disc", Commands->Get_Position(obj));
if(powerup)
{
char tmp[8];
sprintf(tmp, "%d,%d", Commands->Get_ID(obj), Get_Int_Parameter("preset"));
Commands->Attach_Script(powerup, "PickUpScript", tmp);
Set_Is_Powerup_Persistant(powerup,true);
}
}
void BaseDefenceScript::Killed(GameObject *obj, GameObject *shooter)
{
char tmp[8];
InvisObjCont = Commands->Get_ID(Commands->Create_Object("Invisible_Object",Commands->Get_Position(obj)));
sprintf(tmp, "%d", Get_Definition_ID(Commands->Get_Preset_Name(obj)));
Commands->Attach_Script(Commands->Find_Object(InvisObjCont), "BaseDefenceRebuy", tmp);
}
void Hardden::Created(GameObject *obj)
{
Commands->Start_Timer(obj,this,5,1);
}
void Hardden::Timer_Expired(GameObject *obj,int number)
{
if (number == 1)
{
bool doHardern = true;
for(GenericSLNode *x = SmartGameObjList->HeadNode; x != 0; x = x->NodeNext)
{
GameObject *o = (GameObject *)x->NodeData;
if (o != obj) {
if (Commands->Get_Distance(Commands->Get_Position(obj),Commands->Get_Position(o)) < 10) {
doHardern = false;
}
}
}
if (doHardern) {
Commands->Enable_Collisions(obj);
Destroy_Script();
}
else
{
Commands->Start_Timer(obj,this,5,1);
}
}
}
ScriptRegistrant<BaseDefenceScript> BaseDefenceScript_Registrant("BaseDefenceScript", "");
ScriptRegistrant<PickUpScript> PickUpScriptRegistrant("PickUpScript", "ID:int,preset:int");
ScriptRegistrant<BaseDefenceRebuy> BaseDefenceRebuyRegistrant("BaseDefenceRebuy", "preset:int");
ScriptRegistrant<Hardden> Hardden_Registrant("Hardden", "");
Credit for parts of source released by n00bless goes to n00bless members/mods such as pvtschlag and jnz
goztow wrote on Tue, 11 May 2010 08:00 | If we had to ban all who ever cheated or ever created a cheat (obj3cts and such) then I don't think there would be many members left here (sad fact).
|
reborn wrote on Fri, 29 January 2010 23:37 | std is for pro's.
|
[Updated on: Tue, 02 February 2010 07:16] Report message to a moderator
|
|
|
Re: Base defence source [message #419056 is a reply to message #419055] |
Tue, 02 February 2010 07:08 |
raven
Messages: 595 Registered: January 2007 Location: Toronto, Ontario
Karma: 0
|
Colonel |
|
|
Quote: | 11:36:24... +Hex: i used to be nice and release shit
11:36:29... +Hex: then i met you nubs
|
does this mean we aren't nubs anymore
-Jelly Administrator
-Exodus Administrator
|
|
|
|
|
Goto Forum:
Current Time: Fri Jan 10 14:13:57 MST 2025
Total time taken to generate the page: 0.00613 seconds
|