diff -uwr source/MemoryManager/FastAllocator.h sourceold/MemoryManager/FastAllocator.h --- source/MemoryManager/FastAllocator.h 2013-01-13 11:41:06.880921900 +0800 +++ sourceold/MemoryManager/FastAllocator.h 2012-07-28 09:01:32.000000000 +0800 @@ -24,7 +24,6 @@ #define FASTALLOC_STATS #endif #include "TSList.h" -#include DECLSPEC_RESTRICT void* SystemAllocate(size_t size); void SystemFree(void* memory); diff -uwr source/bansystem/bansystem.cpp sourceold/bansystem/bansystem.cpp --- source/bansystem/bansystem.cpp 2013-01-21 11:44:47.630726600 +0800 +++ sourceold/bansystem/bansystem.cpp 2012-07-28 09:12:12.000000000 +0800 @@ -196,7 +196,7 @@ } if (connectionRequest.clientVersion < minVersion) { - refusalMessage.Format(L"You need a newer version of scripts.dll to join this server. Please get the newest version from http://www.tiberiantechnologies.org/"); + refusalMessage.Format(L"This server requires a minimum scripts version of %f", minVersion); status = STATUS_REFUSING; } return status; Binary files source/bin/Debug/shaders.lib and sourceold/bin/Debug/shaders.lib differ Binary files source/bin/Release/shaders.lib and sourceold/bin/Release/shaders.lib differ diff -uwr source/scripts/BuildingAggregateClass.h sourceold/scripts/BuildingAggregateClass.h --- source/scripts/BuildingAggregateClass.h 2013-01-13 11:33:13.737367200 +0800 +++ sourceold/scripts/BuildingAggregateClass.h 2012-07-28 09:11:08.000000000 +0800 @@ -24,7 +24,7 @@ const BuildingAggregateDefClass * Get_BuildingAggregateDef( void ) const {return (BuildingAggregateDefClass *)Definition; } int Get_Current_State(void); void Set_Current_State(int new_state,bool force_update = false); - SHADERS_API bool Is_MCT(void); + bool Is_MCT(void); virtual bool Save( ChunkSaveClass & csave ); virtual bool Load( ChunkLoadClass & cload ); virtual void Save_State( ChunkSaveClass & csave ); diff -uwr source/scripts/BuildingGameObj.h sourceold/scripts/BuildingGameObj.h --- source/scripts/BuildingGameObj.h 2013-01-13 11:33:13.471742200 +0800 +++ sourceold/scripts/BuildingGameObj.h 2012-09-09 17:56:18.000000000 +0800 @@ -94,7 +94,6 @@ virtual bool Get_World_Position (Vector3 &pos) const { pos = Position; return true; } virtual void Get_Description( StringClass & description ); virtual bool Is_Tagged(void) { return false; } - SCRIPTS_API BuildingAggregateClass * Find_MCT(); bool Is_GDI( void ) { return Get_Player_Type() == PLAYERTYPE_GDI; } bool Is_Nod( void ) { return Get_Player_Type() == PLAYERTYPE_NOD; } #ifndef TTLE_EXPORTS diff -uwr source/scripts/DefaultConnectionAcceptanceFilter.cpp sourceold/scripts/DefaultConnectionAcceptanceFilter.cpp --- source/scripts/DefaultConnectionAcceptanceFilter.cpp 2013-01-21 11:44:47.528187500 +0800 +++ sourceold/scripts/DefaultConnectionAcceptanceFilter.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -114,11 +114,6 @@ status = STATUS_REFUSING; refusalMessage = L"Invalid serial."; } - else if (connectionRequest.clientVersion == 4.0f && connectionRequest.clientRevisionNumber < 5219) - { - refusalMessage.Format(L"You need a newer version of scripts.dll to join this server. Please get the newest version from http://www.tiberiantechnologies.org/"); - status = STATUS_REFUSING; - } else { status = STATUS_ACCEPTING; diff -uwr source/scripts/Doxyfile sourceold/scripts/Doxyfile --- source/scripts/Doxyfile 2013-01-11 22:37:51.675781200 +0800 +++ sourceold/scripts/Doxyfile 2012-09-09 17:56:18.000000000 +0800 @@ -203,7 +203,7 @@ # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = "arscript=\ingroup scripts_apocrising\n\n\warning\nThis script is specifically designed for Apocalypse Rising and is subject to change without notice. It is therefore not recommended for use in other games." +ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding diff -uwr source/scripts/HTreeClass.cpp sourceold/scripts/HTreeClass.cpp --- source/scripts/HTreeClass.cpp 2013-01-13 11:48:33.842835900 +0800 +++ sourceold/scripts/HTreeClass.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -11,196 +11,6 @@ */ #include "general.h" #include "HTreeClass.h" -#include "Quaternion.h" - -HTreeClass::HTreeClass() -{ - Name[0] = '\0'; - NumPivots = 0; - Pivots = 0; - ScaleFactor = 1.0f; -} - -HTreeClass::HTreeClass(const HTreeClass& that) -{ - memcpy(Name, that.Name, sizeof(Name)); - NumPivots = that.NumPivots; - - Pivots = new PivotClass[NumPivots]; - for (int i = 0; i < NumPivots; ++i) - { - PivotClass& pivot = Pivots[i]; - pivot = that.Pivots[i]; - - if (pivot.Parent) pivot.Parent = &Pivots[pivot.Parent->Index]; - } - - ScaleFactor = that.ScaleFactor; -} - -HTreeClass::~HTreeClass() -{ - Free(); -} - -HTreeClass* HTreeClass::Create_Interpolated(const HTreeClass* tree_base, const HTreeClass* tree_a, const HTreeClass* tree_b, float weight_a, float weight_b) -{ - assert(tree_base->NumPivots == tree_a->NumPivots); - assert(tree_base->NumPivots == tree_b->NumPivots); - - HTreeClass* tree_out = new HTreeClass(*tree_base); - - float abs_weight_a = WWMath::Fabs(weight_a); - float abs_weight_b = WWMath::Fabs(weight_b); - float abs_weight_base = abs_weight_b + abs_weight_a; - - if (abs_weight_base <= 0.0f || tree_out->NumPivots == 0) - { - return tree_out; - } - - for (int i = 0; i < tree_out->NumPivots; ++i) - { - Vector3 pos; - tree_base->Pivots[i].BaseTransform.Get_Translation(&pos); - - Vector3 pos_a; - tree_a->Pivots[i].BaseTransform.Get_Translation(&pos_a); - - Vector3 pos_b; - tree_b->Pivots[i].BaseTransform.Get_Translation(&pos_b); - - Vector3 contrib_a; - Vector3::Lerp(pos, pos_a, weight_a, &contrib_a); - - Vector3 contrib_b; - Vector3::Lerp(pos, pos_b, weight_b, &contrib_b); - - pos = contrib_a * abs_weight_a + contrib_b * abs_weight_b; - - tree_out->Pivots[i].BaseTransform.Set_Translation(pos / abs_weight_base); - } - - return tree_out; -} - -void HTreeClass::Init_Default() -{ - Free(); - - Name[0] = '\0'; - NumPivots = 1; - Pivots = new PivotClass(); - strcpy_s(Pivots->Name, "RootTransform"); -} - -WW3DErrorType HTreeClass::Load_W3D(ChunkLoadClass& cload) -{ - Free(); - - W3dHierarchyStruct header; - - if (!cload.Open_Chunk()) goto error; - if (cload.Cur_Chunk_ID() != 257) goto error; - if (cload.SimpleRead(header) != sizeof(header)) goto error; - cload.Close_Chunk(); - - bool create_root = false; - if (header.Version < 0x2FFFF) - { - create_root = true; - ++header.NumPivots; - } - - memcpy(Name, header.Name, W3D_NAME_LEN); - NumPivots = header.NumPivots; - - if (NumPivots > 0) - { - Pivots = new PivotClass[NumPivots]; - } - - for (; cload.Open_Chunk(); cload.Close_Chunk()) - { - if (cload.Cur_Chunk_ID() == 258 && read_pivots(cload, create_root) != WW3D_ERROR_OK) - { - Free(); - goto error; - } - } - - return WW3D_ERROR_OK; - -error: - return WW3D_ERROR_GENERIC; -} - -WW3DErrorType HTreeClass::read_pivots(ChunkLoadClass& cload, bool create_root) -{ - int pidx = 0; - if (create_root) - { - Pivots[0].Index = 0; - Pivots[0].Parent = nullptr; - Pivots[0].BaseTransform.Make_Identity(); - Pivots[0].IsVisible = true; - pidx = 1; - } - - while (pidx < NumPivots) - { - W3dPivotStruct pivot_data; - if (cload.SimpleRead(pivot_data) != sizeof(pivot_data)) - { - return WW3D_ERROR_GENERIC; - } - - PivotClass& pivot = Pivots[pidx]; - memcpy(pivot.Name, pivot_data.Name, W3D_NAME_LEN); - pivot.Index = pidx; - - Vector3 translation; - translation.X = pivot_data.Translation.X; - translation.Y = pivot_data.Translation.Y; - translation.Z = pivot_data.Translation.Z; - pivot.BaseTransform.Set_Translation(translation); - - Quaternion rotation; - rotation.X = pivot_data.Rotation.Q[0]; - rotation.Y = pivot_data.Rotation.Q[1]; - rotation.Z = pivot_data.Rotation.Q[2]; - rotation.W = pivot_data.Rotation.Q[3]; - - Matrix3 rotation_matrix = Build_Matrix3(rotation); - pivot.BaseTransform.Set_Rotation(rotation_matrix); - - if (pivot_data.ParentIdx == -1) - { - pivot.Parent = nullptr; - assert(pidx == 0); - } - else - { - if (create_root) ++pivot_data.ParentIdx; - pivot.Parent = &Pivots[pivot_data.ParentIdx]; - } - - ++pidx; - } - - Pivots[0].Transform.Make_Identity(); - Pivots[0].IsVisible = true; - - return WW3D_ERROR_OK; -} - -void HTreeClass::Free() -{ - delete[] Pivots; - Pivots = nullptr; - NumPivots = 0; - ScaleFactor = 1.0f; -} const char* HTreeClass::Get_Name() const { @@ -209,7 +19,7 @@ const Matrix3D& HTreeClass::Get_Transform(int pivot) const { - return this->Pivots[pivot].Transform; + return this->Pivot[pivot].Transform; } RENEGADE_FUNCTION diff -uwr source/scripts/HTreeClass.h sourceold/scripts/HTreeClass.h --- source/scripts/HTreeClass.h 2013-01-13 11:48:33.858460900 +0800 +++ sourceold/scripts/HTreeClass.h 2012-07-28 09:11:08.000000000 +0800 @@ -12,8 +12,6 @@ #ifndef TT_INCLUDE__HTREECLASS_H #define TT_INCLUDE__HTREECLASS_H #include "Matrix3D.h" -#include "engine_3dre.h" - struct PivotClass { char Name[16]; //0 @@ -25,11 +23,9 @@ bool IsCaptured; //121 Matrix3D CapTransform; //124 bool WorldSpaceTranslation; //172 - PivotClass() : Index(0), Parent(0), BaseTransform(true), Transform(true), IsVisible(true), IsCaptured(false), CapTransform(true), WorldSpaceTranslation(false) { } - void Capture_Update() { if (WorldSpaceTranslation) @@ -55,63 +51,41 @@ private: char Name[16]; //0 int NumPivots; //16 - PivotClass* Pivots; //20 + PivotClass* Pivot; //20 float ScaleFactor; //24 - public: - - HTreeClass(); - HTreeClass(const HTreeClass& that); - ~HTreeClass(); - - static HTreeClass* Create_Interpolated(const HTreeClass* base, const HTreeClass* a, const HTreeClass* b, float weightA, float weightB); - - void Init_Default(); - - WW3DErrorType Load_W3D(ChunkLoadClass& cload); - void Free(); - - const char* Get_Name() const; const Matrix3D& HTreeClass::Get_Transform(int pivot) const; void Get_Bone_Control(int, Matrix3D&) const; - int Num_Pivots() const { return NumPivots; } - int Get_Parent_Index(int boneidx) const { - if (Pivots[boneidx].Parent) + if (Pivot[boneidx].Parent) { - return Pivots[boneidx].Parent->Index; + return Pivot[boneidx].Parent->Index; } else { return 0; } } - void Base_Update(Matrix3D& root) { - Pivots->Transform = root; - Pivots->IsVisible = true; + Pivot->Transform = root; + Pivot->IsVisible = true; for (int i = 1;i < NumPivots;i++) { - Matrix3D::Multiply(Pivots[i].Parent->Transform,Pivots[i].BaseTransform,&Pivots[i].Transform); - Pivots[i].IsVisible = true; - if (Pivots[i].IsCaptured) + Matrix3D::Multiply(Pivot[i].Parent->Transform,Pivot[i].BaseTransform,&Pivot[i].Transform); + Pivot[i].IsVisible = true; + if (Pivot[i].IsCaptured) { - Pivots[i].Capture_Update(); + Pivot[i].Capture_Update(); } } } - -private: - HTreeClass& operator = (const HTreeClass& that); // unimplemented - - WW3DErrorType read_pivots(ChunkLoadClass& cload, bool create_root); }; #endif diff -uwr source/scripts/LoopedAnimationController.cpp sourceold/scripts/LoopedAnimationController.cpp --- source/scripts/LoopedAnimationController.cpp 2013-01-13 11:33:13.987367200 +0800 +++ sourceold/scripts/LoopedAnimationController.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -1,14 +1,3 @@ -/* Renegade Scripts.dll - Copyright 2011 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ #include "General.h" #include "LoopedAnimationController.h" #include "ScriptableGameObj.h" diff -uwr source/scripts/LoopedAnimationController.h sourceold/scripts/LoopedAnimationController.h --- source/scripts/LoopedAnimationController.h 2013-01-13 11:33:13.924867200 +0800 +++ sourceold/scripts/LoopedAnimationController.h 2012-07-28 09:11:06.000000000 +0800 @@ -1,14 +1,3 @@ -/* Renegade Scripts.dll - Copyright 2011 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ #pragma once #include "scripts.h" Only in source/scripts: Quaternion.cpp Only in source/scripts: UltraAOW.txt diff -uwr source/scripts/cTeam.h sourceold/scripts/cTeam.h --- source/scripts/cTeam.h 2013-01-13 11:33:13.737367200 +0800 +++ sourceold/scripts/cTeam.h 2012-07-28 09:11:08.000000000 +0800 @@ -1,14 +1,3 @@ -/* Renegade Scripts.dll - Copyright 2011 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ #ifndef TT_INCLUDE__CTEAM_H #define TT_INCLUDE__CTEAM_H diff -uwr source/scripts/dp88_ar.cpp sourceold/scripts/dp88_ar.cpp --- source/scripts/dp88_ar.cpp 2013-01-13 12:06:54.579164100 +0800 +++ sourceold/scripts/dp88_ar.cpp 2012-08-22 21:20:46.000000000 +0800 @@ -261,7 +261,7 @@ void dp88_AR_Vehicle::Custom( GameObject *obj, int type, int param, GameObject *sender ) -{/* +{ // Look for vehicle entry if ( type == CUSTOM_EVENT_VEHICLE_ENTERED ) { @@ -291,7 +291,7 @@ // Look for a message from the attacking terror drone telling us it died - else if ( type == CUSTOM_TD_TD_DIED ) + /*else if ( type == CUSTOM_TD_TD_DIED ) { attackingTerrorDroneID = 0; }*/ @@ -346,6 +346,159 @@ +/*------------------------ +Script for health / armour regeneration based on veterancy +--------------------------*/ + +void dp88_AR_Veterancy_HealthArmourRegen::Created( GameObject *obj ) +{ + // Set initial veterancy level + veterancyLevel = 0; + + // Start timer + Commands->Start_Timer ( obj, this, 1.0f, TIMER_HEALTHARMOURREGENTICK ); +} + + +void dp88_AR_Veterancy_HealthArmourRegen::Timer_Expired( GameObject *obj, int number ) +{ + // Only process this if we are not dead... + if ( Commands->Get_Health ( obj ) > 0.0f ) + { + // Check if unit is below full health + if ( Commands->Get_Health ( obj ) < Commands->Get_Max_Health ( obj ) ) + { + // Work out how much health we can regenerate + float healthRegenAmount = (float)(( veterancyLevel == 0 ) ? Get_Int_Parameter ( "rookie_healthRegenAmount" ) : ( veterancyLevel == 1 ) ? Get_Int_Parameter ( "veteran_healthRegenAmount" ) : Get_Int_Parameter ( "elite_healthRegenAmount" )); + + // If current health + regen amount > max health set to max health + if ( Commands->Get_Health ( obj ) + healthRegenAmount >= Commands->Get_Max_Health ( obj ) ) + Commands->Set_Health ( obj, Commands->Get_Max_Health ( obj ) ); + + // Otherwise add on health regen amount + else + Commands->Set_Health ( obj, Commands->Get_Health( obj ) + healthRegenAmount ); + } + + // Check if unit is below full armour + if ( Commands->Get_Shield_Strength ( obj ) < Commands->Get_Max_Shield_Strength ( obj ) ) + { + // Work out how much armour we can regenerate + float armourRegenAmount = (float)(( veterancyLevel == 0 ) ? Get_Int_Parameter ( "rookie_armourRegenAmount" ) : ( veterancyLevel == 1 ) ? Get_Int_Parameter ( "veteran_armourRegenAmount" ) : Get_Int_Parameter ( "elite_armourRegenAmount" )); + + // If current armour + regen amount > max armour set to max armour + if ( Commands->Get_Shield_Strength ( obj ) + armourRegenAmount >= Commands->Get_Max_Shield_Strength ( obj ) ) + Commands->Set_Shield_Strength ( obj, Commands->Get_Max_Shield_Strength ( obj ) ); + + // Otherwise add on armour regen amount + else + Commands->Set_Shield_Strength ( obj, Commands->Get_Shield_Strength( obj ) + armourRegenAmount ); + } + + // Start timer + Commands->Start_Timer ( obj, this, 1.0f, TIMER_HEALTHARMOURREGENTICK ); + } +} + + +void dp88_AR_Veterancy_HealthArmourRegen::Custom( GameObject *obj, int type, int param, GameObject *sender ) +{ + // If custom == CUSTOM_VETERANCY_PROMOTED update veterancyLevel + if ( type == CUSTOM_VETERANCY_PROMOTED ) + veterancyLevel = param; +} + + + + + + +/*------------------------ +Grant Default Weapon Scripts +Replaces m00_GrantPowerup_Created +--------------------------*/ + +void dp88_AR_grantDefaultWeapon::Created( GameObject *obj ) +{ + //Console_Output ( "Created dp88_AR_grantDefaultWeapon\n" ); + strcpy_s ( weaponName, sizeof(weaponName), Get_Powerup_Weapon ( Get_Parameter ( "powerupPreset" ) ) ); + strcpy_s ( oldWeapon, sizeof(oldWeapon), "null" ); + Commands->Give_PowerUp ( obj, Get_Parameter ( "powerupPreset" ), true ); +} + +void dp88_AR_grantDefaultWeapon::Custom( GameObject *obj, int type, int param, GameObject *sender ) +{ + if ( type == CUSTOM_VETERANCY_PROMOTED ) + { + // Work out if we need to grant them a new weapon + char weaponPowerup[64] = "null"; + switch ( param ) + { + case 1: + if ( strcmp ( Get_Parameter( "powerupPreset_veteran" ), "null" ) != 0 ) + strcpy_s ( weaponPowerup, sizeof(weaponPowerup), Get_Parameter ( "powerupPreset_veteran" ) ); + break; + case 2: + if ( strcmp ( Get_Parameter( "powerupPreset_elite" ), "null" ) != 0 ) + strcpy_s ( weaponPowerup, sizeof(weaponPowerup), Get_Parameter ( "powerupPreset_elite" ) ); + else if ( strcmp ( Get_Parameter( "powerupPreset_veteran" ), "null" ) != 0 ) + strcpy_s ( weaponPowerup, sizeof(weaponPowerup), Get_Parameter ( "powerupPreset_veteran" ) ); + break; + } + + // If we found a powerup to give them then grant it + if ( strcmp ( weaponPowerup, "null" ) != 0 ) + { + if ( Is_Valid_Preset ( weaponPowerup ) ) + { + // Give new weapon, and select if if they were using that weapon + if ( strcmp ( Get_Current_Weapon ( obj ), weaponName ) == 0 ) + { + Commands->Give_PowerUp( obj, weaponPowerup, true ); + strcpy_s ( oldWeapon, sizeof(oldWeapon), weaponName ); + Commands->Start_Timer ( obj, this, 0.1f, TIMER_REMOVE_OLDWEAPON ); + Commands->Select_Weapon ( obj, Get_Powerup_Weapon(weaponPowerup) ); + } + else + { + char curWep[128]; + strcpy_s ( curWep, sizeof(curWep), Get_Current_Weapon ( obj ) ); + Commands->Give_PowerUp( obj, weaponPowerup, true ); + Remove_Weapon ( obj, weaponName ); + Commands->Select_Weapon ( obj, curWep ); + } + + // Set this weapon as their default for future reference + strcpy_s ( weaponName, sizeof(weaponName), Get_Powerup_Weapon(weaponPowerup) ); + } + } + } +} + +void dp88_AR_grantDefaultWeapon::Timer_Expired ( GameObject *obj, int number ) +{ + if ( number == TIMER_REMOVE_OLDWEAPON && strcmp ( oldWeapon, "null" ) != 0 ) + { + char curWep[128]; + strcpy_s ( curWep, sizeof(curWep), Get_Current_Weapon ( obj ) ); + if ( strcmp ( curWep, oldWeapon ) == 0 ) + { + Commands->Select_Weapon ( obj, weaponName ); + Commands->Start_Timer ( obj, this, 0.1f, TIMER_REMOVE_OLDWEAPON ); + } + else + { + Remove_Weapon ( obj, oldWeapon ); + Commands->Select_Weapon ( obj, curWep ); + strcpy_s ( oldWeapon, sizeof(oldWeapon), "null" ); + } + } +} + + + + + @@ -388,6 +541,7 @@ if ( cannotDeployStringId && (soundId = Get_String_Sound_ID(cannotDeployStringId)) != 0 && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000 ) cannotDeploySoundId = soundId; + // Install keyhook if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 ) InstallHook( Get_Parameter("deployKeyhook"), obj ); @@ -404,12 +558,11 @@ if ( deployed ) { // If deployed for less than undeployTime seconds dont allow undeploy - float undeployTime = Get_Float_Parameter("undeployTime"); - if ( time(NULL) - lastDeploy < undeployTime ) + if ( time(NULL) - lastDeploy < Get_Float_Parameter("undeployTime") ) { - StringClass str(true); - str.Format("You cannot undeploy yet, you must wait at least %.*f seconds after deploying to undeploy.", (((int)undeployTime)==undeployTime)?0:2, undeployTime); - Send_Message_Player(obj, DP88_RGB_WARNING_MSG, str); + StringClass str; + str.Format("You cannot undeploy yet, you must wait at least %f seconds after deploying to undeploy.",Get_Float_Parameter("undeployTime")); + Send_Message_Player(obj,153,204,25,str); return; } @@ -424,21 +577,15 @@ const char* powerup = GetWeaponPowerup(currentVetLevel); if ( powerup ) Remove_Weapon ( obj, Get_Powerup_Weapon ( powerup ) ); - - // Re-enable loiters and vehicle entry - if ( SoldierGameObj* sObj = obj->As_SoldierGameObj() ) // Should always be true, but safety first... - sObj->Set_Can_Drive_Vehicles(m_bCanDrive); - Commands->Set_Loiters_Allowed(obj,true); } else { // If deployed for less than deployTime seconds dont allow deploy - float deployTime = Get_Float_Parameter("deployTime"); - if ( time(NULL) - lastDeploy < deployTime ) + if ( time(NULL) - lastDeploy < Get_Float_Parameter("deployTime") ) { - StringClass str(true); - str.Format("You cannot deploy yet, you must wait at least %.*f seconds after undeploying to deploy again.",(((int)deployTime)==deployTime)?0:2, deployTime); - Send_Message_Player(obj, DP88_RGB_WARNING_MSG, str); + StringClass str; + str.Format("You cannot deploy yet, you must wait at least %f seconds after undeploying to deploy again.",Get_Float_Parameter("deployTime")); + Send_Message_Player(obj,153,204,25,str); return; } @@ -483,14 +630,6 @@ deployed = true; lastDeploy = time(NULL); - // Disable loiters and vehicle entry - if ( SoldierGameObj* sObj = obj->As_SoldierGameObj() ) // Should always be true, but safety first... - { - m_bCanDrive = sObj->Can_Drive_Vehicles(); // Save value for when we undeploy... - sObj->Set_Can_Drive_Vehicles(false); - } - Commands->Set_Loiters_Allowed(obj,false); - // TEMP - Start timer to check position Commands->Start_Timer(obj,this,2.0f,154785); } @@ -591,7 +730,7 @@ // Remove script to punish abusers StringClass message; message.Format ("Deployment abuse detected, disabling deploy script... (distance from deployment: %.2fm)", distance); - Send_Message_Player(obj, DP88_RGB_ERROR_MSG, message); + Send_Message_Player(obj,255,50,50,message); RemoveHook(); Destroy_Script(); } @@ -949,7 +1088,7 @@ // Or, if we are a player driven miner, tell the driver we are full else if ( Get_Vehicle_Driver(obj) != NULL ) - Send_Message_Player ( Get_Vehicle_Driver(obj), DP88_RGB_GENERAL_MSG, "Fully loaded with ore, dock at the Refinery to smelt the ore into credits" ); + Send_Message_Player ( Get_Vehicle_Driver(obj), 153, 204, 25, "Fully loaded with ore, dock at the Refinery to smelt the ore into credits" ); } } @@ -960,7 +1099,7 @@ { // Inform driver we are unloading if ( Get_Vehicle_Driver(obj) != NULL ) - Send_Message_Player ( Get_Vehicle_Driver(obj), DP88_RGB_GENERAL_MSG, "Unloading ore, please stand by..." ); + Send_Message_Player ( Get_Vehicle_Driver(obj), 153, 204, 25, "Unloading ore, please stand by..." ); // Set AI state if ( useAI ) @@ -980,9 +1119,9 @@ // Inform the driver that we have finished unloading if ( Get_Vehicle_Driver(obj) != NULL ) { - StringClass message(true); + StringClass message; message.Format ("Ore unloaded successfully, you have earned %d credits for each player and %d points for yourself", oreValue, oreValue/10 ); - Send_Message_Player ( Get_Vehicle_Driver(obj), DP88_RGB_GENERAL_MSG, message ); + Send_Message_Player ( Get_Vehicle_Driver(obj), 153, 204, 25, message ); Commands->Give_Points(Get_Vehicle_Driver(obj),(float)oreValue/10.0f,false); } @@ -1496,12 +1635,12 @@ // Landing Zone void dp88_Aircraft_LandingZone::Entered( GameObject *obj, GameObject *enterer ) { - Commands->Send_Custom_Event( obj, enterer, CUSTOM_TRANSITION_VTOL_LAND_ZONE, 1, 0 ); + Commands->Send_Custom_Event( obj, enterer, CUSTOM_ENTERED_VTOL_LAND_ZONE, 1, 0 ); } void dp88_Aircraft_LandingZone::Exited( GameObject *obj, GameObject *exiter ) { - Commands->Send_Custom_Event( obj, exiter, CUSTOM_TRANSITION_VTOL_LAND_ZONE, 0, 0 ); + Commands->Send_Custom_Event( obj, exiter, CUSTOM_EXITED_VTOL_LAND_ZONE, 1, 0 ); } @@ -1514,7 +1653,7 @@ void dp88_Aircraft_LandingZone_Aircraft::Custom ( GameObject *obj, int type, int param, GameObject *sender ) { - if ( type == CUSTOM_TRANSITION_VTOL_LAND_ZONE && param == 1 ) + if ( type == CUSTOM_ENTERED_VTOL_LAND_ZONE ) { landingZoneCount++; @@ -1523,13 +1662,13 @@ Commands->Set_Animation( obj,Get_Parameter("landing_anim_name"), false, 0, Get_Float_Parameter("landing_anim_first_frame"), Get_Float_Parameter("landing_anim_last_frame"), false ); } - else if ( type == CUSTOM_TRANSITION_VTOL_LAND_ZONE && param == 0 ) + else if ( type == CUSTOM_EXITED_VTOL_LAND_ZONE ) { landingZoneCount--; // Play take off animation if this is the last zone we were in (landing anim in reverse...) if ( landingZoneCount == 0 ) - Commands->Set_Animation( obj, Get_Parameter("landing_anim_name"), false, 0, Get_Float_Parameter("landing_anim_last_frame"), Get_Float_Parameter("landing_anim_first_frame"), false ); + Commands->Set_Animation( obj, Get_Parameter("landing_anim_name"), false, 0, Get_Float_Parameter("landing_anim_last_frame"), Get_Float_Parameter("landing_anim_first_frame"), true ); } else if ( type == CUSTOM_EVENT_VEHICLE_ENTERED && driverID == NULL ) @@ -1542,8 +1681,8 @@ // If the driver exited outside of a landing zone then kablooey! if ( Get_Int_Parameter("require_landing_zone") >= 1 && landingZoneCount == 0 ) { - Commands->Apply_Damage(sender, 10000.0f, "Death", obj ); - Commands->Apply_Damage(obj, 10000.0f, "Death", obj ); + Commands->Apply_Damage(sender, 10000.00f, "Death", obj ); + Commands->Apply_Damage(obj, 10000.00f, "Death", obj ); } } } @@ -2266,162 +2405,30 @@ } } -// ------------------------------------------------------------------------------------------------- - -// Registrar goes here... -// - - - - - - -void dp88_AR_Paradrop::Created( GameObject* pObj ) -{ - if ( !pObj->As_SoldierGameObj() ) +void dp88_AR_paradrop::Created( GameObject *obj ) { - Console_Output ( "[%d:%s:%s] Critical Error: This script is only compatible with soldier game objects. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); - return; - } - //Console_Output ( "Created dp88_AR_paradrop\n" ); - earth_warhead = ArmorWarheadManager::Get_Warhead_Type("Earth"); - m_nParachuteModel = 0; - - const char* parachute_model = Get_Parameter("Parachute_Model"); - if ( strlen(parachute_model) > 0 ) - { - GameObject* pParachute = Commands->Create_Object("Invisible_Object",Commands->Get_Position(pObj)); - Commands->Set_Model ( pParachute, parachute_model ); - Commands->Attach_To_Object_Bone(pParachute, pObj, Get_Parameter("Parachute_Bone")); - m_nParachuteModel = Commands->Get_ID(pParachute); + hit_ground = false; } - Vector3 velocity = Get_Velocity(pObj); - m_fallRate = velocity.Z; - Commands->Start_Timer(pObj, this, 1.0f, TIMER_PARADROP_CHECKFALLRATE ); - - if ( strlen(Get_Parameter("Animation")) > 0 ) - { - m_pAnimController = new LoopedAnimationController(pObj); - m_pAnimController->PlayAnimation ( Get_Parameter("Animation"), Get_Int_Parameter("Animation_First_Frame"), Get_Int_Parameter("Animation_Last_Frame"), (Get_Int_Parameter("Animation_Looped")==1) ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Paradrop::Damaged( GameObject* pObj, GameObject* pDamager, float amount ) -{ - if ( Get_Damage_Warhead() == earth_warhead ) - { - // Repair the falling damage. Note that, in stock Renegade and most mods, falling damage ignores - // armour, so we can't use Apply_Damage to heal the damage, it has to be done manually - float health = Commands->Get_Health(pObj); - float max = Commands->Get_Max_Health(pObj); - health =+ amount; - if ( health > max ) - { - amount = abs(max-health); - health = max; - } - else - amount = 0.0f; - Commands->Set_Health(pObj, health); - - // Apply any left-over repairs to the armour (to support mods where armour takes falling damage) - if ( amount > 0 ) - { - health = Commands->Get_Shield_Strength(pObj); - max = Commands->Get_Max_Shield_Strength(pObj); - health += amount; - if ( health > max ) - health = max; - Commands->Set_Shield_Strength(pObj, health); - } - - Landed(pObj); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Paradrop::Killed( GameObject* pObj, GameObject* pKilled ) -{ - // Despawn the parachute model - if ( m_nParachuteModel != 0 ) - Commands->Destroy_Object(Commands->Find_Object(m_nParachuteModel)); - m_nParachuteModel = 0; - - // Prevent anything else happening, such as Timer_Expired - Destroy_Script(); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Paradrop::Timer_Expired( GameObject* pObj, int number ) -{ - if ( number == TIMER_PARADROP_CHECKFALLRATE ) +void dp88_AR_paradrop::Damaged( GameObject *obj, GameObject* damager, float amount ) { - Vector3 velocity = Get_Velocity(pObj); - if ( velocity.Z > m_fallRate ) - Landed(pObj); - else + if ( hit_ground ) { - m_fallRate = velocity.Z; - Commands->Start_Timer(pObj, this, 1.0f, TIMER_PARADROP_CHECKFALLRATE ); - } + /* Spawn new infantry preset */ + if ( Is_Valid_Preset(Get_Parameter("infantry_preset")) ) + Change_Character(obj, Get_Parameter("infantry_preset") ); } } -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Paradrop::Detach() -{ - delete m_pAnimController; - m_pAnimController = NULL; -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Paradrop::Landed ( GameObject* pObj ) -{ - // Despawn the parachute model - if ( m_nParachuteModel != 0 ) - Commands->Destroy_Object(Commands->Find_Object(m_nParachuteModel)); - m_nParachuteModel = 0; - - - // Swap to new infantry preset - const char* infantry_preset = Get_Parameter("Infantry_Preset"); - if ( strlen(infantry_preset) > 0 && Is_Valid_Preset(infantry_preset) ) +void dp88_AR_paradrop::Custom( GameObject *obj, int type, int param, GameObject *sender ) { - float health = Commands->Get_Health(pObj); - float armour = Commands->Get_Shield_Strength(pObj); - Change_Character(pObj, infantry_preset ); - Commands->Set_Health(pObj, health); - Commands->Set_Shield_Strength(pObj, armour); - } - - // Prevent anything else happening, such as Timer_Expired - Destroy_Script(); + if ( type == CUSTOM_EVENT_FALLING_DAMAGE ) + hit_ground = true; } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_AR_Paradrop_Registrant( - "dp88_AR_Paradrop", - "Infantry_Preset:string," - "Parachute_Model:string," - "Parachute_Bone:string," - "Animation:string," - "Animation_First_Frame:int," - "Animation_Last_Frame:int," - "Animation_Looped:int" -); - @@ -2662,31 +2669,44 @@ { // If this is a connection between the towers we are searching for then // return success - if ( (sortedConnections[i*4] == tower1 && sortedConnections[(i*4)+1] == tower2) - || (sortedConnections[i*4] == tower2 && sortedConnections[(i*4)+1] == tower1) ) + if ( sortedConnections[i*4] == tower1 && sortedConnections[(i*4)+1] == tower2 + || sortedConnections[i*4] == tower2 && sortedConnections[(i*4)+1] == tower1 ) return true; - bool bFound = false; - - // Temporarily mark this connection as "bad" to prevent infinite recursion - sortedConnections[(i*4)+3] = 1; - - // If either of the two towers in this connection matches the desired tower then check for a - // path between the other desired tower and the third party tower it is connected to... + // If one of the towers in this connection matches tower 1 then look for + // a path between the other tower in the connection and tower 2. We do this + // by temporaraily marking the connection as 'bad' before recursing, otherwise + // we cause an infinite recursion, which is bad! if ( sortedConnections[i*4] == tower1 ) - bFound = calculateTowerMapPathSearch(sortedConnections,numConnections,tower2,sortedConnections[(i*4)+1]); - else if ( sortedConnections[(i*4)+1] == tower1 ) - bFound = calculateTowerMapPathSearch(sortedConnections,numConnections,tower2,sortedConnections[i*4]); - else if ( sortedConnections[i*4] == tower2 ) - bFound = calculateTowerMapPathSearch(sortedConnections,numConnections,tower1,sortedConnections[(i*4)+1]); - else if ( sortedConnections[(i*4)+1] == tower2 ) - bFound = calculateTowerMapPathSearch(sortedConnections,numConnections,tower1,sortedConnections[i*4]); - - // Restore this connection as "good" + { + sortedConnections[(i*4)+3] = 1; + bool result = calculateTowerMapPathSearch(sortedConnections,numConnections,tower2,sortedConnections[(i*4)+1]); sortedConnections[(i*4)+3] = 0; + return result; + } + if ( sortedConnections[(i*4)+1] == tower1 ) + { + sortedConnections[(i*4)+3] = 1; + bool result = calculateTowerMapPathSearch(sortedConnections,numConnections,tower2,sortedConnections[i*4]); + sortedConnections[(i*4)+3] = 0; + return result; + } - if ( bFound ) - return true; + // Ditto for tower 2 + if ( sortedConnections[i*4] == tower2 ) + { + sortedConnections[(i*4)+3] = 1; + bool result = calculateTowerMapPathSearch(sortedConnections,numConnections,tower1,sortedConnections[(i*4)+1]); + sortedConnections[(i*4)+3] = 0; + return result; + } + if ( sortedConnections[(i*4)+1] == tower2 ) + { + sortedConnections[(i*4)+3] = 1; + bool result = calculateTowerMapPathSearch(sortedConnections,numConnections,tower1,sortedConnections[i*4]); + sortedConnections[(i*4)+3] = 0; + return result; + } } } @@ -2703,8 +2723,7 @@ void dp88_AR_Prism_Tower::Created( GameObject *obj ) { - loadSettings(obj, false, false); - Init(obj); + dp88_AI_ChargedTurret::Created(obj); // Initialise member variables isAssistingTower = false; @@ -3071,6 +3090,13 @@ // Unit scripts //ScriptRegistrant dp88_AR_Vehicle_Registrant( "dp88_AR_Vehicle", "TD_attack_animName=modelfile.animfile:string,TD_attack_firstFrame=0.0:float,TD_attack_lastFrame=30.0:float,CLEG_Resistance=10:int" ); + +// Replacement for m00_GrantPowerup_Created +ScriptRegistrant dp88_AR_grantDefaultWeapon_Registrant("dp88_AR_grantDefaultWeapon","powerupPreset=presetname:string,powerupPreset_veteran=null:string,powerupPreset_elite=null:string"); + +// Veterancy stuff +ScriptRegistrant dp88_AR_Veterancy_HealthArmourRegen_Registrant("dp88_AR_Veterancy_HealthArmourRegen","rookie_healthRegenAmount=0:int,rookie_armourRegenAmount=0:int,veteran_healthRegenAmount=1:int,veteran_armourRegenAmount=0:int,elite_healthRegenAmount=3:int,elite_armourRegenAmount=2:int"); + // Deployable Infantry ScriptRegistrant dp88_AR_Deployable_Infantry_Registrant("dp88_AR_Deployable_Infantry","deployedObjectPreset=null:string,deployedObjectSpaceRequired=6:float,deployAnimation=obj.obj:string,deployTime=4:float,undeployAnimation=obj.obj:string,undeployTime=4:float,deployedWeaponPowerup=null:string,deployedWeaponPowerup_veteran=null:string,deployedWeaponPowerup_elite=null:string,cannotDeployStringId=0:int,deployKeyhook=IDeploy:string,deployedArmourType=null:string,deployedArmourType_veteran=null:string,deployedArmourType_elite=null:string"); @@ -3107,7 +3133,7 @@ // Paradrop scripts ScriptRegistrant dp88_AR_paradrop_Console_Registrant("dp88_AR_paradrop_Console","team=1:int"); - +ScriptRegistrant dp88_AR_paradrop_Registrant("dp88_AR_paradrop","infantry_preset:string"); // Prism Tower script ScriptRegistrant dp88_AR_Prism_Tower_Registrant("dp88_AR_Prism_Tower","Priority_Infantry=1.0:float,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Priority_Heavy_Vehicle=7.0:float,Priority_VTOL=0.0:float,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Animation_Model:string,Animation_Model_Bone:string,Animation:string,Animation_Idle_Start_Frame:int,Animation_Idle_End_Frame:int,Animation_Unpowered_Start_Frame:int,Animation_Unpowered_End_Frame:int,Animation_Charge_Start_Frame:int,Animation_Charge_End_Frame:int,Charge_Sound:string,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.25:float,Requires_Power=1:int,Debug=0:int"); diff -uwr source/scripts/dp88_ar.h sourceold/scripts/dp88_ar.h --- source/scripts/dp88_ar.h 2013-01-13 12:06:54.626039100 +0800 +++ sourceold/scripts/dp88_ar.h 2012-08-14 23:00:34.000000000 +0800 @@ -14,71 +14,11 @@ #include "dp88_customAI.h" #include "dp88_custom_timer_defines.h" -// ------------------------------------------------------------------------------------------------- -/*! -* \brief Apocalypse Rising Game Controller -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \arscript -* -* The game controller script for Apocalypse Rising, this should be attached to an editor only object -* on every map. It is currently responsible for the following functionality; -* -* - Map specific Mirage Tank disguises, up to 3 variants per map -* - Random country selection for each team from available countries on the current map -* -* In future the country selection code will have additional logic to spawn country-specific objects -* such as the French Grand Cannon at predetermined markers on the map or enable country specific -* units for purchase. Currently the country selection has no actual effect on the game. -* -* \note -* If no country choices are available for one or both teams the controller will choose from all -* available countries at random as a failsafe mechanism. -* -* \param enableCountry_Russia -* Determines if the controller can select Russia as the Soviet country on this map. 1 to enable, -* 0 to disable. -* \param enableCountry_Cuba -* Determines if the controller can select Cuba as the Soviet country on this map. 1 to enable, -* 0 to disable. -* \param enableCountry_Iraq -* Determines if the controller can select Iraq as the Soviet country on this map. 1 to enable, -* 0 to disable. -* \param enableCountry_Libya -* Determines if the controller can select Libya as the Soviet country on this map. 1 to enable, -* 0 to disable. -* \param enableCountry_America -* Determines if the controller can select America as the Allied country on this map. 1 to enable, -* 0 to disable. -* \param enableCountry_France -* Determines if the controller can select France as the Allied country on this map. 1 to enable, -* 0 to disable. -* \param enableCountry_Germany -* Determines if the controller can select Germany as the Allied country on this map. 1 to enable, -* 0 to disable. -* \param enableCountry_GreatBritain -* Determines if the controller can select Great Britain as the Allied country on this map. 1 to -* enable, 0 to disable. -* \param enableCountry_Korea -* Determines if the controller can select Korea as the Allied country on this map. 1 to enable, -* 0 to disable. -* \param MirageTank_disguisePreset_1 -* The name of the first disguise preset for the Mirage Tank on this map. -* \param MirageTank_disguisePreset_2 -* Optional. The name of the second disguise preset for the Mirage Tank on this map. -* \param MirageTank_disguisePreset_3 -* Optional. The name of the third disguise preset for the Mirage Tank on this map. -* \param warminer_refToOre -* Deprecated, pending removal -* \param warminer_oreToRef -* Deprecated, pending removal -* \param warminer_unloadOre -* Deprecated, pending removal -* \param chronominer_refToOre -* Deprecated, pending removal -* \param chronominer_unloadOre -* Deprecated, pending removal -*/ +/*------------------------ +Game Controller + Game controller for AR maps, set's up map variables and manages several events +--------------------------*/ class dp88_AR_GameController : public ScriptImpClass { @@ -104,11 +44,10 @@ char* mirageTank_disguisePresets[3]; }; -// ------------------------------------------------------------------------------------------------- -/*! -* \deprecated - Early AR development script, keeping it temporarily for terror drone code -*/ + + +// Class for vehicles (redundant, keeping it temporaraily for terror drone code) class dp88_AR_Vehicle : public ScriptImpClass { // Variables @@ -128,6 +67,41 @@ +/*! +* A companion script for dp88_veterancyUnit which grants units health and/or armour +* regeneration dependant upon their promotion level (rookie, veteran, elite) +*/ +class dp88_AR_Veterancy_HealthArmourRegen : public ScriptImpClass +{ + void Created( GameObject *obj ); + void Timer_Expired( GameObject *obj, int number ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); + + private: + int veterancyLevel; +}; + + + + +/*! +* A companion script for dp88_veterancyUnit which grants units a weapon upon creation +* which can subsequently be upgraded to a more powerful weapon when the player gets +* promoted +*/ +class dp88_AR_grantDefaultWeapon : public ScriptImpClass { + + char weaponName[64]; + char oldWeapon[64]; + + void Created( GameObject *obj ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); + void Timer_Expired( GameObject *obj, int number ); +}; + + + + /*------------------------ Deployable Infantry script Allows an infantry unit to 'deploy', which involves switching to @@ -173,9 +147,6 @@ /* Original values for Skin & Armour types */ char undeployedSkinType[128], undeployedArmourType[128]; - - /*! Cached value of SoldierGameObj::Can_Drive_Vehicles() prior to deploying */ - bool m_bCanDrive; }; @@ -217,7 +188,6 @@ /*! * \brief AR Miner Script * \author Daniel Paul (danpaul88@yahoo.co.uk) -* \arscript * * This class contains the basic logic for the ore miners used in Apocalypse Rising and supports both * AI and player controlled miners. A miner can collect ore from any ore fields defined by a script @@ -372,57 +342,19 @@ void Entered( GameObject *obj, GameObject *enterer ); }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief Aircraft Landing Zone -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* Attach this script to a zone to designate the zone as an aircraft landing area. When a game object -* enters or exits the zone it will be sent a custom message, which can be used by other scripts to -* determine if the aircraft is currently in a landing area. -* -* \see dp88_Aircraft_LandingZone_Aircraft -*/ + + +/*------------------------ +VTOL Landing Zone Animation +--------------------------*/ + class dp88_Aircraft_LandingZone : public ScriptImpClass { void Entered( GameObject *obj, GameObject *enterer ); void Exited ( GameObject *obj, GameObject *exiter ); }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Aircraft Landing Zone Animation -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* Plays an animation on the attached object whenever it enters or leaves an aircraft landing zone, -* designated by the presence of the dp88_Aircraft_LandingZone script. Upon entering a landing zone -* the landing animation will be played and upon exiting a landing zone the same animation will be -* played in reverse. This can be used to create a landing gear animation for aircraft. -* -* Optionally the script can also enforce the pilot only exiting the aircraft whilst inside a landing -* zone if the require_landing_zone parameter is set to 1. This will cause the vehicle and pilot to -* both be killed if the pilot attempts to leave the vehicle outside of a landing zone. -* -* \note -* This script supports overlapping landing zones and will only play the reverse animation once the -* aircraft has exited all landing zones. -* -* \param landing_anim_name -* Name of the animation to play upon entering a landing zone (and reverse upon leaving) -* \param landing_anim_first_frame -* First frame number of the landing animation to play -* \param landing_anim_last_frame -* Last frame number of the landing animation to play -* \param require_landing_zone -* Whether to enforce the pilot only exiting inside a landing zone. 1 to enable, 0 to disable -* -* \pre -* To enforce the pilot exiting the aircraft only inside a landing zone this script requires a -* warhead named "Death" to be defined in the armor.ini file and for that warhead to be capable of -* inflicting damage upon both the vehicle and pilot. -*/ class dp88_Aircraft_LandingZone_Aircraft : public ScriptImpClass { void Created ( GameObject *obj ); @@ -433,8 +365,6 @@ unsigned int landingZoneCount; // Since we may be in more than one at a time }; -// ------------------------------------------------------------------------------------------------- - /*------------------------ @@ -452,7 +382,8 @@ char defaultModel[32]; };*/ -// ------------------------------------------------------------------------------------------------- + + /*! * \brief Remote Control Vehicle Console @@ -463,11 +394,6 @@ * dp88_RemoteControlVehicle script attached with a matching remoteControlID parameter to work * correctly * -* \pre -* A preset with the name "Invisible_Object_2" must exist to allow the dummy character to be -* created. You can create this by making a copy of the stock Invisible_Object preset and unticking -* the "IsHiddenObject" parameter to enable it to be damagable. -* * \param remoteControlID * Shared ID used by the console and drones to enable them to be linked correctly - each vehicle * preset should use a unique ID, but multiple consoles can share that vehicles ID @@ -539,7 +465,7 @@ dp88_RemoteControlConsole() : m_pLoopedAnimCtrl(0) {} }; -// ------------------------------------------------------------------------------------------------- + /*------------------------ Remote Control Vehicle script @@ -577,15 +503,12 @@ bool canDetonate; }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief AR Paradrop Console -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \arscript -* -* A paradrop console script for AR, this is currently in active development and subject to change. -*/ + +/*------------------------ +Paradrop Console Script +--------------------------*/ + class dp88_AR_paradrop_Console : public ScriptImpClass { void Created( GameObject *obj ); void Poked ( GameObject *obj, GameObject *poker ); @@ -593,61 +516,19 @@ int last_triggered; }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief AR Paradrop -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \arscript -* -* This script can be attached to an infantry unit which can be paradropped, allowing it to survive -* the impact with the ground and optionally, upon hitting the ground, switch to a new character -* preset. -* -* \pre -* A preset with the name "Invisible_Object" must exist to allow the parachute model to be created -* -* \note -* This script determines an infantry unit has hit the ground when it takes damage from an "Earth" -* warhead OR it's Z velocity decreases, which is checked at an interval of 1 second. -* -* \param Infantry_Preset -* Optional. The name of an infantry preset to switch to when the unit hits the ground -* \param Parachute_Model -* Optional. The name of a W3D model to spawn on the infantry unit whilst it is falling. This will -* be removed when the unit hits the ground -* \param Parachute_Bone -* Optional. The name of a bone on the infantry unit to attach the parachute model to, if any -* \param Animation -* Optional. The name of an animation to play on the infantry unit whilst it is falling -* \param Animation_First_Frame -* The first frame of the falling animation to play -* \param Animation_Last_Frame -* The last frame of the falling animation to play -* \param Animation_Looped -* Whether to loop the falling animation -*/ -class dp88_AR_Paradrop : public ScriptImpClass -{ -public: - dp88_AR_Paradrop() : m_pAnimController(0) {}; -protected: - void Created( GameObject* pObj ); - void Damaged( GameObject* pObj, GameObject* pDamager, float amount ); - void Killed( GameObject* pObj, GameObject* pKilled ); - void Timer_Expired ( GameObject* pObj, int number ); - void Detach(); - - void Landed ( GameObject* pObj ); - - unsigned int earth_warhead; //!< ID of the "Earth" warhead - int m_nParachuteModel; //!< ID of the spawned parachute model, if any - float m_fallRate; //!< Falling speed at last check - LoopedAnimationController* m_pAnimController; -}; +/*------------------------ +Paradrop Script +--------------------------*/ -// ------------------------------------------------------------------------------------------------- +class dp88_AR_paradrop : public ScriptImpClass { + void Created( GameObject *obj ); + void Damaged( GameObject *obj, GameObject* damager, float amount ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); + + bool hit_ground; +}; @@ -656,10 +537,8 @@ // ------------------------------------------------------------------------------------------------- /*! -* \brief Apocalypse Rising Prism Tower +* \brief AR Prism Tower script * \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_basedefences -* \arscript * * This script implements the prism tower logic for Apocalypse Rising on top of the generic charged * turret implementation provided by dp88_AI_ChargedTurret. diff -uwr source/scripts/dp88_ar_unitScripts.cpp sourceold/scripts/dp88_ar_unitScripts.cpp --- source/scripts/dp88_ar_unitScripts.cpp 2013-01-13 12:06:54.563539100 +0800 +++ sourceold/scripts/dp88_ar_unitScripts.cpp 2012-07-28 09:11:06.000000000 +0800 @@ -23,180 +23,70 @@ Rocketeer Script Functions --------------------------*/ -void dp88_AR_Rocketeer::Created ( GameObject* pObj ) +void dp88_AR_Rocketeer::Created ( GameObject *obj ) { - if ( m_nSoldierID != 0 ) // Triggered by the flight vehicle we are also listening too - return; - - if ( !pObj->As_SoldierGameObj() ) - { - Console_Output ( "[%d:%s:%s] Critical Error: This script is only compatible with soldier game objects. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); - return; - } + objectID = Commands->Get_ID ( obj ); + isFlying = false; + isDead = false; + lastDeploy = 0; - if ( strlen(Get_Parameter("Flying_Preset")) <= 0 || !Is_Valid_Preset(Get_Parameter("Flying_Preset")) ) - { - Console_Output ( "[%d:%s:%s] Critical Error: The specified flying preset, \"%s\", is not vaild. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name(), Get_Parameter("Flying_Preset") ); + if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 ) + InstallHook( Get_Parameter("Keyhook"), obj ); + else Destroy_Script(); - return; - } - - m_nSoldierID = Commands->Get_ID(pObj); - m_nVehicleID = 0; - m_lastDeploy = 0; - m_bCanDrive = (pObj->As_SoldierGameObj())->Can_Drive_Vehicles(); - - m_minWalkTime = Get_Int_Parameter("Minimum_Walk_Time"); - m_minFlightTime = Get_Int_Parameter("Minimum_Flight_Time"); - - // Only attach keyhooks to players... but for AI units we might do something clever in future so - // don't destroy the script if it's not an actual player - if (Get_Player_ID(pObj) >= 0) - InstallHook( Get_Parameter("Keyhook"), pObj ); } -// ------------------------------------------------------------------------------------------------- -void dp88_AR_Rocketeer::Custom( GameObject* pObj, int type, int param, GameObject* pSender ) +void dp88_AR_Rocketeer::Destroyed ( GameObject *obj ) { - // Only interested in the flight vehicle being destroyed - if ( m_nVehicleID == Commands->Get_ID(pSender) && type == CUSTOM_ROCKETEER_VEHICLEKILLED ) - { - Commands->Attach_Script ( pObj, "RA_DriverDeath", "" ); + isDead = true; RemoveHook(); - m_nVehicleID = 0; - } } -// ------------------------------------------------------------------------------------------------- -void dp88_AR_Rocketeer::Timer_Expired ( GameObject* pObj, int number ) +void dp88_AR_Rocketeer::Killed( GameObject *obj, GameObject *killer ) { - // Ignore any timer events from the flight vehicle - if ( m_nSoldierID != Commands->Get_ID(pObj) ) - return; - - if ( number == TIMER_ROCKETEER_ENTERVEHICLE ) - { - //Console_Output ( "[%d:%s:%s] Transitioning driver into vehicle\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name() ); - if ( GameObject* pVehicle = Commands->Find_Object(m_nVehicleID) ) - { - Commands->Set_Position( pObj, Commands->Get_Position(pVehicle) ); - Soldier_Transition_Vehicle(pObj); - } - } + isDead = true; + RemoveHook(); } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Rocketeer::KeyHook() { - // Find the soldier object and check they are alive and not on a ladder - GameObject* pObj = Commands->Find_Object(m_nSoldierID); - if ( !pObj || Commands->Get_Health(pObj) <= 0.0f || ((SoldierGameObj*)pObj)->Is_On_Ladder() ) + // Find object + GameObject* obj = Commands->Find_Object ( objectID ); + if ( !obj || isDead || Get_Vehicle(obj) || ((SoldierGameObj*)obj)->Is_On_Ladder() ) return; - // If we are not currently flying then toggle flight mode on - if ( m_nVehicleID == 0 && !Get_Vehicle(pObj) ) + if ( (isFlying && time(NULL) - lastDeploy > Get_Int_Parameter("Minimum_Flight_Time")) || + !isFlying && time(NULL) - lastDeploy > Get_Int_Parameter("Minimum_Walk_Time")) { - if (time(NULL) - m_lastDeploy < m_minWalkTime) - { - StringClass message; - message.Format("You must wait at least %d seconds before activating flying mode", m_minWalkTime ); - Send_Message_Player(pObj, DP88_RGB_WARNING_MSG, message); + isFlying = !isFlying; + Toggle_Fly_Mode(obj); + lastDeploy = time(NULL); } else - Toggle_Flight_Mode ( pObj->As_SoldierGameObj(), true ); - } - - // If we are currently flying then toggle flight mode off - else if ( m_nVehicleID != 0 ) - { - if (time(NULL) - m_lastDeploy < m_minFlightTime) { StringClass message; - message.Format("You must wait at least %d seconds before deactivating flying mode", m_minFlightTime ); - Send_Message_Player(pObj, DP88_RGB_WARNING_MSG, message); - } - else - Toggle_Flight_Mode ( pObj->As_SoldierGameObj(), false ); + message.Format("You must wait at least %d seconds before %s flying mode", (isFlying) ? Get_Int_Parameter("Minimum_Flight_Time") : Get_Int_Parameter("Minimum_Walk_Time"), (isFlying) ? "deactivating": "activating"); + Send_Message_Player(obj,153,204,25,message); } } -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Rocketeer::Toggle_Flight_Mode ( SoldierGameObj* pSoldier, bool bState ) -{ - if ( !pSoldier ) - return; - if ( bState && m_nVehicleID == 0 ) +dp88_AR_Rocketeer::~dp88_AR_Rocketeer() { - if ( !m_bCanDrive ) - (pSoldier->As_SoldierGameObj())->Set_Can_Drive_Vehicles(true); - - // Spawn flight vehicle and listen to its events (specifically the Killed event) - Vector3 pos = Commands->Get_Position(pSoldier); - pos.Z += 0.25; - GameObject* pVehicle = Commands->Create_Object(Get_Parameter("Flying_Preset"),pos); - Commands->Set_Facing(pVehicle, Commands->Get_Facing(pSoldier)); - m_nVehicleID = Commands->Get_ID(pVehicle); - - Attach_Script_V ( pVehicle, "JFW_Death_Send_Custom", "%d,%d,0", Commands->Get_ID(pSoldier), CUSTOM_ROCKETEER_VEHICLEKILLED ); - - // Set the flight vehicles health/armour to match ours - Set_Max_Health(pVehicle,Commands->Get_Max_Health(pSoldier)); - Set_Max_Shield_Strength(pVehicle,Commands->Get_Max_Shield_Strength(pSoldier)); - - Commands->Set_Health(pVehicle,Commands->Get_Health(pSoldier)); - Commands->Set_Shield_Strength(pVehicle,Commands->Get_Shield_Strength(pSoldier)); - - // Need to wait for an engine tick before transitioning the soldier into the vehicle - Commands->Set_Is_Rendered(pSoldier,false); - Commands->Start_Timer ( pSoldier, this, 0.5f, TIMER_ROCKETEER_ENTERVEHICLE ); - - m_lastDeploy = time(NULL); - } - - - - - else if ( !bState && m_nVehicleID != 0 ) + // Turn flying mode off if we buy a new infantry unit... + if ( isFlying && !isDead ) { - GameObject* pVehicle = Commands->Find_Object(m_nVehicleID); - if ( pVehicle ) + GameObject* obj = Commands->Find_Object(objectID); + if ( obj != NULL ) { - Commands->Set_Health(pSoldier,Commands->Get_Health(pVehicle)); - Commands->Set_Shield_Strength(pSoldier,Commands->Get_Shield_Strength(pVehicle)); - - Commands->Destroy_Object(pVehicle); + Toggle_Fly_Mode(obj); } - - m_nVehicleID = 0; - m_lastDeploy = time(NULL); - - Commands->Set_Is_Rendered(pSoldier,true); - - if ( !m_bCanDrive ) - (pSoldier->As_SoldierGameObj())->Set_Can_Drive_Vehicles(false); } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_AR_Rocketeer_Registrant( - "dp88_AR_Rocketeer", - "Flying_Preset:string," - "Keyhook=IDeploy:string," - "Minimum_Flight_Time=5:int," - "Minimum_Walk_Time=5:int" -); - - - - - @@ -673,29 +563,15 @@ void dp88_AR_Tesla_Coil::Created( GameObject *obj ) { - loadSettings(obj, false, false); // No need to support secondary fire - Init(obj); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Tesla_Coil::Init ( GameObject* pSelf ) -{ - dp88_AI_ChargedTurret::Init(pSelf); + // Let the base class handle the main initialization + dp88_AI_Turret::Init(obj); + dp88_AI_Turret::loadSettings(obj, false, false); // Initialize our charge level to 0 m_chargeLevel = 0; m_isSupercharged = false; -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AR_Tesla_Coil::loadSettings ( GameObject* pSelf, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ) -{ - dp88_AI_ChargedTurret::loadSettings(pSelf, loadSecondaryFireSettings, loadBuildingTargetSettings); // Load settings - m_chargeWarheadID = ArmorWarheadManager::Get_Warhead_Type(Get_Parameter("Charge_Warhead")); m_chargeDuration = Get_Int_Parameter("Charge_Duration"); m_chargesPowerOn = Get_Int_Parameter("Charges_Power_On"); m_chargesSupercharge = Get_Int_Parameter("Charges_Supercharge"); @@ -703,45 +579,40 @@ // Grant the supercharged weapon powerup preset and save the name of the default weapon preset if ( Is_Valid_Preset(Get_Parameter("Supercharged_Weapon_Powerup_Preset")) ) { - m_defaultWeapon = Get_Current_Weapon(pSelf); - m_defaultWeaponRange = primary_maxRange; + m_defaultWeapon = Get_Current_Weapon(obj); + m_defaultWeaponRange = this->primary_maxRange; - Commands->Give_PowerUp(pSelf, Get_Parameter("Supercharged_Weapon_Powerup_Preset"), false); + Commands->Give_PowerUp(obj, Get_Parameter("Supercharged_Weapon_Powerup_Preset"), false); m_superchargedWeapon = Get_Powerup_Weapon(Get_Parameter("Supercharged_Weapon_Powerup_Preset")); m_superchargedWeaponRange = Get_Int_Parameter("Supercharged_Weapon_Range"); } } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Tesla_Coil::Damaged ( GameObject *obj, GameObject *damager, float amount ) { - // If the damage was done with the right warhead then increase our charge level, unless the last - // charge from this unit wss within 1 second of the current time - prevents double charges due to - // explosion damage - // \todo fix the 1 second limit - if ( Get_Damage_Warhead() == m_chargeWarheadID /*&& chargerScript->m_lastChargeTime < time(NULL)-1*/ ) + // If the damager has the script dp88_AR_Tesla_Coil_Charger attached then + // increase our charge level - unless their last charge time is within 1 + // second of the current time - prevents double charges due to explosion + // damage + dp88_AR_Tesla_Coil_Charger* chargerScript = (dp88_AR_Tesla_Coil_Charger *)(Find_Script_On_Object(damager, "dp88_AR_Tesla_Coil_Charger")); + if ( chargerScript && chargerScript->m_lastChargeTime < time(NULL)-1 ) { // Increase charge level m_chargeLevel++; // Set chargers last charge time - //chargerScript->m_lastChargeTime = time(NULL); + chargerScript->m_lastChargeTime = time(NULL); // Have we reached a sufficient level to become supercharged? - int supercharge_chargesRequired = (dp88_AI_ChargedTurret::checkPowerState(obj)) ? m_chargesSupercharge : m_chargesPowerOn + m_chargesSupercharge; - if ( !m_isSupercharged && m_chargeLevel >= supercharge_chargesRequired ) + if ( !m_isSupercharged && ((Is_Base_Powered(Get_Object_Type(obj)) && m_chargeLevel >= m_chargesSupercharge) || m_chargeLevel >= m_chargesPowerOn + m_chargesSupercharge) ) setSuperchargedState(obj, true); // Start timer to decrement charge level Commands->Start_Timer(obj, this, (float)m_chargeDuration, TIMER_TESLACOIL_DECREMENT_CHARGE ); } - - // Call base class damaged function - dp88_AI_ChargedTurret::Damaged(obj, damager, amount); } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Tesla_Coil::Timer_Expired ( GameObject* obj, int number ) { @@ -751,25 +622,22 @@ m_chargeLevel--; // Have we dropped out of supercharged status? - int supercharge_chargesRequired = (dp88_AI_ChargedTurret::checkPowerState(obj)) ? m_chargesSupercharge : m_chargesPowerOn + m_chargesSupercharge; - if ( m_isSupercharged && m_chargeLevel < supercharge_chargesRequired ) + if ( m_isSupercharged && !((Is_Base_Powered(Get_Object_Type(obj)) && m_chargeLevel >= m_chargesSupercharge) || m_chargeLevel >= m_chargesPowerOn + m_chargesSupercharge) ) setSuperchargedState(obj, false); } // Call base class timer expired - dp88_AI_ChargedTurret::Timer_Expired(obj, number); + dp88_AI_Turret::Timer_Expired(obj, number); } -// ------------------------------------------------------------------------------------------------- // Returns true if the base is powered, if the defence does not require power, or // if the defence has been charged sufficiently to provide base power bool dp88_AR_Tesla_Coil::checkPowerState ( GameObject* obj ) { - return ( dp88_AI_ChargedTurret::checkPowerState(obj) || m_chargeLevel >= Get_Int_Parameter("Charges_Power_On") ); + return ( !requiresPower || Is_Base_Powered(Get_Object_Type(obj)) || m_chargeLevel >= Get_Int_Parameter("Charges_Power_On") ); } -// ------------------------------------------------------------------------------------------------- // Set the supercharged state void dp88_AR_Tesla_Coil::setSuperchargedState(GameObject* obj, bool state) @@ -792,45 +660,12 @@ } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_AR_Tesla_Coil_Registrant( - "dp88_AR_Tesla_Coil", - "Priority_Infantry=1.0:float," - "Splash_Infantry=0:int," - "Priority_Light_Vehicle=5.0:float," - "Priority_Heavy_Vehicle=7.0:float," - "Priority_VTOL=5.0:float," - "Min_Attack_Range=0:int," - "Max_Attack_Range=80:int," - "Animation_Model:string," - "Animation_Model_Bone:string," - "Animation:string," - "Animation_Idle_Start_Frame:int," - "Animation_Idle_End_Frame:int," - "Animation_Unpowered_Start_Frame:int," - "Animation_Unpowered_End_Frame:int," - "Animation_Charge_Start_Frame:int," - "Animation_Charge_End_Frame:int," - "Charge_Sound:string," - "Charge_Warhead=Tesla:string," - "Charge_Duration=5:int," - "Charges_Supercharge=1:int," - "Charges_Power_On=2:int," - "Supercharged_Weapon_Powerup_Preset:string," - "Supercharged_Weapon_Range=100:int," - "Modifier_Distance=0.25:float," - "Modifier_Target_Damage=0.1:float," - "Modifier_Target_Value=0.05:float," - "Requires_Power=1:int," - "Debug=0:int" -); - - +// Rocketeer +ScriptRegistrant dp88_AR_Rocketeer_Registrant( "dp88_AR_Rocketeer", "Flying_Preset:string,Keyhook=IDeploy:string,Minimum_Flight_Time=5:int,Minimum_Walk_Time=5:int" ); // Mirage Tank ScriptRegistrant dp88_AR_MirageTank_Registrant( "dp88_AR_MirageTank", "" ); @@ -838,3 +673,7 @@ // IFV ScriptRegistrant dp88_AR_IFV_Registrant( "dp88_AR_IFV", "Turret_Frames_Animation=v_all_ifv.v_all_ifv:string,Switch_Time=10:int,Switching_Anim_Frame=2:int,Keyhook=VDeploy:string" ); ScriptRegistrant dp88_AR_IFVDriver_Registrant( "dp88_AR_IFVDriver", "IFV_ModelAnimFrame=1:int,IFV_WeaponPowerup_Rookie=null:string,IFV_WeaponPowerup_Veteran=null:string,IFV_WeaponPowerup_Elite=null:string" ); + +// Tesla Coil +ScriptRegistrant dp88_AR_Tesla_Coil_Registrant("dp88_AR_Tesla_Coil","Priority_Infantry=1.0:float,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Priority_Heavy_Vehicle=7.0:float,Priority_VTOL=5.0:float,Min_Attack_Range=0:int,Max_Attack_Range=80:int,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=1:int,Charge_Duration=5:int,Charges_Supercharge=1:int,Charges_Power_On=2:int,Supercharged_Weapon_Powerup_Preset:string,Supercharged_Weapon_Range=100:int,Debug=0:int"); +ScriptRegistrant dp88_AR_Tesla_Coil_Charger_Registrant("dp88_AR_Tesla_Coil_Charger",""); \ No newline at end of file diff -uwr source/scripts/dp88_ar_unitScripts.h sourceold/scripts/dp88_ar_unitScripts.h --- source/scripts/dp88_ar_unitScripts.h 2013-01-13 12:06:54.688539100 +0800 +++ sourceold/scripts/dp88_ar_unitScripts.h 2012-07-28 09:11:08.000000000 +0800 @@ -13,39 +13,36 @@ #include "dp88_ar.h" -/*! -* \brief Apocalypse Rising Rocketeer -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \arscript -* -* Attached to an infantry unit, this script registers a keyhook that allows the player to toggle -* flying mode on or off. When flying mode is enabled a flying vehicle preset is spawned and the -* infantry unit is automatically transitioned into it. Pressing the keyhook again will cause the -* infantry unit to exit the vehicle, which will then be destroyed. -*/ +/*------------------------ +Rocketeer Script +--------------------------*/ + class dp88_AR_Rocketeer : public JFW_Key_Hook_Base { -public: - dp88_AR_Rocketeer() : m_nSoldierID(0) {}; - -protected: - void Created ( GameObject* pObj ); - void Custom ( GameObject* pObj, int type, int param, GameObject* pSender ); - void Timer_Expired ( GameObject* pObj, int number ); + void Created( GameObject *obj ); + void Destroyed ( GameObject *obj ); + void Killed( GameObject *obj, GameObject *killer ); void KeyHook(); - void Toggle_Flight_Mode ( class SoldierGameObj* pSoldier, bool bState ); - int m_nSoldierID; //!< ID of the infantry unit, since KeyHook doesn't pass an object pointer - int m_nVehicleID; //!< ID of the flight vehicle, if it is currently in use - time_t m_lastDeploy; //!< Timestamp of the last deploy event (to restrict usage) - bool m_bCanDrive; //!< Cached value of SoldierGameObj->Can_Drive_Vehicles() - - /*! \name Cached Script Parameters */ - /*! @{ */ - int m_minWalkTime; - int m_minFlightTime; - /*! @} */ +public: + /* Constructor - necessary to set variables used by destructor (Otherwise LE crashes) */ + dp88_AR_Rocketeer() + { + isFlying = false; + isDead = false; + } +private: + /* Destructor - Technically scripts shouldn't have one but it seems to be the best + way to handle events that need to trigger when you buy a new character to replace + the current one... This is only a temporary fix until we implement the new rocketeer + mechanism anyway. */ + ~dp88_AR_Rocketeer(); + + bool isFlying; + bool isDead; // If isDead the destructor knows we shouldn't try to disable flying mode + int objectID; // ID of infantry unit + time_t lastDeploy; // Timestamp of last deploy keyhook event (prevent constant spamming) }; @@ -126,115 +123,11 @@ -/*! -* \brief Apocalypse Rising Tesla Coil -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_basedefences -* \arscript -* -* Based on my standard charged turret AI, this adds additional logic to allow the defence to be -* both powered up in the absence of base power and supercharged to deal additional damage by -* switching to a second weapon preset (which should be setup to deal more damage than the normal -* weapon preset). -* -* The Tesla Coil can be powered up and supercharged by shooting it with a specific warhead defined -* in the script parameters. Each time the coil is hit by a weapon of that warhead will add 1 to the -* charge level. Note that each unit can only charge the defence at most once a second and multiple -* units may work together to increase the charge level. -* -* For more information about the charge up logic see the documentation for dp88_AI_ChargedTurret -* -* \note -* This script does not currently support the use of secondary fire, therefore the parameters -* relevant to secondary fire are not present. -* -* \param Priority_Infantry -* Base targetting priority for infantry targets, or 0 to ignore infantry -* \param Splash_Infantry -* Determines if we should try to damage infantry with splash instead of hitting them directly. -* This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable -* \param Priority_Light_Vehicle -* Base targetting priority for light vehicle targets, or 0 to ignore light vehicles -* \param Priority_Heavy_Vehicle -* Base targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles -* \param Priority_VTOL -* Base targetting priority for flying targets, or 0 to ignore flying targets -* \param Min_Attack_Range -* Minimum distance at which the turret can engage enemies when using primary fire -* \param Max_Attack_Range -* Maximum distance at which the turret can engage enemies when using primary fire -* \param Animation_Model -* Optional name of a W3D model file to spawn and attach to the turret upon which the charge -* animations defined in this script will be applied. This allows the turret itself to be running -* a different set of animations, such as damage states via dp88_damageAnimation -* \param Animation_Model_Bone -* If you specify an Animation_Model above then you must also specify the a bone on the parent -* to which that model should be attached. This allows the animation model to be moved by the -* animation set executing on the turret. -* \param Animation -* Name of the animation which contains the frames for the various charge states -* \param Animation_Idle_Start_Frame -* First frame number for the idle animation, which will loop continually whilst the turret is -* powered and not currently attacking a target -* \param Animation_Idle_End_Frame -* Final frame number for the idle animation -* \param Animation_Unpowered_Start_Frame -* First frame number for the unpowered animation, which will loop continually whilst the turret -* is in the unpowered state. This is not used if Requires_Power is disabled (see below). -* \param Animation_Unpowered_End_Frame -* Final frame number for the unpowered animation -* \param Animation_Charge_Start_Frame -* First frame number for the charging animation, which will be played once each time the turret -* reloads its weapon. Once this animation completes the turret will fire again, therefore the -* length of this animation must be greater than the weapon reload time. -* \param Animation_Charge_End_Frame -* Final frame number for the charging animation -* \param Charge_Sound -* Optional sound effect to be played each time the turret starts charging up -* \param Charge_Warhead -* The name of a warhead in armor.ini which can be used to charge up this tesla coil -* \param Charge_Duration -* How long, in seconds, a charge from a unit lasts -* will last before it expires. -* \param Charges_Supercharge -* The charge level required to supercharge the defence, causing it to switch to the supercharged -* weapon preset. Note that if base power is disabled the number of charges required is this value -* plus the value of the Charges_Power_On parameter (see below) -* \param Charges_Power_On -* The charge level required to provide power to the defence when the base power is offline. If -* this charge level is reached the defence will operate as normal until the charge level drops -* below the required threshold again -* \param Supercharged_Weapon_Powerup_Preset -* The name of a powerup which grants the weapon preset to be used when the defence is in -* supercharged mode -* \param Supercharged_Weapon_Range -* The maximum attack range to use when the defence is in supercharged mode, this overrides the -* Max_Attack_Range parameter to allow the defence weapon to target enemies at a greater distance -* whilst it is using the supercharged weapon -* \param Modifier_Distance -* Priority modification to apply based on distance to target. Higher values will favour targets -* which are closer to the turret, good for less accurate weapons -* \param Modifier_Target_Damage -* Priority modification to apply based on damage a target has already sustained. Higher values -* will favour targets which have already been damaged in combat, picking them off first. -* \param Modifier_Target_Value -* Priority modification to apply based on the value of the target. Higher values will favour -* targets with a higher purchase cost, good for hard hitting weapons. -* \param Requires_Power -* Specify whether this turret requires base power to operate: 1 to require power, 0 to ignore -* \param Debug -* Specify whether to produce a debug logfile about the turrets targetting decisions, this is -* useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable. -* -* \note -* Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker -* script attached to them. -* -* \warning -* Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones -* machines with useless text files everywhere... people usually don't like that :D -*/ -class dp88_AR_Tesla_Coil : public dp88_AI_ChargedTurret +/*------------------------ +Tesla Coil Script +--------------------------*/ + +class dp88_AR_Tesla_Coil : public dp88_AI_Turret { /* ----- Events @@ -244,10 +137,6 @@ void Damaged ( GameObject *obj, GameObject *damager, float amount ); void Timer_Expired ( GameObject *obj, int number ); - // Custom AI initialisation script overloads - virtual void Init( GameObject *obj ); - virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings = true, bool loadBuildingTargetSettings = false ); - // Overload the checkPowerState function to return true when sufficient // charge level exists to provide power virtual bool checkPowerState(GameObject* obj); @@ -271,8 +160,19 @@ int m_superchargedWeaponRange; // Settings - unsigned int m_chargeWarheadID; int m_chargeDuration; int m_chargesPowerOn; int m_chargesSupercharge; }; \ No newline at end of file + + +// Dummy script to mark a unit as being able to charge a tesla coil +class dp88_AR_Tesla_Coil_Charger : public ScriptImpClass +{ +public: + dp88_AR_Tesla_Coil_Charger() { m_lastChargeTime = 0; }; + + // Used by dp88_AR_Tesla_Coil to track last charge times - used to + // prevent double charges due to explosion damage + time_t m_lastChargeTime; +}; \ No newline at end of file diff -uwr source/scripts/dp88_buildingScripts.cpp sourceold/scripts/dp88_buildingScripts.cpp --- source/scripts/dp88_buildingScripts.cpp 2013-01-13 12:06:54.813539100 +0800 +++ sourceold/scripts/dp88_buildingScripts.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -25,34 +25,43 @@ #include "PhysicalGameObj.h" #include "ArmorWarheadManager.h" -// ------------------------------------------------------------------------------------------------- - -extern REF_DECL2(NodHouseColor, Vector3); -extern REF_DECL2(GDIHouseColor, Vector3); -extern REF_DECL2(PublicMessageColor, Vector3); - -// ------------------------------------------------------------------------------------------------- - /*------------------------ Building Controller Script --------------------------*/ -void dp88_buildingScripts_controller::Created ( GameObject *obj ) +void dp88_buildingScripts_buildingController::Created ( GameObject *obj ) { numChildren = 0; children = NULL; buildingOnline = true; - /* Get string IDs and for each one determine if it has a valid sound attached to it */ - team0_buildingOfflineStringId = Get_String_ID_By_Desc(Get_Parameter("Team_0_Building_Offline_String")); - team1_buildingOfflineStringId = Get_String_ID_By_Desc(Get_Parameter("Team_1_Building_Offline_String")); - team0_buildingOnlineStringId = Get_String_ID_By_Desc(Get_Parameter("Team_0_Building_Online_String")); - team1_buildingOnlineStringId = Get_String_ID_By_Desc(Get_Parameter("Team_1_Building_Online_String")); + team0_buildingOfflineSoundId = 0; + team1_buildingOfflineSoundId = 0; + team0_buildingOnlineSoundId = 0; + team1_buildingOnlineSoundId = 0; + + /* Get string IDs and for each one determine if it has a valid sound + attached to it */ + unsigned long soundId; + team0_buildingOfflineStringId = (Is_Valid_String_ID(Get_Int_Parameter("team0_buildingOfflineStringId"))) ? Get_Int_Parameter("team0_buildingOfflineStringId") : 0; + if ( team0_buildingOfflineStringId && (soundId = Get_String_Sound_ID(team0_buildingOfflineStringId)) != 0 && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000 ) + team0_buildingOfflineSoundId = soundId; + + team1_buildingOfflineStringId = (Is_Valid_String_ID(Get_Int_Parameter("team1_buildingOfflineStringId"))) ? Get_Int_Parameter("team1_buildingOfflineStringId") : 0; + if ( team1_buildingOfflineStringId && (soundId = Get_String_Sound_ID(team1_buildingOfflineStringId)) != 0 && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000 ) + team1_buildingOfflineSoundId = soundId; + + team0_buildingOnlineStringId = (Is_Valid_String_ID(Get_Int_Parameter("team0_buildingOnlineStringId"))) ? Get_Int_Parameter("team0_buildingOnlineStringId") : 0; + if ( team0_buildingOnlineStringId && (soundId = Get_String_Sound_ID(team0_buildingOnlineStringId)) != 0 && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000 ) + team0_buildingOnlineSoundId = soundId; + + team1_buildingOnlineStringId = (Is_Valid_String_ID(Get_Int_Parameter("team1_buildingOnlineStringId"))) ? Get_Int_Parameter("team1_buildingOnlineStringId") : 0; + if ( team1_buildingOnlineStringId && (soundId = Get_String_Sound_ID(team1_buildingOnlineStringId)) != 0 && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000 ) + team1_buildingOnlineSoundId = soundId; } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_controller::Destroyed ( GameObject *obj ) +void dp88_buildingScripts_buildingController::Destroyed ( GameObject *obj ) { // Clean up memory if it is still allocated if ( children != NULL ) @@ -63,9 +72,8 @@ } } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_controller::Killed ( GameObject* obj, GameObject* killer ) +void dp88_buildingScripts_buildingController::Killed ( GameObject* obj, GameObject* killer ) { // Do we have any children? if ( children != NULL ) @@ -86,9 +94,8 @@ } } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_controller::Custom( GameObject *obj, int type, int param, GameObject *sender ) +void dp88_buildingScripts_buildingController::Custom( GameObject *obj, int type, int param, GameObject *sender ) { // Child object registrations if ( type == CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD && sender != NULL ) @@ -226,10 +233,22 @@ /* Send messages to teams */ if ( team0_buildingOfflineStringId ) - Send_Translated_Message_Team( team0_buildingOfflineStringId, 0, 255,255,255 ); + { + const char *str = Get_Translated_String(team0_buildingOfflineStringId); + Send_Message_Team(0,255,255,255,str); + delete[] str; + if ( team0_buildingOfflineSoundId ) + Create_2D_Sound_Team(Get_Definition_Name(team0_buildingOfflineSoundId),0); + } if ( team1_buildingOfflineStringId ) - Send_Translated_Message_Team( team1_buildingOfflineStringId, 1, 255,255,255 ); + { + const char *str = Get_Translated_String(team1_buildingOfflineStringId); + Send_Message_Team(1,255,255,255,str); + delete[] str; + if ( team1_buildingOfflineSoundId ) + Create_2D_Sound_Team(Get_Definition_Name(team1_buildingOfflineSoundId),1); + } } } } @@ -347,10 +366,22 @@ /* Send messages to teams */ if ( team0_buildingOnlineStringId ) - Send_Translated_Message_Team( team0_buildingOnlineStringId, 0, 255,255,255 ); + { + const char *str = Get_Translated_String(team0_buildingOnlineStringId); + Send_Message_Team(0,255,255,255,str); + delete[] str; + if ( team0_buildingOnlineSoundId ) + Create_2D_Sound_Team(Get_Definition_Name(team0_buildingOnlineSoundId),0); + } if ( team1_buildingOnlineStringId ) - Send_Translated_Message_Team( team1_buildingOnlineStringId, 1, 255,255,255 ); + { + const char *str = Get_Translated_String(team1_buildingOnlineStringId); + Send_Message_Team(1,255,255,255,str); + delete[] str; + if ( team1_buildingOnlineSoundId ) + Create_2D_Sound_Team(Get_Definition_Name(team1_buildingOnlineSoundId),1); + } } } } @@ -394,9 +425,10 @@ } } -// ------------------------------------------------------------------------------------------------- -int dp88_buildingScripts_controller::findChild ( int objectId ) +// Finds the position of the given object ID in the children array, otherwise returns -1 if it +// is not found +int dp88_buildingScripts_buildingController::findChild ( int objectId ) { // Do we have any children to search? if ( children != NULL ) @@ -414,597 +446,390 @@ return -1; } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_controller_Registrant( - "dp88_buildingScripts_controller", - "Team_0_Building_Offline_String:string," - "Team_1_Building_Offline_String:string," - "Team_0_Building_Online_String:string," - "Team_1_Building_Online_String:string" -); - - - - - /*------------------------ -Building scripts base class +Building Repair Node --------------------------*/ -dp88_buildingScripts_baseClass::dp88_buildingScripts_baseClass() -{ - m_parentId = -1; -} - -// ------------------------------------------------------------------------------------------------- - -GameObject* dp88_buildingScripts_baseClass::RegisterWithParent ( GameObject* obj, const char* preset_name, int type ) -{ - GameObject* parent = Find_Closest_Preset_By_Team( Get_Object_Type(obj), Commands->Get_Position(obj), preset_name ); - if ( !parent ) +void dp88_buildingScripts_repairNode::Created ( GameObject *obj ) { - Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), preset_name ); - Destroy_Script(); - return NULL; - } - - // Send with 0.5 second delay to ensure parent has been initialized - m_parentId = Commands->Get_ID(parent); - Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, type, 0.5f ); - return parent; -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_baseClass::Custom ( GameObject *obj, int type, int param, GameObject *sender ) -{ - if ( (m_parentId == -1 && obj == sender) - || (m_parentId != -1 && Commands->Get_ID(sender) == m_parentId ) ) - { - if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGOFFLINE ) - return OnBuildingOffline(obj); - if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGONLINE ) - return OnBuildingOnline(obj); - if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED ) - return OnBuildingCaptured(obj, param); - if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED ) - { - OnBuildingDestroyed(obj); - m_parentId = -1; - return; - } - } - - OnCustom(obj,type,param,sender); -} - - - - - - - - -/*------------------------ -Building component base class ---------------------------*/ - -dp88_buildingScripts_componentBaseClass::dp88_buildingScripts_componentBaseClass() + // Find parent + GameObject* parent = Find_Object_By_Preset ( Get_Object_Type ( obj ), Get_Parameter("buildingControllerPreset") ); + if ( parent != NULL ) { - m_pAnimController = NULL; // Prevent LE crash when Detach() is destroyed -} + parentId = Commands->Get_ID ( parent ); -// ------------------------------------------------------------------------------------------------- + // Send with 1 second delay to ensure parent has been initialized + Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_GENERIC, 1.0f ); -void dp88_buildingScripts_componentBaseClass::Detach( GameObject* obj ) -{ - delete m_pAnimController; - OnDetach(obj); + // Attach link health script - no point cloning its functionality here + char scriptParams[20]; + sprintf_s ( scriptParams, sizeof(scriptParams), "%d", Commands->Get_ID(parent) ); + Commands->Attach_Script(obj,"dp88_linkHealth",scriptParams); } - -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_componentBaseClass::PlayAnimation( GameObject* obj, const char* animation, int nStartFrame, int nEndFrame, bool bLooped ) -{ - if ( animation == NULL || strlen(animation) == 0 ) + else { - if (m_pAnimController) - m_pAnimController->StopAnimation(); - return; + Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), Get_Parameter("buildingControllerPreset") ); + Destroy_Script(); } - - if ( m_pAnimController == NULL ) - m_pAnimController = new LoopedAnimationController(obj); - - m_pAnimController->StopAnimation(); - m_pAnimController->PlayAnimation(animation, nStartFrame, nEndFrame, (bLooped)?0:1); } - - - - - - -/*------------------------ -Building component script ---------------------------*/ - -void dp88_buildingScripts_component::Created ( GameObject *obj ) +void dp88_buildingScripts_repairNode::Custom( GameObject *obj, int type, int param, GameObject *sender ) { - if ( !RegisterWithParent(obj, Get_Parameter("Building_Controller_Preset"), BUILDING_CHILD_TYPE_GENERIC) ) - return; - - PlayAnimation ( obj, - Get_Parameter("Animation_Name"), - Get_Int_Parameter("Animation_Start_Frame"), - Get_Int_Parameter("Animation_End_Frame"), - (Get_Int_Parameter("Animation_Looped")==1) ); - - // Attach link health script - no point cloning its functionality here - Attach_Script_V ( obj,"dp88_linkHealth", "%d", m_parentId ); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_component::OnBuildingDestroyed( GameObject *obj ) + // Parent building destroyed, spawn dead preset + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED && Commands->Get_ID(sender) == parentId ) { // Spawn dead preset - const char* deadPreset = Get_Parameter("Dead_Preset"); - if ( Is_Valid_Preset(deadPreset) ) + if ( Is_Valid_Preset ( Get_Parameter("dead_preset") ) ) { - GameObject* dead = Commands->Create_Object( deadPreset, Commands->Get_Position(obj) ); + GameObject* dead = Commands->Create_Object ( Get_Parameter("dead_preset"), Commands->Get_Position(obj) ); Commands->Set_Facing( dead, Commands->Get_Facing(obj) ); } // And kill ourself Commands->Apply_Damage( obj, 1000.0f, "Death", obj ); } - -// ------------------------------------------------------------------------------------------------- - -// Registrar -ScriptRegistrant dp88_buildingScripts_component_Registrant( - "dp88_buildingScripts_component", - "Building_Controller_Preset:string," - "Animation_Name:string," - "Animation_Start_Frame=0:int," - "Animation_End_Frame=0:int," - "Animation_Looped=0:int," - "Dead_Preset=null:string" -); - - - - +} /*------------------------ -Major weakpoint script +Weakpoint - Destroy Building Script --------------------------*/ -void dp88_buildingScripts_majorWeakpoint::Created ( GameObject *obj ) +void dp88_buildingScripts_weakpoint_destroyBuilding::Created ( GameObject *obj ) { - if ( !RegisterWithParent(obj, Get_Parameter("Building_Controller_Preset"), BUILDING_CHILD_TYPE_MAJOR_WEAKPOINT) ) - return; + // Find parent + GameObject* parent = Find_Object_By_Preset ( Get_Object_Type ( obj ), Get_Parameter("buildingControllerPreset") ); + if ( parent != NULL ) + { + parentId = Commands->Get_ID ( parent ); - PlayAnimation ( obj, - Get_Parameter("Animation_Name"), - Get_Int_Parameter("Animation_Start_Frame"), - Get_Int_Parameter("Animation_End_Frame"), - (Get_Int_Parameter("Animation_Looped")==1) ); + // Send with 1 second delay to ensure parent has been initialized + Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_MAJOR_WEAKPOINT, 1.0f ); + } + else + { + Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), Get_Parameter("buildingControllerPreset") ); + Destroy_Script(); + } } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_majorWeakpoint::Killed ( GameObject* obj, GameObject* killer ) +void dp88_buildingScripts_weakpoint_destroyBuilding::Killed ( GameObject* obj, GameObject* killer ) { - // This might not be the only major weakpoint so send a custom to the building controller to let - // it know we are dead and it can decide what to do... include the killers ID so they are credited - // with destroying the building if all major weakpoints are now dead - GameObject* parent = Commands->Find_Object ( m_parentId ); + // This might not be the only major weakpoint so send a custom to the building controller to + // let it know we are dead and it can decide what to do... include the killers ID so they are + // credited with destroying the building + GameObject* parent = Commands->Find_Object ( parentId ); if ( parent != NULL ) Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_CHILDDESTROYED, Commands->Get_ID(killer), 0.0f ); // Spawn dead preset - if ( Is_Valid_Preset ( Get_Parameter("Dead_Preset") ) ) + if ( Is_Valid_Preset ( Get_Parameter("dead_preset") ) ) { - GameObject* dead = Commands->Create_Object ( Get_Parameter("Dead_Preset"), Commands->Get_Position(obj) ); + GameObject* dead = Commands->Create_Object ( Get_Parameter("dead_preset"), Commands->Get_Position(obj) ); Commands->Set_Facing ( dead, Commands->Get_Facing(obj) ); } } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_majorWeakpoint::OnBuildingDestroyed( GameObject *obj ) +void dp88_buildingScripts_weakpoint_destroyBuilding::Custom( GameObject *obj, int type, int param, GameObject *sender ) { - // Spawn dead preset - const char* deadPreset = Get_Parameter("Dead_Preset"); - if ( Is_Valid_Preset(deadPreset) ) - { - GameObject* dead = Commands->Create_Object( deadPreset, Commands->Get_Position(obj) ); - Commands->Set_Facing( dead, Commands->Get_Facing(obj) ); + // Parent building now dead, set parentId to -1 to prevent Find_Object returning a non-NULL result and + // potentially causing a pure virtual function call when we try to send the dead building a custom + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED && Commands->Get_ID(sender) == parentId ) + parentId = -1; } - // And kill ourself - Commands->Apply_Damage( obj, 1000.0f, "Death", obj ); -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_majorWeakpoint_Registrant( - "dp88_buildingScripts_majorWeakpoint", - "Building_Controller_Preset:string," - "Animation_Name:string," - "Animation_Start_Frame=0:int," - "Animation_End_Frame=0:int," - "Animation_Looped=0:int," - "Dead_Preset=null:string" -); - - - - - /*------------------------ -Minor weakpoint script +Base Class For Generic Weakpoints --------------------------*/ -void dp88_buildingScripts_minorWeakpoint::Created ( GameObject *obj ) +void MinorWeakpointScriptClass::Created ( GameObject *obj ) { - if ( !RegisterWithParent(obj, Get_Parameter("Building_Controller_Preset"), BUILDING_CHILD_TYPE_MINOR_WEAKPOINT) ) - return; + // Set variables + isDestroyed = false; + m_pLoopedAnimCtrl = NULL; + // Find parent + GameObject* parent = Find_Object_By_Preset ( Get_Object_Type ( obj ), Get_Parameter("buildingControllerPreset") ); + if ( parent != NULL ) + { + parentId = Commands->Get_ID ( parent ); - m_bIsDestroyed = false; - UpdateAnimation(obj); + // Send with 1 second delay to ensure parent has been initialized + Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_MINOR_WEAKPOINT, 1.0f ); + m_pLoopedAnimCtrl = new LoopedAnimationController(obj); + // Set animation + if ( strlen(Get_Parameter("animName")) > 0 ) + { + m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("animName"),Get_Int_Parameter("animStartFrame"),Get_Int_Parameter("animEndFrame"),!Get_Int_Parameter("animLoop")); + } + } + else + { + Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying weakpoint script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), Get_Parameter("buildingControllerPreset") ); + Destroy_Script(); + } } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_minorWeakpoint::Damaged ( GameObject *obj, GameObject *damager, float amount ) -{ - /* Has this weakpoint been "destroyed"? */ - if ( !m_bIsDestroyed && Commands->Get_Shield_Strength(obj) == 0 ) +void MinorWeakpointScriptClass::Damaged ( GameObject *obj, GameObject *damager, float amount ) { - m_bIsDestroyed = true; - - // Send message to game controller indicating we have been destroyed - GameObject* parent = Commands->Find_Object ( m_parentId ); + /* If we are repairable, not destroyed and have 0 shield strength then + disable soldier purchases and set destroyed flag. */ + if ( !isDestroyed && Commands->Get_Shield_Strength(obj) == 0 ) + { + isDestroyed = true; + + // Send message to game controller indicating we have been destroyed. If this is the + // last minor weakpoint to be destroyed our parent will send us a custom indicating + // the building is now offline and instructing us to apply our weakpoint effect + GameObject* parent = Commands->Find_Object ( parentId ); if ( parent != NULL ) Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_CHILDDESTROYED, 0, 0.0f ); // Set animation - UpdateAnimation(obj); + if ( strlen(Get_Parameter("destroyedAnimName")) > 0 ) + { + m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("destroyedAnimName"),Get_Int_Parameter("destroyedAnimStartFrame"),Get_Int_Parameter("destroyedAnimEndFrame"),!Get_Int_Parameter("destroyedAnimLoop")); + } + else + { + m_pLoopedAnimCtrl->StopAnimation(); + } } - // Don't permit any repairs if the parent building is dead - if ( m_parentId == -1 && amount < 0.0f ) - Commands->Set_Shield_Strength(obj, 0); - - - /* Has this weakpoint been fully repaired? */ - else if ( m_bIsDestroyed && amount <= 0.0f && Commands->Get_Shield_Strength(obj) == Commands->Get_Max_Shield_Strength(obj) ) + /* If we are repairable, destroyed and have been repaired to 100% health then + re-enable soldier purchases and unset destroyed flag */ + if ( isDestroyed && amount <= 0.0f && Commands->Get_Shield_Strength(obj) == Commands->Get_Max_Shield_Strength(obj) ) { - m_bIsDestroyed = false; + isDestroyed = false; - // Send message to game controller indicating we have been repaired - GameObject* parent = Commands->Find_Object ( m_parentId ); + // Send message to game controller indicating we have been repaired. If this is the + // last minor weakpoint to be repaired our parent will send us a custom indicating + // the building is now online and instructing us to reverse our weakpoint effect + GameObject* parent = Commands->Find_Object ( parentId ); if ( parent != NULL ) Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_CHILDREPAIRED, 0, 0.0f ); // Set animation - UpdateAnimation(obj); + if ( strlen(Get_Parameter("animName")) > 0 ) + { + m_pLoopedAnimCtrl->PlayAnimation(Get_Parameter("animName"),Get_Int_Parameter("animStartFrame"),Get_Int_Parameter("animEndFrame"),!Get_Int_Parameter("animLoop")); + } + else + { + m_pLoopedAnimCtrl->StopAnimation(); + } } } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_minorWeakpoint::Killed ( GameObject* obj, GameObject* killer ) +void MinorWeakpointScriptClass::Killed ( GameObject* obj, GameObject* killer ) { // A minor weakpoint should never be killed... they should be repairable Console_Output ( "[%d:%s:%s] Script Error: A minor weakpoint has been killed...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name() ); } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_minorWeakpoint::OnBuildingDestroyed( GameObject *obj ) +void MinorWeakpointScriptClass::Custom( GameObject *obj, int type, int param, GameObject *sender ) { - m_bIsDestroyed = true; - Commands->Set_Shield_Strength(obj, 0); - UpdateAnimation(obj); - // Don't call Destroy_Script(), this will stop the destroyed animation -} + GameObject* parent = Commands->Find_Object ( parentId ); + if ( parent == NULL ) + return; -// ------------------------------------------------------------------------------------------------- + // Parent building now dead, set parentId to -1 to prevent Find_Object returning a non-NULL result and + // potentially causing a pure virtual function call when we try to send the dead building a custom + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED && Commands->Get_ID(sender) == parentId ) + parentId = -1; -void dp88_buildingScripts_minorWeakpoint::UpdateAnimation( GameObject* obj ) -{ - if ( !m_bIsDestroyed ) - { - PlayAnimation ( obj, - Get_Parameter("Animation_Name"), - Get_Int_Parameter("Animation_Start_Frame"), - Get_Int_Parameter("Animation_End_Frame"), - (Get_Int_Parameter("Animation_Looped")==1) ); + // Parent building now offline, if param is 1 we need to apply our offline effect (param 1 means this + // was the last weakpoint to die, hence this one is chosen to apply the effects) + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGOFFLINE && Commands->Get_ID(sender) == parentId && param == 1 ) + applyEffect ( obj, parent ); + + // Parent building now online, if param is 1 we need to reverse our offline effect (param 1 means this + // was the last weakpoint to die, hence this one is chosen to reverse the effects) + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGONLINE && Commands->Get_ID(sender) == parentId && param == 1 ) + reverseEffect ( obj, parent ); } - else +void MinorWeakpointScriptClass::Detach ( GameObject *obj ) { - PlayAnimation ( obj, - Get_Parameter("Destroyed_Animation_Name"), - Get_Int_Parameter("Destroyed_Animation_Start_Frame"), - Get_Int_Parameter("Destroyed_Animation_End_Frame"), - (Get_Int_Parameter("Destroyed_Animation_Looped")==1) ); + if (m_pLoopedAnimCtrl) + { + delete m_pLoopedAnimCtrl; } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_minorWeakpoint_Registrant( - "dp88_buildingScripts_minorWeakpoint", - "Building_Controller_Preset:string," - "Animation_Name:string," - "Animation_Start_Frame=0:int," - "Animation_End_Frame=0:int," - "Animation_Looped=0:int," - "Destroyed_Animation_Name:string," - "Destroyed_Animation_Start_Frame=0:int," - "Destroyed_Animation_End_Frame=0:int," - "Destroyed_Animation_Looped=0:int" -); - - - - - - /*------------------------ -Building function - Produce Infantry +Weakpoint - Disable Soldier Purchase --------------------------*/ -void dp88_buildingScripts_functionProduceInfantry::OnBuildingOffline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableSoldierPurchase::applyEffect ( GameObject* obj, GameObject* parent ) { - Set_Can_Generate_Soldiers ( Get_Object_Type(obj), false ); + Set_Can_Generate_Soldiers ( Get_Object_Type(parent), false ); } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionProduceInfantry::OnBuildingOnline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableSoldierPurchase::reverseEffect ( GameObject* obj, GameObject* parent ) { - Set_Can_Generate_Soldiers ( Get_Object_Type(obj), true ); + Set_Can_Generate_Soldiers ( Get_Object_Type(parent), true ); } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionProduceInfantry_Registrant( - "dp88_buildingScripts_functionProduceInfantry", - "" -); - - - - - /*------------------------ -Building function - Produce Vehicles +Weakpoint - Disable Vehicle Purchase --------------------------*/ -void dp88_buildingScripts_functionProduceVehicles::OnBuildingOffline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableVehiclePurchase::applyEffect ( GameObject* obj, GameObject* parent ) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_VehicleFactoryGameObj()) + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_VehicleFactoryGameObj()) { - obj->As_BuildingGameObj()->As_VehicleFactoryGameObj()->Set_Disabled(true); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(true); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_SECRET_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(true); + parent->As_BuildingGameObj()->As_VehicleFactoryGameObj()->Set_Disabled(true); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(true); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_SECRET_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(true); } } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionProduceVehicles::OnBuildingOnline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableVehiclePurchase::reverseEffect ( GameObject* obj, GameObject* parent ) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_VehicleFactoryGameObj()) + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_VehicleFactoryGameObj()) { - obj->As_BuildingGameObj()->As_VehicleFactoryGameObj()->Set_Disabled(false); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(false); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_SECRET_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(false); + parent->As_BuildingGameObj()->As_VehicleFactoryGameObj()->Set_Disabled(false); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(false); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_SECRET_VEHICLES,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(false); } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionProduceVehicles_Registrant( - "dp88_buildingScripts_functionProduceVehicles", - "" -); - - - - - - - /*------------------------ -Building function - Produce Aircraft +Weakpoint - Disable Air Vehicle Purchase --------------------------*/ -void dp88_buildingScripts_functionProduceAircraft::OnBuildingOffline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableAirVehiclePurchase::applyEffect ( GameObject* obj, GameObject* parent ) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_AirFactoryGameObj()) + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_AirFactoryGameObj()) { - obj->As_BuildingGameObj()->As_AirFactoryGameObj()->Set_Disabled(true); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_AIR,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(true); + parent->As_BuildingGameObj()->As_AirFactoryGameObj()->Set_Disabled(true); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_AIR,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(true); } } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionProduceAircraft::OnBuildingOnline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableAirVehiclePurchase::reverseEffect ( GameObject* obj, GameObject* parent ) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_AirFactoryGameObj()) + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_AirFactoryGameObj()) { - obj->As_BuildingGameObj()->As_AirFactoryGameObj()->Set_Disabled(false); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_AIR,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(false); + parent->As_BuildingGameObj()->As_AirFactoryGameObj()->Set_Disabled(false); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_AIR,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(false); } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionProduceAircraft_Registrant( - "dp88_buildingScripts_functionProduceAircraft", - "" -); - - - - - - - - /*------------------------ -Building function - Produce Naval Units +Weakpoint - Disable Naval Vehicle Purchase --------------------------*/ -void dp88_buildingScripts_functionProduceNavalUnits::OnBuildingOffline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase::applyEffect ( GameObject* obj, GameObject* parent ) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_NavalFactoryGameObj()) + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_NavalFactoryGameObj()) { - obj->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(true); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(true); + parent->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(true); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(true); } } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionProduceNavalUnits::OnBuildingOnline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase::reverseEffect ( GameObject* obj, GameObject* parent ) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_NavalFactoryGameObj()) + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_NavalFactoryGameObj()) { - obj->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(false); - PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(obj)))->Set_Page_Disabled(false); + parent->As_BuildingGameObj()->As_NavalFactoryGameObj()->Set_Disabled(false); + PurchaseSettingsDefClass::Find_Definition(PurchaseSettingsDefClass::TYPE_NAVAL,(PurchaseSettingsDefClass::TEAM)PTTEAM(Get_Object_Type(parent)))->Set_Page_Disabled(false); } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionProduceNavalUnits_Registrant( - "dp88_buildingScripts_functionProduceNavalUnits", - "" -); - - - - - - - - /*------------------------ -Building function - Provide Power +Weakpoint - Disable Base Power --------------------------*/ -void dp88_buildingScripts_functionProvidePower::OnBuildingOffline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableBasePower::applyEffect ( GameObject* obj, GameObject* parent ) { - Power_Base ( Get_Object_Type(obj), false ); + Power_Base ( Get_Object_Type(parent), false ); } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionProvidePower::OnBuildingOnline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableBasePower::reverseEffect ( GameObject* obj, GameObject* parent ) { - Power_Base ( Get_Object_Type(obj), true ); + Power_Base ( Get_Object_Type(parent), true ); } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionProvidePower_Registrant( - "dp88_buildingScripts_functionProvidePower", - "" -); - - - - - - - /*------------------------ -Building function - Provide Radar +Weakpoint - Disable Radar --------------------------*/ -void dp88_buildingScripts_functionProvideRadar::OnBuildingOffline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableRadar::applyEffect ( GameObject* obj, GameObject* parent ) { - Enable_Base_Radar ( Get_Object_Type(obj), false ); + Enable_Base_Radar ( Get_Object_Type(parent), false ); } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionProvideRadar::OnBuildingOnline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableRadar::reverseEffect ( GameObject* obj, GameObject* parent ) { - Enable_Base_Radar ( Get_Object_Type(obj), true ); + Enable_Base_Radar ( Get_Object_Type(parent), true ); } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionProvideRadar_Registrant( - "dp88_buildingScripts_functionProvideRadar", - "" -); - - - - - - - /*------------------------ -Building function - Provide Harvester +Weakpoint - Disable Refinery --------------------------*/ -void dp88_buildingScripts_functionProvideHarvester::OnBuildingOffline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableRefinery::applyEffect ( GameObject* obj, GameObject* parent ) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_RefineryGameObj()) - obj->As_BuildingGameObj()->As_RefineryGameObj()->Block_Harvester_Spawn(); + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_RefineryGameObj()) + { + parent->As_BuildingGameObj()->As_RefineryGameObj()->Block_Harvester_Spawn(); + } } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionProvideHarvester::OnBuildingOnline ( GameObject* obj ) +void dp88_buildingScripts_weakpoint_disableRefinery::reverseEffect ( GameObject* obj, GameObject* parent ) +{ + if (parent->As_BuildingGameObj() && parent->As_BuildingGameObj()->As_RefineryGameObj()) { - if (obj->As_BuildingGameObj() && obj->As_BuildingGameObj()->As_RefineryGameObj()) - obj->As_BuildingGameObj()->As_RefineryGameObj()->Allow_Harvester_Spawn(); + parent->As_BuildingGameObj()->As_RefineryGameObj()->Allow_Harvester_Spawn(); + } } - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionProvideHarvester_Registrant( - "dp88_buildingScripts_functionProvideHarvester", - "" -); +/*------------------------ +Building Effect Script +--------------------------*/ +void dp88_BuildingEffectScript::Custom ( GameObject *obj, int type, int param, GameObject *sender ) +{ + if ( obj == sender ) + { + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGOFFLINE ) + OnBuildingOffline(obj); + else if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGONLINE ) + OnBuildingOnline(obj); + else if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED ) + OnBuildingCaptured(obj, param); + else + OnCustom(obj,type,param,sender); + } + else + OnCustom(obj,type,param,sender); +} @@ -1183,13 +1008,21 @@ Building Script Zone --------------------------*/ -void dp88_buildingScripts_functionSpawnZone::Created ( GameObject *obj ) +void dp88_buildingScripts_scriptZone::Created ( GameObject *obj ) { - if ( !RegisterWithParent(obj, Get_Parameter("Building_Controller_Preset"), BUILDING_CHILD_TYPE_GENERIC) ) - return; - + // Set default values + parentId = NULL; zoneId = NULL; + // Find parent + GameObject* parent = Find_Object_By_Preset ( Get_Object_Type ( obj ), Get_Parameter("buildingControllerPreset") ); + if ( parent != NULL ) + { + parentId = Commands->Get_ID ( parent ); + + // Send with 1 second delay to ensure parent has been initialized + Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_GENERIC, 1.0f ); + // Check the script zone preset is valid and, if it is, create the zone if ( Is_Valid_Preset(Get_Parameter("scriptZonePreset")) ) createZone(obj); @@ -1200,34 +1033,35 @@ Destroy_Script(); } } + else + { + Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), Get_Parameter("buildingControllerPreset") ); + Destroy_Script(); + } +} -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_functionSpawnZone::OnBuildingOffline( GameObject* obj ) +void dp88_buildingScripts_scriptZone::Custom( GameObject *obj, int type, int param, GameObject *sender ) { - if ( Get_Int_Parameter("destroyZoneWhenDisabled") == 1 ) + // Ignore messages from anyone but our parent building + if ( Commands->Get_ID(sender) == parentId ) + { + // Parent building is now dead, destroy the script zone if applicable + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED && Get_Int_Parameter("destroyZoneWhenDestroyed") == 1 ) destroyZone(obj); -} -// ------------------------------------------------------------------------------------------------- + // Parent building now offline, destroy the script zone if applicable + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGOFFLINE && Get_Int_Parameter("destroyZoneWhenDisabled") == 1 ) + destroyZone(obj); -void dp88_buildingScripts_functionSpawnZone::OnBuildingOnline ( GameObject* obj ) -{ - if ( Get_Int_Parameter("destroyZoneWhenDisabled") == 1 ) + // Parent building now online, recreate the script zone if applicable + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGONLINE && Get_Int_Parameter("destroyZoneWhenDisabled") == 1 ) createZone(obj); } - -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_functionSpawnZone::OnBuildingDestroyed ( GameObject* obj ) -{ - if ( Get_Int_Parameter("destroyZoneWhenDestroyed") == 1 ) - destroyZone(obj); } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_functionSpawnZone::createZone(GameObject* obj) +void dp88_buildingScripts_scriptZone::createZone(GameObject* obj) { // Check that zoneId is NULL before creating a new zone if ( zoneId == NULL ) @@ -1248,9 +1082,8 @@ } } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_functionSpawnZone::destroyZone(GameObject* obj) +void dp88_buildingScripts_scriptZone::destroyZone(GameObject* obj) { // Check zoneId is not null before attempting to destroy the zone if ( zoneId != NULL ) @@ -1263,21 +1096,6 @@ } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_functionSpawnZone_Registrant( - "dp88_buildingScripts_functionSpawnZone", - "Building_Controller_Preset:string," - "scriptZonePreset:string," - "scriptZoneSize:vector3," - "destroyZoneWhenDisabled=1:int," - "destroyZoneWhenDestroyed=1:int" -); - - - - - @@ -1287,22 +1105,30 @@ void dp88_buildingScripts_capturePoint::Created( GameObject *obj ) { - GameObject* parent = RegisterWithParent(obj, Get_Parameter("Building_Controller_Preset"), BUILDING_CHILD_TYPE_GENERIC); - if ( !parent ) - return; + // Set default values + parentId = NULL; + currentTeam = 0; + + // Find parent + GameObject* parent = Find_Closest_Preset_By_Team ( Get_Object_Type ( obj ), Commands->Get_Position(obj), Get_Parameter("buildingControllerPreset") ); + if ( parent != NULL ) + { + parentId = Commands->Get_ID ( parent ); + currentTeam = Get_Object_Type(parent); + Set_Object_Type(obj,currentTeam); - // Check parent is not a building (since changing the team of a BuildingGameObj results in some - // very strange behaviour that we really don't want) + // Check parent is not a building (since changing the team of a BuildingGameObj results + // in some very strange behaviour that we really don't want) if ( parent->As_BuildingGameObj() ) { Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' is of type BuildingGameObj, capturing is not possible. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name() ); - Commands->Send_Custom_Event(obj, parent, CUSTOM_BUILDINGSCRIPTS_UNREGISTERCHILD, 0, 1.0f); Destroy_Script(); - return; } - currentTeam = Get_Object_Type(parent); - Set_Object_Type(obj,currentTeam); + else + { + // Send with 1 second delay to ensure parent has been initialized + Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_CAPTUREPOINT, 1.0f ); // Set the current health state to match the current team (0 = Soviet, 1 = Allies, -2 = Neutral) if ( currentTeam == 0 ) @@ -1312,29 +1138,33 @@ else Commands->Set_Health(obj, Commands->Get_Max_Health(obj)/2.0f); - m_nAnimTransitionFrames = Get_Int_Parameter("Capture_Anim_Transition_Frames"); - UpdateAnimationFrame(obj); - // Start timer to constantly move health towards equilibrium Commands->Start_Timer (obj, this, 1.0f, TIMER_BUILDINGSCRIPTS_CAPTUREPOINT ); } + } + else + { + Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), Get_Parameter("buildingControllerPreset") ); + Destroy_Script(); + } +} -// ------------------------------------------------------------------------------------------------- +extern REF_DECL2(NodHouseColor, Vector3); +extern REF_DECL2(GDIHouseColor, Vector3); +extern REF_DECL2(PublicMessageColor, Vector3); void dp88_buildingScripts_capturePoint::Damaged( GameObject *obj, GameObject *damager, float amount ) { - // Check the damage was done with the correct warhead, otherwise we are not interested - unsigned int warhead = ArmorWarheadManager::Get_Warhead_Type(Get_Parameter("Warhead")); - if ( warhead != Get_Damage_Warhead() ) - return; - float health = Commands->Get_Health(obj); float max = Commands->Get_Max_Health(obj); - // If the damager was on team 0 then decrease the health by 1 and check if we have been captured - if ( Commands->Get_Player_Type(damager) == 0 ) + // If the damager was the soviet engineer then decrease the health by 1 and + // check if they have now captured the building + unsigned int warhead = ArmorWarheadManager::Get_Warhead_Type(Get_Parameter("warhead")); + if (warhead == Get_Damage_Warhead() && Commands->Get_Player_Type(damager) == 0) { - // Decrease health by 1.00 (unless we are already below 1.25 in which case we just set it to 0.25) + // Decrease health by 1.00 (unless we are already below 1.25 in which + // case we just set it to 0.25) health = ( health <= 1.25f ) ? 0.25f : health - 1.0f; Commands->Set_Health (obj, health ); @@ -1342,31 +1172,69 @@ if ( health == 0.25f && currentTeam != 0 ) { currentTeam = 0; - int red = (int)(NodHouseColor.X * 255); int green = (int)(NodHouseColor.Y * 255); int blue = (int)(NodHouseColor.Z * 255); - - Send_Translated_Message_Team( Get_Int_Parameter("Sov_String_All"), 1, red, green, blue ); - Send_Translated_Message_Team( Get_Int_Parameter("Sov_String_Sov"), 0, red, green, blue ); - - Commands->Send_Custom_Event (obj, Commands->Find_Object(m_parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); + int stringall = Get_Int_Parameter("Sov_String_All"); + if (stringall && Is_Valid_String_ID(stringall)) + { + const char *str = Get_Translated_String(stringall); + Send_Message_Team(1,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringall); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),1); + } + } + int stringsov = Get_Int_Parameter("Sov_String_Sov"); + if (stringsov && Is_Valid_String_ID(stringsov)) + { + const char *str = Get_Translated_String(stringsov); + Send_Message_Team(0,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringsov); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),0); + } + } + Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); Set_Object_Type(obj,currentTeam); } // OK, we didn't capture it, but did we manage to make it neutral? else if ( currentTeam == 1 && health <= max/2.0f ) { - currentTeam = -2; - int red = (int)(PublicMessageColor.X * 255); int green = (int)(PublicMessageColor.Y * 255); int blue = (int)(PublicMessageColor.Z * 255); - - Send_Translated_Message_Team( Get_Int_Parameter("Neutral_String_All"), 1, red, green, blue ); - Send_Translated_Message_Team( Get_Int_Parameter("Neutral_String_Sov"), 0, red, green, blue ); - - Commands->Send_Custom_Event (obj, Commands->Find_Object(m_parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); + int stringall = Get_Int_Parameter("Neutral_String_All"); + if (stringall && Is_Valid_String_ID(stringall)) + { + const char *str = Get_Translated_String(stringall); + Send_Message_Team(1,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringall); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),1); + } + } + int stringsov = Get_Int_Parameter("Neutral_String_Sov"); + if (stringsov && Is_Valid_String_ID(stringsov)) + { + const char *str = Get_Translated_String(stringsov); + Send_Message_Team(0,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringsov); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),0); + } + } + currentTeam = -2; + Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); Set_Object_Type(obj,currentTeam); } } @@ -1385,54 +1253,97 @@ if ( health == max && currentTeam != 1 ) { currentTeam = 1; - int red = (int)(GDIHouseColor.X * 255); int green = (int)(GDIHouseColor.Y * 255); int blue = (int)(GDIHouseColor.Z * 255); - - Send_Translated_Message_Team( Get_Int_Parameter("All_String_All"), 1, red, green, blue ); - Send_Translated_Message_Team( Get_Int_Parameter("All_String_Sov"), 0, red, green, blue ); - - Commands->Send_Custom_Event (obj, Commands->Find_Object(m_parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); + int stringall = Get_Int_Parameter("All_String_All"); + if (stringall && Is_Valid_String_ID(stringall)) + { + const char *str = Get_Translated_String(stringall); + Send_Message_Team(1,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringall); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),1); + } + } + int stringsov = Get_Int_Parameter("All_String_Sov"); + if (stringsov && Is_Valid_String_ID(stringsov)) + { + const char *str = Get_Translated_String(stringsov); + Send_Message_Team(0,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringsov); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),0); + } + } + Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); Set_Object_Type(obj,currentTeam); } // OK, we didn't capture it, but did we manage to make it neutral? else if ( currentTeam == 0 && health >= max/2.0f ) { - currentTeam = -2; - int red = (int)(PublicMessageColor.X * 255); int green = (int)(PublicMessageColor.Y * 255); int blue = (int)(PublicMessageColor.Z * 255); - - Send_Translated_Message_Team( Get_Int_Parameter("Neutral_String_All"), 1, red, green, blue ); - Send_Translated_Message_Team( Get_Int_Parameter("Neutral_String_Sov"), 0, red, green, blue ); - - Commands->Send_Custom_Event (obj, Commands->Find_Object(m_parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); + int stringall = Get_Int_Parameter("Neutral_String_All"); + if (stringall && Is_Valid_String_ID(stringall)) + { + const char *str = Get_Translated_String(stringall); + Send_Message_Team(1,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringall); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),1); + } + } + int stringsov = Get_Int_Parameter("Neutral_String_Sov"); + if (stringsov && Is_Valid_String_ID(stringsov)) + { + const char *str = Get_Translated_String(stringsov); + Send_Message_Team(0,red,green,blue,str); + delete[] str; + int soundId = Get_String_Sound_ID(stringsov); + if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) + { + Create_2D_Sound_Team(Get_Definition_Name(soundId),0); + } + } + currentTeam = -2; + Commands->Send_Custom_Event (obj, Commands->Find_Object(parentId), CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED, currentTeam, 0.0f ); Set_Object_Type(obj,currentTeam); } } - - UpdateAnimationFrame(obj); } -// ------------------------------------------------------------------------------------------------- -void dp88_buildingScripts_capturePoint::OnBuildingDestroyed( GameObject *obj ) +void dp88_buildingScripts_capturePoint::Custom( GameObject *obj, int type, int param, GameObject *sender ) +{ + // Ignore messages from anyone but our parent building + if ( Commands->Get_ID(sender) == parentId ) + { + // If the parent building is dead we have no further purpose, spawn any appropriate 'dead' preset + // and destroy ourselves + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED ) { // Spawn dead preset - if ( Is_Valid_Preset ( Get_Parameter("Dead_Preset") ) ) + if ( Is_Valid_Preset ( Get_Parameter("dead_preset") ) ) { - GameObject* dead = Commands->Create_Object ( Get_Parameter("Dead_Preset"), Commands->Get_Position(obj) ); + GameObject* dead = Commands->Create_Object ( Get_Parameter("dead_preset"), Commands->Get_Position(obj) ); Commands->Set_Facing ( dead, Commands->Get_Facing(obj) ); } // And kill ourself Commands->Apply_Damage ( obj, 1000.0f, "Death", obj ); } + } +} -// ------------------------------------------------------------------------------------------------- void dp88_buildingScripts_capturePoint::Timer_Expired( GameObject *obj, int number ) { @@ -1449,7 +1360,6 @@ // Apply new health Commands->Set_Health(obj, health); - UpdateAnimationFrame(obj); } else @@ -1464,7 +1374,6 @@ // Apply new health Commands->Set_Health(obj, health); - UpdateAnimationFrame(obj); } else if ( health != max/2.0f ) @@ -1480,8 +1389,6 @@ // Otherwise move 0.25 points closer to the halfway point else Commands->Set_Health(obj, (above) ? health-0.25f : health+0.25f ); - - UpdateAnimationFrame(obj); } } @@ -1491,44 +1398,6 @@ } } -// ------------------------------------------------------------------------------------------------- - -void dp88_buildingScripts_capturePoint::UpdateAnimationFrame( GameObject* obj ) -{ - float health = Commands->Get_Health(obj); - if ( health == 0.25f ) - health = 0.0f; // 0.25 is the Soviet state - - float healthPercent = (health/Commands->Get_Max_Health(obj)); - float capturePercent; - if ( healthPercent > 0.5f ) // Only interested in progress beyond the halfway point - capturePercent = (healthPercent-0.5f)*2; - else // Invert progress (% of way from halfway to 0) - capturePercent = (0.5f-healthPercent)*2; - - int animFrame = 1+m_nAnimTransitionFrames; // Neutral frame - int teamFrames = (int)floor((1+m_nAnimTransitionFrames) * capturePercent); - animFrame += (healthPercent < 0.5f) ? (teamFrames*-1) : teamFrames; - Commands->Set_Animation_Frame(obj, Get_Parameter("Capture_Anim"), animFrame); -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_buildingScripts_capturePoint_Registrant( - "dp88_buildingScripts_capturePoint", - "Building_Controller_Preset:string," - "Warhead:string," - "Capture_Anim:string," - "Capture_Anim_Transition_Frames=0:int" - "Dead_Preset=0:int," - "All_String_All:int," - "Sov_String_All:int," - "Neutral_String_All:int," - "All_String_Sov:int," - "Sov_String_Sov:int," - "Neutral_String_Sov:int" -); - @@ -1539,7 +1408,7 @@ /*------------------------ -Spawn Building Part script +Spawn Vehicle Part script --------------------------*/ void dp88_buildingScripts_spawnPart::Created ( GameObject* obj ) @@ -1557,7 +1426,7 @@ /* Part spawn timer */ if ( number == TIMER_SPAWNVEHICLEPART && partObjectId == NULL ) { - /* Spawn the building part and get it's ID */ + /* Spawn the vehicle part and get it's ID */ GameObject* part = Commands->Create_Object_At_Bone ( obj, Get_Parameter("Building_Part_Preset"), Get_Parameter("Spawn_At_Bone") ); Commands->Attach_To_Object_Bone ( part, obj, Get_Parameter ( "Spawn_At_Bone" ) ); partObjectId = Commands->Get_ID(part); @@ -1575,8 +1444,10 @@ GameObject* part = Commands->Find_Object(partObjectId); if ( part ) { - Attach_Script_Once_V ( part, "dp88_linkHealth", "%d", Commands->Get_ID(obj) ); - Attach_Script_Once_V ( part, "dp88_linkVetPoints", "%d", Commands->Get_ID(obj) ); + char hostIdString[12]; + sprintf ( hostIdString, "%d", Commands->Get_ID(obj) ); + Attach_Script_Once ( part, "dp88_linkHealth", hostIdString ); + Attach_Script_Once ( part, "dp88_linkVetPoints", hostIdString ); } } } @@ -1596,11 +1467,106 @@ partObjectId = NULL; } +// ------------------------------------------------------------------------------------------------- + +void dp88_buildingScripts_PT_Script::Created( GameObject *obj ) +{ + m_pLoopedAnimCtrl = NULL; + + // Find parent + GameObject* parent = Find_Object_By_Preset ( Get_Object_Type ( obj ), Get_Parameter("buildingControllerPreset") ); + if ( parent != NULL ) + { + parentId = Commands->Get_ID ( parent ); + + // Send with 1 second delay to ensure parent has been initialized + Commands->Send_Custom_Event ( obj, parent, CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD, BUILDING_CHILD_TYPE_GENERIC, 1.0f ); + Commands->Start_Timer(obj, this, 1.0f, TIMER_CHECK_BASE_POWER_STATE ); + dead = false; + basePowerState = Is_Base_Powered(Get_Object_Type(obj)); + m_pLoopedAnimCtrl = new LoopedAnimationController(obj); + SetDamageAnimation(obj); + } + else + { + Console_Output ( "[%d:%s:%s] Critical Error: Building controller '%s' not found. Destroying script...\n", Commands->Get_ID(obj), Commands->Get_Preset_Name(obj), this->Get_Name(), Get_Parameter("buildingControllerPreset") ); + Destroy_Script(); + } +} + +void dp88_buildingScripts_PT_Script::Detach ( GameObject *obj ) +{ + if (m_pLoopedAnimCtrl) + { + delete m_pLoopedAnimCtrl; + } +} + +void dp88_buildingScripts_PT_Script::Custom( GameObject *obj, int type, int param, GameObject *sender ) +{ + if ( type == CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED && Commands->Get_ID(sender) == parentId ) + { + parentId = -1; + dead = true; + SetDamageAnimation(obj); + } +} +void dp88_buildingScripts_PT_Script::SetDamageAnimation ( GameObject* obj ) +{ + int sFrame = 0; + int eFrame = 0; + if (basePowerState) + { + sFrame = (int)((dead) ? Get_Float_Parameter("DeadAnimationStartFrame") : Get_Float_Parameter("AliveAnimationStartFrame")); + eFrame = (int)((dead) ? Get_Float_Parameter("DeadAnimationEndFrame") : Get_Float_Parameter("AliveAnimationEndFrame")); + } + else + { + sFrame = (int)((dead) ? Get_Float_Parameter("LPDeadAnimationStartFrame") : Get_Float_Parameter("LPAliveAnimationStartFrame")); + eFrame = (int)((dead) ? Get_Float_Parameter("LPDeadAnimationEndFrame") : Get_Float_Parameter("LPAliveAnimationEndFrame")); + } + m_pLoopedAnimCtrl->PlayAnimation ( Get_Parameter("Animation"), sFrame, eFrame ); +} + +void dp88_buildingScripts_PT_Script::Timer_Expired ( GameObject* obj, int number ) +{ + if ( number == TIMER_CHECK_BASE_POWER_STATE ) + { + if ( Is_Base_Powered(Get_Object_Type(obj)) != basePowerState ) + { + basePowerState = !basePowerState; + SetDamageAnimation(obj); + } + + // Restart timer + Commands->Start_Timer(obj, this, 1.0f, TIMER_CHECK_BASE_POWER_STATE ); + } +} + +ScriptRegistrant dp88_buildingScripts_buildingController_Registrant( "dp88_buildingScripts_buildingController", "team0_buildingOfflineStringId=0:int,team1_buildingOfflineStringId=0:int,team0_buildingOnlineStringId=0:int,team1_buildingOnlineStringId=0:int" ); + +ScriptRegistrant dp88_buildingScripts_repairNode_Registrant( "dp88_buildingScripts_repairNode", "buildingControllerPreset:string,dead_preset=null:string" ); + +ScriptRegistrant dp88_buildingScripts_weakpoint_destroyBuilding_Registrant( "dp88_buildingScripts_weakpoint_destroyBuilding", "buildingControllerPreset:string,dead_preset=null:string" ); + +ScriptRegistrant dp88_buildingScripts_weakpoint_disableSoldierPurchase_Registrant( "dp88_buildingScripts_weakpoint_disableSoldierPurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" ); +ScriptRegistrant dp88_buildingScripts_weakpoint_disableVehiclePurchase_Registrant( "dp88_buildingScripts_weakpoint_disableVehiclePurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" ); +ScriptRegistrant dp88_buildingScripts_weakpoint_disableAirVehiclePurchase_Registrant( "dp88_buildingScripts_weakpoint_disableAirVehiclePurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" ); +ScriptRegistrant dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase_Registrant( "dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" ); +ScriptRegistrant dp88_buildingScripts_weakpoint_disableBasePower_Registrant( "dp88_buildingScripts_weakpoint_disableBasePower", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" ); +ScriptRegistrant dp88_buildingScripts_weakpoint_disableRadar_Registrant( "dp88_buildingScripts_weakpoint_disableRadar", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" ); +ScriptRegistrant dp88_buildingScripts_weakpoint_disableRefinery_Registrant( "dp88_buildingScripts_weakpoint_disableRefinery", "buildingControllerPreset:string,animName:string,animStartFrame=0:int,animEndFrame=0:int,animLoop=0:int,destroyedAnimName:string,destroyedAnimStartFrame=0:int,destroyedAnimEndFrame=0:int,destroyedAnimLoop=0:int" ); ScriptRegistrant dp88_buildingScripts_functionMoneyTrickle_Registrant( "dp88_buildingScripts_functionMoneyTrickle", "creditsPerSec=3.0:float" ); ScriptRegistrant dp88_buildingScripts_functionSpawnTeamZone_Registrant( "dp88_buildingScripts_functionSpawnTeamZone", "scriptZonePreset_team0:string,scriptZonePreset_team1:string,scriptZonePreset_team2:string,scriptZoneBone:string,scriptZoneSize:vector3,destroyZoneWhenDisabled=1:int" ); ScriptRegistrant dp88_buildingScripts_functionMoneyGrant_Registrant( "dp88_buildingScripts_functionMoneyGrant", "credits:float,onceOnly=1:int"); + +ScriptRegistrant dp88_buildingScripts_scriptZone_Registrant( "dp88_buildingScripts_scriptZone", "buildingControllerPreset:string,scriptZonePreset:string,scriptZoneSize:vector3,destroyZoneWhenDisabled=1:int,destroyZoneWhenDestroyed=1:int" ); + +ScriptRegistrant dp88_buildingScripts_capturePoint_Registrant( "dp88_buildingScripts_capturePoint", "buildingControllerPreset:string,dead_preset=null:string,warhead:string,All_String_All:int,Sov_String_All:int,Neutral_String_All:int,All_String_Sov:int,Sov_String_Sov:int,Neutral_String_Sov:int"); + ScriptRegistrant dp88_buildingScripts_spawnPart_Registrant("dp88_buildingScripts_spawnPart","Building_Part_Preset:string,Spawn_At_Bone:string,IsDecorative=0:int"); +ScriptRegistrant dp88_buildingScripts_PT_Script_Registrant( "dp88_buildingScripts_PT_Script", "buildingControllerPreset:string,Animation:string,AliveAnimationStartFrame:float,AliveAnimationEndFrame:float,DeadAnimationStartFrame:float,DeadAnimationEndFrame:float,LPAliveAnimationStartFrame:float,LPAliveAnimationEndFrame:float,LPDeadAnimationStartFrame:float,LPDeadAnimationEndFrame:float"); diff -uwr source/scripts/dp88_buildingScripts.h sourceold/scripts/dp88_buildingScripts.h --- source/scripts/dp88_buildingScripts.h 2013-01-21 11:44:47.540882800 +0800 +++ sourceold/scripts/dp88_buildingScripts.h 2012-07-28 09:11:06.000000000 +0800 @@ -26,7 +26,7 @@ Building Controller Script --------------------------*/ -class dp88_buildingScripts_controller : public ScriptImpClass +class dp88_buildingScripts_buildingController : public ScriptImpClass { // Struct to contain data for building children struct ChildData @@ -51,11 +51,6 @@ // Array of data for child objects belonging to this building controller int numChildren; ChildData* children; - - /*! - * Find the position of the given object ID in the children array - * \return Array index of child, or -1 if not found - */ int findChild ( int objectId ); // Is the building online? @@ -66,343 +61,216 @@ unsigned long team1_buildingOfflineStringId; unsigned long team0_buildingOnlineStringId; unsigned long team1_buildingOnlineStringId; + + // String sound IDs + unsigned long team0_buildingOfflineSoundId; + unsigned long team1_buildingOfflineSoundId; + unsigned long team0_buildingOnlineSoundId; + unsigned long team1_buildingOnlineSoundId; }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief dp88 Building Scripts - Base Class -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* This is the base class for all scripts in the dp88_BuildingScripts set except the controller. It -* handles location of the parent building (where necessary) and parsing all of the custom messages -* from the parent building. -*/ -class dp88_buildingScripts_baseClass : public ScriptImpClass -{ -public: - dp88_buildingScripts_baseClass(); -protected: - /*! This function should be called in the Created() function of any derived script which is placed - on an object other than the one with the dp88_buildingScripts_controller script attached. - If no parent is found this will call Destroy_Script() and return false */ - GameObject* RegisterWithParent( GameObject* obj, const char* preset_name, int type ); +/*------------------------ +Building Repair Node +--------------------------*/ - /*! Handles custom messages from the parent building, should not be overridden by derived classes, - which should instead override the new OnCustom() stub function if they need to do their own custom - processing */ +class dp88_buildingScripts_repairNode : public ScriptImpClass +{ + void Created( GameObject *obj ); void Custom( GameObject *obj, int type, int param, GameObject *sender ); - /*! This function is called by Custom() for any custom it has not handled itself */ - virtual void OnCustom( GameObject* obj, int type, int param, GameObject *sender ) {}; - + // ID of the building controller we belong to + int parentId; +}; - /*! Event function called when the building enters the "offline" state */ - virtual void OnBuildingOffline( GameObject* obj ) {}; - /*! Event function called when the building enters the "online" state */ - virtual void OnBuildingOnline( GameObject* obj ) {}; - /*! Event function called when the building has been captured by a team or become neutral */ - virtual void OnBuildingCaptured( GameObject* obj, int team ) {}; - /*! Event function called when the building has been destroyed */ - virtual void OnBuildingDestroyed( GameObject* obj ) {}; +/*------------------------ +Weakpoint - Destroy Building Script +--------------------------*/ +class dp88_buildingScripts_weakpoint_destroyBuilding : public ScriptImpClass +{ + void Created( GameObject *obj ); + void Killed( GameObject *obj, GameObject *killer ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); - /*! ID of the building controller we belong to */ - int m_parentId; + // ID of the building controller we belong to + int parentId; }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief dp88 Building Scripts - Component Base Class -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* An extension of dp88_buildingScripts_objectBaseClass which adds extra support for building -* components such as weakpoints and purchase terminals. -*/ -class dp88_buildingScripts_componentBaseClass : public dp88_buildingScripts_baseClass +class dp88_buildingScripts_PT_Script : public ScriptImpClass { -public: - dp88_buildingScripts_componentBaseClass(); - -protected: - /*! Cleans up animation controller */ + void Created( GameObject *obj ); void Detach( GameObject* obj ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); + void Timer_Expired ( GameObject* obj, int number ); + void SetDamageAnimation ( GameObject* obj ); - /*! Called by Detach() to allow derived classes to use the event without overriding Detach() */ - virtual void OnDetach( GameObject* obj ) {}; - + // ID of the building controller we belong to + int parentId; + bool dead; + bool basePowerState; - /*! Plays the specified animation, creating a new animation controller if one does not exist. If - the animation name is NULL, a zero length string or invalid any existing animation is stopped */ - void PlayAnimation( GameObject* obj, const char* animation, int nStartFrame, int nEndFrame, bool bLooped ); - - - /*! Controller for the weakpoint animation */ - LoopedAnimationController* m_pAnimController; -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief dp88 Building Scripts - Building Component -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* Attach this script to any object whose health should be linked with the health of the parent -* building. This can be used to create areas of the building which have different skin/shield types, -* such as repair nodes which allow faster repairing or weak areas which cause more damage. -* -* \pre -* There must be a warhead of type "Death" defined in armor.ini which can cause damage to the -* object this script is attached to otherwise it will not be destroyed when the parent building -* gets killed. -* -* \param Building_Controller_Preset -* Name of the preset to which the controller script for this building is attached. Note that if -* there are multiple copies of this preset on the map the script will use the closest instance -* as its parent. -* \param Animation_Name -* Optional. The name of an animation to play on this component -* \param Animation_Start_Frame -* Optional. The first frame number to play within the named animation -* \param Animation_End_Frame -* Optional. The last frame number to play within the named animation -* \param Animation_Looped -* Optional. Whether to loop the animation. 1 to enable, 0 to disable -* \param Dead_Preset -* Optional. The name of a preset to spawn in place of this component when it has been destroyed -* -* \note -* If you want a more complex animation with multiple damage levels you can leave the animation -* parameters in this script blank and use a script such as dp88_damageAnimation to provide more -* control over the component animation. -*/ -class dp88_buildingScripts_component : public dp88_buildingScripts_componentBaseClass -{ protected: - void Created( GameObject *obj ); - void OnBuildingDestroyed( GameObject *obj ); + LoopedAnimationController* m_pLoopedAnimCtrl; +public: + dp88_buildingScripts_PT_Script() : m_pLoopedAnimCtrl(0) {} }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief dp88 Building Scripts - Major Weakpoint -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* Attach this script to a building part which should function as a major weakpoint, which can be -* attacked by an enemy to destroy the building. If a building has multiple major weakpoints they -* must all be destroyed before the parent building is destroyed. -* -* \pre -* There must be a warhead of type "Death" defined in armor.ini which can cause damage to the -* object this script is attached to otherwise it will not be destroyed when the parent building -* gets killed. -* -* \param Building_Controller_Preset -* Name of the preset to which the controller script for this building is attached. Note that if -* there are multiple copies of this preset on the map the script will use the closest instance -* as its parent. -* \param Animation_Name -* Optional. The name of an animation to play on this weakpoint -* \param Animation_Start_Frame -* Optional. The first frame number to play within the named animation -* \param Animation_End_Frame -* Optional. The last frame number to play within the named animation -* \param Animation_Looped -* Optional. Whether to loop the animation. 1 to enable, 0 to disable -* \param Dead_Preset -* Optional. The name of a preset to spawn in place of this weakpoint when it has been destroyed -* -* \note -* If you want a more complex animation with multiple damage levels you can leave the animation -* parameters in this script blank and use a script such as dp88_damageAnimation to provide more -* control over the weakpoint animation. -*/ -class dp88_buildingScripts_majorWeakpoint : public dp88_buildingScripts_componentBaseClass -{ -protected: - void Created( GameObject *obj ); - void Killed( GameObject *obj, GameObject *killer ); - void OnBuildingDestroyed( GameObject *obj ); -}; -// ------------------------------------------------------------------------------------------------- +/*------------------------ +Base Class For Generic Minor Weakpoints + +All of the minor weakpoints function in basically the same way with different effects applied +to the building they are attached to, so this base class provides the general functionality +and defines two abstract methods which the inheriting classes will implement to apply and +reverse their destroyed effect. +--------------------------*/ -/*! -* \brief dp88 Building Scripts - Minor Weakpoint -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* Attach this script to a building part which should function as a minor weakpoint, which can be -* attacked by an enemy to disable the building until the weakpoint is repaired. If a building has -* multiple minor weakpoints they must all be destroyed before the building is disabled and, once -* disabled, they must all be fully repaired before the building is enabled again. -* -* The exact effects of disabling the building are determined by the building function scripts which -* are attached to the object with the dp88_buildingScripts_controller attached. -* -* \pre -* The weakpoint is considered destroyed if the shield strength is 0 and the object should be -* indestructable to allow it to be repaired (if desired). The recommended way to implement this is -* to give the preset a health value of 1 with a "blamo" skin type. The shield strength alone will -* then function as the weakpoints total hitpoints. -* -* \param Building_Controller_Preset -* Name of the preset to which the controller script for this building is attached. Note that if -* there are multiple copies of this preset on the map the script will use the closest instance -* as its parent. -* \param Animation_Name -* Optional. The name of an animation to play on this weakpoint in the "alive" state -* \param Animation_Start_Frame -* Optional. The first frame number to play within the named animation for the "alive" state -* \param Animation_End_Frame -* Optional. The last frame number to play within the named animation for the "alive" state -* \param Animation_Looped -* Optional. Whether to loop the animation in the "alive" state. 1 to enable, 0 to disable -* \param Destroyed_Animation_Name -* Optional. The name of an animation to play on this weakpoint in the "destroyed" state -* \param Destroyed_Animation_Start_Frame -* Optional. The first frame number to play within the named animation for the "destroyed" state -* \param Destroyed_Animation_End_Frame -* Optional. The last frame number to play within the named animation for the "destroyed" state -* \param Destroyed_Animation_Looped -* Optional. Whether to loop the animation in the "destroyed" state. 1 to enable, 0 to disable -* -* \note -* The "alive" and "destroyed" animations can both be contained in the same animation if desired -*/ -class dp88_buildingScripts_minorWeakpoint : public dp88_buildingScripts_componentBaseClass +class MinorWeakpointScriptClass : public ScriptImpClass { -protected: void Created( GameObject *obj ); + void Detach ( GameObject *obj ); void Damaged ( GameObject *obj, GameObject *damager, float amount ); void Killed( GameObject *obj, GameObject *killer ); - void OnBuildingDestroyed( GameObject *obj ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); - void UpdateAnimation( GameObject* pSelf ); + // ID of the building controller we belong to + int parentId; - /*! Tracks whether this weakpoint has been destroyed, so we can trigger the repaired event - upon reaching 100% health again */ - bool m_bIsDestroyed; + // We use this to remember when we are in the destroyed state, so we know + // that when we next reach 100% health we need to trigger the repaired event + bool isDestroyed; + + // Abstract functions + virtual void applyEffect ( GameObject *obj, GameObject *parent ) = 0; + virtual void reverseEffect ( GameObject *obj, GameObject *parent ) = 0; +protected: + LoopedAnimationController* m_pLoopedAnimCtrl; +public: + MinorWeakpointScriptClass() : m_pLoopedAnimCtrl(0) {} }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief Building function - Produce Infantry -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* \todo document script -*/ -class dp88_buildingScripts_functionProduceInfantry : public dp88_buildingScripts_baseClass +/*------------------------ +Weakpoint - Disable Soldier Purchase +--------------------------*/ + +class dp88_buildingScripts_weakpoint_disableSoldierPurchase : public MinorWeakpointScriptClass { -protected: - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline( GameObject* obj ); + void applyEffect ( GameObject *obj, GameObject *parent ); + void reverseEffect ( GameObject *obj, GameObject *parent ); }; -/*! -* \brief Building function - Produce Vehicles -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* \todo document script -*/ -class dp88_buildingScripts_functionProduceVehicles : public dp88_buildingScripts_baseClass +/*------------------------ +Weakpoint - Disable Vehicle Purchase +--------------------------*/ + +class dp88_buildingScripts_weakpoint_disableVehiclePurchase : public MinorWeakpointScriptClass { -protected: - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline( GameObject* obj ); + void applyEffect ( GameObject *obj, GameObject *parent ); + void reverseEffect ( GameObject *obj, GameObject *parent ); }; -/*! -* \brief Building function - Produce Aircraft -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* \todo document script -*/ -class dp88_buildingScripts_functionProduceAircraft : public dp88_buildingScripts_baseClass +/*------------------------ +Weakpoint - Disable Air Vehicle Purchase +--------------------------*/ + +class dp88_buildingScripts_weakpoint_disableAirVehiclePurchase : public MinorWeakpointScriptClass { -protected: - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline( GameObject* obj ); + void applyEffect ( GameObject *obj, GameObject *parent ); + void reverseEffect ( GameObject *obj, GameObject *parent ); }; -/*! -* \brief Building function - Produce Naval Units -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* \todo document script -*/ -class dp88_buildingScripts_functionProduceNavalUnits : public dp88_buildingScripts_baseClass +/*------------------------ +Weakpoint - Disable Naval Vehicle Purchase +--------------------------*/ + +class dp88_buildingScripts_weakpoint_disableNavalVehiclePurchase : public MinorWeakpointScriptClass { -protected: - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline( GameObject* obj ); + void applyEffect ( GameObject *obj, GameObject *parent ); + void reverseEffect ( GameObject *obj, GameObject *parent ); }; -/*! -* \brief Building function - Provide Power -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* \todo document script -*/ -class dp88_buildingScripts_functionProvidePower : public dp88_buildingScripts_baseClass +/*------------------------ +Weakpoint - Disable Base Power +--------------------------*/ + +class dp88_buildingScripts_weakpoint_disableBasePower : public MinorWeakpointScriptClass { -protected: - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline( GameObject* obj ); + void applyEffect ( GameObject *obj, GameObject *parent ); + void reverseEffect ( GameObject *obj, GameObject *parent ); }; -/*! -* \brief Building function - Provide Radar -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts scripts_radar -* -* \todo document script -*/ -class dp88_buildingScripts_functionProvideRadar : public dp88_buildingScripts_baseClass + + + +/*------------------------ +Weakpoint - Disable Radar +--------------------------*/ + +class dp88_buildingScripts_weakpoint_disableRadar : public MinorWeakpointScriptClass { -protected: - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline( GameObject* obj ); + void applyEffect ( GameObject *obj, GameObject *parent ); + void reverseEffect ( GameObject *obj, GameObject *parent ); }; -/*! -* \brief Building function - Provide Harvester -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* \todo document script -*/ -class dp88_buildingScripts_functionProvideHarvester : public dp88_buildingScripts_baseClass + +/*------------------------ +Weakpoint - Disable Refinery +--------------------------*/ + +class dp88_buildingScripts_weakpoint_disableRefinery : public MinorWeakpointScriptClass { -protected: - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline( GameObject* obj ); + void applyEffect ( GameObject *obj, GameObject *parent ); + void reverseEffect ( GameObject *obj, GameObject *parent ); +}; + + +/*------------------------ +Base Class For Building Functions + +All of the building function scripts are derived from this class to add +additional events which are triggered by the building controller. +--------------------------*/ + +class dp88_BuildingEffectScript : public ScriptImpClass +{ + void Custom ( GameObject *obj, int type, int param, GameObject *sender ); + + + /* --------------------------------- + * Virtual stub functions which can be overloaded by events to perform + * any actions they need to perform + * ---------------------------------*/ + + // Called when the building is taken offline + virtual void OnBuildingOffline( GameObject* obj ) {}; + + // Called when the building is brought back online + virtual void OnBuildingOnline ( GameObject* obj ) {}; + + // Called when the building is captured + virtual void OnBuildingCaptured ( GameObject* obj, int team ) {}; + + // Called by Custom() if it has not handled the message + virtual void OnCustom ( GameObject *obj, int type, int param, GameObject *sender ) {}; }; // Money trickle function - gives the owning team X credits per second whilst alive -class dp88_buildingScripts_functionMoneyTrickle : public dp88_buildingScripts_baseClass +class dp88_buildingScripts_functionMoneyTrickle : public dp88_BuildingEffectScript { void Created ( GameObject* obj ); void Timer_Expired ( GameObject* obj, int number ); @@ -412,34 +280,16 @@ bool isTimerRunning; }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief Building function - Grant Money On Capture -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* Grants a fixed amount of money to a team when they capture this building. If the building is not -* neutral when this script is attached the current team will immediately get money. Can either give -* money each time the building is captured or only the first time it is captured. This script should -* be attached to the same object as the dp88_buildingScripts_controller script for the building. -* -* \param credits -* The amount of credits to be given -* \param onceOnly -* Only give credits the first time the building is captured -*/ -class dp88_buildingScripts_functionMoneyGrant : public dp88_buildingScripts_baseClass +class dp88_buildingScripts_functionMoneyGrant : public dp88_BuildingEffectScript { void Created ( GameObject* obj ); void OnBuildingCaptured ( GameObject* obj, int team ); }; -// ------------------------------------------------------------------------------------------------- - // Spawn team zone - spawns a script zone depending on which team currently owns // the building -class dp88_buildingScripts_functionSpawnTeamZone : public dp88_buildingScripts_baseClass +class dp88_buildingScripts_functionSpawnTeamZone : public dp88_BuildingEffectScript { void Created ( GameObject* obj ); void OnBuildingOffline( GameObject* obj ); @@ -459,42 +309,22 @@ -/*! -* \brief Building Function - Spawn Zone -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* Spawns a script zone at the location of the object this script is attached to and, optionally, -* destroys the zone when the parent building is offline and/or destroyed. This can be used to proxy -* script zones into the correct locations using Daves Arrow type presets with this script. -* -* \param Building_Controller_Preset -* Name of the preset to which the controller script for this building is attached. Note that if -* there are multiple copies of this preset on the map the script will use the closest instance -* as its parent. -* \param scriptZonePreset -* Name of the script zone preset to be spawned -* \param scriptZoneSize -* The size of the script zone in the + and - directions on each axis, so a size of 1x1x2 will -* create a 2x2x4 script zone centered on the object this script is attached to -* \param destroyZoneWhenDisabled -* Whether to destroy the spawned script zone when the parent building is offline. It will be -* created again when the building comes back online. 1 to enable, 0 to disable -* \param destroyZoneWhenDestroyed -* Whether to destroy the spawned script zone when the parent building is destroyed. 1 to enable, -* 0 to disable -*/ -class dp88_buildingScripts_functionSpawnZone : public dp88_buildingScripts_baseClass +/*------------------------ +Building Script Zone +--------------------------*/ + +class dp88_buildingScripts_scriptZone : public ScriptImpClass { void Created( GameObject *obj ); - void OnBuildingOffline( GameObject* obj ); - void OnBuildingOnline ( GameObject* obj ); - void OnBuildingDestroyed ( GameObject* obj ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); // Functions to create and destroy the script zone void createZone(GameObject* obj); void destroyZone(GameObject* obj); + // ID of the building controller we belong to + int parentId; + // ID of the zone we have created int zoneId; }; @@ -502,29 +332,19 @@ -/*! -* \brief dp88 Building Scripts - Capture Point -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_dp88BuildingScripts -* -* \todo document script -*/ -class dp88_buildingScripts_capturePoint : public dp88_buildingScripts_baseClass +/*------------------------ +Building Capture Point +--------------------------*/ + +class dp88_buildingScripts_capturePoint : public ScriptImpClass { -protected: void Created( GameObject *obj ); void Damaged ( GameObject *obj, GameObject *damager, float amount ); - void OnBuildingDestroyed( GameObject *obj ); + void Custom( GameObject *obj, int type, int param, GameObject *sender ); void Timer_Expired( GameObject *obj, int number ); - void UpdateAnimationFrame( GameObject* obj ); - + int parentId; int currentTeam; - - /*! \name Cached Script Parameters */ - /*! @{ */ - int m_nAnimTransitionFrames; - /*! @} */ }; @@ -533,7 +353,7 @@ Spawn Building Part script --------------------------*/ -class dp88_buildingScripts_spawnPart : public dp88_buildingScripts_baseClass +class dp88_buildingScripts_spawnPart : public dp88_BuildingEffectScript { void Created ( GameObject* obj ); void Timer_Expired( GameObject *obj, int number ); diff -uwr source/scripts/dp88_customAI.cpp sourceold/scripts/dp88_customAI.cpp --- source/scripts/dp88_customAI.cpp 2013-01-13 12:06:54.641664100 +0800 +++ sourceold/scripts/dp88_customAI.cpp 2012-08-16 09:51:48.000000000 +0800 @@ -23,10 +23,8 @@ --------------------------*/ void dp88_customAI::Created( GameObject *obj ) { - // Note: Init is done in a seperate function because derived classes might want to pass different - // parameters to loadSettings, thus we cannot assume they will call this function - loadSettings(obj, true, false); Init(obj); + loadSettings(obj); } void dp88_customAI::Action_Complete( GameObject *obj, int action_id, ActionCompleteReason complete_reason ) @@ -39,6 +37,7 @@ } } + void dp88_customAI::Init( GameObject *obj ) { // Set default values @@ -54,28 +53,28 @@ Commands->Enable_Vehicle_Transitions( obj, false ); } -void dp88_customAI::loadSettings ( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ) +void dp88_customAI::loadSettings ( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings, bool oldSettingNames ) { // Load base target type priorities - priority_infantry = Get_Float_Parameter("Priority_Infantry"); - priority_lightVehicle = Get_Float_Parameter("Priority_Light_Vehicle"); - priority_heavyVehicle = Get_Float_Parameter("Priority_Heavy_Vehicle"); - priority_VTOL = Get_Float_Parameter("Priority_VTOL"); - priority_building = ( loadBuildingTargetSettings ) ? Get_Float_Parameter("Priority_Building") : 0; + priority_infantry = ( oldSettingNames ) ? Get_Int_Parameter ( "Priority_Infantry" ) : Get_Float_Parameter ( "Priority_Infantry" ); + priority_lightVehicle = ( oldSettingNames ) ? Get_Int_Parameter ( "priority_lightVehicle" ) : Get_Float_Parameter ( "Priority_Light_Vehicle" ); + priority_heavyVehicle = ( oldSettingNames ) ? Get_Int_Parameter ( "priority_heavyVehicle" ) : Get_Float_Parameter ( "Priority_Heavy_Vehicle" ); + priority_VTOL = ( oldSettingNames ) ? Get_Int_Parameter ( "Priority_VTOL" ) : Get_Float_Parameter ( "Priority_VTOL" ); + priority_building = ( loadBuildingTargetSettings ) ? (( oldSettingNames ) ? Get_Int_Parameter ( "Priority_Building" ) : Get_Float_Parameter ( "Priority_Building" )) : 0; // Load priority modifiers - modifier_distance = Get_Float_Parameter("Modifier_Distance"); - modifier_target_damage = Get_Float_Parameter("Modifier_Target_Damage"); - modifier_target_value = Get_Float_Parameter("Modifier_Target_Value"); + modifier_distance = ( oldSettingNames ) ? 0.25f : Get_Float_Parameter("Modifier_Distance"); + modifier_target_damage = ( oldSettingNames ) ? 0.1f : Get_Float_Parameter("Modifier_Target_Damage"); + modifier_target_value = ( oldSettingNames ) ? 0.05f : Get_Float_Parameter("Modifier_Target_Value"); // Load primary / secondary fire states for target types primary_infantry = ( loadSecondaryFireSettings ) ? (( Get_Int_Parameter ( "Weapon_Infantry" ) == 2 ) ? false : true ) : true; - primary_lightVehicle = ( loadSecondaryFireSettings ) ? (( Get_Int_Parameter("Weapon_Light_Vehicle") == 2) ? false : true ) : true; - primary_heavyVehicle = ( loadSecondaryFireSettings ) ? (( Get_Int_Parameter("Weapon_Heavy_Vehicle") == 2) ? false : true ) : true; + primary_lightVehicle = ( loadSecondaryFireSettings ) ? (( (oldSettingNames && Get_Int_Parameter ( "Weapon_Vehicle" ) == 2) || (!oldSettingNames && Get_Int_Parameter("Weapon_Light_Vehicle") == 2) ) ? false : true ) : true; + primary_heavyVehicle = ( loadSecondaryFireSettings ) ? (( (oldSettingNames && Get_Int_Parameter ( "Weapon_Vehicle" ) == 2) || (!oldSettingNames && Get_Int_Parameter("Weapon_Heavy_Vehicle") == 2) ) ? false : true ) : true; primary_VTOL = ( loadSecondaryFireSettings ) ? (( Get_Int_Parameter ( "Weapon_VTOL" ) == 2 ) ? false : true ) : true; - primary_building = ( loadSecondaryFireSettings && loadBuildingTargetSettings ) ? (( Get_Int_Parameter ( "Weapon_Building" ) == 2 ) ? false : true) : true; + primary_building = ( loadSecondaryFireSettings ) ? (( loadBuildingTargetSettings ) ? (( Get_Int_Parameter ( "Weapon_Building" ) == 2 ) ? false : true) : true ) : true; // Get min and max ranges @@ -126,10 +125,10 @@ // Assign base priority - if ( Get_Vehicle_Mode(target) == VEHICLE_TYPE_FLYING || (target->As_SoldierGameObj() && (Get_Fly_Mode(target)||Find_Script_On_Object(target,"dp88_AR_Paradrop")) ) ) - priority = (float)priority_VTOL; - else if ( target->As_SoldierGameObj() ) + if ( target->As_SoldierGameObj() && !Get_Fly_Mode(target) ) priority = (float)priority_infantry; + else if ( Get_Vehicle_Mode ( target ) == VEHICLE_TYPE_FLYING || (target->As_SoldierGameObj() && Get_Fly_Mode(target)) ) + priority = (float)priority_VTOL; else if ( target->As_VehicleGameObj() && Is_Script_Attached ( target, "dp88_AI_heavyVehicleMarker" ) ) priority = (float)priority_heavyVehicle; else if ( target->As_VehicleGameObj() ) @@ -233,39 +232,26 @@ Offensive Tank AI --------------------------*/ -void dp88_AI_Tank_Offensive::Created( GameObject *obj ) +void dp88_tankAI_Offensive::Created( GameObject *obj ) { - // Load settings and init - loadSettings( obj, true, true ); Init(obj); -} - -// ------------------------------------------------------------------------------------------------- -void dp88_AI_Tank_Offensive::Init( GameObject *obj ) -{ - dp88_customAI::Init(obj); - - m_bMovingToTarget = false; - m_pCurrentObjective = NULL; - - // Start timer which runs for the lifetime of this object - this belongs in Init - Commands->Start_Timer ( obj, this, 1.0, TIMER_CUSTOMAI_THINK ); -} + // Load settings - using old setting names + loadSettings( obj, true, true, true ); -// ------------------------------------------------------------------------------------------------- -void dp88_AI_Tank_Offensive::loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ) -{ - dp88_customAI::loadSettings(obj, loadSecondaryFireSettings, loadBuildingTargetSettings); + // Set unit specific settings + movingToTarget = false; primary_prefRange = Get_Int_Parameter ( "Preferred_Attack_Range" ); secondary_prefRange = Get_Int_Parameter ( "Preferred_Attack_Range_Secondary" ); + + // Start timer which runs for the lifetime of this object + Commands->Start_Timer ( obj, this, 1.0, TIMER_CUSTOMAI_THINK ); } -// ------------------------------------------------------------------------------------------------- -void dp88_AI_Tank_Offensive::Enemy_Seen ( GameObject *obj, GameObject *enemy ) +void dp88_tankAI_Offensive::Enemy_Seen ( GameObject *obj, GameObject *enemy ) { // If we saw a soldier in a vehicle, switch the GameObject to that of the vehicle GameObject *o = Get_Vehicle(enemy); @@ -282,13 +268,11 @@ return; } - // Get priority for seen object and return if 0 or lower than current target + // Get priority for seen object and return if 0 float seenPriority = getPriority( obj, enemy ); - if ( seenPriority == 0.0 || (targetID!=0 && seenPriority <= targetPriority) ) + if ( seenPriority == 0.0 ) return; - //fprintf( debugFile, "Higher priority than existing target... attacking!\n" ); - // Decide if we want to use primary or secondary fire bool attackPrimary = getPrimary ( enemy ); @@ -298,14 +282,48 @@ return; //fprintf( debugFile, "Range to enemy: %d\n", (int)targetDistance ); + // Work out its targeting priority, to see if we should shoot it + if ( targetID == 0 || seenPriority > targetPriority ) + { + //fprintf( debugFile, "Higher priority than existing target... attacking!\n" ); + + ActionParamsStruct params; + params.Set_Basic( this, 100, 2 ); - // All good, attack the enemy - AttackTarget ( obj, enemy ); + if ( attackPrimary && targetDistance < primary_maxRange ) + { + targetID = Commands->Get_ID ( enemy ); + primary_target = attackPrimary; + targetLastSeen = (int)time(NULL); + + if ( targetDistance > primary_prefRange ) + { + movingToTarget = true; + params.Set_Movement(enemy, 1.0f, (float)primary_prefRange ); + } + params.Set_Attack( enemy, (float)primary_maxRange, 0.0, true); + params.AttackCheckBlocked = false; + Commands->Action_Attack( obj, params ); } + else if ( !attackPrimary && targetDistance < secondary_maxRange ) + { + targetID = Commands->Get_ID ( enemy ); + primary_target = attackPrimary; + targetLastSeen = (int)time(NULL); -// ------------------------------------------------------------------------------------------------- + if ( targetDistance > secondary_prefRange ) + { + movingToTarget = true; + params.Set_Movement( enemy, 1.0f, (float)secondary_prefRange ); + } + params.Set_Attack( enemy, (float)secondary_maxRange, 0.0, false); + params.AttackCheckBlocked = false; + Commands->Action_Attack( obj, params ); + } + } +} -void dp88_AI_Tank_Offensive::Timer_Expired( GameObject *obj, int number ) +void dp88_tankAI_Offensive::Timer_Expired( GameObject *obj, int number ) { // Check target is still alive, still an enemy (eg: stolen vehicles) and in range if ( number == TIMER_CUSTOMAI_THINK ) @@ -326,148 +344,68 @@ { //fprintf( debugFile, "Target invalid, aborting.. \n" ); targetID = 0; - m_bMovingToTarget = false; Commands->Action_Reset ( obj, 100 ); } - // Chase after them if they are running away... - if ( !m_bMovingToTarget ) - { - float targetDistance = getDistance ( obj, target ); - int prefDistance = ((primary_target)?primary_prefRange:secondary_prefRange); - if ( targetDistance > prefDistance ) - { - ActionParamsStruct params; - Commands->Get_Action_Params(obj, params); - params.Set_Movement( target, 1.0f, (float)prefDistance );; - Commands->Modify_Action(obj,ACTION_ID_ATTACK_ENEMY,params,true,true); - } - } - } - - - // Verify current objective (if any) is still valid - if ( m_pCurrentObjective && !dp88_AI_Objective::IsValidObjective(m_pCurrentObjective) ) - { - m_pCurrentObjective = NULL; - m_bMovingToTarget = false; - } - - - if ( targetID == 0 && !m_bMovingToTarget ) + // Stop chasing if we have reached preferred range + else if ( movingToTarget && primary_target && getDistance ( obj, target ) <= primary_prefRange ) { - GoToObjective(obj); - } + Commands->Action_Reset ( obj, 100 ); + movingToTarget = false; - // Timer always runs - Commands->Start_Timer ( obj, this, 1.0, TIMER_CUSTOMAI_THINK ); - } + ActionParamsStruct params; + params.Set_Basic( this, 100, 2 ); + params.Set_Attack( target, (float)primary_maxRange, 0.0, true); + params.AttackCheckBlocked = false; + Commands->Action_Attack ( obj, params ); } -// ------------------------------------------------------------------------------------------------- - -void dp88_AI_Tank_Offensive::AttackTarget ( GameObject* obj, GameObject* target ) + else if ( movingToTarget && !primary_target && getDistance ( obj, target ) <= secondary_prefRange ) { - // Clear any existing action - if (targetID == 0 ) Commands->Action_Reset(obj,100); + movingToTarget = false; - m_bMovingToTarget = false; - targetID = Commands->Get_ID(target); - primary_target = getPrimary(target); - targetLastSeen = (int)time(NULL); - - // Build a new action struct ActionParamsStruct params; - params.Set_Basic( this, 90, ACTION_ID_ATTACK_ENEMY ); - params.Set_Attack( target, (float)((primary_target)?primary_maxRange:secondary_maxRange), 0.0, true); + params.Set_Basic( this, 100, 2 ); + params.Set_Attack( target, (float)secondary_maxRange, 0.0, false); params.AttackCheckBlocked = false; - - float targetDistance = getDistance ( obj, target ); - int prefDistance = ((primary_target)?primary_prefRange:secondary_prefRange); - if ( targetDistance > prefDistance ) - params.Set_Movement( target, 1.0f, (float)prefDistance ); - Commands->Action_Attack( obj, params ); } -// ------------------------------------------------------------------------------------------------- - -void dp88_AI_Tank_Offensive::GoToObjective ( GameObject* obj ) + // Chase them if they are moving away from us... + else if ( !movingToTarget && primary_target && getDistance ( obj, target ) > primary_prefRange ) { - // Verify current objective (if any) is still valid - if ( m_pCurrentObjective && !dp88_AI_Objective::IsValidObjective(m_pCurrentObjective) ) - m_pCurrentObjective = NULL; + Commands->Action_Reset ( obj, 100 ); + movingToTarget = true; - // Obtain a new objective if we don't have one - if ( m_pCurrentObjective == NULL ) - { - m_pCurrentObjective = dp88_AI_Objective::GetObjective(obj,dp88_AI_Objective::TYPE_OFFENSIVE); - if ( !m_pCurrentObjective ) - m_pCurrentObjective = dp88_AI_Objective::GetObjective(obj,dp88_AI_Objective::TYPE_DEFENSIVE); + ActionParamsStruct params; + params.Set_Basic( this, 100, 2 ); + params.Set_Movement( target, 1.0f, (float)primary_prefRange ); + params.Set_Attack( target, (float)primary_maxRange, 0.0, true); + params.AttackCheckBlocked = false; + Commands->Action_Attack ( obj, params ); } - if ( m_pCurrentObjective != NULL ) + // Chase them if they are moving away from us... + else if ( !movingToTarget && !primary_target && getDistance ( obj, target ) > secondary_prefRange ) { - m_bMovingToTarget = true; + Commands->Action_Reset ( obj, 100 ); + movingToTarget = true; ActionParamsStruct params; - params.Set_Basic( this, 80, ACTION_ID_MOVE_TO_OBJECTIVE ); - params.Set_Movement( m_pCurrentObjective->GetGameObject(), 1.0f, (float)m_pCurrentObjective->GetDistance() ); - Commands->Action_Goto ( obj, params ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AI_Tank_Offensive::Action_Complete ( GameObject *obj, int action_id, ActionCompleteReason reason) -{ - if ( action_id == ACTION_ID_ATTACK_ENEMY ) - { - if ( reason == MOVEMENT_COMPLETE_ARRIVED ) - { - AttackTarget(obj, Commands->Find_Object(targetID)); + params.Set_Basic( this, 100, 2 ); + params.Set_Movement( target, 1.0f, (float)secondary_prefRange ); + params.Set_Attack( target, (float)secondary_maxRange, 0.0, false); + params.AttackCheckBlocked = false; + Commands->Action_Attack ( obj, params ); } } - else if ( action_id == ACTION_ID_MOVE_TO_OBJECTIVE ) - { - m_bMovingToTarget = false; + // Timer always runs + Commands->Start_Timer ( obj, this, 1.0, TIMER_CUSTOMAI_THINK ); } } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_AI_Tank_Offensive_Registrant( - "dp88_AI_Tank_Offensive", - "Priority_Infantry=1.0:float," - "Weapon_Infantry=1:int," - "Splash_Infantry=0:int," - "Priority_Light_Vehicle=5.0:float," - "Weapon_Light_Vehicle=1:int," - "Priority_Heavy_Vehicle=7.0:float," - "Weapon_Heavy_Vehicle=1:int," - "Priority_VTOL=5.0:float," - "Weapon_VTOL=1:int," - "Priority_Building=12.0:float," - "Weapon_Building=1:int," - "Max_Attack_Range=150:int," - "Min_Attack_Range=0:int," - "Preferred_Attack_Range=60:int," - "Max_Attack_Range_Secondary=150:int," - "Min_Attack_Range_Secondary=0:int," - "Preferred_Attack_Range_Secondary=60:int," - "Modifier_Distance=0.25:float," - "Modifier_Target_Damage=0.1:float," - "Modifier_Target_Value=0.05:float," - "Debug=0:int" -); - -// Legacy Registrant -// \todo remove this -ScriptRegistrant dp88_tankAI_Offensive_Registrant("dp88_tankAI_Offensive","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=1:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Priority_Building=12.0:float,Weapon_Building=1:int,Max_Attack_Range=150:int,Min_Attack_Range=0:int,Preferred_Attack_Range=60:int,Max_Attack_Range_Secondary=150:int,Min_Attack_Range_Secondary=0:int,Preferred_Attack_Range_Secondary=60:int,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Debug=0:int"); - - @@ -478,6 +416,12 @@ Turret AI --------------------------*/ +void dp88_AI_Turret::Created( GameObject *obj ) +{ + Init(obj); + loadSettings(obj); +} + void dp88_AI_Turret::Init( GameObject *obj ) { dp88_customAI::Init( obj ); @@ -489,7 +433,6 @@ void dp88_AI_Turret::loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ) { dp88_customAI::loadSettings(obj, loadSecondaryFireSettings, loadBuildingTargetSettings); - requiresPower = (Get_Int_Parameter("Requires_Power") > 0 ) ? true: false; splashInfantry = (Get_Int_Parameter("Splash_Infantry") > 0 ) ? true: false; } @@ -873,10 +816,8 @@ // Charged Turret AI // ------------------------------------------------------------------------------------------------- -void dp88_AI_ChargedTurret::Init( GameObject* pSelf ) +void dp88_AI_ChargedTurret::Created ( GameObject* pSelf ) { - dp88_AI_Turret::Init(pSelf); - m_bIsCharging = false; m_bIsDischarging = false; m_chargeAnimObjId = NULL; @@ -912,15 +853,8 @@ m_bPowerState = checkPowerState(pSelf); ApplyIdleAnimation(pSelf); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AI_ChargedTurret::loadSettings( GameObject* pSelf, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ) -{ - dp88_AI_Turret::loadSettings(pSelf, loadSecondaryFireSettings, loadBuildingTargetSettings); - // Not currently loading any settings... probably should add this sometime... + dp88_AI_Turret::Created(pSelf); } // ------------------------------------------------------------------------------------------------- @@ -1135,137 +1069,6 @@ - -// ------------------ -// Custom AI Objective -// ------------------ - -int dp88_AI_Objective::s_nObjectives = 0; -dp88_AI_Objective** dp88_AI_Objective::s_pObjectives = NULL; - -// ------------------------------------------------------------------------------------------------- - -void dp88_AI_Objective::Created ( GameObject* obj ) -{ - // Register objective - dp88_AI_Objective** pOldObjectives = s_pObjectives; - s_pObjectives = new dp88_AI_Objective*[++s_nObjectives]; - for ( int i = 0; i < s_nObjectives-1; ++i ) - s_pObjectives[i] = pOldObjectives[i]; - s_pObjectives[s_nObjectives-1] = this; - - // Store data - m_objID = Commands->Get_ID(obj); - m_priority = Get_Int_Parameter("Priority"); - m_distance = Get_Int_Parameter("Distance"); - m_type = (unsigned char)Get_Int_Parameter("Type"); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_AI_Objective::Detach ( GameObject* obj ) -{ - // De-register objective - dp88_AI_Objective** pOldObjectives = s_pObjectives; - if ( s_pObjectives != NULL && --s_nObjectives != 0 ) - { - s_pObjectives = new dp88_AI_Objective*[s_nObjectives]; - for ( int i = 0, j = 0; i < s_nObjectives; ++i, ++j ) - { - if ( pOldObjectives[j] == this ) - ++j; - s_pObjectives[i] = pOldObjectives[j]; - } - } - delete [] pOldObjectives; -} - -// ------------------------------------------------------------------------------------------------- - -GameObject* dp88_AI_Objective::GetGameObject() -{ - return Commands->Find_Object(m_objID); -} - -// ------------------------------------------------------------------------------------------------- - -bool dp88_AI_Objective::IsSuitable ( GameObject* obj, unsigned char objective_type ) -{ - int team = Get_Int_Parameter("Team"); - if ( objective_type != m_type || (team != 2 && Get_Object_Type(obj) != team) ) - return false; - - if ( obj->As_SoldierGameObj() && !Get_Fly_Mode(obj) ) - return ( Get_Int_Parameter("Soldier_Objective") == 1 ); - - if ( Get_Vehicle_Mode(obj) == VEHICLE_TYPE_FLYING || (obj->As_SoldierGameObj() && Get_Fly_Mode(obj)) ) - return ( Get_Int_Parameter("Aircraft_Objective") == 1 ); - - if ( obj->As_VehicleGameObj() ) - return (Is_Script_Attached ( obj, "dp88_AI_heavyVehicleMarker" )) - ? ( Get_Int_Parameter("Heavy_Vehicle_Objective") == 1 ) - : ( Get_Int_Parameter("Light_Vehicle_Objective") == 1 ); - - return false; -} - -// ------------------------------------------------------------------------------------------------- - -dp88_AI_Objective* dp88_AI_Objective::GetObjective ( GameObject* obj, unsigned char objective_type ) -{ - dp88_AI_Objective* result = NULL; - int top_priority = 0; - - for ( int i = 0; i < s_nObjectives; ++i ) - { - if ( s_pObjectives[i]->IsSuitable(obj,objective_type) - && s_pObjectives[i]->GetPriority() >= top_priority - && s_pObjectives[i]->GetGameObject() != NULL ) - { - // Always switch to a higher priority objective and allow a random chance to switch to - // another equal priority objective - if ( s_pObjectives[i]->m_priority > top_priority || Commands->Get_Random_Int(1,3) == 1 ) - { - top_priority = s_pObjectives[i]->GetPriority(); - result = s_pObjectives[i]; - } - } - } - - return result; -} - -// ------------------------------------------------------------------------------------------------- - -bool dp88_AI_Objective::IsValidObjective(dp88_AI_Objective* pObjective) -{ - for ( int i = 0; i < s_nObjectives; ++i ) - { - if ( s_pObjectives[i] == pObjective ) - return ( s_pObjectives[i]->GetGameObject() != NULL ); - } - - return false; -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_AI_Objective_Registrant( - "dp88_AI_Objective", - "Priority=1:int," - "Distance=50:int," - "Team:int," - "Type=1:int," - "Soldier_Objective=1:int," - "Light_Vehicle_Objective=1:int," - "Heavy_Vehicle_Objective=1:int," - "Aircraft_Objective=1:int"); - - - - - - // ------------------------------------------------------------------------------------------------- // Script Registrants // ------------------------------------------------------------------------------------------------- @@ -1273,8 +1076,9 @@ // Heavy vehicle marker (dummy script) ScriptRegistrant dp88_AI_heavyVehicleMarker_Registrant("dp88_AI_heavyVehicleMarker",""); -ScriptRegistrant dp88_AI_Turret_Registrant("dp88_AI_Turret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=1:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int"); -ScriptRegistrant dp88_AI_PopupTurret_Registrant("dp88_AI_PopupTurret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=1:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Deploy_Animation:string,Deploy_Animation_Frames:int,Deploy_Sound:string,Deploy_Timeout:int,Spotter_Preset:string,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int"); +ScriptRegistrant dp88_tankAI_Offensive_Registrant("dp88_tankAI_Offensive","Priority_Infantry=1:int,Weapon_Infantry=1:int,priority_lightVehicle=5:int,priority_heavyVehicle=7:int,Weapon_Vehicle=1:int,Priority_VTOL=5:int,Weapon_VTOL=1:int,Priority_Building=12:int,Weapon_Building=1:int,Max_Attack_Range=150:int,Min_Attack_Range=0:int,Preferred_Attack_Range=60:int,Max_Attack_Range_Secondary=150:int,Min_Attack_Range_Secondary=0:int,Preferred_Attack_Range_Secondary=60:int"); +ScriptRegistrant dp88_AI_Turret_Registrant("dp88_AI_Turret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=5:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int"); +ScriptRegistrant dp88_AI_PopupTurret_Registrant("dp88_AI_PopupTurret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=5:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Deploy_Animation:string,Deploy_Animation_Frames:int,Deploy_Sound:string,Deploy_Timeout:int,Spotter_Preset:string,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int"); ScriptRegistrant dp88_AI_PopupTurret_Spotter_Registrant("dp88_AI_PopupTurret_Spotter","tId:int"); -ScriptRegistrant dp88_AI_ChargedTurret_Registrant("dp88_AI_ChargedTurret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=1:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Animation_Model:string,Animation_Model_Bone:string,Animation:string,Animation_Idle_Start_Frame:int,Animation_Idle_End_Frame:int,Animation_Unpowered_Start_Frame:int,Animation_Unpowered_End_Frame:int,Animation_Charge_Start_Frame:int,Animation_Charge_End_Frame:int,Charge_Sound:string,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int"); +ScriptRegistrant dp88_AI_ChargedTurret_Registrant("dp88_AI_ChargedTurret","Priority_Infantry=1.0:float,Weapon_Infantry=1:int,Splash_Infantry=0:int,Priority_Light_Vehicle=5.0:float,Weapon_Light_Vehicle=5:int,Priority_Heavy_Vehicle=7.0:float,Weapon_Heavy_Vehicle=1:int,Priority_VTOL=5.0:float,Weapon_VTOL=1:int,Min_Attack_Range=0:int,Max_Attack_Range=150:int,Min_Attack_Range_Secondary=0:int,Max_Attack_Range_Secondary=150:int,Animation_Model:string,Animation_Model_Bone:string,Animation:string,Animation_Idle_Start_Frame:int,Animation_Idle_End_Frame:int,Animation_Unpowered_Start_Frame:int,Animation_Unpowered_End_Frame:int,Animation_Charge_Start_Frame:int,Animation_Charge_End_Frame:int,Charge_Sound:string,Modifier_Distance=0.25:float,Modifier_Target_Damage=0.1:float,Modifier_Target_Value=0.05:float,Requires_Power=0:int,Debug=0:int"); ScriptRegistrant dp88_AI_ChargedTurret_Animation_Registrant("dp88_AI_ChargedTurret_Animation","tId:int"); diff -uwr source/scripts/dp88_customAI.h sourceold/scripts/dp88_customAI.h --- source/scripts/dp88_customAI.h 2013-01-13 11:33:13.581117200 +0800 +++ sourceold/scripts/dp88_customAI.h 2012-09-09 17:56:18.000000000 +0800 @@ -86,7 +86,7 @@ ----- */ virtual void Init( GameObject *obj ); - virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ); + virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings = true, bool loadBuildingTargetSettings = false, bool oldSettingNames = false ); float getDistance ( GameObject *obj1, GameObject *obj2 ); virtual float getPriority( GameObject *obj, GameObject *target ); @@ -119,41 +119,24 @@ * This is a somewhat experimental AI for vehicles which can track targets over a predefined distance * and attack them. This script is not yet suitable for use in maps or mods and is subject to change. */ -class dp88_AI_Tank_Offensive : public dp88_customAI +class dp88_tankAI_Offensive : public dp88_customAI { -public: - // Game Events - void Created( GameObject *obj ); - void Enemy_Seen ( GameObject *obj, GameObject *enemy ); - void Timer_Expired ( GameObject *obj, int number ); - void Action_Complete ( GameObject *obj, int action_id, ActionCompleteReason reason); - - // Custom AI initialisation script overloads - virtual void Init( GameObject *obj ); - virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ); - - -protected: - static const int ACTION_ID_MOVE_TO_OBJECTIVE = 7850001; - static const int ACTION_ID_ATTACK_ENEMY = 7850002; - - void AttackTarget ( GameObject* obj, GameObject* target ); - - /*! When the unit has finished any combat actions it will call this function to start moving to - its current objective. If it has no current objective it will try to obtain a new one. */ - void GoToObjective ( GameObject* obj ); + /* ---- + Variables + ----- */ - /*! \name Cached Script Parameters */ - /*! @{ */ + // Preferred attack ranges int primary_prefRange, secondary_prefRange; - int retreatDamageAmount; - /*! @} */ + bool movingToTarget; - /*! True if moving towards a target (either an enemy unit or an objective), false otherwise */ - bool m_bMovingToTarget; + // Other + int retreatDamageAmount; + FILE *debugFile; - // Current objective - class dp88_AI_Objective* m_pCurrentObjective; + // Events + void Created( GameObject *obj ); + void Enemy_Seen ( GameObject *obj, GameObject *enemy ); + void Timer_Expired( GameObject *obj, int number ); }; // ------------------------------------------------------------------------------------------------- @@ -228,16 +211,16 @@ { public: // Events + virtual void Created( GameObject *obj ); virtual void Enemy_Seen ( GameObject *obj, GameObject *enemy ); virtual void Timer_Expired( GameObject *obj, int number ); - // Custom AI initialisation script overloads - virtual void Init( GameObject *obj ); - virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ); - protected: bool requiresPower, splashInfantry; + virtual void Init( GameObject *obj ); + virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings = true, bool loadBuildingTargetSettings = false ); + // These can be overloaded from their default functionality as required, allowing the default // enemy seen procedure to be reused even when the behaviour of these checks has been altered virtual bool checkTeam ( GameObject* obj, GameObject* target ); @@ -514,15 +497,12 @@ { public: // Game events + virtual void Created ( GameObject* pSelf ); virtual void Timer_Expired ( GameObject* pSelf, int number ); virtual void Custom ( GameObject* pSelf, int type, int param, GameObject* pSender ); virtual void Animation_Complete ( GameObject* pSelf, const char* animation_name ); virtual void Destroyed( GameObject* pSelf ); - // Custom AI initialisation script overloads - virtual void Init( GameObject* pSelf ); - virtual void loadSettings( GameObject* pSelf, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ); - protected: /*! Are we currently charging ready for an attack? */ @@ -570,8 +550,7 @@ * \brief Chargeup Animation Detector * \author Daniel Paul (danpaul88@yahoo.co.uk) * -* A script to allow detection of animations if the "separate object" feature is used, this script -* should not be attached manually via LevelEdit. +* A script to allow detection of animations if the "separate object" feature is used */ class dp88_AI_ChargedTurret_Animation : public ScriptImpClass { @@ -580,75 +559,3 @@ }; // ------------------------------------------------------------------------------------------------- - -/*! -* \brief AI Objective -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_ai -* -* This script should be attached to any object which offensive AI scripts should treat as a mission -* objective, for example a building. Compatible scripts include dp88_AI_Tank_Offensive. Note that -* the objective is used as a go-to location rather than a target to shoot at, so the behaviour of -* the unit when it arrives at an objective depends upon the script being used and its configuration. -* -* \param Priority -* The priority of this objective, AIs will attempt to accomplish the highest priority objectives -* first, randomly choosing between objecives with equal priority -* \param Distance -* The target distance from this objective the unit will try to achieve. Be careful not to set this -* too low or the AI might be unable to calculate a successful route. -* \param Team -* Which team this objective applies to. 0 for Nod/Soviets, 1 for GDI/Allies and 2 for both -* \param Type -* What type of objective this is, valid values are 1 (Offensive) or 2 (Defensive). -* \param Soldier_Objective -* Whether this objective is suitable for soldiers to attempt. 1 to enable, 0 to disable -* \param Light_Vehicle_Objective -* Whether this objective is suitable for a light vehicle to attempt. 1 to enable, 0 to disable -* \param Heavy_Vehicle_Objective -* Whether this objective is suitable for a heavy vehicle to attempt. 1 to enable, 0 to disable -* \param Aircraft_Objective -* Whether this objective is suitable for aircraft to attempt. 1 to enable, 0 to disable -*/ -class dp88_AI_Objective : public ScriptImpClass -{ -public: - void Created ( GameObject* obj ); - void Detach ( GameObject* obj ); - - GameObject* GetGameObject(); - int GetPriority() { return m_priority; } - int GetDistance() { return m_distance; } - unsigned char GetType() { return m_type; } - - /*! Check if this objective is suitable for the unit type of the specified object */ - bool IsSuitable ( GameObject* obj, unsigned char objective_type ); - - /*! - * Finds the highest priority objective suitable for the type of unit which is passed as the - * parameter and returns it. If multiple objectives share the highest priority one will be picked - * at random - */ - static dp88_AI_Objective* GetObjective ( GameObject* obj, unsigned char objective_type ); - - /*! Checks if the specified objective is still valid */ - static bool IsValidObjective ( dp88_AI_Objective* pObjective ); - - /*! \name Objective types */ - /*! @{ */ - const static unsigned char TYPE_OFFENSIVE = 1; - const static unsigned char TYPE_DEFENSIVE = 2; - /*! @} */ - -protected: - /*! \name Cached Script Parameters */ - /*! @{ */ - int m_objID; - int m_priority; - int m_distance; - unsigned char m_type; - /*! @} */ - - static int s_nObjectives; - static dp88_AI_Objective** s_pObjectives; -}; \ No newline at end of file diff -uwr source/scripts/dp88_custom_timer_defines.h sourceold/scripts/dp88_custom_timer_defines.h --- source/scripts/dp88_custom_timer_defines.h 2013-01-13 12:06:54.844789100 +0800 +++ sourceold/scripts/dp88_custom_timer_defines.h 2012-07-28 09:11:08.000000000 +0800 @@ -11,138 +11,19 @@ */ #pragma once -// ------------------------------------------------------------------------------------------------- - -#define DP88_RGB_GENERAL_MSG 50,200,50 // Green -#define DP88_RGB_WARNING_MSG 153,204,25 // Yellow -#define DP88_RGB_ERROR_MSG 255,50,50 // Red - -// ------------------------------------------------------------------------------------------------- - -#define DP88_CUSTOM 0xDA000000 -#define DP88_TIMER 0xDB000000 - -// ------------------------------------------------------------------------------------------------- -// Custom and timer groups -// ------------------------------------------------------------------------------------------------- - -#define MISC 0x00000000 -#define VETERANCY 0x00010000 -#define BUILDINGSCRIPTS 0x00020000 -#define CONQUEST 0x00030000 -#define REMOTECONTROL 0x00040000 - -#define AR_MINER 0x00A00000 -#define AR_IFV 0x00A10000 - -// ------------------------------------------------------------------------------------------------- -// Misc group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_TRANSITION_VTOL_LAND_ZONE (DP88_CUSTOM|MISC|0x01) //!< Sent by dp88_Aircraft_LandingZone to any GameObjects entering (param=1) or exiting (param=0) the zone -#define CUSTOM_UNITSOUNDS_HEALDECREMENT (DP88_CUSTOM|MISC|0x02) //!< Used by dp88_unitSounds to track the amount of healing a unit has recieved over a time period -#define CUSTOM_ROCKETEER_VEHICLEKILLED (DP88_CUSTOM|MISC|0x03) //!< Used by dp88_AR_Rocketeer to notify itself when the flight vehicle dies (via JFW_Death_Send_Custom) - -#define TIMER_RANDOMWEATHER (DP88_TIMER|MISC|0x01) //!< Timer to do a weather update -#define TIMER_SPAWNVEHICLEPART (DP88_TIMER|MISC|0x02) //!< Used by dp88_spawnVehiclePart -#define TIMER_MIRAGE_CHECKMOVEMENT (DP88_TIMER|MISC|0x03) //!< Used by dp88_AR_MirageTank to test for movement to toggle mirage mode -#define TIMER_TURRETSOUND (DP88_TIMER|MISC|0x04) //!< Used by dp88_turretSound to test for turret rotation -#define TIMER_ROCKETEER_ENTERVEHICLE (DP88_TIMER|MISC|0x05) //!< Used by dp88_AR_Rocketeer to enter the flight vehicle -#define TIMER_PARADROP_CHECKFALLRATE (DP88_TIMER|MISC|0x06) //!< Used by dp88_AR_Paradrop to check if the falling speed drops (ie: landed) - -// ------------------------------------------------------------------------------------------------- -// Veterancy group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_VETERANCY_PROMOTED (DP88_CUSTOM|VETERANCY|0x01) //!< Sent to self to notify other scripts about a promotion -#define CUSTOM_VETERANCY_REMOVE_OLD_WEAPON (DP88_CUSTOM|VETERANCY|0x02) //!< Remove infantry units previous weapon after a promotion upgraded it -#define CUSTOM_VETERANCY_GRANT_POINTS_DELAY (DP88_CUSTOM|VETERANCY|0x03) //!< Sent by dp88_veterancyGrantPoints to itself to delay the points grant until after game init - -#define TIMER_VETERANCY_EXPIRE_PROMOTION_CHEVRON (DP88_TIMER|VETERANCY|0x01) //!< Timer to clear promotion chevron - -// ------------------------------------------------------------------------------------------------- -// Building scripts group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD (DP88_CUSTOM|BUILDINGSCRIPTS|0x01) -#define CUSTOM_BUILDINGSCRIPTS_UNREGISTERCHILD (DP88_CUSTOM|BUILDINGSCRIPTS|0x02) -#define CUSTOM_BUILDINGSCRIPTS_CHILDDESTROYED (DP88_CUSTOM|BUILDINGSCRIPTS|0x03) //!< Sent to the controller when a child is destroyed (minor / major WP) -#define CUSTOM_BUILDINGSCRIPTS_CHILDREPAIRED (DP88_CUSTOM|BUILDINGSCRIPTS|0x04) //!< Sent to the controller when a child is repaired (minor WP) -#define CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED (DP88_CUSTOM|BUILDINGSCRIPTS|0x05) //!< Sent by the controller to children when the building is destroyed -#define CUSTOM_BUILDINGSCRIPTS_BUILDINGOFFLINE (DP88_CUSTOM|BUILDINGSCRIPTS|0x06) //!< Sent by the controller to children when the building is offline -#define CUSTOM_BUILDINGSCRIPTS_BUILDINGONLINE (DP88_CUSTOM|BUILDINGSCRIPTS|0x07) //!< Sent by the controller to children when the building is online -#define CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED (DP88_CUSTOM|BUILDINGSCRIPTS|0x08) //!< Sent by the controller to children when the building has been captured or made neutral, or from a capture point to a building when it has been captured or made neutral - -#define TIMER_BUILDINGSCRIPTS_CAPTUREPOINT (DP88_TIMER|BUILDINGSCRIPTS|0x01) //!< Runs on a building capture point to constantly move the health towards equilibrium -#define TIMER_BUILDINGSCRIPTS_TRICKLEMONEY (DP88_TIMER|BUILDINGSCRIPTS|0x02) //!< Runs on a trickle money building effect to grant money once per second - -// ------------------------------------------------------------------------------------------------- -// Conquest scripts group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_CONQUEST_GIVEPOINTS_T0 (DP88_CUSTOM|CONQUEST|0x01) //!< Sent to the dp88_conquestController to grant points to team 0 -#define CUSTOM_CONQUEST_GIVEPOINTS_T1 (DP88_CUSTOM|CONQUEST|0x02) //!< Sent to the dp88_conquestController to grant points to team 1 - -#define TIMER_CONQUEST_DOINTRO (DP88_TIMER|CONQUEST|0x01) //!< Used by dp88_conquestController to trigger the intro message -#define TIMER_CONQUEST_DOSCORES (DP88_TIMER|CONQUEST|0x02) //!< Used by dp88_conquestController to trigger the scores message -#define TIMER_CONQUEST_TICK (DP88_TIMER|CONQUEST|0x03) //!< Tick event timer used by conquest scripts -#define TIMER_CONQUEST_THINK (DP88_TIMER|CONQUEST|0x04) //!< Think event timer used by conquest scripts - -// ------------------------------------------------------------------------------------------------- -// Remote control group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_REMOTECONTROL_CREATED (DP88_CUSTOM|REMOTECONTROL|0x01) //!< Sent by a remote controlled vehicle when it is created -#define CUSTOM_REMOTECONTROL_DRIVEREXIT (DP88_CUSTOM|REMOTECONTROL|0x02) //!< Sent by a remote controlled vehicle when it's driver exits -#define CUSTOM_REMOTECONTROL_DESTROYED (DP88_CUSTOM|REMOTECONTROL|0x03) //!< Sent by a remote controlled vehicle when it is destroyed -#define CUSTOM_REMOTECONTROL_CONSOLEID (DP88_CUSTOM|REMOTECONTROL|0x04) -#define CUSTOM_REMOTECONTROL_CONSOLEACK (DP88_CUSTOM|REMOTECONTROL|0x05) -#define CUSTOM_REMOTECONTROL_DISABLED (DP88_CUSTOM|REMOTECONTROL|0x06) //!< Send to a remote control console to disable it -#define CUSTOM_REMOTECONTROL_ENABLED (DP88_CUSTOM|REMOTECONTROL|0x07) //!< Send to a remote control console to enable it - -#define TIMER_REMOTECONTROL_TIMEOUT (DP88_TIMER|REMOTECONTROL|0x01) //!< Timer to time out a remote vehicle purchase if we don't get confirmation within the deadline -#define TIMER_REMOTECONTROL_DRIVERENTER (DP88_TIMER|REMOTECONTROL|0x02) //!< Timer to place driver into remove vehicle once transitions are enabled -#define TIMER_REMOTECONTROL_DRIVEREXIT (DP88_TIMER|REMOTECONTROL|0x03) //!< Timer to return driver from a dead remote vehicle -#define TIMER_REMOTECONTROL_CHARGETICK (DP88_TIMER|REMOTECONTROL|0x04) //!< Timer to count down charge time - -// ------------------------------------------------------------------------------------------------- -// AR Miner group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_MINER_ENTERED_ORE_FIELD (DP88_CUSTOM|AR_MINER|0x01) //!< Sent by ore field zone to miners on entry -#define CUSTOM_MINER_EXITED_ORE_FIELD (DP88_CUSTOM|AR_MINER|0x02) //!< Sent by ore field zone to miners on exit -#define CUSTOM_MINER_ENTERED_DUMP_ZONE (DP88_CUSTOM|AR_MINER|0x03) //!< Sent by ore dump zone to miners on entry -#define CUSTOM_MINER_INCREASE_ORE_LOAD (DP88_CUSTOM|AR_MINER|0x04) //!< Sent by miners to themselves on a delay to increase their ore load -#define CUSTOM_MINER_UNLOAD_ORE_COMPLETE (DP88_CUSTOM|AR_MINER|0x05) //!< Sent by miners to themselves on a delay to finish unloading ore -#define CUSTOM_CHRONO_MINER_DO_CHRONOSHIFT (DP88_CUSTOM|AR_MINER|0x06) //!< Sent by Chrono Miner to itself to trigger chronoshift -#define CUSTOM_CHRONO_MINER_RETRY_CHRONOSHIFT (DP88_CUSTOM|AR_MINER|0x07) //!< Sent by Chrono Miner to itself to retry a failed chronoshift - -// ------------------------------------------------------------------------------------------------- -// AR IFV group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_IFV_REQUESTDRIVERDATA (DP88_CUSTOM|AR_IFV|0x01) //!< Request IFV anim frame and powerup data from driver -#define CUSTOM_IFV_DRIVER_ANIMFRAME (DP88_CUSTOM|AR_IFV|0x02) //!< IFV deployed anim frame for driver -#define CUSTOM_IFV_DRIVER_ROOKIEPOWID (DP88_CUSTOM|AR_IFV|0x03) //!< IFV deployed rookie weapon POW id for driver -#define CUSTOM_IFV_DRIVER_VETERANPOWID (DP88_CUSTOM|AR_IFV|0x04) //!< IFV deployed veteran weapon POW id for driver -#define CUSTOM_IFV_DRIVER_ELITEPOWID (DP88_CUSTOM|AR_IFV|0x05) //!< IFV deployed elite weapon POW id for driver - -#define TIMER_IFV_ALLOWDEPLOY (DP88_TIMER|AR_IFV|0x01) //!< Timer to allow deployment again -#define TIMER_IFV_DEPLOYCOMPLETE (DP88_TIMER|AR_IFV|0x02) //!< Timer to set new animation frame after deployment - - - - - - - - - /**************************** -Unsorted customs and timers +Define custom codes ****************************/ -//#define CUSTOM_PILOTED_VEHICLE_ID 10022554 +//#define CUSTOM_PROMOTED 10022551 +//#define CUSTOM_ENTERED_ORE_FIELD 10022552 +//#define CUSTOM_EXITED_ORE_FIELD 10022553 +#define CUSTOM_PILOTED_VEHICLE_ID 10022554 +//#define CUSTOM_DRIVER_PROMOTED 10022555 +#define CUSTOM_CHEVRON_ID_CHECK 10022556 +//#define CUSTOM_ENTERED_ORE_DROP_ZONE 10022557 +#define CUSTOM_ENTERED_VTOL_LAND_ZONE 10022558 +#define CUSTOM_EXITED_VTOL_LAND_ZONE 10022559 /*#define CUSTOM_TD_TARGET_ID 10022560 #define CUSTOM_TD_TARGET_DIED 10022561 #define CUSTOM_TD_TARGET_REPAIRED 10022562 @@ -151,14 +32,60 @@ #define CUSTOM_TD_PURCHASEWAIT_OK 10022565 #define CUSTOM_TD_REPORTCREATION 10022566 #define CUSTOM_TD_CONSOLEID 10022567 -#define CUSTOM_TD_DRIVEREXIT 10022568 +#define CUSTOM_TD_DRIVEREXIT 10022568*/ #define CUSTOM_KILLSELF 10022569 -#define CUSTOM_RESET_SHIELD 10022570*/ +#define CUSTOM_RESET_SHIELD 10022570 + +// Customs for veterancy system +#define CUSTOM_VETERANCY_PROMOTED 1144000001 // Sent to self to notify other scripts about a promotion +#define CUSTOM_VETERANCY_REMOVE_OLD_WEAPON 1144000002 // Remove infantry units previous weapon after a promotion upgraded it +#define CUSTOM_VETERANCY_GRANT_POINTS_DELAY 1144000003 // Sent by dp88_veterancyGrantPoints to itself to delay the points grant until after game init + +// Customs for IFV scripts +#define CUSTOM_IFV_REQUESTDRIVERDATA 1144010001 // Request IFV anim frame and powerup data from driver +#define CUSTOM_IFV_DRIVER_ANIMFRAME 1144010002 // IFV deployed anim frame for driver +#define CUSTOM_IFV_DRIVER_ROOKIEPOWID 1144010003 // IFV deployed rookie weapon POW id for driver +#define CUSTOM_IFV_DRIVER_VETERANPOWID 1144010004 // IFV deployed veteran weapon POW id for driver +#define CUSTOM_IFV_DRIVER_ELITEPOWID 1144010005 // IFV deployed elite weapon POW id for driver + +// Custom for indirect targetting +#define CUSTOM_INSTALL_IT_DECREMENT 1144020001 // Attach decrease hook script + +// Customs for dp88_unitSounds +#define CUSTOM_UNITSOUNDS_HEALDECREMENT 1144030001 + +// Customs for building scripts +#define CUSTOM_BUILDINGSCRIPTS_REGISTERCHILD 1144040001 +#define CUSTOM_BUILDINGSCRIPTS_UNREGISTERCHILD 1144040002 +#define CUSTOM_BUILDINGSCRIPTS_CHILDDESTROYED 1144040003 // Sent to the controller when a child is destroyed (minor / major WP) +#define CUSTOM_BUILDINGSCRIPTS_CHILDREPAIRED 1144040004 // Sent to the controller when a child is repaired (minor WP) +#define CUSTOM_BUILDINGSCRIPTS_BUILDINGDESTROYED 1144040005 // Sent by the controller to children when the building is destroyed +#define CUSTOM_BUILDINGSCRIPTS_BUILDINGOFFLINE 1144040006 // Sent by the controller to children when the building is offline +#define CUSTOM_BUILDINGSCRIPTS_BUILDINGONLINE 1144040007 // Sent by the controller to children when the building is online +#define CUSTOM_BUILDINGSCRIPTS_BUILDINGCAPTURED 1144040008 // Sent by the controller to children when the building has been captured or made neutral, or from a capture point to a building when it has been captured or made neutral + +// Customs for AR Miners +#define CUSTOM_MINER_ENTERED_ORE_FIELD 1144050001 // Sent by ore field zone to miners on entry +#define CUSTOM_MINER_EXITED_ORE_FIELD 1144050002 // Sent by ore field zone to miners on exit +#define CUSTOM_MINER_ENTERED_DUMP_ZONE 1144050003 // Sent by ore dump zone to miners on entry +#define CUSTOM_MINER_INCREASE_ORE_LOAD 1144050004 // Sent by miners to themselves on a delay to increase their ore load +#define CUSTOM_MINER_UNLOAD_ORE_COMPLETE 1144050005 // Sent by miners to themselves on a delay to finish unloading ore +#define CUSTOM_CHRONO_MINER_DO_CHRONOSHIFT 1144050006 // Sent by Chrono Miner to itself to trigger chronoshift +#define CUSTOM_CHRONO_MINER_RETRY_CHRONOSHIFT 1144050007 // Sent by Chrono Miner to itself to retry a failed chronoshift // Customs for Prism Tower script #define CUSTOM_PRISMTOWER_REQUEST_CHARGING 1144060001 #define CUSTOM_PRISMTOWER_STOP_CHARGING 1144060002 +// Customs for Remote Control script +#define CUSTOM_REMOTECONTROL_CREATED 1144070001 // Sent by a remote controlled vehicle when it is created +#define CUSTOM_REMOTECONTROL_DRIVEREXIT 1144070002 // Sent by a remote controlled vehicle when it's driver exits +#define CUSTOM_REMOTECONTROL_DESTROYED 1144070003 // Sent by a remote controlled vehicle when it is destroyed +#define CUSTOM_REMOTECONTROL_CONSOLEID 1144070004 +#define CUSTOM_REMOTECONTROL_CONSOLEACK 1144070005 +#define CUSTOM_REMOTECONTROL_DISABLED 1144070006 // Send to a remote control console to disable it +#define CUSTOM_REMOTECONTROL_ENABLED 1144070007 // Send to a remote control console to enable it + // Customs for custom turret AI scripts #define CUSTOM_TURRETAI_ENEMYSEEN 1144080001 // Sent from dp88_AI_PopupTurret_Spotter to dp88_AI_PopupTurret #define CUSTOM_TURRETAI_ANIMATIONCOMPLETE 1144080002 // Send from dp88_AI_ChargeTurret_Animation to dp88_AI_ChargeTurret @@ -166,25 +93,56 @@ -#define TIMER_CHECK_BASE_POWER_STATE 10055220 // Used by scripts which need to check if a base is still powered +/**************************** +Define timer numbers +****************************/ +#define TIMER_CHECK_BASE_POWER_STATE 10055220 // Used by scripts which need to check if a base is still powered +#define TIMER_REMOVE_OLDWEAPON 10055221 #define TIMER_CLEG_PHASEDEATH 10055222 #define TIMER_CLEG_CHECKDROPOBJ 10055223 #define TIMER_CLEG_CHECKRELEASETARGET 10055224 +//#define TIMER_EXPIRE_PROMOTION_CHEVRON 10055225 +//#define TIMER_INCREASE_ORE_LOAD 10055226 +//#define TIMER_CHRONOMINER_CHRONOSHIFT_COMPLETE 10055227 +//#define TIMER_UNLOAD_ORE_COMPLETE 10055228 /*#define TIMER_TD_DO_DAMAGE 10055229 #define TIMER_TD_PURCHASEWAIT 10055230 #define TIMER_TD_PURCHASETIMEEXPIRED 10055231 #define TIMER_TD_TRANSITIONS_ENABLE 10055232 #define TIMER_TD_DIED_DRIVERFREE 10055233*/ +#define TIMER_MIRAGE_CHECKMOVEMENT 10055234 #define TIMER_LINKHEALTH 10055235 #define TIMER_LINKVETPOINTS 10055236 +#define TIMER_SPAWNVEHICLEPART 10055237 // Used by dp88_spawnVehiclePart #define TIMER_HEALTHARMOURREGENTICK 10055239 +// Timers for veterancy system +#define TIMER_VETERANCY_EXPIRE_PROMOTION_CHEVRON 2244000001 // Timer to clear promotion chevron + +// Timers for IFV scripts +#define TIMER_IFV_ALLOWDEPLOY 2244010001 // Timer to allow deployment again +#define TIMER_IFV_DEPLOYCOMPLETE 2244010002 // Timer to set new animation frame after deployment + +// Timer for random weather script +#define TIMER_RANDOMWEATHER 2244020001 // Timer to do a weather update + +// Timers for building scripts +#define TIMER_BUILDINGSCRIPTS_CAPTUREPOINT 2244030001 // Runs on a building capture point to constantly move the health towards equilibrium + +// Timers for building effect scripts +#define TIMER_BUILDINGSCRIPTS_TRICKLEMONEY 2244030501 // Runs on a trickle money effect to grant money once per second // Timers for prism towers and tesla coils -#define TIMER_CUSTOMAI_THINK 2244040001 //!< Timer that fires every 1 second in my custom AI scripts to update target state etc +#define TIMER_CUSTOMAI_THINK 2244040001 // Timer that fires every 1 second in my custom AI scripts to update target state etc #define TIMER_TESLACOIL_DECREMENT_CHARGE 2244040002 // Timers for dp88_chronoTank -#define TIMER_CHRONOTANK_ADVANCE_STATE 2244060001 //!< Timer to advance to the next state -#define TIMER_CHRONOTANK_RANDOM_INTERFERENCE 2244060002 //!< Timer to randomly alter velocity and heading during shifted out phase (unstable vortex) \ No newline at end of file +#define TIMER_CHRONOTANK_ADVANCE_STATE 2244060001 // Timer to advance to the next state +#define TIMER_CHRONOTANK_RANDOM_INTERFERENCE 2244060002 // Timer to randomly alter velocity and heading during shifted out phase (unstable vortex) + +// Timers for Remote Control script +#define TIMER_REMOTECONTROL_TIMEOUT 2244070001 // Timer to time out a remote vehicle purchase if we don't get confirmation within the deadline +#define TIMER_REMOTECONTROL_DRIVERENTER 2244070002 // Timer to place driver into remove vehicle once transitions are enabled +#define TIMER_REMOTECONTROL_DRIVEREXIT 2244070003 // Timer to return driver from a dead remote vehicle +#define TIMER_REMOTECONTROL_CHARGETICK 2244070004 // Timer to count down charge time \ No newline at end of file diff -uwr source/scripts/dp88_misc.cpp sourceold/scripts/dp88_misc.cpp --- source/scripts/dp88_misc.cpp 2013-01-21 11:44:47.533070300 +0800 +++ sourceold/scripts/dp88_misc.cpp 2012-07-28 09:11:06.000000000 +0800 @@ -16,11 +16,6 @@ #include "VehicleGameObj.h" #include "SoldierGameObj.h" #include "SoldierGameObjDef.h" -#include "GameObjManager.h" -#include "ScriptZoneGameObj.h" -#include "RenderObjClass.h" -#include "cPlayer.h" -#include "cTeam.h" /*------------------------ @@ -210,6 +205,180 @@ /*------------------------ +Indirect Targetting Scripts +--------------------------*/ + +void dp88_indirectTargetting::Created ( GameObject* obj ) +{ + objectID = Commands->Get_ID ( obj ); + pilotID = NULL; + targettingLevel = new int(0); + + Console_Output ( "TL1: %p\n", targettingLevel ); + + Commands->Send_Custom_Event (obj,obj,CUSTOM_INSTALL_IT_DECREMENT,0,0.0f); +} + + +void dp88_indirectTargetting::Destroyed ( GameObject* obj ) +{ + delete targettingLevel; +} + + +void dp88_indirectTargetting::Custom( GameObject *obj, int type, int param, GameObject *sender ) +{ + // Look for vehicle entry + if ( type == CUSTOM_EVENT_VEHICLE_ENTERED ) + { + if ( pilotID == NULL ) + { + pilotID = Commands->Get_ID(sender); + + InstallHook( "TargettingLevelInc", sender ); + } + } + + + + + // Look for vehicle exit + else if ( type == CUSTOM_EVENT_VEHICLE_EXITED ) + { + if ( Commands->Get_ID(sender) == pilotID ) + { + pilotID = NULL; + + RemoveHook(); + } + } + + + // Look for install decrement script + else if ( type == CUSTOM_INSTALL_IT_DECREMENT ) + { + char* script_parameters = new char[strlen(Get_Parameter ( "targettingAnimation" ))+193]; + sprintf ( script_parameters, "%s,%d,%d,%d,%p", Get_Parameter ( "targettingAnimation" ), Get_Int_Parameter ( "targettingLevels"), Get_Int_Parameter ( "maxFrame" ), Get_Int_Parameter ( "maxFrame" ), &targettingLevel ); + Console_Output ( "script params: %s\n", script_parameters ); + Commands->Attach_Script ( obj, "dp88_indirectTargetting_Dec", script_parameters ); + delete [] script_parameters; + } +} + + +void dp88_indirectTargetting::KeyHook() +{ + // Find object + GameObject* obj = Commands->Find_Object ( objectID ); + if ( !obj ) + return; + + + if ( (*targettingLevel)++ <= Get_Int_Parameter ( "targettingLevels" ) ) + { + float framesPerLevel = ((float)Get_Int_Parameter ( "maxFrame" ) - (float)Get_Int_Parameter ( "minFrame" )) / (float)Get_Int_Parameter ( "targettingLevels" ); + float targetFrame = framesPerLevel * (float)(*targettingLevel); + + Console_Output ( "framesPerLevel: %.4f\n", framesPerLevel ); + Console_Output ( "targetFrame: %.4f\n", targetFrame ); + + Commands->Set_Animation ( obj, Get_Parameter ( "targettingAnimation" ), false, NULL, Get_Animation_Frame ( obj ), targetFrame, false ); + } + else + (*targettingLevel) = Get_Int_Parameter ( "targettingLevels" ); +} + + + + + +void dp88_indirectTargetting_Dec::Created ( GameObject* obj ) +{ + objectID = Commands->Get_ID ( obj ); + pilotID = NULL; + targettingLevel = (int*)Get_Int_Parameter ( "TL_ADDR" ); + + Console_Output ( "TL2: %p\n", targettingLevel ); + + // Catch errors + if ( targettingLevel == NULL ) + { + Console_Output ( "ERROR: dp88_indirectTargetting_Dec should never be used on it's own, use dp88_indirectTargetting instead.\n" ); + Destroy_Script(); + } +} + + +void dp88_indirectTargetting_Dec::Custom( GameObject *obj, int type, int param, GameObject *sender ) +{ + // Look for vehicle entry + if ( type == CUSTOM_EVENT_VEHICLE_ENTERED ) + { + if ( pilotID == NULL ) + { + pilotID = Commands->Get_ID(sender); + + InstallHook( "TargettingLevelDec", sender ); + } + } + + + + + // Look for vehicle exit + else if ( type == CUSTOM_EVENT_VEHICLE_EXITED ) + { + if ( Commands->Get_ID(sender) == pilotID ) + { + pilotID = NULL; + + RemoveHook(); + } + } +} + + +void dp88_indirectTargetting_Dec::KeyHook() +{ + // Find object + GameObject* obj = Commands->Find_Object ( objectID ); + if ( !obj ) + return; + + + (*targettingLevel)--; + float targetFrame = (float)((*targettingLevel)/2); + Commands->Set_Animation ( obj, Get_Parameter ( "targettingAnimation" ), false, NULL, 1.0f, targetFrame, false ); +} + + +ScriptRegistrant dp88_indirectTargetting_Registrant( + "dp88_indirectTargetting", + "targettingAnimation=obj.obj:string," + "targettingLevels=100:int," + "minFrame=1:int," + "maxFrame=100:int" +); + +ScriptRegistrant dp88_indirectTargetting_Dec_Registrant( + "dp88_indirectTargetting_Dec", + "targettingAnimation=obj.obj:string," + "targettingLevels=100:int," + "minFrame=1:int," + "maxFrame=100:int," + "TL_ADDR=0:int" +); + + + + + + + + + + +/*------------------------ Unit sounds script --------------------------*/ @@ -492,7 +661,7 @@ if ( amount >= 0 ) { while ( currentDamageLevel < 5 && damageLevelBoundaries[currentDamageLevel+1] >= 0 - && ((Get_Hitpoints(obj)/Get_Max_Hitpoints(obj))*100.0f) < damageLevelBoundaries[currentDamageLevel+1] ) + && ((Commands->Get_Health(obj)/Commands->Get_Max_Health(obj))*100.0f) < damageLevelBoundaries[currentDamageLevel+1] ) { currentDamageLevel++; basePowerState = Is_Base_Powered(Get_Object_Type(obj)); @@ -504,7 +673,7 @@ if ( amount <= 0 ) { while ( currentDamageLevel > 0 - && ((Get_Hitpoints(obj)/Get_Max_Hitpoints(obj))*100.0f) > damageLevelBoundaries[currentDamageLevel] ) + && ((Commands->Get_Health(obj)/Commands->Get_Max_Health(obj))*100.0f) > damageLevelBoundaries[currentDamageLevel] ) { currentDamageLevel--; basePowerState = Is_Base_Powered(Get_Object_Type(obj)); @@ -630,11 +799,6 @@ announcement was made then trigger the under attack announcement */ if ( amount > 0 && time(NULL) - lastAnnouncementTime > minimumAnnounceInterval ) { - // Don't trigger above 95% health to avoid lots of annoying announcements when it takes a tiny - // bit of damage from an explosion - if ( 0.95f < (Commands->Get_Health(obj)+Commands->Get_Shield_Strength(obj))/(Commands->Get_Max_Health(obj)+Commands->Get_Max_Shield_Strength(obj)) ) - return; - lastAnnouncementTime = time(NULL); /* Send messages to teams */ @@ -1116,8 +1280,10 @@ GameObject* part = Commands->Find_Object(partObjectId); if ( part ) { - Attach_Script_Once_V ( part, "dp88_linkHealth", "%d", Commands->Get_ID(obj) ); - Attach_Script_Once_V ( part, "dp88_linkVetPoints", "%d", Commands->Get_ID(obj) ); + char hostIdString[12]; + sprintf ( hostIdString, "%d", Commands->Get_ID(obj) ); + Attach_Script_Once ( part, "dp88_linkHealth", hostIdString ); + Attach_Script_Once ( part, "dp88_linkVetPoints", hostIdString ); } } } @@ -1153,6 +1319,8 @@ + + /*------------------------ Custom Points script --------------------------*/ @@ -1161,15 +1329,14 @@ { // Preload values since converting strings to floats every time we take // damage is very inefficient - m_killPoints = Get_Float_Parameter("killPoints"); - m_damagePoints = Get_Float_Parameter("damagePoints"); - m_repairPoints = Get_Float_Parameter("repairPoints"); - m_killMoney = Get_Float_Parameter("killMoney"); - m_damageMoney = Get_Float_Parameter("damageMoney"); - m_repairMoney = Get_Float_Parameter("repairMoney"); + killPoints = Get_Float_Parameter("killPoints"); + damagePoints = Get_Float_Parameter("damagePoints"); + repairPoints = Get_Float_Parameter("repairPoints"); + killMoney = Get_Float_Parameter("killMoney"); + damageMoney = Get_Float_Parameter("damageMoney"); + repairMoney = Get_Float_Parameter("repairMoney"); } -// ------------------------------------------------------------------------------------------------- void dp88_customPoints::Damaged ( GameObject *obj, GameObject *damager, float amount ) { @@ -1182,8 +1349,8 @@ calculating points granted */ bool bRepair = (amount < 0); amount = abs(amount); - float points = ((bRepair) ? m_repairPoints : m_damagePoints) * amount; - float money = ((bRepair) ? m_repairMoney : m_damageMoney) * amount; + float points = ((bRepair) ? repairPoints : damagePoints) * amount; + float money = ((bRepair) ? repairMoney : damageMoney) * amount; // Is this player an APB spy? bool bSpy = Is_Spy(damager); @@ -1197,10 +1364,10 @@ } // Give the damager their points and money - GivePointsAndMoney ( damager, points, money ); + Commands->Give_Points(damager, points, false); + Commands->Give_Money(damager, money, false); } -// ------------------------------------------------------------------------------------------------- void dp88_customPoints::Killed ( GameObject* obj, GameObject *killer ) { @@ -1212,35 +1379,17 @@ // Killed own teammate? That would be negative points and no cash for you then... if ( Get_Object_Type(obj) == Get_Object_Type(killer) ) { - GivePointsAndMoney ( killer, m_killPoints*-1.0f, 0.0f ); + Commands->Give_Points(killer, killPoints*-1.0f, false); } else { // Give the killer their points and money - GivePointsAndMoney ( killer, m_killPoints, m_killMoney ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_customPoints::GivePointsAndMoney ( GameObject* obj, float points, float money ) -{ - int playerId = Get_Player_ID(obj); - if ( playerId >= 0 ) - { - if ( cPlayer* player = Find_Player(playerId) ) - { - player->Set_Score(player->Get_Score()+points); - player->Increment_Money(money); - } + Commands->Give_Points(killer, killPoints, false); + Commands->Give_Money(killer, killMoney, false); } - - int team = Get_Object_Type(obj); - Set_Team_Score(team, Get_Team_Score(team) + points); } -// ------------------------------------------------------------------------------------------------- ScriptRegistrant dp88_customPoints_Registrant( "dp88_customPoints", @@ -1251,696 +1400,3 @@ "damageMoney:float," "repairMoney:float" ); - - - - - - - - -/*------------------------ -Conquest Controller ---------------------------*/ - -void dp88_conquestController::Created ( GameObject* pSelf ) -{ - m_scoringMode = (unsigned char)Get_Int_Parameter("ScoringMode"); - - m_targets[0] = Get_Int_Parameter("TargetScoreTeam0"); - m_targets[1] = Get_Int_Parameter("TargetScoreTeam1"); - - m_points[0] = ( m_scoringMode == MODE_DEFAULT ) ? 0 : m_targets[0]; - m_points[1] = ( m_scoringMode == MODE_DEFAULT ) ? 0 : m_targets[1]; - - // Do game intro after 30 seconds, giving people time to load up - Commands->Start_Timer( pSelf, this, 30.0f, TIMER_CONQUEST_DOINTRO ); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_conquestController::Timer_Expired ( GameObject* pSelf, int number ) -{ - if ( number == TIMER_CONQUEST_DOINTRO ) - { - // Show intro - // \todo Send intro message - - // Start scores timer if interval > 0 - int scoreInterval = Get_Int_Parameter("ScoreInterval"); - if ( scoreInterval > 0 ) - Commands->Start_Timer( pSelf, this, (float)scoreInterval, TIMER_CONQUEST_DOSCORES ); - } - - - else if ( number == TIMER_CONQUEST_DOSCORES ) - { - // Show scores - // \todo Send scores message - char scoresMsg[1000]; - sprintf_s ( scoresMsg, sizeof(scoresMsg), "Scores are currently: Team 0 (%d/%d), Team 1 (%5d/%d)", m_points[0], m_targets[0], m_points[1], m_targets[1]); - Send_Message(50,200,50,scoresMsg); - - Commands->Start_Timer( pSelf, this, (float)Get_Int_Parameter("ScoreInterval"), TIMER_CONQUEST_DOSCORES ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_conquestController::Custom ( GameObject* pSelf, int type, int param, GameObject* pSender ) -{ - if ( type == CUSTOM_CONQUEST_GIVEPOINTS_T0 || type == CUSTOM_CONQUEST_GIVEPOINTS_T1 ) - { - int team = (type==CUSTOM_CONQUEST_GIVEPOINTS_T0) ? 0 : 1; - int otherteam = (team==0) ? 1 : 0; - - // In normal scoring mode grant points to the earning team - if ( m_scoringMode == MODE_DEFAULT ) - { - m_points[team] += param; - - // Have we won? - if ( m_points[team] >= m_targets[team] ) - { - BaseControllerClass::Find_Base(otherteam)->Set_Base_Destroyed(true); - } - } - - // In deduction scoring mode deduct points from the opposing team - else if ( m_scoringMode == MODE_DEDUCTION ) - { - m_points[otherteam] -= param; - - // Have they lost? - if ( m_points[otherteam] < 0 ) - { - BaseControllerClass::Find_Base(otherteam)->Set_Base_Destroyed(true); - } - } - } -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_conquestController_Registrant( - "dp88_conquestController", - "ScoringMode=0:int," - "TargetScoreTeam0=100:int," - "TargetScoreTeam1=100:int," - "IntroString:string," - "ScoreInterval=60:int," - "ScoreString:string," - "ScoreStringTeam0:string," - "ScoreStringTeam1:string" -); - - - - - - - - - - -/*------------------------ -Conquest Control Zone ---------------------------*/ - -void dp88_conquestControlZone::Created ( GameObject* pObj ) -{ - // Find the controller - GameObject* pController = Find_Object_With_Script("dp88_conquestController"); - if ( !pController ) - { - Console_Output ( "[%d:%s:%s] Critical Error: Conquest controller object not found. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); - return; - } - m_controllerID = Commands->Get_ID(pController); - - // Validate zone preset - if ( !Is_Valid_Preset(Get_Parameter("ZonePreset")) ) - { - Console_Output ( "[%d:%s:%s] Critical Error: A script zone preset with the name '%s' was not found. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name(), Get_Parameter("ZonePreset") ); - Destroy_Script(); - return; - } - - // Determine the size and rotation for the control zone - Vector3 position; - Vector3::Add ( Commands->Get_Position(pObj), Get_Vector3_Parameter("ZoneOffset"), &position ); - Vector3 size = Get_Vector3_Parameter("ZoneSize"); - Matrix3 rotation(true); - rotation.Rotate_Z(Commands->Get_Facing(pObj)); - - // Define the bounding box and create the zone - OBBoxClass zoneBoundingBox ( position, size, rotation ); - GameObject* pZone = Create_Zone(Get_Parameter("ZonePreset"), zoneBoundingBox ); - m_zoneID = Commands->Get_ID(pZone); - - // Load settings - m_captureTime = Get_Int_Parameter("CaptureTime"); - m_bAllowMajorityCapture = (Get_Int_Parameter("AllowMajorityCapture") > 0); - m_multiCaptureCap = Get_Int_Parameter("MultiCaptureCap"); - m_multiCaptureMultiplier = Get_Float_Parameter("MultiCaptureMultiplier"); - m_nAnimTransitionFrames = Get_Int_Parameter("CaptureAnimTransitionFrames"); - - if ( m_captureTime <= 0 || m_multiCaptureCap <= 0 || m_multiCaptureMultiplier <= 0.0f || m_nAnimTransitionFrames < 0 ) - { - Console_Output ( "[%d:%s:%s] Critical Error: Invaild script parameters. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); - return; - } - - // Determine starting team and, if not neutral, start the tick timer to grant points per tick - int team = (unsigned char)Get_Object_Type(pObj); - if ( team < 2 ) - { - m_captureState = (float)((team==0) ? (m_captureTime*-1) : m_captureTime); - Commands->Start_Timer( pObj, this, (float)Get_Int_Parameter("TickInterval"), TIMER_CONQUEST_TICK ); - m_bTickRunning = true; - } - else - { - m_captureState = 0.0f; - m_bTickRunning = false; - - // Force correct neutral team - Set_Object_Type(pObj, 2); - } - - // Set initial animation state - UpdateAnimationFrame(pObj); - - // Start the think timer to track players in the zone and update ownership accordingly - Commands->Start_Timer( pObj, this, 1.0f, TIMER_CONQUEST_THINK ); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_conquestControlZone::Timer_Expired ( GameObject* pObj, int number ) -{ - ScriptZoneGameObj* pZone = (ScriptZoneGameObj*)Commands->Find_Object(m_zoneID); - if ( !pZone || !((GameObject*)pZone)->As_ScriptZoneGameObj() ) // Sanity checking - return; - - if ( number == TIMER_CONQUEST_THINK ) - { - // Count the objects inside the zone - not we don't simply use Get_Object_Count_In_Zone because - // we don't want to count vehicles *and* their drivers... but we do want to allow AI units to - // contribute. Also ignore dead units... - int nPlayers[2] = {0}; - for (SLNode *z = GameObjManager::SmartGameObjList.Head();z;z = z->Next()) - { - SmartGameObj* o = z->Data(); - int team = Get_Object_Type(o); - if ( Commands->Get_Health(o) == 0 || team < 0 || team > 2 || !pZone->Inside_Me(o) ) - continue; - - // Only AI-enabled vehicles count - if ( o->As_VehicleGameObj() && !((VehicleGameObj*)o)->Get_Action()->Is_Acting() ) - continue; - - nPlayers[team]++; - } - - // Check which team currently controls the area inside the zone (and can therefore capture it) - int capturingTeam = -1; - if ( nPlayers[0] != nPlayers[1] ) - { - if ( nPlayers[0] > nPlayers[1] && (nPlayers[1] == 0 || m_bAllowMajorityCapture) ) - capturingTeam = 0; - else if ( nPlayers[1] > nPlayers[0] && (nPlayers[0] == 0 || m_bAllowMajorityCapture) ) - capturingTeam = 1; - } - - Console_Output("ccz: think (%d, %d, %d)\n", nPlayers[0], nPlayers[1], capturingTeam ); - // Increment the capture progress for the team in control of the area inside the zone - if ( capturingTeam != -1 ) - IncrementCaptureProgress ( pObj, capturingTeam, nPlayers[capturingTeam]-nPlayers[(capturingTeam==0)?1:0] ); - - - // Otherwise revert to previous state if partially captured and nobody is in the zone (don't - // trigger this if there are players in the zone but they don't currently qualify to capture it, - // avoids losing capture progress whilst fending off enemy attackers) - else if ( (nPlayers[0] == 0 && nPlayers[1] == 0) && m_captureState != 0.0f && abs(m_captureState) != m_captureTime ) - { - int team = Get_Object_Type(pObj); - int targetState = (team==2) ? 0 : ((team==0) ? (m_captureTime*-1) : m_captureTime); - - if ( targetState > m_captureState ) - { - m_captureState += 1.0f; - if ( m_captureState > targetState ) - m_captureState = (float)targetState; - } - else - { - m_captureState -= 1.0f; - if ( m_captureState < targetState ) - m_captureState = (float)targetState; - } - - UpdateAnimationFrame(pObj); - } - - - // Restart timer - Commands->Start_Timer( pObj, this, 1.0f, TIMER_CONQUEST_THINK ); - } - - - - - else if ( number == TIMER_CONQUEST_TICK ) - { - int team = Get_Object_Type(pObj); - if ( team != 2 ) - { - GameObject* pController = Commands->Find_Object(m_controllerID); - if ( !pController ) - return; - - // Grant points to owning team - int custom = (team==0) ? CUSTOM_CONQUEST_GIVEPOINTS_T0 : CUSTOM_CONQUEST_GIVEPOINTS_T1; - Commands->Send_Custom_Event ( pObj, pController, custom, Get_Int_Parameter("TickPoints"), 0.0f); - - Commands->Start_Timer( pObj, this, (float)Get_Int_Parameter("TickInterval"), TIMER_CONQUEST_TICK ); - } - else - m_bTickRunning = false; - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_conquestControlZone::IncrementCaptureProgress( GameObject* pObj, int team, int nPlayers ) -{ - // If the team already fully controls the zone then don't do anything - int targetState = (team==0) ? (m_captureTime*-1) : m_captureTime; - if ( m_captureState == targetState || nPlayers == 0 ) - return; - - // Apply multi capture cap and work out the additional progress to be applied - nPlayers = min(nPlayers,m_multiCaptureCap); - float progress = 1.0f + ((nPlayers-1)*m_multiCaptureMultiplier); - - // Apply progress - if ( team == 0 ) - { - m_captureState -= progress; - if ( m_captureState < targetState ) - m_captureState = (float)targetState; - } - else - { - m_captureState += progress; - if ( m_captureState > targetState ) - m_captureState = (float)targetState; - } - - - // Have we taken control of the zone? - if ( m_captureState == targetState && Get_Object_Type(pObj) != team ) - { - // \todo Send control taken message - Send_Message_Team(team, 50, 200, 50, "zone now controlled by your team" ); - Send_Message_Team((team==0)?1:0, 50, 200, 50, "zone now controlled by enemy team" ); - - // \todo Give capture points - - Set_Object_Type(pObj,team); - - // Set AI objectives - int aiPriority = Get_Int_Parameter("AIObjectivePriority"); - if ( aiPriority > 0 ) - { - Remove_Script(pObj,"dp88_AI_Objective"); - - Vector3 size = Get_Vector3_Parameter("ZoneSize"); - int distance = (int)(min(size.X, size.Y)*0.75f); - Attach_Script_V(pObj, "dp88_AI_Objective", "%d,%d,%d,1,1,1,1,0", aiPriority, distance, (team==0)?1:0 ); // Offensive - Attach_Script_V(pObj, "dp88_AI_Objective", "%d,%d,%d,2,1,1,1,0", aiPriority, distance, team ); // Defensive - } - - if ( !m_bTickRunning ) - Commands->Start_Timer( pObj, this, (float)Get_Int_Parameter("TickInterval"), TIMER_CONQUEST_TICK ); - } - - - // Has the zone become neutral? - else if ( (m_captureState == 0.0f || (team == 0 && m_captureState < 0.0f) || (team == 1 && m_captureState < 1.0f)) - && Get_Object_Type(pObj) != 2 ) - { - // \todo Send neutral message - Send_Message_Team(0, 50, 200, 50, "zone now neutral" ); - Send_Message_Team(1, 50, 200, 50, "zone now neutral" ); - - Set_Object_Type(pObj,2); - - // Set AI objectives - int aiPriority = Get_Int_Parameter("AIObjectivePriority"); - if ( aiPriority > 0 ) - { - Remove_Script(pObj,"dp88_AI_Objective"); - - Vector3 size = Get_Vector3_Parameter("ZoneSize"); - int distance = (int)(min(size.X, size.Y)*0.75f); - Attach_Script_V(pObj, "dp88_AI_Objective", "%d,%d,2,1,1,1,1,0", aiPriority, distance ); - } - } - - - // Set animation state - UpdateAnimationFrame(pObj); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_conquestControlZone::UpdateAnimationFrame( GameObject* pObj ) -{ - int animFrame = 1+m_nAnimTransitionFrames; // Neutral frame - int teamFrames = (int)floor((1+m_nAnimTransitionFrames) * (abs(m_captureState)/m_captureTime)); - animFrame += (m_captureState<0) ? (teamFrames*-1) : teamFrames; - Console_Output ( "ccf: uaf: %d (%d, %f/%d = %f)\n", animFrame, teamFrames, m_captureState, m_captureTime, (abs(m_captureState)/m_captureTime) ); - Commands->Set_Animation_Frame(pObj, Get_Parameter("CaptureAnim"), animFrame); -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_conquestControlZone_Registrant( - "dp88_conquestControlZone", - "ZoneSize:vector3," - "ZoneOffset:vector3," - "ZonePreset=Script_Zone_All:string," - "CapturePoints=5:int," - "CapturePointsFirstTeamOnly=1:int," - "TickPoints=1:int," - "TickInterval=3:int," - "CaptureTime=20:int," - "MultiCaptureCap=3:int," - "MultiCaptureMultiplier=0.5:float," - "AllowMajorityCapture=1:int," - "CaptureAnim:string," - "CaptureAnimTransitionFrames=0:int" - "CapturingString:string," - "NeutralString:string," - "CapturedString:string," - "AIObjectivePriority=0:int" -); - - - - - - - - - - -/*------------------------ -Radar Invisibility ---------------------------*/ - -void dp88_radarInvisibility::Created ( GameObject* pObj ) -{ - PhysicalGameObj* phys = pObj->As_PhysicalGameObj(); - if ( !phys ) - { - Console_Output ( "[%d:%s:%s] Critical Error: This script is only compatible with physical game objects. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); - return; - } - - // Disable the radar blip for this object - m_originalRadarMode = phys->Get_Radar_Blip_Shape_Type(); - phys->Set_Radar_Blip_Shape_Type(RADAR_BLIP_SHAPE_NONE); - - // If this is a vehicle then setup the passenger data structures - m_nSeats = 0; - if ( VehicleGameObj* pVehicle = pObj->As_VehicleGameObj() ) - { - m_nSeats = pVehicle->Get_Definition().Get_Seat_Count(); - m_pPassengerIds = new int[m_nSeats]; - m_pPassengerRadarModes = new int[m_nSeats]; - for ( int i = 0; i < m_nSeats; ++i ) - m_pPassengerIds[i] = NULL; - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_radarInvisibility::Custom ( GameObject* pObj, int type, int param, GameObject* pSender ) -{ - if ( type == CUSTOM_EVENT_VEHICLE_ENTERED ) - { - HidePassengerBlip(pObj->As_VehicleGameObj(), pSender->As_SoldierGameObj()); - } - - else if ( type == CUSTOM_EVENT_VEHICLE_EXITED ) - { - RestorePassengerBlip(pSender->As_SoldierGameObj()); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_radarInvisibility::HidePassengerBlip ( VehicleGameObj* pVehicle, SoldierGameObj* pSoldier ) -{ - if ( !pVehicle || !pSoldier || !m_pPassengerIds || !pSoldier->As_PhysicalGameObj() ) - return; - - for ( int i = 0; i < m_nSeats; ++i ) - { - if ( pVehicle->Get_Occupant(i) == pSoldier ) - { - m_pPassengerIds[i] = Commands->Get_ID(pSoldier); - m_pPassengerRadarModes[i] = pSoldier->As_PhysicalGameObj()->Get_Radar_Blip_Shape_Type(); - pSoldier->As_PhysicalGameObj()->Set_Radar_Blip_Shape_Type(RADAR_BLIP_SHAPE_NONE); - } - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_radarInvisibility::RestorePassengerBlip ( SoldierGameObj* pSoldier ) -{ - if ( !pSoldier || !m_pPassengerIds || !pSoldier->As_PhysicalGameObj() ) - return; - - int soldierId = Commands->Get_ID(pSoldier); - - for ( int i = 0; i < m_nSeats; ++i ) - { - if ( m_pPassengerIds[i] == soldierId ) - { - pSoldier->As_PhysicalGameObj()->Set_Radar_Blip_Shape_Type(m_pPassengerRadarModes[i]); - m_pPassengerIds[i] = NULL; - } - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_radarInvisibility::Detach ( GameObject* pObj ) -{ - if ( Exe != 4 ) // Don't trigger this code in LevelEdit - { - if ( PhysicalGameObj* phys = pObj->As_PhysicalGameObj() ) - phys->Set_Radar_Blip_Shape_Type(m_originalRadarMode); - - for ( int i = 0; i < m_nSeats; ++i ) - { - if ( m_pPassengerIds[i] != NULL ) - { - if ( GameObject* pSoldier = Commands->Find_Object(m_pPassengerIds[i]) ) - RestorePassengerBlip( pSoldier->As_SoldierGameObj() ); - } - } - } - - delete [] m_pPassengerIds; - delete [] m_pPassengerRadarModes; -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_radarInvisibility_Registrant( - "dp88_radarInvisibility", - "" -); - - - - - - - - -void dp88_turretSound::Created ( GameObject* pObj ) -{ - if ( VehicleGameObj* vObj = pObj->As_VehicleGameObj() ) - { - m_nMinDifferential = Get_Float_Parameter("Min_Differential_Rad"); - m_lastFacing = Get_Turret_Facing(vObj->Peek_Model()); - m_nSoundId = -1; - Commands->Start_Timer(pObj, this, 0.5f, TIMER_TURRETSOUND ); - } - else - { - Console_Output ( "[%d:%s:%s] Critical Error: This script is only compatible with vehicle game objects. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_turretSound::Timer_Expired ( GameObject* pObj, int number ) -{ - if ( number == TIMER_TURRETSOUND ) - { - if ( VehicleGameObj* vObj = pObj->As_VehicleGameObj() ) - { - float newFacing = Get_Turret_Facing(vObj->Peek_Model()); - - // Check if we are rotating - ignore tiny rotation amounts - bool bRotating = ( abs(newFacing-m_lastFacing) > m_nMinDifferential ); - - if ( m_nSoundId == -1 && bRotating) - Play_Sound(pObj); - - else if ( m_nSoundId != -1 && !bRotating ) - Stop_Sound(pObj); - - m_lastFacing = newFacing; - } - - // Restart timer to check for rotation - Commands->Start_Timer(pObj, this, 0.5f, TIMER_TURRETSOUND ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_turretSound::Custom ( GameObject* pObj, int type, int param, GameObject* pSender ) -{ - if (type == CUSTOM_EVENT_SOUND_ENDED && param == m_nSoundId) - { - // We will allow the timer to stop the sound if necessary, since this might trigger - // on the same engine tick, thus checking our facing against the previous timer - // facing could produce a false-positive for "stopped rotating" - Play_Sound(pObj); - } -} - -// ------------------------------------------------------------------------------------------------- - -float dp88_turretSound::Get_Turret_Facing ( RenderObjClass* pRenderObj ) -{ - if ( pRenderObj ) - { - Matrix3D vehicleTransform = pRenderObj->Get_Transform(); - Matrix3D transform = pRenderObj->Get_Bone_Transform("turret"); - return abs(vehicleTransform.getRotationZ()-transform.getRotationZ()); - } - - return 0.0f; -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_turretSound::Play_Sound ( GameObject* pObj ) -{ - m_nSoundId = Commands->Create_3D_Sound_At_Bone(Get_Parameter("Sound_Preset"), pObj, "turret"); - Commands->Monitor_Sound(pObj, m_nSoundId); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_turretSound::Stop_Sound ( GameObject* pObj ) -{ - Commands->Stop_Sound(m_nSoundId,true); - m_nSoundId = -1; -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_turretSound_Registrant( - "dp88_turretSound", - "Sound_Preset:string," - "Min_Differential_Rad=0.25:float" -); - - - - - - - - - - -// ------------------------------------------------------------------------------------------------- -// Teleportation script -// ------------------------------------------------------------------------------------------------- - -void dp88_teleport::Created ( GameObject* pObj ) -{ - m_nObjectID = Get_Int_Parameter("ObjectID"); // Don't check object ID right now, it might be created later - m_bUseBone = strlen(Get_Parameter("Bone")) > 0; - m_offset = Get_Vector3_Parameter("Offset"); - - m_bTeleportInfantry = (Get_Int_Parameter("Teleport_Infantry") == 1); - m_bTeleportVehicles = (Get_Int_Parameter("Teleport_Vehicles") == 1); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_teleport::Entered ( GameObject* pObj, GameObject* pEnterer ) -{ - if ( (m_bTeleportInfantry && pEnterer->As_SoldierGameObj()) || (m_bTeleportVehicles && pEnterer->As_VehicleGameObj()) ) - { - Vector3 location = m_offset; - - if ( m_nObjectID != 0 ) - { - GameObject* pTarget = Commands->Find_Object(m_nObjectID); - if ( !pTarget ) - return; - - location = ( m_bUseBone ) ? Commands->Get_Bone_Position(pTarget,Get_Parameter("bone")) : Commands->Get_Position(pTarget); - location.X += m_offset.X; - location.Y += m_offset.Y; - location.Z += m_offset.Z; - } - - Commands->Set_Position(pEnterer, location); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_teleport::Custom ( GameObject* pObj, int type, int param, GameObject* pSender ) -{ - if ( type == CUSTOM_EVENT_POWERUP_GRANTED ) - Entered ( pObj, pSender ); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_teleport::Poked ( GameObject* pObj, GameObject* pPoker ) -{ - Entered ( pObj, pPoker ); -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_teleport_Registrant( - "dp88_teleport", - "ObjectID=0:int," - "Bone:string," - "Offset:vector3," - "Teleport_Infantry=1:int," - "Teleport_Vehicles=1:int" -); \ No newline at end of file diff -uwr source/scripts/dp88_misc.h sourceold/scripts/dp88_misc.h --- source/scripts/dp88_misc.h 2013-01-21 11:44:47.536976600 +0800 +++ sourceold/scripts/dp88_misc.h 2012-09-11 08:40:48.000000000 +0800 @@ -116,6 +116,38 @@ /*------------------------ +Indirect targetting script +--------------------------*/ + +class dp88_indirectTargetting : public JFW_Key_Hook_Base +{ + void Created ( GameObject* obj ); + void Destroyed ( GameObject* obj ); + void Custom ( GameObject* obj, int type, int param, GameObject* sender ); + void KeyHook(); + + /* General variables. ID of this object, ID of the pilot, current + targetting level. */ + int objectID, pilotID, * targettingLevel; +}; + + +class dp88_indirectTargetting_Dec : public JFW_Key_Hook_Base +{ + void Created ( GameObject* obj ); + void Custom ( GameObject* obj, int type, int param, GameObject* sender ); + void KeyHook(); + + /* General variables. ID of this object, ID of the pilot, current + targetting level. */ + int objectID, pilotID, * targettingLevel; +}; + + + + + +/*------------------------ Unit sounds script --------------------------*/ @@ -364,399 +396,20 @@ -/*! -* \brief Custom Unit Points & Credits -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts -* -* This script provides finer control over the points and credits awarded for damaging or repairing -* an object, as opposed to the values in an LevelEdit preset which award equal amounts of score and -* credits. -* -* \note -* You should set the points value of the object to 0 in the LevelEdit preset settings or both -* values will be applied -* -* \param killPoints -* Number of points to award for killing the object -* \param damagePoints -* Number of points to award per hitpoint of damage done to the object -* \param repairPoints -* Number of points to award per hitpoint repaired on object -* \param killMoney -* Amount of credits to award for killing the object -* \param damageMoney -* Amount of credits to award per hitpoint of damage done to the object -* \param repairMoney -* Amount of credits to award per hitpoint repaired on object -*/ +/*------------------------ +Custom Points script +--------------------------*/ + class dp88_customPoints : public ScriptImpClass { -protected: void Created ( GameObject* obj ); void Damaged ( GameObject *obj, GameObject *damager, float amount ); void Killed ( GameObject* obj, GameObject *killer ); - void GivePointsAndMoney ( GameObject* obj, float points, float money ); - - /*! \name Cached Script Parameters */ - /*! @{ */ - float m_killPoints; - float m_damagePoints; - float m_repairPoints; - float m_killMoney; - float m_damageMoney; - float m_repairMoney; - /*! @} */ -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Conquest Mode - Controller -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_conquest -* -* This script controls conquest mode and must be placed on exactly one object on any map where you -* want to enable conquest mode, such as a Daves Arrow. It stores the points totals for each team -* and continually sends messages to the server with the current scores. -* -* The controller allows you to choose from one of two scoring systems, which basically work the same -* way but in different directions. The default scoring system is points accumulation mode, where -* each team starts with zero points and the points they earn are added to their total. The first -* team to reach the target score wins the game. -* -* Alternatively you can enable points deducation mode, where each team starts with a set number of -* points and the points they score are removed from the other teams total. The first team to have -* their score reduced to zero loses the game. -* -* \pre -* Requires the base destruction victory mode to be enabled in the server configuration otherwise -* it will be unable to end the game when a team achieves their victory condition -* -* \param ScoringMode -* Specifies which scoring system to use. 0 = default, 1 = deduction mode -* \param TargetScoreTeam0 -* This is the number of points team 0 (Nod / Soviet) need to win the game or, if deduction mode -* is enabled, the number of points team 0 starts with -* \param TargetScoreTeam1 -* This is the number of points team 1 (GDI / Allies) need to win the game or, if deduction mode -* is enabled, the number of points team 1 starts with -* \param IntroString -* The name of an entry in the strings database containing a message to be displayed to players at -* the start of the map which can be used to explain how to win. It will also be sent to players -* when they join mid game. See the note below for a list of macros you can use in this string -* \param ScoreInterval -* Specifies how often, in seconds, the controller should send a message to the server with the -* current scores. Set this to 0 if you do not want the scores to be shown. -* \param ScoreString -* The name of strings database entry containing the message to be sent to the server with the -* current scores. If this is blank a generic message will be shown. See the note below for a list -* of macros you can use in this string -* \param ScoreStringTeam0 -* Optional. The name of a strings database entry containing an alternative score string to be -* used if team 0 are currently winning. If this is blank the value of ScoreString will be used -* instead. See the note below for a list of macros you can use in this string -* \param ScoreStringTeam1 -* Optional. The name of a strings database entry containing an alternative score string to be -* used if team 1 are currently winning. If this is blank the value of ScoreString will be used -* instead. See the note below for a list of macros you can use in this string -* -* \note -* The following macros can be used in strings database entries;\n -* \n -* -* -* -* -* -* -* -* -* -* -* -* -*
Macro Value
%%TEAM0% Translated name of team 0
%%TEAM1% Translated name of team 1
%%WINNINGTEAM% Translated name of winning team, or 'Neither' if the points are level
%%LOSINGTEAM% Translated name of losing team, or 'Neither' if the points are level
%%TEAM0TARGET% Target score for team 0 (or starting score in deduction mode)
%%TEAM1TARGET% Target score for team 1 (or starting score in deduction mode)
%%TEAM0SCORE% Current score for team 0
%%TEAM1SCORE% Current score for team 1
%%TEAM0SCORENEEDED% Points required before team 0 will win
%%TEAM1SCORENEEDED% Points required before team 1 will win
-*/ -class dp88_conquestController : public ScriptImpClass -{ - void Created ( GameObject* pSelf ); - void Timer_Expired ( GameObject* pSelf, int number ); - void Custom ( GameObject* pSelf, int type, int param, GameObject* pSender ); - -protected: - /*! - * \name Scoring Modes - * Scoring mode definitions, see the class description for an explaination of these modes - */ - ///@{ - static const unsigned char MODE_DEFAULT = 0; /*!< Default, points accumulation mode */ - static const unsigned char MODE_DEDUCTION = 1; /*!< Points deduction mode */ - ///@} - - unsigned char m_scoringMode; /*!< The scoring mode being used */ - int m_points[2]; /*!< Current points total for each team */ - int m_targets[2]; /*!< Target for each team, or starting points in deduction mode */ - -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Conquest Mode - Control Zone -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_conquest -* -* Attach this script to an object to create a conquest control zone around or near that object. A -* control zone can be taken over by a team if one or more players from that team are standing in the -* zone with no enemy players. A zone can grant conquest points to a team upon it's initial capture -* and continually for as long as they control the zone. Requires a controller object to be placed -* on the map with the dp88_conquestController script attached to it before this script can work. -* -* If the zone is currently neutral it takes CaptureTime seconds for one player to take control of -* the zone for their team. If the zone is currently owned by the enemy team it takes CaptureTime -* seconds for one player to make the zone neutral, after which they can take control of the zone as -* normal. -* -* Additional units can contribute to the capturing process to reduce the time required to take -* control of the zone, up to MultiCaptureCap. Any additional players in the zone beyond the maximum -* cap will not provide any additional boost to the capture speed. Note that the cap is the total -* number of units, including the first unit to enter the zone, so a cap of 1 will disable the -* ability to boost capture speeds. -* -* Each additional player within the cap, beyond the first player, will reduce the capture time by -* (CaptureTime*MultiCaptureMultiplier) seconds, thus with a multipler of 0.5 each additional player -* will reduce the capture time by half of the original time. -* -* If AllowMajorityCapture is enabled the zone can be captured whilst there are enemy players in the -* zone by the team which has the most players in the zone. If combined with a MultiCaptureCap >1 -* each enemy player in the zone nullifies the effect of one of the majority teams players, reducing -* the capture speed boost. Thus, with 5 players on the majority team and 3 players on the minority -* team in the zone the capture speed will be 50% of the original time, rather than the 20% it would -* be if there were no enemy team players in the zone (assuming a MultiCaptureMultiplier of 1.0). -* -* An animation can be played on the object upon which the script is attached to indicate the current -* state of the control zone, which consists of a single frame for each of the three fixed states -* (team0 controlled, neutral, team1 controlled) and optionally a series of intermediate transition -* frames which will be used to indicate how close the zone is to being captured or returned to its -* neutral state. You could attach other animated objects to the animation using bones if a continual -* animation is required, such as a waving flag that moves up and down a flagpole during capture. -* -* If the zone is partially captured and there is no longer anybody in the zone it will slowly revert -* to its previous state, losing 1 second of capture progress per second. -* -* \param ZoneSize -* The size of the capture zone to be created -* \param ZoneOffset -* Optional. The offset from the object location the zone should be centered upon -* \param ZonePreset -* The preset to use for the capture zone, this does not require any scripts to be attached -* \param CapturePoints -* The number of points to give to a team when they take control of the zone from neutral. If the -* control point spawns as non-neutral no points will be given to the initial team -* \param CapturePointsFirstTeamOnly -* Determines if CapturePoints are every time a team takes control of a zone or if they are only -* given the first time the zone is taken over from neutral. 1 to enable, 0 to disable -* \param TickPoints -* Conquest points to give to the team which currently owns the zone every 'TickInterval' seconds -* \param TickInterval -* Tick interval, in seconds, at which to give conquest points to the zones current owner -* \param CaptureTime -* Time, in seconds, required to take control of the zone from neutral or restore the zone to the -* neutral state from enemy control -* \param MultiCaptureCap -* The maximum number of units that can contribute to speeding up the capture process. If set to 1 -* or 0 multi capture will be disabled. See the class description for more information -* \param MultiCaptureMultiplier -* The multipler to be applied to the capture speed by each additional unit, up to the specified -* cap, where 1.0 gives a 100% boost to the capture speed and 0.5 gives a 50% boost. See the class -* description for more information -* \param AllowMajorityCapture -* Allow a zone to be captured by the team with more players in the zone, even if enemy players are -* also in the zone. See the class description for more information. 1 to enable, 0 to disable -* \param CaptureAnim -* Optional. The name of an animation to play on the object to indicate capture progress. This -* animation should be in the following order: (team0 controlled) -> (team0<->neutral transition) -* -> (neutral) -> (neutral<->team1 transition) -> (team1 controlled). The controlled and neutral -* states should be a single frame. The transitions are optional, but if present must contain the -* same number of frames -* \param CaptureAnimTransitionFrames -* The number of transition frames between the controlled and neutral states in the CaptureAnim, or -* zero if there are no transition frames -* \param CapturingString -* Optional. The name of a strings database entry containing a message to be displayed to the team -* which currently controls the zone when the enemy team are capturing it. See the note below for a -* list of macros you can use in this string -* \param NeutralString -* Optional. The name of a strings database entry containing a message to be displayed to all -* players when a capture zone becomes neutral. See the note below for a list of macros you can use -* in this string -* \param CapturedString -* Optional. The name of a strings database entry containing a message to be displayed to all -* players when a team takes control of a capture zone. See the note below for a list of macros you -* can use in this string -* \param AIObjectivePriority -* Optional. When used in conjunction with danpaul88's custom AI scripts this allows this zone to -* be marked as an AI objective for both teams, either an offensive objective (for teams that do -* not currently control it) or a defensive objective (for the team that does control the zone). -* The objective distance will be set to three quarters of the zones smallest dimension and will -* be suitable for infantry, light and heavy vehicles. See \ref dp88_AI_Objective for more info. -* -* \note -* The following macros can be used in strings database entries;\n -* \n -* -* -* -* -* -* -* -*
Macro Value
%%OWNINGTEAM% Translated name of the team which controls (or controlled) the zone
%%OTHERTEAM% Translated name of the other team
%%CAPTUREPOINTS% The value of CapturePoints
%%TICKPOINTS% The value of TickPoints
%%TICKINTERVAL% The value of TickInterval
-*/ -class dp88_conquestControlZone : public ScriptImpClass -{ -public: - void Created( GameObject* pObj ); - void Timer_Expired( GameObject* pObj, int number ); - -protected: - void IncrementCaptureProgress( GameObject* pObj, int team, int nPlayers ); - void UpdateAnimationFrame( GameObject* pObj ); - - int m_controllerID; /*!< ID of the GameObject with the controller script attached */ - int m_zoneID; /*!< ID of the control zone GameObject */ - float m_captureState; /*!< Current capture progress. 0 = neutral, negative = team0, positive = team1 */ - - bool m_bTickRunning; /*!< True if the tick timer is currently running, false otherwise */ - - /*! \name Cached Script Parameters */ - /*! @{ */ - int m_captureTime; - int m_multiCaptureCap; - float m_multiCaptureMultiplier; - bool m_bAllowMajorityCapture; - int m_nAnimTransitionFrames; - /*! @} */ -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Radar Invisibility -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_radar -* -* Attach this script to an object to make it invisible to the radar - when the script is detached it -* will restore the original radar state. If this script is attached to a vehicle it will also make -* passengers radar-invisible until they leave the vehicle again. -*/ -class dp88_radarInvisibility : public ScriptImpClass -{ -public: - /*! Constructor to prevent crashes in LE due to uninitialised variables */ - dp88_radarInvisibility() : m_pPassengerIds(), m_pPassengerRadarModes(0) {}; - -protected: - void Created ( GameObject* pObj ); - void Custom ( GameObject* pObj, int type, int param, GameObject* pSender ); - void Detach ( GameObject* pObj ); - - void HidePassengerBlip ( class VehicleGameObj* pVehicle, class SoldierGameObj* pSoldier ); - void RestorePassengerBlip ( class SoldierGameObj* pSoldier ); - - int m_originalRadarMode; //!< The original radar mode of this object - int* m_pPassengerIds; //!< For vehicles, the ID of each passenger - int* m_pPassengerRadarModes; //!< For vehicles, the original radar mode of each passenger - int m_nSeats; //!< For vehicles, cache the number of seats (for Detach() to use) -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Turret Rotation Sound Effect -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup scripts_sound -* -* This script plays a 3d sound at a vehicles turret bone when that bone is being rotated and stops -* the sound when the rotation stops. The sound will be looped whilst the turret is being rotated. -* -* \note -* This script uses the difference between the vehicle rotation and the turret bone rotation to -* determine if the turret is rotating. This means simply aiming in one direction and spinning on -* the spot will cause the sound to be played, since the turret is rotating relative to the vehicle -* -* \param Sound_Preset -* The name of a 3D sound preset to be played whilst the turret is rotating -* \param Min_Differential_Rad -* The minimum difference in the turret rotation, in radians, to be considered as "rotating", this -* helps to filter out tiny movements caused by driving along uneven terrain. -*/ -class dp88_turretSound : public ScriptImpClass -{ -protected: - void Created ( GameObject* pObj ); - void Timer_Expired ( GameObject* pObj, int number ); - void Custom ( GameObject* pObj, int type, int param, GameObject* pSender ); - - float Get_Turret_Facing ( class RenderObjClass* pRenderObj ); - void Play_Sound ( GameObject* pObj ); - void Stop_Sound ( GameObject* pObj ); - - float m_lastFacing; - int m_nSoundId; - - /*! \name Cached Script Parameters */ - /*! @{ */ - float m_nMinDifferential; - /*! @} */ -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Yet Another Teleport Script -* \author Daniel Paul -* \ingroup scripts -* -* The teleport script to end all teleport scripts, this is designed to cover almost any scenario for -* teleporting units to a location or another object. It can be attached to either a script zone, a -* pokeable object or a powerup for maximum flexibility. -* -* \param ObjectID -* The ID of an object to teleport to, or 0 to teleport to a location instead. If a target object -* with the specified ID is not found the script will not teleport the unit. -* \param Bone -* The bone on the object to teleport to, or 0 to teleport to the objects origin. Not applicable -* if ObjectID is set to 0. -* \param Offset -* If teleporting to an object (or one of it's bones), apply this offset to the object location. -* Otherwise this is used as the absolute position to teleport to (ie: an offset from 0,0,0) -* \param Teleport_Infantry -* Set this to 1 if infantry should be teleported by this script, 0 if it should ignore infantry -* \param Teleport_Vehicles -* Set this to 1 if vehicles should be teleported by this script, 0 if it should ignore vehicles -* -* \note -* If you only want to teleport players and not AI controlled units use a script zone and tick the -* CheckStarsOnly box in LevelEdit. -*/ -class dp88_teleport : public ScriptImpClass -{ -protected: - void Created ( GameObject* pObj ); - void Entered ( GameObject* pObj, GameObject* pEnterer ); - void Custom ( GameObject* pObj, int type, int param, GameObject* pSender ); - void Poked ( GameObject* pObj, GameObject* pPoker ); - - /*! \name Cached Script Parameters */ - /*! @{ */ - int m_nObjectID; - bool m_bUseBone; - Vector3 m_offset; - - bool m_bTeleportInfantry; - bool m_bTeleportVehicles; - /*! @} */ + float killPoints; + float damagePoints; + float repairPoints; + float killMoney; + float damageMoney; + float repairMoney; }; \ No newline at end of file diff -uwr source/scripts/dp88_veterancy.cpp sourceold/scripts/dp88_veterancy.cpp --- source/scripts/dp88_veterancy.cpp 2013-01-21 11:44:47.544789100 +0800 +++ sourceold/scripts/dp88_veterancy.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -161,7 +161,7 @@ give nothing Points given: (pointsValue / total hit points) * damage */ - if ( amount > 0 && Get_Object_Type(damager) != Get_Object_Type(obj) && Get_Object_Type(obj) < 2 ) + if ( amount > 0 && Get_Object_Type(damager) != Get_Object_Type(obj) ) grantVeterancyPoints ( damager, (pointsValue/totalHitPoints)*amount ); /* Otherwise if damage is < 0 then it is repairs, grant veterancy points if the repairer is on @@ -352,22 +352,19 @@ const char *str = Get_Translated_Preset_Name (obj); message.Format ( "You currently have %.2f infantry veterancy points. A %s requires %d points for Veteran status and %d points for Elite status.", infantryVeterancyPoints, str, infantryVeteranRequirement, infantryEliteRequirement ); delete[] str; - Send_Message_Player( obj,DP88_RGB_GENERAL_MSG,message ); + Send_Message_Player( obj,50,255,50,message ); // Send vehicle page if ( Get_Vehicle ( obj ) != NULL ) { const char *str2 = Get_Translated_Preset_Name (Get_Vehicle(obj)); - if ( vehicleVeteranRequirement > 0 ) message.Format ( "You currently have %.2f vehicle veterancy points. A %s requires %d points for Veteran status and %d points for Elite status.", vehicleVeterancyPoints, str2, vehicleVeteranRequirement, vehicleEliteRequirement ); - else - message.Format ( "You currently have %.2f vehicle veterancy points. A %s cannot be promoted", vehicleVeterancyPoints, str2 ); delete[] str2; } else message.Format ( "You currently have %.2f vehicle veterancy points.", vehicleVeterancyPoints ); - Send_Message_Player( obj,DP88_RGB_GENERAL_MSG,message ); + Send_Message_Player( obj,50,255,50,message ); } @@ -587,31 +584,31 @@ if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 ) { // Send page - StringClass str(true); + char consoleInput[128]; const char* playerName = Get_Player_Name( obj ); - str.Format("Congratulations %s, you have been promoted to veteran rank", playerName ); + sprintf ( consoleInput, "ppage %d Congratulations %s, you have been promoted to veteran.", Get_Player_ID( obj ), playerName ); delete [] playerName; - Send_Message_Player( obj, DP88_RGB_GENERAL_MSG, str ); + Console_Input( consoleInput ); // Play promotion sound - Create_2D_WAV_Sound_Player(obj,"promotion.wav"); + sprintf ( consoleInput, "sndp %d promotion.wav", Get_Player_ID ( obj ) ); + Console_Input( consoleInput ); } // Send page and promotion sound if unit driver is a player else if ( obj->As_VehicleGameObj() && Get_Vehicle_Driver(obj) != NULL && Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) >= 0 ) { - GameObject* driver = Get_Vehicle_Driver(obj); - // Send page - StringClass str(true); - const char* playerName = Get_Player_Name(driver); - str.Format("Congratulations %s, your vehicle has been promoted to veteran rank", playerName ); + char consoleInput[128]; + const char* playerName = Get_Player_Name( Get_Vehicle_Driver ( obj ) ); + sprintf ( consoleInput, "ppage %d Congratulations %s, your vehicle has been promoted to veteran.", Get_Player_ID( Get_Vehicle_Driver ( obj ) ), playerName ); delete [] playerName; - Send_Message_Player( driver, DP88_RGB_GENERAL_MSG, str ); + Console_Input( consoleInput ); // Play promotion sound - Create_2D_WAV_Sound_Player( driver, "promotion.wav" ); + sprintf ( consoleInput, "sndp %d promotion.wav", Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) ); + Console_Input( consoleInput ); } @@ -639,7 +636,7 @@ Commands->Send_Custom_Event ( obj, obj, CUSTOM_VETERANCY_REMOVE_OLD_WEAPON, 0, 0.1f ); } - // Remove immediately + // Remove immediatly else Remove_Weapon ( obj, rookieWeapon ); } @@ -681,31 +678,31 @@ if ( obj->As_SoldierGameObj() && Get_Player_ID ( obj ) >= 0 ) { // Send page - StringClass str(true); + char consoleInput[128]; const char* playerName = Get_Player_Name( obj ); - str.Format("Congratulations %s, you have been promoted to elite rank", playerName ); + sprintf ( consoleInput, "ppage %d Congratulations %s, you have been promoted to elite.", Get_Player_ID( obj ), playerName ); delete [] playerName; - Send_Message_Player( obj, DP88_RGB_GENERAL_MSG, str ); + Console_Input( consoleInput ); // Play promotion sound - Create_2D_WAV_Sound_Player(obj,"promotion.wav"); + sprintf ( consoleInput, "sndp %d promotion.wav", Get_Player_ID ( obj ) ); + Console_Input( consoleInput ); } // Send page and promotion sound if unit driver is a player else if ( obj->As_VehicleGameObj() && Get_Vehicle_Driver(obj) != NULL && Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) >= 0 ) { - GameObject* driver = Get_Vehicle_Driver(obj); - // Send page - StringClass str(true); - const char* playerName = Get_Player_Name(driver); - str.Format("Congratulations %s, your vehicle has been promoted to elite rank", playerName ); + char consoleInput[128]; + const char* playerName = Get_Player_Name( Get_Vehicle_Driver ( obj ) ); + sprintf ( consoleInput, "ppage %d Congratulations %s, your vehicle has been promoted to elite.", Get_Player_ID( Get_Vehicle_Driver ( obj ) ), playerName ); delete [] playerName; - Send_Message_Player( driver, DP88_RGB_GENERAL_MSG, str ); + Console_Input( consoleInput ); // Play promotion sound - Create_2D_WAV_Sound_Player( driver, "promotion.wav" ); + sprintf ( consoleInput, "sndp %d promotion.wav", Get_Player_ID ( Get_Vehicle_Driver ( obj ) ) ); + Console_Input( consoleInput ); } @@ -1093,248 +1090,3 @@ "veteranArmourIncrease=0:int," "eliteHealthIncrease=0:int," "eliteArmourIncrease=0:int"); - - - - - - - - -// ------------------------------------------------------------------------------------------------- -// Veterancy - Regeneration -// ------------------------------------------------------------------------------------------------- - -void dp88_veterancyRegeneration::Created( GameObject *obj ) -{ - veterancyLevel = 0; - Commands->Start_Timer ( obj, this, 1.0f, TIMER_HEALTHARMOURREGENTICK ); - - m_regenAmount = Get_Int_Parameter("rookie_regenAmount"); - m_bRepairArmour = (Get_Int_Parameter("rookie_repairArmour")==1); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_veterancyRegeneration::Timer_Expired( GameObject *obj, int number ) -{ - // Only process this if we are not dead... - float hitpoints = Commands->Get_Health(obj); - if ( hitpoints > 0.0f && m_regenAmount > 0 ) - { - float regenAmount = (float)m_regenAmount; - - // First try to heal some of our health, but don't go beyond the maximum - float max = Commands->Get_Max_Health(obj); - if ( hitpoints < max ) - { - hitpoints += regenAmount; - regenAmount = 0; - - if ( hitpoints > max ) - { - regenAmount = max-hitpoints; - hitpoints = max; - } - - Commands->Set_Health( obj, hitpoints ); - } - - - // If we have any leftover regeneration then apply it to our armour, if enabled - if ( m_bRepairArmour && regenAmount > 0 ) - { - hitpoints = Commands->Get_Shield_Strength(obj); - max = Commands->Get_Max_Shield_Strength(obj); - - if ( hitpoints < max ) - { - hitpoints += regenAmount; - - if ( hitpoints > max ) - hitpoints = max; - } - - Commands->Set_Shield_Strength( obj, hitpoints ); - } - } - - // Restart the timer - Commands->Start_Timer ( obj, this, 1.0f, TIMER_HEALTHARMOURREGENTICK ); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_veterancyRegeneration::Custom( GameObject *obj, int type, int param, GameObject *sender ) -{ - if ( type == CUSTOM_VETERANCY_PROMOTED ) - { - veterancyLevel = param; - if ( veterancyLevel == 2 ) - { - m_regenAmount = Get_Int_Parameter("elite_regenAmount"); - m_bRepairArmour = (Get_Int_Parameter("elite_repairArmour")==1); - } - else if ( veterancyLevel == 1 ) - { - m_regenAmount = Get_Int_Parameter("veteran_regenAmount"); - m_bRepairArmour = (Get_Int_Parameter("veteran_repairArmour")==1); - } - else - { - m_regenAmount = Get_Int_Parameter("rookie_regenAmount"); - m_bRepairArmour = (Get_Int_Parameter("rookie_repairArmour")==1); - } - } -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_veterancyRegeneration_Registrant( - "dp88_veterancyRegeneration", - "rookie_regenAmount=0:int," - "rookie_repairArmour=1:int," - "veteran_regenAmount=0:int," - "veteran_repairArmour=1:int," - "elite_regenAmount=1:int," - "elite_repairArmour=1:int"); - -// Legacy registrant for existing AR presets -ScriptRegistrant dp88_AR_Veterancy_HealthArmourRegen_Registrant( - "dp88_AR_Veterancy_HealthArmourRegen", - "rookie_healthRegenAmount=0:int," - "rookie_armourRegenAmount=0:int," - "veteran_healthRegenAmount=1:int," - "veteran_armourRegenAmount=0:int," - "elite_healthRegenAmount=3:int," - "elite_armourRegenAmount=2:int"); - - - - - - - - -// ------------------------------------------------------------------------------------------------- -// Veterancy - Grant Powerup -// ------------------------------------------------------------------------------------------------- - -void dp88_veterancyGrantPowerup::Created( GameObject *obj ) -{ - //Console_Output ( "Created dp88_AR_grantDefaultWeapon\n" ); - veterancyLevel = 0; - strcpy_s ( weaponName, sizeof(weaponName), "null" ); - strcpy_s ( oldWeapon, sizeof(oldWeapon), "null" ); - - const char* powerupPreset = Get_Parameter ( "powerupPreset" ); - if ( Is_Valid_Preset(powerupPreset) ) - { - Commands->Give_PowerUp ( obj, powerupPreset, true ); - if ( Get_Powerup_Weapon(powerupPreset) != NULL ) - strcpy_s ( weaponName, sizeof(weaponName), Get_Powerup_Weapon (powerupPreset) ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_veterancyGrantPowerup::Custom( GameObject *obj, int type, int param, GameObject *sender ) -{ - if ( type == CUSTOM_VETERANCY_PROMOTED ) - { - // Work out if we need to grant them a new weapon - char powerupPreset[64] = "null"; - switch ( param ) - { - case 1: - if ( strcmp ( Get_Parameter( "powerupPreset_veteran" ), "null" ) != 0 ) - strcpy_s ( powerupPreset, sizeof(powerupPreset), Get_Parameter ( "powerupPreset_veteran" ) ); - break; - case 2: - if ( strcmp ( Get_Parameter( "powerupPreset_elite" ), "null" ) != 0 ) - strcpy_s ( powerupPreset, sizeof(powerupPreset), Get_Parameter ( "powerupPreset_elite" ) ); - else if ( strcmp ( Get_Parameter( "powerupPreset_veteran" ), "null" ) != 0 ) - strcpy_s( powerupPreset, sizeof(powerupPreset), Get_Parameter ( "powerupPreset_veteran" ) ); - break; - } - - // If we found a powerup to give them then grant it - if ( strcmp ( powerupPreset, "null" ) != 0 && Is_Valid_Preset(powerupPreset) ) - { - // Not a weapon powerup? - if ( Get_Powerup_Weapon(powerupPreset) == NULL ) - Commands->Give_PowerUp( obj, powerupPreset, true ); - - else - { - // Give new weapon, and select if if they were using that weapon - const char* newWeapon = Get_Powerup_Weapon(powerupPreset); - if ( strcmp ( newWeapon, weaponName ) == 0 ) // Same weapon? Nothing to do... - return; - - if ( strcmp( Get_Current_Weapon(obj), weaponName ) == 0 ) - { - Commands->Give_PowerUp( obj, powerupPreset, true ); - strcpy_s( oldWeapon, sizeof(oldWeapon), weaponName ); - Commands->Send_Custom_Event( obj, obj, CUSTOM_VETERANCY_REMOVE_OLD_WEAPON, 0, 0.1f); - Commands->Select_Weapon( obj, newWeapon ); - } - else - { - char currentWeapon[128]; - strcpy_s ( currentWeapon, sizeof(currentWeapon), Get_Current_Weapon(obj) ); - Commands->Give_PowerUp( obj, powerupPreset, true ); - Remove_Weapon( obj, weaponName ); - Commands->Select_Weapon( obj, currentWeapon ); - } - - // Set this weapon as their default for future reference - strcpy_s ( weaponName, sizeof(weaponName), newWeapon ); - } - } - } - - - else if ( type == CUSTOM_VETERANCY_REMOVE_OLD_WEAPON && strcmp ( oldWeapon, "null" ) != 0 ) - { - /* For whatever reason removing a non-selected weapon changes the selected weapon, so store the - selected weapon here so we can restore it afterwards */ - char currentWeapon[128]; - strcpy_s ( currentWeapon, sizeof(currentWeapon), Get_Current_Weapon(obj) ); - - /* Make sure they don't have oldWeapon selected, otherwise crashy-fun-time will happen. If they - do have it selected then swap it for their new weapon and fire the custom again */ - if ( strcmp ( currentWeapon, oldWeapon ) == 0 ) - { - if ( strcmp ( oldWeapon, weaponName ) != 0 ) // Sanity check... - { - Commands->Select_Weapon ( obj, weaponName ); - Commands->Send_Custom_Event ( obj, obj, CUSTOM_VETERANCY_REMOVE_OLD_WEAPON, 0, 0.1f); - } - } - else - { - Remove_Weapon ( obj, oldWeapon ); - strcpy_s ( oldWeapon, sizeof(oldWeapon), "null" ); - - /* Reselect current weapon (also triggers the back model of the old weapon to be removed so it - doesn't crash on the next promotion) */ - Commands->Select_Weapon ( obj, currentWeapon ); - } - } -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_veterancyGrantPowerup_Registrant( - "dp88_veterancyGrantPowerup", - "powerupPreset=presetname:string," - "powerupPreset_veteran=null:string," - "powerupPreset_elite=null:string"); - -// Legacy registrant for existing AR presets -ScriptRegistrant dp88_AR_grantDefaultWeapon_Registrant( - "dp88_AR_grantDefaultWeapon", - "powerupPreset=presetname:string," - "powerupPreset_veteran=null:string," - "powerupPreset_elite=null:string"); \ No newline at end of file diff -uwr source/scripts/dp88_veterancy.h sourceold/scripts/dp88_veterancy.h --- source/scripts/dp88_veterancy.h 2013-01-13 12:06:54.782289100 +0800 +++ sourceold/scripts/dp88_veterancy.h 2012-07-28 09:11:06.000000000 +0800 @@ -43,11 +43,13 @@ int vehicleVeteranRequirement, vehicleEliteRequirement; int chevronObjId, promotionChevronObjId; - /* Flags to mark whether we have upgraded weapons for veteran or rookie levels (saves lots of - string comparisions and preset validation later on) */ + /* Flags to mark whether we have upgraded weapons for veteran or + rookie levels (saves lots of string comparisions and preset + validation later on) */ bool hasVeteranWeaponPowerup, hasEliteWeaponPowerup; - /* Original values for weapons / skin / armour type (req. for vehicles only) */ + /* Original values for weapons / skin / armour type (req. for + vehicles only) */ char rookieWeapon[128], rookieSkinType[128], rookieShieldType[128]; // ID for vehicle pilot (vehicles only) @@ -67,25 +69,28 @@ Functions *****************/ - /*! Grant x veterancy points to the specified unit */ + // Grant x veterancy points to the specified unit void grantVeterancyPoints ( GameObject* obj, float points ); - /*! Get a pointer to the dp88_veterancyUnit class object for the specified GameObject */ + /* Get a pointer to the dp88_veterancyUnit class object for + the specified gameObject */ dp88_veterancyUnit* getVeterancyData ( GameObject* obj ); - /*! Handle promotion events */ + /* Handle promotion events */ void promoteToVeteran(); void promoteToElite(); - /*! Handle demotion event - Mainly for vehicles when their drivers get out */ + /* Handle demotion event - Mainly for vehicles when + their drivers get out */ void demoteToRookie(); - /*! Chevron scripts */ + /* Chevron scripts */ void createChevrons(); void clearChevrons(); }; -// ------------------------------------------------------------------------------------------------- + + /* Script for a crate which grants veterancy points to the collector */ class dp88_veterancyCrate : public ScriptImpClass @@ -93,7 +98,8 @@ void Custom ( GameObject *obj, int type, int param, GameObject *sender ); }; -// ------------------------------------------------------------------------------------------------- + + /* Script to grant veterancy points to whatever it is attached to */ class dp88_veterancyGrantPoints : public ScriptImpClass @@ -102,7 +108,8 @@ void Custom ( GameObject *obj, int type, int param, GameObject *sender ); }; -// ------------------------------------------------------------------------------------------------- + + // Script to link veterancy points of two objects together class dp88_linkVetPoints : public ScriptImpClass @@ -116,7 +123,6 @@ float lastVehiclePoints; }; -// ------------------------------------------------------------------------------------------------- // Script to grant extra health / armour upon promotion class dp88_veterancyPromotionHealthArmourIncrease : public ScriptImpClass @@ -127,79 +133,3 @@ private: int m_veterancyLevel; }; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Veterancy - Regeneration -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* This is a companion script for dp88_veterancyUnit which grants health regeneration to a unit based -* upon it's current promotion level (rookie, veteran, elite). It can optionally also repair their -* armour, but only once their health has been fully restored and at the same speed. -* -* \param rookie_regenAmount -* Number of hitpoints to heal, per second, whilst this unit is at rookie level -* \param rookie_repairArmour -* Whether to repair armour as well as health, whilst this unit is at rookie level. 1 to enable -* armour repairs, 0 to disable and only restore health -* \param veteran_regenAmount -* Number of hitpoints to heal, per second, whilst this unit is at veteran level -* \param veteran_repairArmour -* Whether to repair armour as well as health, whilst this unit is at veteran level. 1 to enable -* armour repairs, 0 to disable and only restore health -* \param elite_regenAmount -* Number of hitpoints to heal, per second, whilst this unit is at elite level -* \param elite_repairArmour -* Whether to repair armour as well as health, whilst this unit is at elite level. 1 to enable -* armour repairs, 0 to disable and only restore health -*/ -class dp88_veterancyRegeneration : public ScriptImpClass -{ - void Created( GameObject *obj ); - void Timer_Expired( GameObject *obj, int number ); - void Custom( GameObject *obj, int type, int param, GameObject *sender ); - -private: - int veterancyLevel; - - int m_regenAmount; - bool m_bRepairArmour; -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Veterancy - Grant Weapon -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* This is a companion script to dp88_veterancyUnit which grants an additional weapon to a unit upon -* spawning and replaces the weapon with a (presumably) more powerful version when the unit gets -* promoted. Alternatively it can grant an additional weapon to a unit when it reaches veteran or -* elite level, without granting anything to a rookie unit. -* -* Similar to the m00_GrantPowerup_Created stock script, with the additional veterancy logic added. -* -* \note -* Whilst this script is designed to be used for granting additional weapons there's no technical -* reason it can't also be used to grant other powerup types. If non-weapon powerups are granted -* their effects will not be removed when the next veterancy level is reached. -* -* \param powerupPreset -* The name of a powerup preset to grant to the unit when it is spawned at rookie level -* \param powerupPreset_veteran -* The name of a powerup preset to grant to the unit when it is promoted to veteran level -* \param powerupPreset_elite -* The name of a powerup preset to grant to the unit when it is promoted to elite level -*/ -class dp88_veterancyGrantPowerup : public ScriptImpClass -{ - char weaponName[64]; - char oldWeapon[64]; - - void Created( GameObject *obj ); - void Custom( GameObject *obj, int type, int param, GameObject *sender ); - -private: - int veterancyLevel; -}; \ No newline at end of file diff -uwr source/scripts/engine_dmg.cpp sourceold/scripts/engine_dmg.cpp --- source/scripts/engine_dmg.cpp 2013-01-13 12:06:54.766664100 +0800 +++ sourceold/scripts/engine_dmg.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -727,15 +727,4 @@ } } } - -float SCRIPTS_API Get_Max_Hitpoints ( GameObject* obj ) -{ - return Commands->Get_Max_Health(obj) + Commands->Get_Max_Shield_Strength(obj); -} - -float SCRIPTS_API Get_Hitpoints ( GameObject* obj ) -{ - return Commands->Get_Health(obj) + Commands->Get_Shield_Strength(obj); -} - #endif diff -uwr source/scripts/engine_dmg.h sourceold/scripts/engine_dmg.h --- source/scripts/engine_dmg.h 2013-01-13 12:06:54.657289100 +0800 +++ sourceold/scripts/engine_dmg.h 2012-07-28 09:11:06.000000000 +0800 @@ -40,33 +40,4 @@ void SCRIPTS_API Kill_Occupants(GameObject *obj); //kill all the occupants of a vehicle void SCRIPTS_API Damage_Occupants(GameObject *obj,float Damage,const char *Warhead); //Damage all the occupants of a vehicle void SCRIPTS_API Ranged_Variable_Percent_Vehicle_Damage(float EnemyPercentage, float FriendPecentage, bool ForceFriendly, const char *Warhead,Vector3 Location,float DamageRadius,GameObject *Damager); //damage vehicles based on a percentage factor - -/*! -* \brief Get maximum hitpoints -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* Returns the maximum hitpoints for the specified object, rather than having to manually add up the -* maximum health and shield values -* -* \param[in] obj -* Object to get the maximum hitpoints of -* \returns -* The combined maximum health and shield strength of the object -*/ -float SCRIPTS_API Get_Max_Hitpoints ( GameObject* obj ); - -/*! -* \brief Get current hitpoints -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* Returns the current hitpoints for the specified object, rather than having to manually add up the -* current health and shield values -* -* \param[in] obj -* Object to get the maximum hitpoints of -* \returns -* The combined current health and shield strength of the object -*/ -float SCRIPTS_API Get_Hitpoints ( GameObject* obj ); - #endif diff -uwr source/scripts/engine_game.cpp sourceold/scripts/engine_game.cpp --- source/scripts/engine_game.cpp 2013-01-13 11:33:13.877992200 +0800 +++ sourceold/scripts/engine_game.cpp 2012-07-28 09:11:06.000000000 +0800 @@ -668,15 +668,3 @@ } return ReturnPos; } - -BuildingAggregateClass *BuildingGameObj::Find_MCT() -{ - for (auto it = Aggregates.Iterator(); it; ++it) - { - if (it->Is_MCT()) - { - return it.Get_Obj(); - } - } - return 0; -} \ No newline at end of file diff -uwr source/scripts/engine_game.h sourceold/scripts/engine_game.h --- source/scripts/engine_game.h 2013-01-11 22:37:51.957031200 +0800 +++ sourceold/scripts/engine_game.h 2012-07-28 09:11:08.000000000 +0800 @@ -14,7 +14,6 @@ #include "GameData.h" /*! -* \ingroup api_teamcontrol * Enable or disable base power for a team, this correctly handles all the relavent stuff including base defences and purchase time/cost changes. * * \param[in] team @@ -27,7 +26,6 @@ void SCRIPTS_API Power_Base(int team,bool powered); /*! -* \ingroup api_teamcontrol * Enable or disable advanced infantry purchasability for a team * * \param[in] team @@ -40,7 +38,6 @@ void SCRIPTS_API Set_Can_Generate_Soldiers(int team,bool cangenerate); /*! -* \ingroup api_teamcontrol * Enable or disable vehicle purchasability for a team * * \param[in] team @@ -53,7 +50,6 @@ void SCRIPTS_API Set_Can_Generate_Vehicles(int team,bool cangenerate); /*! -* \ingroup api_teamcontrol * Destroy the base of a team * * \param[in] team @@ -63,7 +59,6 @@ void SCRIPTS_API Destroy_Base(int team); /*! -* \ingroup api_teamcontrol * Set or clear the "beacon destroyed base" flag for a team * * \param[in] team @@ -76,7 +71,6 @@ void SCRIPTS_API Beacon_Destroyed_Base(int team, bool destroyed); /*! -* \ingroup api_teamcontrol * Enable or disable radar for a team * * \param[in] team @@ -100,7 +94,6 @@ bool SCRIPTS_API Is_Harvester(GameObject *obj); /*! -* \ingroup api_teamcontrol * Check if a teams base radar is enabled * * \param[in] team @@ -134,7 +127,6 @@ bool SCRIPTS_API Is_Building_Dead(GameObject *obj); /*! -* \ingroup api_objectfind * Find the first building of a given building type for this team * * \param[in] team @@ -149,7 +141,6 @@ GameObject SCRIPTS_API *Find_Building_By_Type(int team,int type); /*! -* \ingroup api_objectfind * Find the first base defense building for this team (if any) * * \param[in] Team @@ -171,7 +162,6 @@ GameObject SCRIPTS_API *Create_Building(const char *preset,const Vector3 & Position); //Create a building controller /*! -* \ingroup api_objectfind * Find the AI harvester for a team (if any) * * \param[in] team @@ -183,7 +173,6 @@ GameObject SCRIPTS_API *Find_Harvester(int team); /*! -* \ingroup api_teamcontrol * Check if a teams base is powered * * \param[in] team @@ -195,7 +184,6 @@ bool SCRIPTS_API Is_Base_Powered(int team); /*! -* \ingroup api_teamcontrol * Check if a team can currently purchase vehicles * * \param[in] team @@ -207,7 +195,6 @@ bool SCRIPTS_API Can_Generate_Vehicles(int team); /*! -* \ingroup api_teamcontrol * Check if a team can currently purchase advanced infantry characters * * \param[in] team @@ -251,7 +238,6 @@ cGameDataSinglePlayer SCRIPTS_API *The_Single_Player_Game(); /*! -* \ingroup api_teamcontrol * Get the count of how many buildings a given team has * * \param[in] Team @@ -263,7 +249,6 @@ int SCRIPTS_API Get_Building_Count_Team(int Team); /*! -* \ingroup api_objectfind * Find the first building for this team * * \param[in] Team @@ -275,7 +260,6 @@ GameObject SCRIPTS_API *Find_Building_By_Team(int Team); /*! -* \ingroup api_objectfind * Find the first building of a given preset type for this team * * \param[in] Team @@ -290,7 +274,6 @@ GameObject SCRIPTS_API *Find_Building_By_Preset(int Team,const char *Preset_Name); /*! -* \ingroup api_objectfind * Find the first power plant for this team (if any) * * \param[in] Team @@ -302,7 +285,6 @@ GameObject SCRIPTS_API *Find_Power_Plant(int Team); /*! -* \ingroup api_objectfind * Find the first construction yard for this team (if any) * * \param[in] Team @@ -314,7 +296,6 @@ GameObject SCRIPTS_API *Find_Construction_Yard(int Team); /*! -* \ingroup api_objectfind * Find the first refinery for this team (if any) * * \param[in] Team @@ -326,7 +307,6 @@ GameObject SCRIPTS_API *Find_Refinery(int Team); /*! -* \ingroup api_objectfind * Find the first repair bay for this team (if any) * * \param[in] Team @@ -338,7 +318,6 @@ GameObject SCRIPTS_API *Find_Repair_Bay(int Team); /*! -* \ingroup api_objectfind * Find the first soldier factory for this team (if any) * * \param[in] Team @@ -350,7 +329,6 @@ GameObject SCRIPTS_API *Find_Soldier_Factory(int Team); /*! -* \ingroup api_objectfind * Find the first vehicle factory for this team (if any) * * \param[in] Team @@ -362,7 +340,6 @@ GameObject SCRIPTS_API *Find_Vehicle_Factory(int Team); /*! -* \ingroup api_objectfind * Find the first com center for this team (if any) * * \param[in] Team @@ -374,7 +351,6 @@ GameObject SCRIPTS_API *Find_Com_Center(int Team); /*! -* \ingroup api_objectfind * Find the first special building for this team (if any) * * \param[in] Team @@ -386,7 +362,6 @@ GameObject SCRIPTS_API *Find_Special(int Team); /*! -* \ingroup api_objectfind * Find the first naval factory for this team (if any) * * \param[in] Team @@ -398,7 +373,6 @@ GameObject SCRIPTS_API *Find_Naval_Factory(int Team); /*! -* \ingroup api_objectfind * Find the first tech center for this team (if any) * * \param[in] Team @@ -410,7 +384,6 @@ GameObject SCRIPTS_API *Find_Tech_Center(int Team); /*! -* \ingroup api_objectfind * Find the first helipad for this team (if any) * * \param[in] Team @@ -422,7 +395,6 @@ GameObject SCRIPTS_API *Find_Helipad(int Team); /*! -* \ingroup api_objectfind * Find the first shrine for this team (if any) * * \param[in] Team @@ -516,7 +488,6 @@ bool SCRIPTS_API Vehicle_Preset_Is_Naval(int preset); /*! -* \ingroup api_teamcontrol * Find the center point of a base * * \param[in] team diff -uwr source/scripts/engine_script.cpp sourceold/scripts/engine_script.cpp --- source/scripts/engine_script.cpp 2013-01-13 11:33:13.721742200 +0800 +++ sourceold/scripts/engine_script.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -569,37 +569,3 @@ } } } - - -void Attach_Script_V ( GameObject* pObj, const char* script, const char* params, va_list vargs ) -{ - if ( !pObj ) - return; - - int length = _vscprintf_p(params,vargs); - char* formattedParams = new char[length+1]; - _vsnprintf_s(formattedParams, length+1, length, params, vargs); - - Commands->Attach_Script(pObj, script, formattedParams); - - delete[] formattedParams; -} - -void SCRIPTS_API Attach_Script_V ( GameObject* pObj, const char* script, const char* params, ... ) -{ - va_list vargs; - va_start ( vargs, params ); - Attach_Script_V(pObj,script,params,vargs); - va_end(vargs); -} - -void SCRIPTS_API Attach_Script_Once_V ( GameObject* pObj, const char* script, const char* params, ... ) -{ - if ( !pObj || Is_Script_Attached(pObj,script)) - return; - - va_list vargs; - va_start ( vargs, params ); - Attach_Script_V(pObj,script,params,vargs); - va_end(vargs); -} \ No newline at end of file diff -uwr source/scripts/engine_script.h sourceold/scripts/engine_script.h --- source/scripts/engine_script.h 2013-01-13 11:33:13.549867200 +0800 +++ sourceold/scripts/engine_script.h 2012-07-28 09:11:08.000000000 +0800 @@ -39,61 +39,4 @@ SCRIPTS_API void Send_Custom_Event_To_Objects_With_Script_Ranged( GameObject *sender, const char *script, int message, int param, float delay, float range ); // Script to send a custom to all objects with a specific script in a specified range SCRIPTS_API ScriptImpClass* Find_Script_On_Object(GameObject* obj, const char *script); // Returns a pointer to the first instance of the named script on the given object, or NULL if not found SCRIPTS_API void Attach_Script_Occupants(GameObject *obj,const char *script,const char *params); //attaches a script to all occupants of a vehicle - -/*! -* \brief Attach Script with Formatted Parameters -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup api_scripts -* -* This is a variant of ScriptCommands::Attach_Script which uses a variable length arguments list to -* format the script parameters, rather than having to do it manually inside scripts using a string -* variable of some sort. -* -* \param[in] pObj -* The object to attach this script to -* \param[in] script -* The name of the script to be attached to the object -* \param[in] params -* The format string for the script parameters -*/ -SCRIPTS_API void Attach_Script_V ( GameObject* pObj, const char* script, const char* params, ... ); - -/*! -* \brief Attach Script with Formatted Parameters (va_list) -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup api_scripts -* -* A variant of Attach_Script which takes a va_list object rather than a variable number of arguments -* so it can be called from within another function which itself takes a variable number of arguments -* -* \param[in] pObj -* The object to attach this script to -* \param[in] script -* The name of the script to be attached to the object -* \param[in] params -* The format string for the script parameters -* \param[in] vargs -* The variable arguments object -*/ -SCRIPTS_API void Attach_Script_V ( GameObject* pObj, const char* script, const char* params, va_list vargs ); - -/*! -* \brief Attach Script Once with Formatted Parameters -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup api_scripts -* -* This is a variant of Attach_Script_Once which uses a variable length arguments list to format the -* script parameters, rather than having to do it manually inside scripts using a string variable of -* some sort. -* -* \param[in] pObj -* The object to attach this script to -* \param[in] script -* The name of the script to be attached to the object -* \param[in] params -* The format string for the script parameters -*/ -SCRIPTS_API void Attach_Script_Once_V ( GameObject* pObj, const char* script, const char* params, ... ); - - #endif diff -uwr source/scripts/engine_tdb.cpp sourceold/scripts/engine_tdb.cpp --- source/scripts/engine_tdb.cpp 2013-01-13 11:33:13.549867200 +0800 +++ sourceold/scripts/engine_tdb.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -18,7 +18,6 @@ #include "TranslateDBClass.h" #include "Engine_Obj.h" #include "Engine_Def.h" - const wchar_t *VehicleGameObj::Get_Vehicle_Name() { if (( Get_Definition().VehicleNameID != 0 ) && (Get_Definition().VehicleNameID < TranslateDBClass::Get_Object_Count())) { diff -uwr source/scripts/engine_tdb.h sourceold/scripts/engine_tdb.h --- source/scripts/engine_tdb.h 2013-01-13 11:33:13.846742200 +0800 +++ sourceold/scripts/engine_tdb.h 2012-09-11 08:40:48.000000000 +0800 @@ -137,5 +137,4 @@ * found with the specified translation ID or the translation has no associated sound */ SCRIPTS_API unsigned long Get_String_Sound_ID(unsigned long ID); - #endif diff -uwr source/scripts/engine_tt.cpp sourceold/scripts/engine_tt.cpp --- source/scripts/engine_tt.cpp 2013-01-13 11:33:13.768617200 +0800 +++ sourceold/scripts/engine_tt.cpp 2012-08-24 20:46:46.000000000 +0800 @@ -21,7 +21,6 @@ #include "engine_player.h" #include "engine_obj2.h" #include "engine_script.h" -#include "engine_tdb.h" #include "SmartGameObjDef.h" #include "VehicleGameObj.h" #include "SoldierGameObj.h" @@ -221,27 +220,6 @@ } } -// ------------------------------------------------------------------------------------------------- - -SCRIPTS_API void Send_Translated_Message_Team ( unsigned long ID, int team, int red, int green, int blue, bool bPlaySound ) -{ - if ( Is_Valid_String_ID(ID) ) - { - const char *str = Get_Translated_String(ID); - Send_Message_Team(team,red,green,blue,str); - delete[] str; - - if ( bPlaySound ) - { - int soundId = Get_String_Sound_ID(ID); - if (soundId && Is_Valid_Preset_ID(soundId) && Find_Definition(soundId)->Get_Class_ID() == 0x5000) - Create_2D_Sound_Team(Get_Definition_Name(soundId),team); - } - } -} - -// ------------------------------------------------------------------------------------------------- - SCRIPTS_API void Set_Obj_Radar_Blip_Shape_Team(int Team,GameObject *obj,int shape) { SLNode *x = GameObjManager::StarGameObjList.Head(); diff -uwr source/scripts/engine_tt.h sourceold/scripts/engine_tt.h --- source/scripts/engine_tt.h 2013-01-13 11:33:13.487367200 +0800 +++ sourceold/scripts/engine_tt.h 2012-08-24 20:46:46.000000000 +0800 @@ -290,15 +290,8 @@ JFW_Key_Hook_Base() : hookid(0) { } - - /*! Overloaded from ScriptImpClass to call Detach, if a derived class also overrides this that - class must ensure it calls this base class function in it's own implementation */ void Detach(GameObject *obj); - - /*! Overloaded from ScriptImpClass to call Detach, if a derived class also overrides this that - class must ensure it calls this base class function in it's own implementation */ void Destroyed(GameObject *obj); - void InstallHook(const char *keyname,GameObject *obj); void RemoveHook(); virtual void KeyHook() = 0; @@ -387,25 +380,3 @@ SCRIPTS_API void Delete_Console_Function(const char *name); SCRIPTS_API void Sort_Function_List(); SCRIPTS_API void Verbose_Help_File(); - -/*! -* \brief Send Translated Message To Team(s) -* \ingroup api_translations -* -* Sends the string associated with the specified translation as a message to the specified team and -* optionally also plays the sound associated with the translation (if any) to the team -* -* \param[in] ID -* The ID of the translation containing the message to be sent -* \param[in] team -* The team to send the message to, or 2 to send to both teams -* \param[in] red -* The red component of the colour to use for the message -* \param[in] green -* The green component of the colour to use for the message -* \param[in] blue -* The blue component of the colour to use for the message -* \param[in] bPlaySound -* Whether to also play the sound associated with the translation to the specified team -*/ -SCRIPTS_API void Send_Translated_Message_Team ( unsigned long ID, int team, int red, int green, int blue, bool bPlaySound = true ); diff -uwr source/scripts/engine_weap.cpp sourceold/scripts/engine_weap.cpp --- source/scripts/engine_weap.cpp 2013-01-13 12:06:54.672914100 +0800 +++ sourceold/scripts/engine_weap.cpp 2012-07-28 09:11:06.000000000 +0800 @@ -50,286 +50,573 @@ AT2(0x0070D610,0x0070CBD0); #endif -// ------------------------------------------------------------------------------------------------- - -/*! Internal utility function to get the current weapon for an object, reducing code duplication */ -WeaponClass* _Get_Current_Weapon ( GameObject* obj ) +SCRIPTS_API int Get_Current_Bullets(GameObject *obj) { if (!obj) - return NULL; + { + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(w->Get_Index()); + return wc->Get_Clip_Rounds(); + } + return 0; +} + - PhysicalGameObj* pPhysObjo2 = obj->As_PhysicalGameObj(); - if (!pPhysObjo2) - return NULL; - if ( ArmedGameObj* pArmedObj = pPhysObjo2->As_ArmedGameObj() ) +void C4GameObj::Restore_Owner() { - WeaponBagClass* w = pArmedObj->Get_Weapon_Bag(); - if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count())) - return w->Peek_Weapon(w->Get_Index()); + int at = AmmoDef->AmmoType; + if (!Owner && Player && AmmoDef && (1 != at)) + { + TT_FOREACH(object, GameObjManager::StarGameObjList) + { + if (object->Get_Player_Data() == Player) + { + Owner = object; + break; + } } - return NULL; + /* + if (!Owner) + { + Player = NULL; + C4GameObj::Defuse(this); + } + */ + } } -SCRIPTS_API int Get_Current_Bullets(GameObject *obj) + + +SCRIPTS_API int Get_Current_Clip_Bullets(GameObject *obj) +{ + if (!obj) { - if ( WeaponClass* wc = _Get_Current_Weapon(obj) ) - return wc->Get_Clip_Rounds(); return 0; } - -SCRIPTS_API int Get_Current_Max_Bullets(GameObject *obj) + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) { - if ( WeaponClass* wc = _Get_Current_Weapon(obj) ) - return wc->Get_Definition()->ClipSize; return 0; } - -SCRIPTS_API int Get_Current_Clip_Bullets(GameObject *obj) + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) { - if ( WeaponClass* wc = _Get_Current_Weapon(obj) ) - return wc->Get_Inventory_Rounds(); return 0; } - -SCRIPTS_API int Get_Current_Clip_Max_Bullets(GameObject *obj) + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count())) { - if ( WeaponClass* wc = _Get_Current_Weapon(obj) ) - return wc->Get_Definition()->MaxInventoryRounds; + WeaponClass *wc = w->Peek_Weapon(w->Get_Index()); + return wc->Get_Inventory_Rounds(); + } return 0; } SCRIPTS_API int Get_Current_Total_Bullets(GameObject *obj) { - if ( WeaponClass* wc = _Get_Current_Weapon(obj) ) + if (!obj) { - int bullets = wc->Get_Clip_Rounds(); - int clipbullets = wc->Get_Inventory_Rounds(); - - if (clipbullets < 0) - return -1; - - return bullets+clipbullets; + return 0; } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { return 0; } - -SCRIPTS_API int Get_Current_Total_Max_Bullets(GameObject *obj) + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) { - if ( WeaponClass* wc = _Get_Current_Weapon(obj) ) + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count())) { - int bullets = wc->Get_Definition()->ClipSize; - int clipbullets = wc->Get_Definition()->MaxInventoryRounds; - + WeaponClass *wc = w->Peek_Weapon(w->Get_Index()); + int bullets = wc->Get_Clip_Rounds(); + int clipbullets = wc->Get_Inventory_Rounds(); if (clipbullets < 0) + { return -1; - + } return bullets+clipbullets; } return 0; } -// ------------------------------------------------------------------------------------------------- - -/*! Internal utility function to get the weapon in a specific position for an object, reducing code duplication */ -WeaponClass* _Get_Position_Weapon ( GameObject* obj, int position ) +SCRIPTS_API int Get_Position_Bullets(GameObject *obj,int position) { if (!obj) - return NULL; - - PhysicalGameObj* pPhysObjo2 = obj->As_PhysicalGameObj(); - if (!pPhysObjo2) - return NULL; - - if ( ArmedGameObj* pArmedObj = pPhysObjo2->As_ArmedGameObj() ) { - WeaponBagClass* w = pArmedObj->Get_Weapon_Bag(); - if ((position) && (position < w->Get_Count())) - return w->Peek_Weapon(position); + return 0; } - - return NULL; + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; } - -SCRIPTS_API int Get_Position_Bullets(GameObject *obj,int position) + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) { - if ( WeaponClass* wc = _Get_Position_Weapon(obj,position) ) - return wc->Get_Clip_Rounds(); return 0; } - -SCRIPTS_API int Get_Position_Max_Bullets(GameObject *obj, int position) + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((position) && (position < w->Get_Count())) { - if ( WeaponClass* wc = _Get_Position_Weapon(obj,position) ) - return wc->Get_Definition()->ClipSize; + WeaponClass *wc = w->Peek_Weapon(position); + return wc->Get_Clip_Rounds(); + } return 0; } SCRIPTS_API int Get_Position_Clip_Bullets(GameObject *obj,int position) { - if ( WeaponClass* wc = _Get_Position_Weapon(obj,position) ) - return wc->Get_Inventory_Rounds(); + if (!obj) + { return 0; } - -SCRIPTS_API int Get_Position_Clip_Max_Bullets(GameObject *obj, int position) + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) { - if ( WeaponClass* wc = _Get_Position_Weapon(obj,position) ) - return wc->Get_Definition()->MaxInventoryRounds; + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((position) && (position < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(position); + return wc->Get_Inventory_Rounds(); + } return 0; } SCRIPTS_API int Get_Position_Total_Bullets(GameObject *obj, int position) { - if ( WeaponClass* wc = _Get_Position_Weapon(obj,position) ) + if (!obj) + { + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((position) && (position < w->Get_Count())) { + WeaponClass *wc = w->Peek_Weapon(position); int bullets = wc->Get_Clip_Rounds(); int clipbullets = wc->Get_Inventory_Rounds(); - if (clipbullets < 0) + { return -1; - + } return bullets+clipbullets; } return 0; } -SCRIPTS_API int Get_Position_Total_Max_Bullets(GameObject *obj,int position) +SCRIPTS_API int Get_Bullets(GameObject *obj,const char *weapon) { - if ( WeaponClass* wc = _Get_Position_Weapon(obj,position) ) + if (!obj) { - int bullets = wc->Get_Definition()->ClipSize; - int clipbullets = wc->Get_Definition()->MaxInventoryRounds; - - if (clipbullets < 0) - return -1; - - return bullets+clipbullets; + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + int x = w->Get_Count(); + for (int i = 0;i < x;i++) + { + if (w->Peek_Weapon(i)) + { + if (!_stricmp(w->Peek_Weapon(i)->Get_Name(),weapon)) + { + WeaponClass *wc = w->Peek_Weapon(i); + return wc->Get_Clip_Rounds(); + } + } } return 0; } -// ------------------------------------------------------------------------------------------------- - -/*! Internal utility function to get the named weapon preset for an object, reducing code duplication */ -WeaponClass* _Get_Weapon ( GameObject* obj, const char* weapon ) +SCRIPTS_API int Get_Clip_Bullets(GameObject *obj,const char *weapon) { if (!obj) - return NULL; - - PhysicalGameObj* pPhysObjo2 = obj->As_PhysicalGameObj(); - if (!pPhysObjo2) - return NULL; - - if ( ArmedGameObj* pArmedObj = pPhysObjo2->As_ArmedGameObj() ) { - WeaponBagClass* w = pArmedObj->Get_Weapon_Bag(); + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); int x = w->Get_Count(); for (int i = 0;i < x;i++) { if (w->Peek_Weapon(i)) { if (!_stricmp(w->Peek_Weapon(i)->Get_Name(),weapon)) - return w->Peek_Weapon(i); + { + WeaponClass *wc = w->Peek_Weapon(i); + return wc->Get_Inventory_Rounds(); } } } - - return NULL; + return 0; } -SCRIPTS_API int Get_Bullets(GameObject *obj,const char *weapon) +SCRIPTS_API int Get_Total_Bullets(GameObject *obj,const char *weapon) { - if ( WeaponClass* wc = _Get_Weapon(obj,weapon) ) - return wc->Get_Clip_Rounds(); + if (!obj) + { + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + int x = w->Get_Count(); + for (int i = 0;i < x;i++) + { + if (w->Peek_Weapon(i)) + { + if (!_stricmp(w->Peek_Weapon(i)->Get_Name(),weapon)) + { + WeaponClass *wc = w->Peek_Weapon(i); + int bullets = wc->Get_Clip_Rounds(); + int clipbullets = wc->Get_Inventory_Rounds(); + if (clipbullets < 0) + { + return -1; + } + return bullets+clipbullets; + } + } + } return 0; } -SCRIPTS_API int Get_Max_Bullets(GameObject *obj,const char *weapon) +SCRIPTS_API int Get_Current_Max_Bullets(GameObject *obj) { - if ( WeaponClass* wc = _Get_Weapon(obj,weapon) ) + if (!obj) + { + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(w->Get_Index()); return wc->Get_Definition()->ClipSize; + } return 0; } -SCRIPTS_API int Get_Clip_Bullets(GameObject *obj,const char *weapon) +SCRIPTS_API int Get_Current_Clip_Max_Bullets(GameObject *obj) +{ + if (!obj) { - if ( WeaponClass* wc = _Get_Weapon(obj,weapon) ) - return wc->Get_Inventory_Rounds(); return 0; } - -SCRIPTS_API int Get_Max_Clip_Bullets(GameObject *obj,const char *weapon) + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) { - if ( WeaponClass* wc = _Get_Weapon(obj,weapon) ) + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(w->Get_Index()); return wc->Get_Definition()->MaxInventoryRounds; + } return 0; } -SCRIPTS_API int Get_Total_Bullets(GameObject *obj,const char *weapon) +SCRIPTS_API int Get_Current_Total_Max_Bullets(GameObject *obj) { - if ( WeaponClass* wc = _Get_Weapon(obj,weapon) ) + if (!obj) { - int bullets = wc->Get_Clip_Rounds(); - int clipbullets = wc->Get_Inventory_Rounds(); - + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((w->Get_Index()) && (w->Get_Index() < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(w->Get_Index()); + int bullets = wc->Get_Definition()->ClipSize; + int clipbullets = wc->Get_Definition()->MaxInventoryRounds; if (clipbullets < 0) + { return -1; - + } return bullets+clipbullets; } return 0; } -SCRIPTS_API int Get_Max_Total_Bullets(GameObject *obj,const char *weapon) +SCRIPTS_API int Get_Position_Max_Bullets(GameObject *obj, int position) +{ + if (!obj) { - if ( WeaponClass* wc = _Get_Weapon(obj,weapon) ) + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((position) && (position < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(position); + return wc->Get_Definition()->ClipSize; + } + return 0; +} + +SCRIPTS_API int Get_Position_Clip_Max_Bullets(GameObject *obj, int position) +{ + if (!obj) + { + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((position) && (position < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(position); + return wc->Get_Definition()->MaxInventoryRounds; + } + return 0; +} + +SCRIPTS_API int Get_Position_Total_Max_Bullets(GameObject *obj,int position) +{ + if (!obj) + { + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + if ((position) && (position < w->Get_Count())) + { + WeaponClass *wc = w->Peek_Weapon(position); int bullets = wc->Get_Definition()->ClipSize; int clipbullets = wc->Get_Definition()->MaxInventoryRounds; - if (clipbullets < 0) + { return -1; - + } return bullets+clipbullets; } return 0; } -// ------------------------------------------------------------------------------------------------- +SCRIPTS_API int Get_Max_Bullets(GameObject *obj,const char *weapon) +{ + if (!obj) + { + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + int x = w->Get_Count(); + for (int i = 0;i < x;i++) + { + if (w->Peek_Weapon(i)) + { + if (!_stricmp(w->Peek_Weapon(i)->Get_Name(),weapon)) + { + WeaponClass *wc = w->Peek_Weapon(i); + return wc->Get_Definition()->ClipSize; + } + } + } + return 0; +} -void C4GameObj::Restore_Owner() +SCRIPTS_API int Get_Max_Clip_Bullets(GameObject *obj,const char *weapon) { - int at = AmmoDef->AmmoType; - if (!Owner && Player && AmmoDef && (1 != at)) + if (!obj) { - TT_FOREACH(object, GameObjManager::StarGameObjList) + return 0; + } + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) { - if (object->Get_Player_Data() == Player) + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) { - Owner = object; - break; + return 0; } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + int x = w->Get_Count(); + for (int i = 0;i < x;i++) + { + if (w->Peek_Weapon(i)) + { + if (!_stricmp(w->Peek_Weapon(i)->Get_Name(),weapon)) + { + WeaponClass *wc = w->Peek_Weapon(i); + return wc->Get_Definition()->MaxInventoryRounds; + } + } + } + return 0; } - /* - if (!Owner) +SCRIPTS_API int Get_Max_Total_Bullets(GameObject *obj,const char *weapon) { - Player = NULL; - C4GameObj::Defuse(this); + if (!obj) + { + return 0; } - */ + PhysicalGameObj *o2 = obj->As_PhysicalGameObj(); + if (!o2) + { + return 0; + } + ArmedGameObj *o3 = o2->As_ArmedGameObj(); + if (!o3) + { + return 0; + } + WeaponBagClass *w = o3->Get_Weapon_Bag(); + int x = w->Get_Count(); + for (int i = 0;i < x;i++) + { + if (w->Peek_Weapon(i)) + { + if (!_stricmp(w->Peek_Weapon(i)->Get_Name(),weapon)) + { + WeaponClass *wc = w->Peek_Weapon(i); + int bullets = wc->Get_Definition()->ClipSize; + int clipbullets = wc->Get_Definition()->MaxInventoryRounds; + if (clipbullets < 0) + { + return -1; + } + return bullets+clipbullets; } } + } + return 0; +} SCRIPTS_API const char *Get_Powerup_Weapon(const char *Powerup) { DefinitionClass *powerupdef = Find_Named_Definition(Powerup); PowerUpGameObjDef *c = (PowerUpGameObjDef *)powerupdef; - if (c && c->Get_Grant_Weapon_ID()) + if (!c) + { + return "None"; + } + if (c->Get_Grant_Weapon_ID()) { - if ( DefinitionClass *weapondef = Find_Definition(c->Get_Grant_Weapon_ID()) ) + DefinitionClass *weapondef = Find_Definition(c->Get_Grant_Weapon_ID()); return weapondef->Get_Name(); } return "None"; diff -uwr source/scripts/engine_weap.h sourceold/scripts/engine_weap.h --- source/scripts/engine_weap.h 2013-01-13 12:06:54.751039100 +0800 +++ sourceold/scripts/engine_weap.h 2012-07-28 09:11:06.000000000 +0800 @@ -16,228 +16,25 @@ class WeaponDefinitionClass; class ExplosionDefinitionClass; class BeaconGameObj; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Get Loaded Bullets -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \param weapon The preset name of the weapon to be checked -* \returns -* If the object has the specified weapon this returns the number of bullets currently loaded into -* it, or 0 if the object does not have this weapon. Note that 0 is also a valid result if it has -* no ammo or are reloading. -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Bullets(GameObject *obj,const char *weapon); - -/*! -* \brief Get Maximum Loaded Bullets -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \param weapon The preset name of the weapon to be checked -* \returns -* If the object has the specified weapon this returns the maximum number of bullets that can be -* loaded into it, or 0 if the object does not have this weapon. -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Max_Bullets(GameObject *obj,const char *weapon); - -/*! -* \brief Get Inventory Bullets -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \param weapon The preset name of the weapon to be checked -* \returns -* If the object has the specified weapon this returns the number of additional bullets for it in -* inventory, or 0 if the object does not have this weapon. Note that 0 is also a valid result if -* it has no additional ammo -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Clip_Bullets(GameObject *obj,const char *weapon); - -/*! -* \brief Get Maximum Inventory Bullets -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \param weapon The preset name of the weapon to be checked -* \returns -* If the object has the specified weapon this returns the maximum number of additional bullets for -* it that can be held in inventory, or 0 if the object does not have this weapon. -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Max_Clip_Bullets(GameObject *obj,const char *weapon); - -/*! -* \brief Get Total Bullets -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \param weapon The preset name of the weapon to be checked -* \returns -* If the object has the specified weapon this returns the total number of bullets for it, both -* loaded and in inventory, or 0 if the object does not have this weapon. Note that 0 is also a -* valid result if it has no ammo -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Total_Bullets(GameObject *obj,const char *weapon); - -/*! -* \brief Get Maximum Total Bullets -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \param weapon The preset name of the weapon to be checked -* \returns -* If the object has the specified weapon this returns the maximum total number of bullets for it, -* both loaded and in inventory, or 0 if the object does not have this weapon. -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Max_Total_Bullets(GameObject *obj,const char *weapon); - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Get Loaded Bullets - Current Weapon -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns The number of bullets currently loaded into the selected weapon -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Current_Bullets(GameObject *obj); - -/*! -* \brief Get Maximum Loaded Bullets - Current Weapon -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns The maximum number of bullets that can be loaded into the selected weapon -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Current_Max_Bullets(GameObject *obj); - -/*! -* \brief Get Inventory Bullets - Current Weapon -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns The number of additional bullets in inventory for the selected weapon -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Current_Clip_Bullets(GameObject *obj); - -/*! -* \brief Get Maximum Inventory Bullets - Current Weapon -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns The maximum number of additional bullets in inventory for the selected weapon -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Current_Clip_Max_Bullets(GameObject *obj); - -/*! -* \brief Get Total Bullets - Current Weapon -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns The total number of bullets for the selected weapon, both loaded and in inventory -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Current_Total_Bullets(GameObject *obj); - -/*! -* \brief Get Maximum Total Bullets - Current Weapon -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns The maximum total number of bullets for the selected weapon, both loaded and in inventory -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Current_Total_Max_Bullets(GameObject *obj); - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Get Loaded Bullets - Weapon Position -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns -* The number of bullets Positionly loaded into the specified weapon, or 0 if the specified weapon -* position is invalid. Note that 0 is also a valid result if it has no ammo or is reloading -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Position_Bullets(GameObject *obj, int position); - -/*! -* \brief Get Maximum Loaded Bullets - Weapon Position -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns -* The maximum number of bullets that can be loaded into the specified weapon, or 0 if the -* specified weapon position is invalid. -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Position_Max_Bullets(GameObject *obj, int position); - -/*! -* \brief Get Inventory Bullets - Weapon Position -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns -* The number of additional bullets in inventory for the specified weapon, or 0 if the specified -* weapon position is invalid. Note that 0 is also a valid result if it has no additional ammo -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Position_Clip_Bullets(GameObject *obj, int position); - -/*! -* \brief Get Maximum Inventory Bullets - Weapon Position -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns -* The maximum number of additional bullets in inventory for the specified weapon, or 0 if the -* specified weapon position is invalid. -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Position_Clip_Max_Bullets(GameObject *obj, int position); - -/*! -* \brief Get Total Bullets - Weapon Position -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns -* The total number of bullets for the specified weapon, both loaded and in inventory, or 0 if the -* specified weapon position is invalid. Note that 0 is also a valid result if it has no ammo -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Position_Total_Bullets(GameObject *obj, int position); - -/*! -* \brief Get Maximum Total Bullets - Weapon Position -* \ingroup api_weapons -* -* \param obj The object whose weapon we want to check -* \returns -* The maximum total number of bullets for the specified weapon, both loaded and in inventory, or 0 -* if the specified weapon position is invalid. -* \note A bullet count of -1 indicates infinite ammo -*/ -SCRIPTS_API int Get_Position_Total_Max_Bullets(GameObject *obj, int position); - -// ------------------------------------------------------------------------------------------------- - +SCRIPTS_API int Get_Current_Bullets(GameObject *obj); //Get loaded bullets for an objects current gun +SCRIPTS_API int Get_Current_Clip_Bullets(GameObject *obj); //Get clip/backpack bullets for an objects current gun +SCRIPTS_API int Get_Current_Total_Bullets(GameObject *obj); //Get total bullets for an objects current gun +SCRIPTS_API int Get_Total_Bullets(GameObject *obj,const char *weapon); //Get total bullets for a specific gun (if the object doesnt have the gun, return is zero) +SCRIPTS_API int Get_Clip_Bullets(GameObject *obj,const char *weapon); //Get clip/backpack bullets for a specific gun (if the object doesnt have the gun, return is zero) +SCRIPTS_API int Get_Bullets(GameObject *obj,const char *weapon); //Get loaded bullets for a specific gun (if the object doesnt have the gun, return is zero) +SCRIPTS_API int Get_Current_Max_Bullets(GameObject *obj); //Get max loaded bullets for an objects current gun +SCRIPTS_API int Get_Current_Clip_Max_Bullets(GameObject *obj); //Get max clip/backpack bullets for an objects current gun +SCRIPTS_API int Get_Current_Total_Max_Bullets(GameObject *obj); //Get total bullets for an objects current gun +SCRIPTS_API int Get_Max_Total_Bullets(GameObject *obj,const char *weapon); //Get max total bullets for a specific gun (if the object doesnt have the gun, return is zero) +SCRIPTS_API int Get_Max_Clip_Bullets(GameObject *obj,const char *weapon); //Get max clip/backpack bullets for a specific gun (if the object doesnt have the gun, return is zero) +SCRIPTS_API int Get_Max_Bullets(GameObject *obj,const char *weapon); //Get max loaded bullets for a specific gun (if the object doesnt have the gun, return is zero) +SCRIPTS_API int Get_Position_Total_Bullets(GameObject *obj, int position); //Get total bullets for an objects gun at a specific position +SCRIPTS_API int Get_Position_Bullets(GameObject *obj,int position); //Get loaded bullets for an objects gun at a specific position +SCRIPTS_API int Get_Position_Clip_Bullets(GameObject *obj,int position); //Get clip/backpack bullets for an objects gun at a specific position +SCRIPTS_API int Get_Position_Total_Max_Bullets(GameObject *obj, int position); //Get total bullets for an objects gun at a specific position +SCRIPTS_API int Get_Position_Max_Bullets(GameObject *obj,int position); //Get loaded bullets for an objects gun at a specific position +SCRIPTS_API int Get_Position_Clip_Max_Bullets(GameObject *obj,int position); //Get clip/backpack bullets for an objects gun at a specific position +//For all of these, -1 means "infinate ammo" SCRIPTS_API const char *Get_Powerup_Weapon(const char *Powerup); //Get the weapon name that a powerup will grant if collected SCRIPTS_API const AmmoDefinitionClass *Get_Weapon_Ammo_Definition(const char *weapon,bool PrimaryFire); //Get the AmmoDefinitionClass of a weapon given its preset name SCRIPTS_API const WeaponDefinitionClass *Get_Weapon_Definition(const char *weapon); //Get the WeaponDefinitionClass of a weapon given its preset name diff -uwr source/scripts/gmgame.cpp sourceold/scripts/gmgame.cpp --- source/scripts/gmgame.cpp 2013-01-13 11:33:13.768617200 +0800 +++ sourceold/scripts/gmgame.cpp 2012-09-09 17:56:18.000000000 +0800 @@ -928,13 +928,13 @@ for (int i = 0;i < RegisteredEvents[EVENT_POWERUP_PURCHASE_HOOK].Count();i++) { int ret = RegisteredEvents[EVENT_POWERUP_PURCHASE_HOOK][i]->OnPowerupPurchase(base,purchaser,cost,preset,data); - if (ret == -2) + if (ret != -1) { - fp = true; + return ret; } - else if (ret != -1) + if (ret == -2) { - return ret; + fp = true; } } if (fp) @@ -961,13 +961,13 @@ for (int i = 0;i < RegisteredEvents[EVENT_VEHICLE_PURCHASE_HOOK].Count();i++) { int ret = RegisteredEvents[EVENT_VEHICLE_PURCHASE_HOOK][i]->OnVehiclePurchase(base,purchaser,cost,preset,data); - if (ret == -2) + if (ret != -1) { - fp = true; + return ret; } - else if (ret != -1) + if (ret == -2) { - return ret; + fp = true; } } if (fp) @@ -1002,13 +1002,13 @@ for (int i = 0;i < RegisteredEvents[EVENT_CHARACTER_PURCHASE_HOOK].Count();i++) { int ret = RegisteredEvents[EVENT_CHARACTER_PURCHASE_HOOK][i]->OnCharacterPurchase(base,purchaser,cost,preset,data); - if (ret == -2) + if (ret != -1) { - fp = true; + return ret; } - else if (ret != -1) + if (ret == -2) { - return ret; + fp = true; } } if (fp) diff -uwr source/scripts/groups.dox sourceold/scripts/groups.dox --- source/scripts/groups.dox 2013-01-13 12:06:54.610414100 +0800 +++ sourceold/scripts/groups.dox 2012-09-11 08:40:48.000000000 +0800 @@ -1,9 +1,8 @@ /*! * \defgroup scripts Object Scripts * -* This group contains all of the scripts which can be attached to objects. Additionally some scripts -* are sorted into one or more subgroups based upon their functionality to make it easier to find a -* script to accomplish a specific task, such as controlling a base defence. +* This group contains all of the scripts which can be attached to objects, which are sorted into +* subgroups for easy reference */ /*! @@ -16,100 +15,11 @@ */ /*! -* \defgroup scripts_weaponmanagement Scripts - Weapon Management -* \ingroup scripts -* -* The scripts in this group are related to management of the weapons available to an armed game -* object, such as a vehicle or infantry unit. Examples of weapon management include granting an -* additional weapon, removing weapons and altering the ammo count of a weapon. -*/ - -/*! -* \defgroup scripts_teamcontrol Scripts - Team (Base) Control -* \ingroup scripts -* -* Scripts in this group can monitor and/or modify the state of the logical team base, such as -* setting the base power state or whether a team can produce vehicles. -*/ - -/*! * \defgroup scripts_weather Scripts - Weather * \ingroup scripts -* -* Scripts that control weather effects. -*/ - -/*! -* \defgroup scripts_customgenerators Scripts - Custom Generators -* \ingroup scripts -* -* Scripts that trigger custom messages to be sent when certain conditions are met, these can be used -* as triggers for scripts in the \ref scripts_customconsumers "Custom Consumers" scripts group. -*/ - -/*! -* \defgroup scripts_customconsumers Scripts - Custom Consumers -* \ingroup scripts -* -* Scripts that listen for specific custom messages and perform actions when they are recieved. Note -* that this does not include all scripts that use customs internally, only those which allow the ID -* of the custom(s) they are listening for to be modified in script parameters. +* \brief Scripts that control weather effects */ -/*! -* \defgroup scripts_apocrising Scripts - Apocalypse Rising -* \ingroup scripts -* -* Scripts designed specifically for Apocalypse Rising, a game by Bluehell Productions. These are -* subject to change without notice to suit the needs of AR and are therefore not recommended for -* use in any other game. -*/ - -/*! -* \defgroup scripts_conquest Scripts - Conquest Mode -* \ingroup scripts -* -* A set of standalone scripts that can be used to create a conquest style map whereby teams must -* accumulate a specific number of points by achieving various objectives. Alternatively both teams -* can start with a set number of points and the first team to reduce the other teams points to zero -* wins... basically the same thing in reverse. -*/ - -/*! -* \defgroup scripts_radar Scripts - Radar Control -* \ingroup scripts -* -* Scripts that are related to the radar, such as enabling or disabling a teams radar and changing -* the radar visibility of an object -*/ - -/*! -* \defgroup scripts_dp88BuildingScripts Scripts - danpaul88's Custom Building Scripts -* \ingroup scripts -* -* A set of scripts by danpaul88 to create more interactive buildings, either using actual building -* controllers or normal gameobjects. These scripts allow buildings to contain weakpoints, repair -* nodes and capture points, all linked to a central controller script for that building. -*/ - -/*! -* \defgroup scripts_ai Scripts - AI -* \ingroup scripts -* -* Custom AI scripts for units -*/ - -/*! -* \defgroup scripts_sound Scripts - Sound Effects -* \ingroup scripts -* -* Scripts which create sound effects when events occur, such as a turret rotation sound. -*/ - - - - - @@ -117,42 +27,12 @@ * \defgroup api Engine API * * This group contains all of the various engine API commands, which are sorted into subgroups for -* easy reference. +* easy reference */ /*! * \defgroup api_translations Engine API - Translations * \ingroup api * -* Engine API commands related to the translations database. -*/ - -/*! -* \defgroup api_objectfind Engine API - Object Find / Search -* \ingroup api -* -* Engine API commands related to finding one or more game objects that meet specific criteria. -*/ - -/*! -* \defgroup api_scripts Engine API - Scripts Management -* \ingroup api -* -* Engine API commands related to managing the scripts attached to an object -*/ - -/*! -* \defgroup api_teamcontrol Engine API - Team (Base) Control -* \ingroup api -* -* Engine API commands related to controlling and querying the state of the logical team base, such -* as checking or setting whether the specified teams base can produce vehicles. -*/ - -/*! -* \defgroup api_weapons Engine API - Weapons -* \ingroup api -* -* Engine API commands related to weapons, including managing an objects weapons bag, switching the -* selected weapon, checking and altering the number of bullets an object has etc. +* Engine API commands related to the translations database */ \ No newline at end of file diff -uwr source/scripts/jfwcust.cpp sourceold/scripts/jfwcust.cpp --- source/scripts/jfwcust.cpp 2013-01-13 11:33:13.893617200 +0800 +++ sourceold/scripts/jfwcust.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -1600,31 +1600,6 @@ Destroy_Script(); } -void JFW_Send_Custom_On_Damage::Created(GameObject *obj) -{ - above = true; -} - -void JFW_Send_Custom_On_Damage::Damaged(GameObject *obj,GameObject *damager,float amount) -{ - float hp = Commands->Get_Health(obj) + Commands->Get_Shield_Strength(obj); - float val = Get_Float_Parameter("Health"); - if (hp < val && above) - { - above = false; - int msg = Get_Int_Parameter("Message1"); - int ID = Get_Int_Parameter("ID1"); - Commands->Send_Custom_Event(obj,Commands->Find_Object(ID),msg,0,0); - } - else if (hp > val && !above) - { - above = true; - int msg = Get_Int_Parameter("Message2"); - int ID = Get_Int_Parameter("ID2"); - Commands->Send_Custom_Event(obj,Commands->Find_Object(ID),msg,0,0); - } -} - ScriptRegistrant JFW_Send_Custom_Distance_Objects_Timer_Registrant("JFW_Send_Custom_Distance_Objects_Timer","Distance:float,Message:int,Time:float,TimerNum:int,Player_Type:int"); ScriptRegistrant JFW_Send_Custom_Distance_Objects_Custom_Registrant("JFW_Send_Custom_Distance_Objects_Custom","Distance:float,Message:int,Player_Type:int,ListenMessage:int"); ScriptRegistrant JFW_Send_Custom_All_Objects_Timer_Registrant("JFW_Send_Custom_All_Objects_Timer","Message:int,Time:float,TimerNum:int,Player_Type:int"); @@ -1713,4 +1688,3 @@ ScriptRegistrant JFW_Startup_Custom_Self_Registrant("JFW_Startup_Custom_Self","Message:int"); ScriptRegistrant JFW_Set_Skin_Custom_Registrant("JFW_Set_Skin_Custom","Message:int,Armour:string"); ScriptRegistrant JFW_Set_Armor_Custom_Registrant("JFW_Set_Armor_Custom","Message:int,Armour:string"); -ScriptRegistrant JFW_Send_Custom_On_Damage_Registrant("JFW_Send_Custom_On_Damage","Message1:int,ID1:int,Message2:int,ID2:int,Health:float"); diff -uwr source/scripts/jfwcust.h sourceold/scripts/jfwcust.h --- source/scripts/jfwcust.h 2013-01-13 11:33:13.862367200 +0800 +++ sourceold/scripts/jfwcust.h 2012-09-11 08:40:48.000000000 +0800 @@ -30,20 +30,6 @@ void Custom(GameObject *obj,int type,int param,GameObject *sender); }; -/*! -* \brief Send Custom on Death -* \author jonwil -* ingroup scripts_customgenerators -* -* Script to send a custom message when the object it is attached to is killed -* -* \param ID -* ID of the object to send the custom message to -* \param Message -* The type of custom message to send -* \param Param -* The parameter to send with the custom message -*/ class JFW_Death_Send_Custom : public ScriptImpClass { void Killed(GameObject *obj,GameObject *killer); }; @@ -477,33 +463,3 @@ class JFW_Startup_Custom_Self : public ScriptImpClass { void Created(GameObject *obj); }; - -/*! -* \brief Send a custom based on health values -* \author jonwil -* \ingroup scripts_customgenerators -* -* Attach this to an object with health. When the script starts up, it sets a flag to "above". -* When the object is damaged, it checks the value of "current health" + "current shield strength" -* against the "Health" parameter. If "current health" + "current shield strength" is less than the -* "Health" parameter and the "above" flag is set, it clears the "above" flag and sends the custom -* specified by "Message1" to the object with "ID1". If "current health" + "current shield strength" -* is greater than the "Health" parameter and the "above" flag is not set, it sets the "above" flag -* and sends the custom specified by "Message2" to the object with "ID2". -* -* \param Message1 -* Message to send when the objects health+shield goes below the set value -* \param ID1 -* ID of the object to send Message1 to -* \param Message2 -* Message to send when the objects health+shield goes above the set value -* \param ID2 -* ID of the object to send Message2 to -* \param Health -* Health value to check against -*/ -class JFW_Send_Custom_On_Damage : public ScriptImpClass { - bool above; - void Created(GameObject *obj); - void Damaged(GameObject *obj,GameObject *damager,float amount); -}; diff -uwr source/scripts/jfwmisc.h sourceold/scripts/jfwmisc.h --- source/scripts/jfwmisc.h 2013-01-11 22:37:51.769531200 +0800 +++ sourceold/scripts/jfwmisc.h 2012-07-28 09:11:08.000000000 +0800 @@ -35,73 +35,14 @@ void Exited(GameObject *obj,GameObject *exiter); }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Set Building Power State On Custom -* \author jonwil -* \ingroup scripts_teamcontrol scripts_customconsumers -* -* Attached to a building controller, this script sets the power state of the building upon receiving -* a custom message. Despite the name it can be used to turn the power on as well as turning it off. -* Only really has an impact on base defences, other types of buildings will continue to operate as -* normal (just as they would if base power was disabled) -* -* \param Message_Off -* ID of the custom message to turn off building power -* \param Message_On -* ID of the custom message to turn on building power -*/ class JFW_Power_Off : public ScriptImpClass { void Custom(GameObject *obj,int type,int param,GameObject *sender); }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Follow Waypath -* \author jonwil -* -* This script causes the SmartGameObject it is attached to to try and follow a specified waypath ID -* without attacking any objects en route. -* -* \param Waypathid -* ID of the waypath to follow -* \param speed -* The speed at which the unit should follow the waypath -*/ class JFW_Follow_Waypath : public ScriptImpClass { void Created(GameObject *obj); }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Draw a Series of Models -* \author jonwil -* \ingroup scripts_customconsumers -* -* Draws a series of W3D models at a specified location, iterating to the next model in the series -* when a custom is received. Will loop back to the first model after reaching the end of the list. -* -* \pre -* A cinematic preset with the name "Generic_Cinematic" must exist -* -* \note -* No model will be drawn until the custom message is received for the first time -* -* \param Location -* The location at which to draw the models -* \param Custom -* ID of the custom message to iterate to the next model -* \param BaseName -* Common part of the W3D filename, this will have a number appended to it to generate the full -* filename, such as BaseName1.w3d, BaseName2.w3d etc. -* \param Count -* The number of models in the series -* \param Facing -* The direction the models should face when drawn -*/ class JFW_Object_Draw_In_Order : public ScriptImpClass { int currentmodelnumber; int currentmodelid; @@ -110,36 +51,6 @@ public: void Register_Auto_Save_Variables(); }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Draw a Subset of a Series of Models -* \author jonwil -* \ingroup scripts_customconsumers -* -* A modified verison of JFW_Object_Draw_In_Order which can show a subset of the model series, from -* model [i]Start_Number[/i] to model [i]Count[/i]. -* -* \pre -* A cinematic preset with the name "Generic_Cinematic" must exist -* -* \note -* No model will be drawn until the custom message is received for the first time -* -* \param Location -* The location at which to draw the models -* \param Custom -* ID of the custom message to iterate to the next model -* \param BaseName -* Common part of the W3D filename, this will have a number appended to it to generate the full -* filename, such as BaseName1.w3d, BaseName2.w3d etc. -* \param Count -* The number of models in the series, or the last model number from the series to draw -* \param Facing -* The direction the models should face when drawn -* \param Start_Number -* The first model number in the series to draw -*/ class JFW_Object_Draw_In_Order_2 : public ScriptImpClass { int currentmodelnumber; int currentmodelid; @@ -148,35 +59,6 @@ public: void Register_Auto_Save_Variables(); }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Draw a Randomised Series of Models -* \author jonwil -* \ingroup scripts_customconsumers -* -* A modified verison of JFW_Object_Draw_In_Order which randomly picks one of the available models to -* draw each time the custom message is received, which might be the same as the previously drawn -* model. -* -* \pre -* A cinematic preset with the name "Generic_Cinematic" must exist -* -* \note -* No model will be drawn until the custom message is received for the first time -* -* \param Location -* The location at which to draw the models -* \param Custom -* ID of the custom message to iterate to the next model -* \param BaseName -* Common part of the W3D filename, this will have a number appended to it to generate the full -* filename, such as BaseName1.w3d, BaseName2.w3d etc. -* \param Count -* The number of models in the series, or the last model number from the series to draw -* \param Facing -* The direction the models should face when drawn -*/ class JFW_Object_Draw_Random : public ScriptImpClass { int currentmodelid; void Created(GameObject *obj); @@ -271,25 +153,6 @@ public: void Register_Auto_Save_Variables(); }; -/*! -* \brief Change Spawn Character -* \author jonwil -* -* Sets the spawn character preset for a team to the specified infantry preset. To set the spawn -* character for a map this script should be attached to an editor only object such as a daves -* arrow and one copy of that object should be placed on the map. To modify the spawn character -* for both teams simply add two copies of this script to that object. -* -* It is possible to modify the spawn character at any point during the game by causing a copy -* of this script to be created, for example by using JFW_Attach_Script_Custom to attach copies of -* this script to an object at runtime, allowing the spawn character to be changed in response to -* events that occur during the game. -* -* \param Player_Type -* ID of the team to set the spawn character of. 0 = Nod / Soviet, 1 = GDI / Allies -* \param Character -* The name of an infantry preset to use as the teams new spawn character -*/ class JFW_Change_Spawn_Character : public ScriptImpClass { void Created(GameObject *obj); }; diff -uwr source/scripts/jfwscr.h sourceold/scripts/jfwscr.h --- source/scripts/jfwscr.h 2013-01-13 11:33:13.471742200 +0800 +++ sourceold/scripts/jfwscr.h 2012-07-28 09:11:08.000000000 +0800 @@ -41,25 +41,7 @@ void Killed(GameObject *obj,GameObject *killer); }; -/*! -* \brief Attach Script on Custom -* \author jonwil -* \ingroup scripts_customconsumers -* -* Upon receiving the specified custom message this script will attach another script to the object -* it is attached to. -* -* \param Script -* The name of the script to be attached -* \param Params -* The parameters for the script to be attached -* \param Delim -* The delimiter between each value in the Params parameter -* \param Message -* The custom message to listen for -*/ -class JFW_Attach_Script_Custom : public ScriptImpClass -{ +class JFW_Attach_Script_Custom : public ScriptImpClass { void Custom(GameObject *obj,int type,int param,GameObject *sender); }; diff -uwr source/scripts/jfwweap.cpp sourceold/scripts/jfwweap.cpp --- source/scripts/jfwweap.cpp 2013-01-13 12:06:54.797914100 +0800 +++ sourceold/scripts/jfwweap.cpp 2012-08-21 22:31:22.000000000 +0800 @@ -1445,11 +1445,11 @@ LastSwitch = time(NULL); if (Weapon2) { - Remove_Weapon(Owner(),Get_Powerup_Weapon(Get_Parameter("WeaponPowerup1"))); + Remove_Weapon(Owner(),Get_Powerup_Weapon(Get_Parameter("WeaponPowerup2"))); } else { - Remove_Weapon(Owner(),Get_Powerup_Weapon(Get_Parameter("WeaponPowerup2"))); + Remove_Weapon(Owner(),Get_Powerup_Weapon(Get_Parameter("WeaponPowerup1"))); } Commands->Start_Timer(Owner(),this,Get_Float_Parameter("SwitchTime"),1); } @@ -1466,7 +1466,6 @@ Commands->Give_PowerUp(obj,Get_Parameter("WeaponPowerup1"),false); Commands->Select_Weapon(obj,Get_Powerup_Weapon(Get_Parameter("WeaponPowerup1"))); } - Weapon2 = !Weapon2; } ScriptRegistrant JFW_Nod_Turret_Registrant("JFW_Nod_Turret",""); diff -uwr source/scripts/jfwweap.h sourceold/scripts/jfwweap.h --- source/scripts/jfwweap.h 2013-01-11 22:37:51.988281200 +0800 +++ sourceold/scripts/jfwweap.h 2012-08-21 22:30:00.000000000 +0800 @@ -120,33 +120,10 @@ public: void Register_Auto_Save_Variables(); }; -/*! -* \brief Remove All Weapons On Zone Entry -* \author jonwil -* \ingroup scripts_weaponmanagement -* -* Removes all weapons from an object when it enters a zone this script is attached to -*/ class JFW_Clear_Weapons : public ScriptImpClass { void Entered(GameObject *obj,GameObject *enterer); }; -/*! -* \brief Grant Weapon On Zone Entry -* \author jonwil -* \ingroup scripts_weaponmanagement -* -* Grants a weapon powerup to an object when it enters a zone this script is attached to. It can -* optionally be restricted to objects on a specific team. -* -* \note -* Technically there is no reason this script cannot also be used to grant non-weapon powerups -* -* \param Weapon_Name -* The name of a powerup preset which grants the weapon to be given to the object -* \param Player_Type -* The player type (or, team) this script will trigger for. 0 = Nod, 1 = GDI, 2 = All -*/ class JFW_Zone_Weapon : public ScriptImpClass { void Entered(GameObject *obj,GameObject *enterer); }; @@ -167,19 +144,6 @@ void Custom(GameObject *obj,int type,int param,GameObject *sender); }; -/*! -* \brief Remove All Weapons On Custom -* \author jonwil -* \ingroup scripts_weaponmanagement -* -* Removes all weapons from the object the script is attached to when it recieves a specified custom -* message. -* -* \param Message -* The ID of the custom message which will trigger this script -* \param Weapon -* Redundant parameter -*/ class JFW_Clear_Weapons_On_Custom : public ScriptImpClass { void Custom(GameObject *obj,int type,int param,GameObject *sender); }; @@ -192,15 +156,6 @@ void Custom(GameObject *obj,int type,int param,GameObject *sender); }; -/*! -* \brief Remove All Weapons -* \author jonwil -* \ingroup scripts_weaponmanagement -* -* Removes all weapons from the object the script is attached to, this can either be done when the -* object spawns by adding this script to the preset or at any point during the game to remove all -* weapons the object has at that time. -*/ class JFW_Clear_Weapons_Create : public ScriptImpClass { void Created(GameObject *obj); }; @@ -209,26 +164,6 @@ void Custom(GameObject *obj,int type,int param,GameObject *sender); }; -/*! -* \brief Weapon Switch on Keyhook - Vehicle -* \author jonwil -* \ingroup scripts_weaponmanagement -* -* This script allows the driver of a vehicle to swap the weapon being used by the vehicle for an -* alternative one by pressing a key. Pressing the key again will restore the original weapon. -* -* \param Powerup -* The name of a powerup preset which grants the alternative weapon -* \param Keyhook -* The name of the keyhook binding to trigger the weapon swap -* \param SwitchTime -* The amount of time the weapon swap takes, in seconds. During this time the player will be able -* to fire either weapon. -* \param OldSound -* The name of a sound preset to play when switching to the original vehicle weapon -* \param NewSound -* The name of a sound preset to play when switching to the alternative weapon -*/ class JFW_Vehicle_Weapon_Switcher : public JFW_Key_Hook_Base { bool switching; bool newweap; @@ -242,37 +177,6 @@ void KeyHook(); }; -/*! -* \brief Weapon Switch on Keyhook - Infantry Character -* \author jonwil -* \ingroup scripts_weaponmanagement -* -* This script allows a player to swap one of their weapons for an alternative weapon by pressing a -* key. The original weapon will be removed from the player and they will be granted a powerup with -* the alternative weapon. Pressing the key again will remove the alternative weapon from them and -* grant them a powerup containing their original weapon. -* -* \note -* This script will not grant the original weapon to the player, it should be given to them -* either as their default weapon or by another script such as M00_GrantPowerup_Created.\n -* \n -* Because the weapons are removed from the player when swapping from one to the other the ammo -* count is not preserved, so after swapping a weapon will have whatever amount of ammunition is -* specified in the powerup that granted it.\n -* \n -* After the weapon switch has occurred the newly granted weapon will be selected as the active -* weapon, regardless of whether the removed weapon was active when the swap key was pressed. -* -* \param SwitchTime -* The amount of time the weapon swap takes, in seconds. During this time the player will not have -* either their original weapon or the alternative weapon available to them. -* \param WeaponPowerup1 -* The name of a powerup preset which grants the players original weapon -* \param WeaponPowerup2 -* The name of a powerup preset which grants the alternative weapon -* \param Keyhook -* The name of the keyhook binding to trigger the weapon swap -*/ class JFW_Char_Weapon_Switcher : public JFW_Key_Hook_Base { time_t LastSwitch; bool Weapon2; diff -uwr source/scripts/jfwzone.cpp sourceold/scripts/jfwzone.cpp --- source/scripts/jfwzone.cpp 2013-01-13 11:33:14.049867200 +0800 +++ sourceold/scripts/jfwzone.cpp 2012-07-28 09:11:06.000000000 +0800 @@ -2581,7 +2581,7 @@ const char *preset = Commands->Get_Preset_Name(Commands->Find_Object(ID)); float cost = ((float)Get_Cost(preset) / 2); Commands->Give_Money(Get_Vehicle_Driver(Commands->Find_Object(ID)),cost,false); - Commands->Send_Custom_Event(Owner(),Commands->Find_Object(ID),CUSTOM_TRANSITION_VTOL_LAND_ZONE,1,0); // Compatibility with dp88_Aircraft_LandingZone_Aircraft + Commands->Send_Custom_Event(Owner(),Commands->Find_Object(ID),CUSTOM_ENTERED_VTOL_LAND_ZONE,0,0); Force_Occupants_Exit(Commands->Find_Object(ID)); Commands->Start_Timer(Owner(),this,1,ID); RemoveHook(); @@ -3399,7 +3399,7 @@ void JFW_Destroy_Vehicle_Zone::Entered(GameObject *obj,GameObject *enterer) { - if (enterer->As_VehicleGameObj() && !Is_Script_Attached(enterer,"dp88_RemoteControlVehicle")) + if (enterer->As_VehicleGameObj()) { Attach_Script_Occupants(enterer,"RA_DriverDeath", "0"); } Only in source/scripts: keyhooks.dox diff -uwr source/scripts/renalert.h sourceold/scripts/renalert.h --- source/scripts/renalert.h 2013-01-13 11:33:13.706117200 +0800 +++ sourceold/scripts/renalert.h 2012-07-28 09:11:06.000000000 +0800 @@ -103,21 +103,7 @@ void Timer_Expired (GameObject *obj,int number); }; - -/*! -* \brief Driver Death Script -* -* This script kills the object it is attached to after 0.5 seconds and is generally attached by -* another script to kill a vehicle driver once the parent vehicle has died (since doing so on the -* same engine frame would cause a crash). It could also be attached on a custom message by using -* a script such as JFW_Attach_Script_Custom -* -* \pre -* A warhead of type "Death" must exist in armor.ini which is capable of damaging the object this -* script is attached to. -*/ -class RA_DriverDeath : public ScriptImpClass -{ +class RA_DriverDeath : public ScriptImpClass { void Created(GameObject *obj); void Timer_Expired(GameObject *obj,int number); }; diff -uwr source/scripts/scripts.vcxproj sourceold/scripts/scripts.vcxproj --- source/scripts/scripts.vcxproj 2013-01-13 11:48:33.936585900 +0800 +++ sourceold/scripts/scripts.vcxproj 2012-10-18 19:23:16.000000000 +0800 @@ -474,7 +474,6 @@ - @@ -522,6 +521,7 @@ + @@ -573,10 +573,8 @@ - - @@ -841,6 +839,7 @@ + @@ -944,17 +943,12 @@ - - - - - @@ -978,7 +972,6 @@ - diff -uwr source/scripts/scripts.vcxproj.filters sourceold/scripts/scripts.vcxproj.filters --- source/scripts/scripts.vcxproj.filters 2013-01-13 11:48:33.920960900 +0800 +++ sourceold/scripts/scripts.vcxproj.filters 2012-10-18 19:23:16.000000000 +0800 @@ -9,6 +9,9 @@ {0728cb88-d40c-4ea5-abf5-9a2871fddeff} h;hpp;hxx;hm;inl + + {5e366579-cb1f-4e1c-ad6d-4be536adb3f3} + {3a838239-ff5c-4a89-ad2a-19a5da3fc8b6} @@ -27,21 +30,18 @@ {7ea39079-9716-4808-9729-03ec59ee0623} + + {370b7bfa-7e9c-4970-a892-0d09f28d96f4} + + + {801d5c01-d34a-4efe-8732-24c88360c57e} + {ba24906d-1b40-49a7-aa3d-da4d65476041} {694fc3c1-10b6-4967-a04e-8983bdf5cc06} - - {5e366579-cb1f-4e1c-ad6d-4be536adb3f3} - - - {07a0b0e4-825d-4906-84b7-7793cb89466b} - - - {5a499a49-9769-4188-a2b5-e7ef5669e06d} - @@ -257,6 +257,9 @@ 01. Sources + + 01. Sources + 03. New Sources @@ -446,6 +449,9 @@ 01. Sources\Tib. Crystal War + + 01. Sources\UberAOW + 01. Sources\Tib. Crystal War @@ -467,6 +473,30 @@ 01. Sources\Tib. Crystal War + + 01. Sources + + + 01. Sources + + + 01. Sources + + + 01. Sources + + + 01. Sources + + + 01. Sources + + + 01. Sources + + + 01. Sources\UberAOW + 01. Sources\Tib. Crystal War @@ -515,47 +545,11 @@ 01. Sources\Tib. Crystal War\Campaign - - 01. Sources - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW - - - 01. Sources\UltraAOW + 01. Sources - - 03. New Sources + + 01. Sources @@ -921,6 +915,9 @@ 02. Headers + + 02. Headers + 03. New Sources @@ -1476,6 +1473,9 @@ 02. Headers\Tib. Crystal War + + 02. Headers\UberAOW + 02. Headers\Tib. Crystal War @@ -1503,12 +1503,36 @@ 02. Headers\Tib. Crystal War + + 02. Headers + 03. New Sources 03. New Sources + + 02. Headers + + + 02. Headers + + + 02. Headers + + + 02. Headers + + + 02. Headers + + + 02. Headers + + + 02. Headers\UberAOW + 02. Headers @@ -1569,115 +1593,82 @@ 02. Headers\Tib. Crystal War\Campaign - - 02. Headers - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW - - - 02. Headers\UltraAOW + 02. Headers - - 02. Headers\UltraAOW + + 02. Headers - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files - Documentation + Readme files 01. Sources\Coop Sources @@ -1685,17 +1676,5 @@ 01. Sources\Tib. Crystal War - - Documentation - - - Documentation - - - Documentation - - - 01. Sources\UltraAOW - \ No newline at end of file diff -uwr source/scripts/tcw_game.cpp sourceold/scripts/tcw_game.cpp --- source/scripts/tcw_game.cpp 2013-01-11 22:37:51.894531200 +0800 +++ sourceold/scripts/tcw_game.cpp 2012-07-31 21:54:14.000000000 +0800 @@ -70,11 +70,11 @@ void tcw_Map_Intro::Created(GameObject *obj) { - Commands->Start_Timer(obj,this,25.0f,251); - Commands->Start_Timer(obj,this,28.0f,252); - Commands->Start_Timer(obj,this,31.0f,253); - Commands->Start_Timer(obj,this,34.0f,254); - Commands->Start_Timer(obj,this,37.0f,255); + Commands->Start_Timer(obj,this,15.0f,251); + Commands->Start_Timer(obj,this,18.0f,252); + Commands->Start_Timer(obj,this,21.0f,253); + Commands->Start_Timer(obj,this,24.0f,254); + Commands->Start_Timer(obj,this,27.0f,255); } void tcw_Map_Intro::Timer_Expired(GameObject *obj, int number) { diff -uwr source/scripts/tcw_sp_scripts.cpp sourceold/scripts/tcw_sp_scripts.cpp --- source/scripts/tcw_sp_scripts.cpp 2013-01-13 11:33:13.456117200 +0800 +++ sourceold/scripts/tcw_sp_scripts.cpp 2012-08-05 10:29:26.000000000 +0800 @@ -1,14 +1,3 @@ -/* Renegade Scripts.dll - Copyright 2011 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ #include "General.h" #include "engine.h" #include "scripts.h" diff -uwr source/scripts/tcw_sp_scripts.h sourceold/scripts/tcw_sp_scripts.h --- source/scripts/tcw_sp_scripts.h 2013-01-13 11:33:13.971742200 +0800 +++ sourceold/scripts/tcw_sp_scripts.h 2012-08-05 10:29:26.000000000 +0800 @@ -1,14 +1,3 @@ -/* Renegade Scripts.dll - Copyright 2011 Tiberian Technologies - - This file is part of the Renegade scripts.dll - The Renegade scripts.dll is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2, or (at your option) any later - version. See the file COPYING for more details. - In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. - Only the source code to the module(s) containing the licenced code has to be released. -*/ #pragma once /* diff -uwr source/scripts/z.cpp sourceold/scripts/z.cpp --- source/scripts/z.cpp 2013-01-11 22:37:52.691406200 +0800 +++ sourceold/scripts/z.cpp 2012-07-28 09:11:06.000000000 +0800 @@ -291,13 +291,11 @@ Commands->Send_Custom_Event(obj,Commands->Find_Object(Get_Int_Parameter("ID")),Get_Int_Parameter("Message"),Get_Int_Parameter("param"),0); } -void z_NoDamageMoneyPoints::Created(GameObject *obj) -{ - Set_Damage_Points(obj,0.0f); -} void z_NoDamageMoneyPoints::Damaged(GameObject *obj, GameObject *damager, float damage) { Commands->Set_Health(obj,Commands->Get_Max_Health(obj)); + Commands->Give_Points(damager,(float)(damage*-1.0),false); + Commands->Give_Money(damager,(float)(damage*-1.0),false); } void z_Set_Team::Created(GameObject *obj) diff -uwr source/scripts/z.h sourceold/scripts/z.h --- source/scripts/z.h 2013-01-11 22:37:52.441406200 +0800 +++ sourceold/scripts/z.h 2012-07-28 09:11:08.000000000 +0800 @@ -201,7 +201,6 @@ }; class z_NoDamageMoneyPoints : public ScriptImpClass { - void Created(GameObject *obj); void Damaged(GameObject *obj, GameObject *damager, float damage); }; Only in sourceold/scripts: z_airraid.cpp Only in sourceold/scripts: z_airraid.h diff -uwr source/scripts/z_misc.cpp sourceold/scripts/z_misc.cpp --- source/scripts/z_misc.cpp 2013-01-11 22:37:52.769531200 +0800 +++ sourceold/scripts/z_misc.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -431,8 +431,6 @@ void z_Capturable_TibSilo::Created(GameObject *obj) { owner = Get_Int_Parameter("Owner"); - if (owner > -2) Set_Damage_Points(obj,0.300f); - else Set_Damage_Points(obj,0.0f); Commands->Set_Player_Type(obj,owner); Attach_Script_Once(obj,"z_Credit_Trickle",""); playdmg = true; @@ -795,17 +793,6 @@ } } -void z_Vehicle_Exit_Set_Object_Team_Sender::Custom(GameObject *obj, int message, int param, GameObject *sender)//using on the map TheCanyon to set the team on the Silo's when players exit it -{ - int team = Get_Object_Type(sender); - if (message == CUSTOM_EVENT_VEHICLE_EXITED) - { - Commands->Set_Player_Type(obj,team); - } -} - - -ScriptRegistrant z_Vehicle_Exit_Set_Object_Team_Sender_Registrant("z_Vehicle_Exit_Set_Object_Team_Sender",""); ScriptRegistrant z_Min_Veh_Z_Pos_Registrant("z_Min_Veh_Z_Pos","Min=0:float"); ScriptRegistrant z_Set_Mine_Limit_Created_Registrant("z_Set_Mine_Limit_Created","Limit=36:int"); ScriptRegistrant z_Set_Time_Limit_Created_Registrant("z_Set_Time_Limit_Created","Time_Seconds=3600:int"); diff -uwr source/scripts/z_misc.h sourceold/scripts/z_misc.h --- source/scripts/z_misc.h 2013-01-11 22:37:51.628906200 +0800 +++ sourceold/scripts/z_misc.h 2012-07-28 09:11:08.000000000 +0800 @@ -130,7 +130,3 @@ void Timer_Expired(GameObject *obj, int number); }; -class z_Vehicle_Exit_Set_Object_Team_Sender : public ScriptImpClass { - void Custom(GameObject *obj, int message, int param, GameObject *sender); -}; - Only in source/scripts: z_snowwarfare.cpp Only in source/scripts: z_snowwarfare.h diff -uwr source/scripts/z_uberaow.cpp sourceold/scripts/z_uberaow.cpp --- source/scripts/z_uberaow.cpp 2013-01-11 22:37:52.113281200 +0800 +++ sourceold/scripts/z_uberaow.cpp 2012-07-28 09:11:08.000000000 +0800 @@ -155,21 +155,21 @@ void z_Tiberium_Field::Entered(GameObject *obj, GameObject *enter) { - if (Is_Script_Attached(enter,"z_Tiberium_Truck")) + if (strstr(Commands->Get_Preset_Name(enter),"CnC_Nod_Truck_Player_Secret")) { Commands->Send_Custom_Event(obj,enter,1000,1,0);//harveting started } } void z_Tiberium_Field::Exited(GameObject *obj, GameObject *exit) { - if (Is_Script_Attached(exit,"z_Tiberium_Truck")) + if (strstr(Commands->Get_Preset_Name(exit),"CnC_Nod_Truck_Player_Secret")) { Commands->Send_Custom_Event(obj,exit,1001,1,0);//not harvesting anymore } } void z_Tiberium_Deposit::Entered(GameObject *obj, GameObject *enter) { - if (Is_Script_Attached(enter,"z_Tiberium_Truck")) + if (strstr(Commands->Get_Preset_Name(enter),"CnC_Nod_Truck_Player_Secret")) { Commands->Send_Custom_Event(obj,enter,1002,1,0);//dump } Only in source/scripts: z_under_siege.cpp Only in source/scripts: z_under_siege.h