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/GameData.h sourceold/scripts/GameData.h --- source/scripts/GameData.h 2013-02-12 09:36:05.831054600 +0800 +++ sourceold/scripts/GameData.h 2012-07-28 09:11:07.222656200 +0800 @@ -57,9 +57,6 @@ } virtual ~Signaler() { - if (Forward) - Forward->SignalDropped(*this); - Forward = 0; } void SignalMe(Signaler &sig) { diff -uwr source/scripts/SoldierGameObj.h sourceold/scripts/SoldierGameObj.h --- source/scripts/SoldierGameObj.h 2013-01-29 13:00:07.149414000 +0800 +++ sourceold/scripts/SoldierGameObj.h 2012-08-18 03:19:10.575195300 +0800 @@ -105,7 +105,7 @@ bool Is_Airborne( void ) { return Get_State() == HumanStateClass::AIRBORNE; } bool Is_Crouched( void ) { return HumanState.Get_State_Flag( HumanStateClass::CROUCHED_FLAG ); } bool Is_Sniping( void ) { return HumanState.Get_State_Flag( HumanStateClass::SNIPING_FLAG ); } - void Set_Is_Sniping() { HumanState.Toggle_State_Flag(HumanStateClass::SNIPING_FLAG); Set_Object_Dirty_Bit(BIT_OCCASIONAL, true); } + void Set_Is_Sniping() { HumanState.Toggle_State_Flag(HumanStateClass::SNIPING_FLAG); } bool Is_Slow( void ) { return (Get_Sub_State() & HumanStateClass::SUB_STATE_SLOW) != 0; } bool Is_On_Ladder( void ) { return Get_State() == HumanStateClass::LADDER; } bool Is_In_Vehicle( void ) { return Get_State() == HumanStateClass::IN_VEHICLE; } diff -uwr source/scripts/dp88_ar.cpp sourceold/scripts/dp88_ar.cpp --- source/scripts/dp88_ar.cpp 2013-02-19 19:54:31.516601500 +0800 +++ sourceold/scripts/dp88_ar.cpp 2013-01-13 12:06:54.579164100 +0800 @@ -845,10 +845,6 @@ - - - - /*------------------------ AR Miner Script - Base Class @@ -856,197 +852,174 @@ and implements common functionality used by both scripts --------------------------*/ -void dp88_Ore_Miner::Created ( GameObject *obj ) -{ - m_aiState = MINER_AISTATE_IDLE; - m_oreMined = 0; - m_oreValue = 0; - - m_bUseAI = ( Get_Int_Parameter ( "Use_AI" ) == 1 ) ? true : false; - m_oreCapacity = Get_Int_Parameter("Ore_Capacity"); - m_oreMiningTime = Get_Float_Parameter("Ore_Mining_Time"); - m_oreDumpTime = Get_Float_Parameter("Ore_Dump_Time"); - - m_oreFieldId = 0; - m_oreFieldRand = 0; - - // Load animation settings - m_animations[MINER_ANIM_IDLE] = Get_Parameter("Idle_Animation"); - m_animations[MINER_ANIM_MINING] = Get_Parameter("Mining_Animation"); - m_animations[MINER_ANIM_DUMPING] = Get_Parameter("Dump_Animation"); - m_animSounds[MINER_ANIM_IDLE] = NULL; - m_animSounds[MINER_ANIM_MINING] = Get_Parameter("Mining_Sound"); - m_animSounds[MINER_ANIM_DUMPING] = Get_Parameter("Dump_Sound"); - - for ( int i = MINER_ANIM_IDLE; i < MINER_ANIM_DUMPING; ++i ) +void dp88_AR_Miner::Created ( GameObject *obj ) { - if (m_animations[i] != NULL && strlen(m_animations[i]) < 0) - m_animations[i] = NULL; - if (m_animSounds[i] != NULL && strlen(m_animSounds[i]) < 0) - m_animSounds[i] = NULL; + oreFieldRand = 0; + oreFieldValue = 0; + oreLoadLevel = 0; + oreValue = 0; + animating = false; + + useAI = ( Get_Int_Parameter ( "enableAI" ) == 1 ) ? true : false; + aiState = MINER_AISTATE_IDLE; + + /* If this miner is AI controlled then send the ore unload complete event in 10 + seconds, which will cause the AI to set off towards an ore field. Note that the + delay is required to prevent the normal harvester AI taking over */ + if ( useAI ) + Commands->Send_Custom_Event( obj, obj, CUSTOM_MINER_UNLOAD_ORE_COMPLETE, 1, (float)Get_Int_Parameter("aiStartDelay") ); + if (strlen(Get_Parameter("idleAnimation")) > 0) + Commands->Set_Animation(obj,Get_Parameter("idleAnimation"),true,0,0,-1,false); } - // Set the initial animation state - m_currentAnimId = MINER_ANIM_DUMPING; - UpdateAnimation(obj, MINER_ANIM_IDLE); - /* For AI miners send a message to ourselves to start searching for an ore field - note the delay - * which is required to prevent the default harvester AI taking over */ - if ( m_bUseAI ) - Commands->Send_Custom_Event( obj, obj, CUSTOM_MINER_AI_SEARCH_FOR_ORE, 1, (float)Get_Int_Parameter("AI_Init_Delay") ); -} +void dp88_AR_Miner::Custom ( GameObject *obj, int type, int param, GameObject *sender ) +{ + // Message from an ore field notifying us that we have entered it. Start + // collecting ore and call EnteredOreField() + if ( type == CUSTOM_MINER_ENTERED_ORE_FIELD && oreLoadLevel < Get_Int_Parameter("loadLevels") ) + { + // Store the value of the ore field and generate a random integer to identify + // this trip into the ore field - prevents glitching the timers by entering + // and exiting constantly + oreFieldValue = param; + oreFieldRand = Commands->Get_Random_Int(2,10240); -// ------------------------------------------------------------------------------------------------- + // Set AI state + if ( useAI ) + aiState = MINER_AISTATE_COLLECTING_ORE; -void dp88_Ore_Miner::Custom ( GameObject *obj, int type, int param, GameObject *sender ) -{ - // Message from an ore field indicating we have entered it - if ( type == CUSTOM_MINER_ENTERED_ORE_FIELD ) - { + // Send message to increase ore load and, if a player vehicle, inform the driver + // that we have started collecting ore + Commands->Send_Custom_Event ( obj, obj, CUSTOM_MINER_INCREASE_ORE_LOAD, oreFieldRand, Get_Float_Parameter("timePerLoadLevel") ); + if ( Get_Vehicle_Driver(obj) != NULL ) + Send_Message_Player ( Get_Vehicle_Driver(obj), 153, 204, 25, "Collecting ore..." ); + + // Call EnteredOreField() EnteredOreField(obj, sender); } - // Message from an ore field indicating we have left it + // Message from an ore field notifying us that we have left it. Stop + // collecting ore and call ExitedOreField() else if ( type == CUSTOM_MINER_EXITED_ORE_FIELD ) { + // Reset ore field parameters + oreFieldValue = 0; + oreFieldRand = 0; + + // Call ExitedOreField() ExitedOreField(obj, sender); } - // Message to ourselves to mine another ore load - else if ( type == CUSTOM_MINER_INCREASE_ORE_LOAD && param == m_oreFieldRand ) + // Message to ourselves to increase our ore load + else if ( type == CUSTOM_MINER_INCREASE_ORE_LOAD && param == oreFieldRand ) { - GameObject* pOreField = Commands->Find_Object(m_oreFieldId); - dp88_Ore_Field* pOreFieldScript = (!pOreField) ? NULL : (dp88_Ore_Field *)(Find_Script_On_Object(pOreField,"dp88_Ore_Field")); - // Unless we are already full increase our load level and the value of our load - if ( m_oreMined < m_oreCapacity && pOreFieldScript ) - { - if ( pOreFieldScript->RemoveOre(1) == 1 ) + if ( oreLoadLevel < Get_Int_Parameter("loadLevels") ) { // Play the mining sound - if ( m_animSounds[MINER_ANIM_MINING] != NULL ) - Commands->Create_Sound(m_animSounds[MINER_ANIM_MINING],Commands->Get_Position(obj),obj); + if (strlen(Get_Parameter("miningSound")) > 0) + Commands->Create_Sound(Get_Parameter("miningSound"),Commands->Get_Position(obj),obj); - m_oreMined++; - m_oreValue += pOreFieldScript->GetOreValue(); - } + oreLoadLevel++; + oreValue += oreFieldValue*Get_Int_Parameter("orePerLoadLevel"); } // If we are still not full start send a delayed custom to increase it again - if ( m_oreMined < m_oreCapacity && pOreFieldScript && (pOreFieldScript->IsInfinite() || pOreFieldScript->NumOreUnits() > 0) ) - Commands->Send_Custom_Event ( obj, obj, CUSTOM_MINER_INCREASE_ORE_LOAD, m_oreFieldRand, m_oreMiningTime ); + if ( oreLoadLevel < Get_Int_Parameter("loadLevels") ) + Commands->Send_Custom_Event ( obj, obj, CUSTOM_MINER_INCREASE_ORE_LOAD, oreFieldRand, Get_Float_Parameter("timePerLoadLevel") ); - // Otherwise we are full of ore... or the ore field is depleted... + // Otherwise we are full of ore... else { - UpdateAnimation(obj, MINER_ANIM_IDLE); - + // Stop the mining animation + animating = false; + obj->As_PhysicalGameObj()->Clear_Animation(); + if (strlen(Get_Parameter("idleAnimation")) > 0) + Commands->Set_Animation(obj,Get_Parameter("idleAnimation"),true,0,0,-1,false); // If using the AI start driving to the refinery - if ( m_bUseAI ) + if ( useAI ) + { + aiState = MINER_AISTATE_RETURN_TO_REFINERY; ReturnToRefinery(obj); + } // Or, if we are a player driven miner, tell the driver we are full else if ( Get_Vehicle_Driver(obj) != NULL ) - { - if ( m_oreMined < m_oreCapacity ) - Send_Message_Player ( Get_Vehicle_Driver(obj), DP88_RGB_GENERAL_MSG, "The ore field is depleted, find another ore field or dock at the Refinery to smelt the ore you have collected so far..." ); - else 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" ); } } - } // Message from the ore dump zone notifying us that we have entered it. If // we have ore to unload then immobilize the vehicle and begin unloading it - else if ( type == CUSTOM_MINER_ENTERED_DUMP_ZONE && m_oreMined > 0 ) + else if ( type == CUSTOM_MINER_ENTERED_DUMP_ZONE && oreLoadLevel > 0 ) { // 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..." ); // Set AI state - if ( m_bUseAI ) - m_aiState = MINER_AISTATE_UNLOADING_ORE; + if ( useAI ) + aiState = MINER_AISTATE_UNLOADING_ORE; // Send a timed event to notify us when the ore unload is completed and // call the DockedAtRefinery() event - Commands->Send_Custom_Event ( obj, obj, CUSTOM_MINER_UNLOAD_ORE_COMPLETE, 0, m_oreDumpTime ); + Commands->Send_Custom_Event ( obj, obj, CUSTOM_MINER_UNLOAD_ORE_COMPLETE, 0, Get_Float_Parameter("unloadTime") ); DockedAtRefinery(obj); } // Message to ourselves to indicate ore unloading is complete, grant money // to the team and set off to collect some more ore - else if ( type == CUSTOM_MINER_UNLOAD_ORE_COMPLETE ) + if ( type == CUSTOM_MINER_UNLOAD_ORE_COMPLETE ) { // Inform the driver that we have finished unloading if ( Get_Vehicle_Driver(obj) != NULL ) { StringClass message(true); - message.Format ("Ore unloaded successfully, you have earned %d credits for each player and %d points for yourself", m_oreValue, m_oreValue/10 ); + 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 ); - Commands->Give_Points(Get_Vehicle_Driver(obj),(float)m_oreValue/10.0f,false); + Commands->Give_Points(Get_Vehicle_Driver(obj),(float)oreValue/10.0f,false); } // Grant money to team and reset ore load level - Commands->Give_Money ( obj, (float)m_oreValue, true ); - m_oreMined = 0; - m_oreValue = 0; + Commands->Give_Money ( obj, (float)oreValue, true ); + oreLoadLevel = 0; + oreValue = 0; // Call UndockedFromRefinery UndockedFromRefinery(obj); } - - - // AI message to search for an ore field... - else if ( type == CUSTOM_MINER_AI_SEARCH_FOR_ORE ) - { - DriveToOreField(obj); - } } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::Action_Complete ( GameObject *obj, int action_id, ActionCompleteReason complete_reason ) +void dp88_AR_Miner::Action_Complete ( GameObject *obj, int action_id, ActionCompleteReason complete_reason ) { // If the completed action was RETURN_TO_REFINERY then set the AI state to // docking and call DockAtRefinery(); if ( action_id == MINER_ACTIONID_RETURN_TO_REFINERY ) { - //Console_Output ( "dp88_Ore_Miner: Arrived at refinery... start docking\n" ); - m_aiState = MINER_AISTATE_DOCK_AT_REFINERY; + //Console_Output ( "dp88_AR_Miner: Arrived at refinery... start docking\n" ); + aiState = MINER_AISTATE_DOCK_AT_REFINERY; DockAtRefinery(obj); } } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::DriveToOreField ( GameObject *obj ) +void dp88_AR_Miner::DriveToOreField ( GameObject *obj ) { - m_aiState = MINER_AISTATE_SEARCH_FOR_ORE; - - // \todo Check number of units available in an ore field and find one with a sufficient quantity - - // ideally 1.5x our capacity to avoid it being depleted before we get there! - SList oreFields; - Find_All_Objects_With_Script_By_Distance ( "dp88_Ore_Field", oreFields, Commands->Get_Position(obj)); - - for ( SLNode* oreFieldNode = oreFields.Head(); oreFieldNode != NULL; oreFieldNode = oreFieldNode->Next() ) - { - if ( GameObject* oreField = oreFieldNode->Data() ) + /* Find and drive to an ore field */ + GameObject* zone = Find_Closest_Object_With_Script("dp88_AR_Ore_Field_Zone", Commands->Get_Position(obj)); + if ( zone != NULL ) { - dp88_Ore_Field* pOreFieldScript = (dp88_Ore_Field *)(Find_Script_On_Object(oreField,"dp88_Ore_Field")); - if ( !pOreFieldScript || (!pOreFieldScript->IsInfinite() && pOreFieldScript->NumOreUnits() < 15) ) // 15 is a magic number currently, should fix... - continue; - - Vector3 position = Commands->Get_Position(oreField); - //Console_Output ( "dp88_Ore_Miner: Driving to location: %.2f, %.2f, %.2f\n", position.X, position.Y, position.Z ); + Vector3 position = Commands->Get_Position(zone); + //Console_Output ( "dp88_AR_Miner: Driving to location: %.2f, %.2f, %.2f\n", position.X, position.Y, position.Z ); /* Setup parameters and get going! */ - m_aiState = MINER_AISTATE_DRIVE_TO_ORE; ActionParamsStruct params; params.Set_Basic( this, 100.0f, MINER_ACTIONID_DRIVE_TO_ORE ); params.Set_Movement ( position, 1.0f, 1.0f ); @@ -1054,81 +1027,51 @@ params.ShutdownEngineOnArrival = true; params.AttackActive = false; Commands->Action_Goto( obj, params ); - - return; - } } - - // No ore fields are available at the moment... send ourselves a message to have another look in 5 seconds... - Commands->Send_Custom_Event( obj, obj, CUSTOM_MINER_AI_SEARCH_FOR_ORE, 1, (float)5.0f ); } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::EnteredOreField ( GameObject *obj, GameObject* oreField ) +void dp88_AR_Miner::EnteredOreField ( GameObject *obj, GameObject* oreField ) { - // Ignore this if we are already full - if ( m_oreMined >= m_oreCapacity ) - return; - - // Check if this is a valid ore field - dp88_Ore_Field* pOreFieldScript = (dp88_Ore_Field *)(Find_Script_On_Object(oreField,"dp88_Ore_Field")); - if ( !pOreFieldScript ) - return; + // If we are using AI then reset the action now that we have arrived + if ( useAI ) + Commands->Action_Reset ( obj, 101.0f ); - // Set AI state, notify driver or abort if neither AI controlled nor player driven... - if ( m_bUseAI ) + // Start the mining animation if it is not already running + if ((strlen(Get_Parameter("miningAnimation")) > 0) && !animating) { - m_aiState = MINER_AISTATE_COLLECTING_ORE; - Commands->Action_Reset ( obj, 101.0f ); + animating = true; + Commands->Set_Animation(obj,Get_Parameter("miningAnimation"),true,0,0,-1,false); } - else if ( Get_Vehicle_Driver(obj) != NULL ) - Send_Message_Player ( Get_Vehicle_Driver(obj), DP88_RGB_GENERAL_MSG, "Collecting ore..." ); - else - return; - - // Save the ore field ID and generate a random integer to identify this trip into the ore field - // to prevent glitching the timers by entering and exiting constantly - m_oreFieldId = Commands->Get_ID(oreField); - m_oreFieldRand = Commands->Get_Random_Int(2,10240); - - // Send delayed message to increase ore load - Commands->Send_Custom_Event ( obj, obj, CUSTOM_MINER_INCREASE_ORE_LOAD, m_oreFieldRand, m_oreMiningTime ); - - UpdateAnimation(obj, MINER_ANIM_MINING); } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::ExitedOreField ( GameObject *obj, GameObject* oreField ) +void dp88_AR_Miner::ExitedOreField ( GameObject *obj, GameObject* oreField ) { - // Reset ore field parameters - m_oreFieldId = 0; - m_oreFieldRand = 0; - // Stop the mining animation - UpdateAnimation(obj, MINER_ANIM_IDLE); + animating = false; + obj->As_PhysicalGameObj()->Clear_Animation(); + if (strlen(Get_Parameter("idleAnimation")) > 0) + Commands->Set_Animation(obj,Get_Parameter("idleAnimation"),true,0,0,-1,false); // If this is an AI miner and our state is still collecting ore then we were probably shoved out // of the ore field by some bully in a vehicle so drive back in to finish mining - if ( m_bUseAI && m_aiState == MINER_AISTATE_COLLECTING_ORE ) + if ( useAI && aiState == MINER_AISTATE_COLLECTING_ORE ) DriveToOreField(obj); } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::ReturnToRefinery ( GameObject *obj ) +void dp88_AR_Miner::ReturnToRefinery ( GameObject *obj ) { /* Find and drive to the refinery */ - m_aiState = MINER_AISTATE_RETURN_TO_REFINERY; GameObject *refinery = Find_Refinery(Commands->Get_Player_Type(obj)); if ( refinery != NULL ) { - GameObject* zone = Find_Closest_Object_With_Script("dp88_Ore_Dump_Zone", Commands->Get_Position(refinery)); + GameObject* zone = Find_Closest_Object_With_Script("dp88_AR_Ore_Deposit_Zone", Commands->Get_Position(refinery)); if ( zone != NULL ) { Vector3 position = Commands->Get_Position(zone); - //Console_Output ( "dp88_Ore_Miner: Driving to location: %.2f, %.2f, %.2f\n", position.X, position.Y, position.Z ); + //Console_Output ( "dp88_AR_Miner: Driving to location: %.2f, %.2f, %.2f\n", position.X, position.Y, position.Z ); /* Setup parameters and get going! */ ActionParamsStruct params; @@ -1142,19 +1085,18 @@ } } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::DockAtRefinery ( GameObject *obj ) +void dp88_AR_Miner::DockAtRefinery ( GameObject *obj ) { // Reset current action Commands->Action_Reset(obj, 101.0f); /* Find and drive to the refinery unloading area */ - GameObject* zone = Find_Closest_Object_With_Script("dp88_Ore_Dump_Zone", Commands->Get_Position(obj)); + GameObject* zone = Find_Closest_Object_With_Script("dp88_AR_Ore_Deposit_Zone", Commands->Get_Position(obj)); if ( zone != NULL ) { Vector3 position = Commands->Get_Position(zone); - //Console_Output ( "dp88_Ore_Miner: Docking at location: %.2f, %.2f, %.2f\n", position.X, position.Y, position.Z ); + //Console_Output ( "dp88_AR_Miner: Docking at location: %.2f, %.2f, %.2f\n", position.X, position.Y, position.Z ); /* Setup parameters and get going! */ ActionParamsStruct params; @@ -1167,14 +1109,17 @@ } } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::DockedAtRefinery ( GameObject *obj ) +void dp88_AR_Miner::DockedAtRefinery ( GameObject *obj ) { - UpdateAnimation(obj, MINER_ANIM_DUMPING); + // Start dock animation and sound + if (strlen(Get_Parameter("dockAnimation")) > 0) + Commands->Set_Animation(obj,Get_Parameter("dockAnimation"),false,0,0,-1,false); + if (strlen(Get_Parameter("dockSound")) > 0) + Commands->Create_Sound(Get_Parameter("dockSound"),Commands->Get_Position(obj),obj); // If we are using AI then reset the action now that we have arrived - if (m_bUseAI) + if (useAI) Commands->Action_Reset ( obj, 101.0f ); // Immobilize the vehicle and disable engine sounds @@ -1185,9 +1130,8 @@ } } -// ------------------------------------------------------------------------------------------------- -void dp88_Ore_Miner::UndockedFromRefinery ( GameObject *obj ) +void dp88_AR_Miner::UndockedFromRefinery ( GameObject *obj ) { // Un-immobilize the vehicle and enable engine sounds if ( obj->As_VehicleGameObj() ) @@ -1197,52 +1141,16 @@ } // If using the AI then set the AI state and start driving to the ore field - if ( m_bUseAI ) + if ( useAI ) { + aiState = MINER_AISTATE_DRIVE_TO_ORE; DriveToOreField(obj); } - - UpdateAnimation(obj, MINER_ANIM_IDLE); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Miner::UpdateAnimation ( GameObject* pObj, MINER_ANIMID animId ) -{ - if ( animId == m_currentAnimId ) - return; - - pObj->As_PhysicalGameObj()->Clear_Animation(); - - if ( animId < sizeof(m_animations) && m_animations[animId] != NULL ) - { - bool bLooping = (animId == MINER_ANIM_DUMPING) ? true : false; - Commands->Set_Animation(pObj,m_animations[animId],bLooping,0,0,-1,false); - } - - if ( animId < sizeof(m_animSounds) && m_animSounds[animId] != NULL && animId != MINER_ANIM_DUMPING ) - Commands->Create_Sound(m_animSounds[animId],Commands->Get_Position(pObj),pObj); + obj->As_PhysicalGameObj()->Clear_Animation(); + if (strlen(Get_Parameter("idleAnimation")) > 0) + Commands->Set_Animation(obj,Get_Parameter("idleAnimation"),true,0,0,-1,false); } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_Ore_Miner_Registrant( - "dp88_Ore_Miner", - "Use_AI=1:int," - "Ore_Capacity=10:int," - "Ore_Mining_Time=2.0:float," - "Ore_Dump_Time=8.0:float," - "AI_Init_Delay=10:int," - "Dump_Animation:string," - "Dump_Sound:string," - "Mining_Animation:String," - "Mining_Sound:string," - "Idle_Animation:string" -); - - - - @@ -1252,27 +1160,25 @@ void dp88_AR_Chrono_Miner::Created( GameObject *obj ) { - dp88_Ore_Miner::Created(obj); + dp88_AR_Miner::Created(obj); objectId = Commands->Get_ID(obj); driverId = NULL; } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Chrono_Miner::Damaged( GameObject *obj, GameObject *damager, float amount ) { // If AI miner health drops below the emergency chronoshift health threshold and we are driving to // the ore field or collecting ore then begin an emergency chronoshift - if ( m_bUseAI && Commands->Get_Health(obj) < (Commands->Get_Max_Health(obj)*(Get_Float_Parameter("emergencyChronoshiftHealthThreshold")/100.0f)) - && (m_aiState == MINER_AISTATE_COLLECTING_ORE && m_oreMined > 0) ) + if ( useAI && Commands->Get_Health(obj) < (Commands->Get_Max_Health(obj)*(Get_Float_Parameter("emergencyChronoshiftHealthThreshold")/100.0f)) + && (aiState == MINER_AISTATE_COLLECTING_ORE && oreLoadLevel > 0) ) { - // Attempt to start a chronoshift - if it fails don't bother with anything else, driving away - // won't help... + // Attempt to start a chronoshift - if it fails don't bother + // with anything else, driving away won't help... Start_Chronoshift(obj); } } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Chrono_Miner::Custom( GameObject *obj, int type, int param, GameObject *sender ) { @@ -1294,7 +1200,7 @@ // AI miner failed to chronoshift back to the refinery, if we are still more than 150m // from the target then try again - else if ( type == CUSTOM_CHRONO_MINER_RETRY_CHRONOSHIFT && m_aiState == MINER_AISTATE_RETURN_TO_REFINERY ) + else if ( type == CUSTOM_CHRONO_MINER_RETRY_CHRONOSHIFT && aiState == MINER_AISTATE_RETURN_TO_REFINERY ) { GameObject *refinery = Find_Refinery(Commands->Get_Player_Type(obj)); if ( refinery != NULL && Commands->Get_Distance(Commands->Get_Position(refinery),Commands->Get_Position(obj)) > 150.0f ) @@ -1315,10 +1221,9 @@ // Otherwise pass the message on to the base class else - dp88_Ore_Miner::Custom ( obj, type, param, sender ); + dp88_AR_Miner::Custom ( obj, type, param, sender ); } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Chrono_Miner::KeyHook() { @@ -1327,14 +1232,13 @@ if ( !obj ) return; - if ( m_aiState != CMINER_AISTATE_CHRONOSHIFTING ) + if ( aiState != CMINER_AISTATE_CHRONOSHIFTING ) { if ( !Start_Chronoshift(obj) ) Send_Message_Player ( Get_Vehicle_Driver(obj), 153, 204, 25, "Unable to chronoshift, all target zones are unavailable..." ); } } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Chrono_Miner::ReturnToRefinery ( GameObject *obj ) { @@ -1342,7 +1246,7 @@ if ( !Start_Chronoshift(obj) ) { // Can't chronoshift... drive there instead! - dp88_Ore_Miner::ReturnToRefinery(obj); + dp88_AR_Miner::ReturnToRefinery(obj); Send_Message_Team ( Get_Object_Type(obj), 153, 204, 25, "The AI Chronominer was unable to chronoshift, please clear the area around the refinery" ); // Send a delayed custom to retry the chronoshift in 5 seconds @@ -1350,12 +1254,11 @@ } } -// ------------------------------------------------------------------------------------------------- bool dp88_AR_Chrono_Miner::Start_Chronoshift( GameObject *obj ) { // If we are currently chronoshifting then bail out - if ( m_aiState == CMINER_AISTATE_CHRONOSHIFTING ) + if ( aiState == CMINER_AISTATE_CHRONOSHIFTING ) return false; /* Find a zone to chronoshift in to */ @@ -1367,26 +1270,56 @@ if ( Commands->Get_Health(refinery) == 0 ) return false; + SList chronoZones; + Find_All_Objects_With_Script ( "dp88_AR_Chrono_Miner_Chronozone", chronoZones ); + + GameObject* zone = NULL; + dp88_AR_Chrono_Miner_Chronozone *chronozone_script = NULL; + // Define the maximum distance we will shift from the refinery - this prevents us // from going to the enemy refinery const float maxDist = 50.0f; - Vector3 refineryPos = Commands->Get_Position(refinery); - SList chronoZones; - Find_All_Objects_With_Script_By_Distance ( "dp88_AR_Chrono_Miner_Chronozone", chronoZones, refineryPos ); + // Search for the closest zone which we can chronoshift to + Vector3 pos = Commands->Get_Position(refinery); + while ( zone == NULL && !chronoZones.Is_Empty() ) + { + float closestdist = 0.0f; - for ( SLNode* x = chronoZones.Head(); x != NULL; x = x->Next() ) + // Find the closest zone + SLNode *x = chronoZones.Head(); + while (x) { - GameObject* zone = x->Data(); - dp88_AR_Chrono_Miner_Chronozone *chronozone_script = NULL; + GameObject *o = x->Data(); + x = x->Next(); + + float dist = Commands->Get_Distance(Commands->Get_Position(o),pos); + if ( dist > maxDist ) + chronoZones.Remove(o); + + else if (zone == NULL || dist < closestdist) + { + closestdist = dist; + zone = o; + } + } if ( !zone ) - continue; + break; + + // OK, got the closest... can we chronoshift there? - // OK, got a candidate zone, can we chronoshift here? - Vector3 zonePos = Commands->Get_Position(zone); - if ( Commands->Get_Distance(zonePos,refineryPos) > maxDist || !CanChronoshiftToLocation(obj, zonePos) ) - continue; + // Get physical game object and moveable phys class references (used to check if we can move to the zone) + MoveablePhysClass* mphys = ( obj->As_PhysicalGameObj() ) ? obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass() : NULL; + + // Can we move to this position without getting stuck? + if ( !mphys->Can_Teleport( Matrix3D( Commands->Get_Position(zone)) ) ) + { + // Nope, we can't... eliminate this zone from the list of possibilities and + // loop around for another try + chronoZones.Remove(zone); + zone = NULL; + } // Is this zone in use for another chronoshift operation? If so then we cannot use it chronozone_script = (dp88_AR_Chrono_Miner_Chronozone*)Find_Script_On_Object(zone, "dp88_AR_Chrono_Miner_Chronozone"); @@ -1394,16 +1327,26 @@ && Commands->Find_Object(chronozone_script->chronominer_id) && Commands->Get_Health(Commands->Find_Object(chronozone_script->chronominer_id)) > 0) ) { - continue; + // Yes, it's in use... eliminate this zone from the list of possibilities and + // loop around for another try + chronoZones.Remove(zone); + chronozone_script = NULL; + zone = NULL; + } } - // OK, got ourselves a target zone, lock the zone to our ID and set up for chronoshift... + // If we failed to find a suitable target zone bail out + if ( !zone ) + return false; + + // Set the chronominer_id of the script zone to our own ID to prevent other + // miners trying to use it chronozone_script->chronominer_id = Commands->Get_ID(obj); // NB: We use the AI state flag to determine if we are currently in the middle of // a chronoshift for player driven miners too - m_aiState = CMINER_AISTATE_CHRONOSHIFTING; + aiState = CMINER_AISTATE_CHRONOSHIFTING; // Immobilise the vehicle if ( obj->As_VehicleGameObj() ) @@ -1440,12 +1383,10 @@ return true; } - } return false; } -// ------------------------------------------------------------------------------------------------- void dp88_AR_Chrono_Miner::Do_Chronoshift( GameObject *obj, int target_zone_id ) { @@ -1457,90 +1398,42 @@ GameObject *zone = Commands->Find_Object(target_zone_id); if ( zone != NULL ) { - // NB: We use the AI state flag to determine if we are currently in the middle - // of a chronoshift for player driven miners too - m_aiState = MINER_AISTATE_IDLE; - // Get a reference to the chronozone script and check if the chronominer_id // matches ours. If so zero it and continue, otherwise bail out... dp88_AR_Chrono_Miner_Chronozone *chronozone_script = (dp88_AR_Chrono_Miner_Chronozone*)Find_Script_On_Object(zone, "dp88_AR_Chrono_Miner_Chronozone"); if ( !chronozone_script || chronozone_script->chronominer_id != Commands->Get_ID(obj) ) - { - // Have another go at a chronoshift... - ReturnToRefinery(obj); return; - } chronozone_script->chronominer_id = 0; + // NB: We use the AI state flag to determine if we are currently in the middle + // of a chronoshift for player driven miners too + aiState = MINER_AISTATE_IDLE; + // Chronoshift to position of zone (resetting rotation in the process) - Vector3 zonePos = Commands->Get_Position(zone); - if ( CanChronoshiftToLocation(obj, zonePos) ) - Set_Transform(obj, Matrix3D(zonePos) ); - else - { - // Oh noes! Some dipstick has driven into the chronoshift zone... try again - ReturnToRefinery(obj); - return; - } + Set_Transform(obj, Matrix3D(Commands->Get_Position(zone)) ); } /* If using AI start driving to refinery now */ - if ( m_bUseAI ) + if ( useAI ) { - if ( m_oreMined > 0 ) + if ( oreLoadLevel > 0 ) { - dp88_Ore_Miner::ReturnToRefinery(obj); + aiState = MINER_AISTATE_RETURN_TO_REFINERY; + dp88_AR_Miner::ReturnToRefinery(obj); } // No ore collected... guess we must have chronoshifted away from an attack // so lets set off towards the ore field again... what a waste of time! else { - DriveToOreField(obj); - } + aiState = MINER_AISTATE_DRIVE_TO_ORE; + dp88_AR_Miner::DriveToOreField(obj); } } - -// ------------------------------------------------------------------------------------------------- - -bool dp88_AR_Chrono_Miner::CanChronoshiftToLocation ( GameObject* obj, Vector3& location ) -{ - // Get physical game object and moveable phys class references - MoveablePhysClass* mphys = ( obj->As_PhysicalGameObj() ) ? obj->As_PhysicalGameObj()->Peek_Physical_Object()->As_MoveablePhysClass() : NULL; - - // Can we move to this position without getting stuck? - return mphys->Can_Teleport( Matrix3D(location) ); } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_AR_Chrono_Miner_Registrant( - "dp88_AR_Chrono_Miner", - "Use_AI=1:int," - "chronoshift_time=2.5:float," - "chronoshift_out_effect_preset:string," - "chronoshift_out_effect_time:float," - "chronoshift_in_effect_preset:string," - "chronoshift_in_effect_time:float," - "chronoshiftKeyhook=VDeploy:string," - "Ore_Capacity=5:int," - "Ore_Mining_Time=1.00:float," - "Ore_Dump_Time=4.0:float," - "emergencyChronoshiftHealthThreshold=30.0:float," - "AI_Init_Delay=10:int," - "Dump_Animation:string," - "Dump_Sound:string," - "Mining_Animation:String," - "Mining_Sound:string," - "Idle_Animation:string" -); - - - - - @@ -1562,256 +1455,24 @@ chronominer_id = NULL; } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_AR_Chrono_Miner_Chronozone_Registrant( - "dp88_AR_Chrono_Miner_Chronozone", - "" -); - - - - - - - - -/*------------------------ -Ore Field ---------------------------*/ - -void dp88_Ore_Field::Created ( GameObject* pObj ) -{ - m_myObjId = Commands->Get_ID(pObj); - - - m_oreValue = Get_Int_Parameter("Ore_Value"); - m_oreCapacity = Get_Int_Parameter("Ore_Capacity"); - m_nOreUnits = Get_Int_Parameter("Ore_Units"); - - if ( m_nOreUnits > m_oreCapacity ) - m_nOreUnits = m_oreCapacity; - - - m_strAnimation = Get_Parameter("Animation_Name"); - if ( strlen(m_strAnimation) <= 0 ) - m_strAnimation = NULL; - else - { - m_nAnimationFullFrame = Get_Int_Parameter("Animation_Full_Frame"); - m_nAnimationEmptyFrame = Get_Int_Parameter("Animation_Empty_Frame"); - UpdateAnimationFrame(); - } - - - m_zoneSizeFull = Get_Vector3_Parameter("Zone_Size"); - if ( m_strAnimation ) - { - m_zoneStepX = Get_Float_Parameter("Zone_Anim_Step_X"); - m_zoneStepY = Get_Float_Parameter("Zone_Anim_Step_Y"); - } - - - // Create the miner script zone - Matrix3 rotation(true); - rotation.Rotate_Z(Commands->Get_Facing(pObj)); - - // Define the bounding box and create the zone - OBBoxClass zoneBoundingBox ( Commands->Get_Position(pObj), m_zoneSizeFull, rotation ); - if ( GameObject* pMinerZone = Create_Zone("Script_Zone_All",zoneBoundingBox) ) - { - m_minerZoneId = Commands->Get_ID(pMinerZone); - - // Attach observer to the script zone - m_pZoneObserver = new dp88_Ore_Field_Observer(this); - pMinerZone->Add_Observer(m_pZoneObserver); - - return; - } - - - m_pZoneObserver = NULL; - Console_Output ( "[%d:%s:%s] Critical Error: Unable to create the miner script zone. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Field::Detach ( GameObject* pObj ) -{ - ScriptImpClass::Detach(pObj); - - if ( m_pZoneObserver != NULL ) - { - if ( GameObject* pMinerZone = Commands->Find_Object(m_minerZoneId) ) - pMinerZone->Remove_Observer(m_pZoneObserver); - delete m_pZoneObserver; - m_pZoneObserver = NULL; - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Field::Entered ( GameObject* pZoneObj, GameObject* pEnterer ) -{ - if ( pZoneObj == Commands->Find_Object(m_minerZoneId) ) - { - GameObject* pObj = Commands->Find_Object(m_myObjId); - - Commands->Send_Custom_Event( pObj, pEnterer, CUSTOM_MINER_ENTERED_ORE_FIELD, 0, 0 ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Field::Exited ( GameObject* pZoneObj, GameObject* pExiter ) -{ - if ( pZoneObj == Commands->Find_Object(m_minerZoneId) ) - { - GameObject* pObj = Commands->Find_Object(m_myObjId); - - Commands->Send_Custom_Event( pObj, pExiter, CUSTOM_MINER_EXITED_ORE_FIELD, 0, 0 ); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Field::AddOre ( unsigned int nUnits ) -{ - if ( m_oreCapacity != 0 ) - { - m_nOreUnits += min(nUnits,m_oreCapacity-m_nOreUnits); - UpdateAnimationFrame(); - } -} - -// ------------------------------------------------------------------------------------------------- - -unsigned int dp88_Ore_Field::RemoveOre ( unsigned int nUnits ) -{ - if ( m_oreCapacity != 0 ) - { - nUnits = min(nUnits,m_nOreUnits); - m_nOreUnits -= nUnits; - UpdateAnimationFrame(); - } - return nUnits; -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Field::UpdateAnimationFrame() -{ - if ( GameObject* pObj = Commands->Find_Object(m_myObjId) ) - UpdateAnimationFrame(pObj); -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Field::UpdateAnimationFrame( GameObject* pObj ) -{ - if ( m_oreCapacity != 0 && m_strAnimation != NULL ) - { - int frame = m_nAnimationFullFrame - (int)ceil((m_nAnimationFullFrame-m_nAnimationEmptyFrame)*((float)m_nOreUnits/m_oreCapacity)); - Commands->Set_Animation_Frame(pObj, m_strAnimation, frame); - } -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_Ore_Field_Registrant( - "dp88_Ore_Field", - "Ore_Value:int," - "Ore_Capacity:int," - "Ore_Units:int," - "Animation_Name:string," - "Animation_Full_Frame:int," - "Animation_Empty_Frame:int," - "Zone_Size:vector3," - "Zone_Anim_Step_X:float," - "Zone_Anim_Step_Y:float" -); - - - - /*------------------------ -Ore Extractor +Ore Field Zone Controller --------------------------*/ -void dp88_Ore_Extractor::Created ( GameObject* pObj ) -{ - if ( GameObject* pOreField = Find_Closest_Object_With_Script("dp88_Ore_Field", Commands->Get_Position(pObj)) ) +void dp88_AR_Ore_Field_Zone::Entered( GameObject *obj, GameObject *enterer ) { - m_oreFieldId = Commands->Get_ID(pOreField); - - m_nOreUnits = Get_Int_Parameter("Ore_Units"); - m_interval = Get_Int_Parameter("Extraction_Interval"); - m_strAnimation = Get_Parameter("Extraction_Animation"); - if ( strlen(m_strAnimation) <= 0 ) - m_strAnimation = NULL; - - Commands->Start_Timer(pObj, this, (float)m_interval, TIMER_OREMINING_EXTRACTOR ); - return; - } - - - Console_Output ( "[%d:%s:%s] Critical Error: Unable to locate an ore field zone. Destroying script...\n", Commands->Get_ID(pObj), Commands->Get_Preset_Name(pObj), this->Get_Name() ); - Destroy_Script(); + Commands->Send_Custom_Event( obj, enterer, CUSTOM_MINER_ENTERED_ORE_FIELD, Get_Int_Parameter("oreValue"), 0 ); } -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Extractor::Timer_Expired ( GameObject* pObj, int number ) +void dp88_AR_Ore_Field_Zone::Exited ( GameObject *obj, GameObject *exiter ) { - if ( number == TIMER_OREMINING_EXTRACTOR ) - { - if ( m_strAnimation ) - Commands->Set_Animation ( pObj, m_strAnimation, false, NULL, 0, -1, false ); - else - Animation_Complete(pObj, NULL); - } + Commands->Send_Custom_Event( obj, exiter, CUSTOM_MINER_EXITED_ORE_FIELD, 0, 0 ); } -// ------------------------------------------------------------------------------------------------- - -void dp88_Ore_Extractor::Animation_Complete ( GameObject* pObj, const char* animationName ) -{ - if ( (m_strAnimation == NULL && animationName == NULL) || _stricmp(m_strAnimation,animationName) == 0 ) - { - // Populate ore field with additional ore - GameObject* pOreField = Commands->Find_Object(m_oreFieldId); - if ( !pOreField ) - Destroy_Script(); - - dp88_Ore_Field* pOreFieldScript = (dp88_Ore_Field *)(Find_Script_On_Object(pOreField, "dp88_Ore_Field")); - if ( !pOreFieldScript ) - Destroy_Script(); - - pOreFieldScript->AddOre(m_nOreUnits); - - // Set timer for next extraction - Commands->Start_Timer(pObj, this, (float)m_interval, TIMER_OREMINING_EXTRACTOR ); - } -} - -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_Ore_Extractor_Registrant( - "dp88_Ore_Extractor", - "Ore_Units:int," - "Extraction_Interval:int," - "Extraction_Animation:string" -); - - - - - @@ -1819,23 +1480,12 @@ Ore Deposit Zone Controller --------------------------*/ -void dp88_Ore_Dump_Zone::Entered( GameObject *obj, GameObject *enterer ) +void dp88_AR_Ore_Deposit_Zone::Entered( GameObject *obj, GameObject *enterer ) { - if ( Get_Object_Type(enterer) == Get_Int_Parameter( "Team" ) ) - Commands->Send_Custom_Event( obj, enterer, CUSTOM_MINER_ENTERED_DUMP_ZONE, Get_Int_Parameter( "Team" ), 0 ); + if ( Get_Object_Type(enterer) == Get_Int_Parameter( "teamID" ) ) + Commands->Send_Custom_Event( obj, enterer, CUSTOM_MINER_ENTERED_DUMP_ZONE, Get_Int_Parameter( "teamID" ), 0 ); } -// ------------------------------------------------------------------------------------------------- - -ScriptRegistrant dp88_Ore_Dump_Zone_Registrant( - "dp88_Ore_Dump_Zone", - "Team=0:int" -); - - - - - @@ -1862,17 +1512,6 @@ landingZoneCount = 0; } -void dp88_Aircraft_LandingZone_Aircraft::Killed ( GameObject *obj, GameObject* killer ) -{ - // We can't simply kill the pilot because things go horribly wrong... instead use the script - // JFW_Timer_Destroy_Object to kill them as soon as possible. - if ( driverID != 0 && landingZoneCount == 0 && Get_Int_Parameter("require_landing_zone") >= 1 ) - { - if ( GameObject* driver = Commands->Find_Object(driverID) ) - Commands->Attach_Script ( driver, "JFW_Timer_Destroy_Object", "1.0,547859,5000.0,Death" ); - } -} - void dp88_Aircraft_LandingZone_Aircraft::Custom ( GameObject *obj, int type, int param, GameObject *sender ) { if ( type == CUSTOM_TRANSITION_VTOL_LAND_ZONE && param == 1 ) @@ -1912,10 +1551,6 @@ - - - - /*------------------------ Terror Drone Script --------------------------*/ @@ -3445,6 +3080,12 @@ // CLEG resistance script ScriptRegistrant dp88_AR_CLEG_target_Registrant( "dp88_AR_CLEG_target", "resistance=20:int,clegEffectPreset=null:string" ); +// Ore Miners +ScriptRegistrant dp88_AR_Miner_Registrant("dp88_AR_War_Miner","enableAI=1:int,loadLevels=10:int,orePerLoadLevel=100:int,timePerLoadLevel=2.0:float,unloadTime=8.0:float,aiStartDelay=10:int,dockAnimation:string,dockSound:string,miningAnimation:String,miningSound:string,idleAnimation:string"); +ScriptRegistrant dp88_AR_Chrono_Miner_Registrant("dp88_AR_Chrono_Miner","enableAI=1:int,chronoshift_time=2.5:float,chronoshift_out_effect_preset:string,chronoshift_out_effect_time:float,chronoshift_in_effect_preset:string,chronoshift_in_effect_time:float,chronoshiftKeyhook=VDeploy:string,loadLevels=10:int,orePerLoadLevel=50:int,timePerLoadLevel=1.00:float,unloadTime=4.0:float,emergencyChronoshiftHealthThreshold=30.0:float,aiStartDelay=10:int,dockAnimation:string,dockSound:string,miningAnimation:String,miningSound:string,idleAnimation:string"); +ScriptRegistrant dp88_AR_Chrono_Miner_Chronozone_Registrant("dp88_AR_Chrono_Miner_Chronozone",""); +ScriptRegistrant dp88_AR_Ore_Field_Zone_Registrant("dp88_AR_Ore_Field_Zone","oreValue=1:int"); +ScriptRegistrant dp88_AR_Ore_Deposit_Zone_Registrant("dp88_AR_Ore_Deposit_Zone","teamID=0:int"); // Aircraft Landing Zone @@ -3469,7 +3110,7 @@ // 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,Detects_Stealth=1:int"); +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"); // Health link script ScriptRegistrant dp88_linkHealth_Registrant("dp88_linkHealth","parentObjectId=0:int"); diff -uwr source/scripts/dp88_ar.h sourceold/scripts/dp88_ar.h --- source/scripts/dp88_ar.h 2013-02-19 19:54:31.532226500 +0800 +++ sourceold/scripts/dp88_ar.h 2013-01-13 12:06:54.626039100 +0800 @@ -215,11 +215,9 @@ // ------------------------------------------------------------------------------------------------- /*! -* \brief Ore Miner +* \brief AR Miner Script * \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* \todo Update this documentation to remove references to AR specific logic - now a general purpose -* script for use with dp88_Ore_Field and dp88_Ore_Dump_Zone +* \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 @@ -232,7 +230,7 @@ * * Miners can deposit ore at any time as long as they have at least one unit mined, with the total * value of the deposit being based on the number of units collected and the value of each unit. Ore -* deposits are achieved by entering a script zone with the dp88_Ore_Dump_Zone attached to it +* deposits are achieved by entering a script zone with the dp88_AR_Ore_Deposit_Zone attached to it * with the team parameter matching that of the miner. * * When the AI is enabled the miner will use the pathfind grid to locate the nearest ore field and @@ -242,26 +240,29 @@ * you should place pathfind blockers around the problematic areas and re-generate pathfind data to * make it route around those locations. * -* \param Use_AI +* \param enableAI * Specifies that this miner should use its AI to mine autonomously. 1 to enable AI, 0 otherwise -* \param Ore_Capacity -* Maximum number of ore units this miner can store -* \param Ore_Mining_Time +* \param loadLevels +* Specifies the total number of ore units this miner can hold at any time +* \param orePerLoadLevel +* Amount of ore mined in each unit, this is multiplied by the oreValue parameter in the script +* attached to the ore field to calculate the credit value of each ore unit +* \param timePerLoadLevel * The amount of time, in seconds, it takes to mine one ore unit from an ore field -* \param Ore_Dump_Time +* \param unloadtime * The amount of time, in seconds, it takes to unload all ore units at an ore deposit zone -* \param AI_Init_Delay +* \param aiStartDelay * If the miner AI is enabled this specifies the initial delay before starting the first AI action, * which is required to avoid the original Renegade Harvester AI overriding this one. -* \param Dump_Animation +* \param dockAnimation * An optional animation to be played when depositing ore at a refinery -* \param Dump_Sound +* \param dockSound * An optional sound effect to be played when depositing ore at a refinery -* \param Mining_Animation +* \param miningAnimation * An optional animation to be played in a loop whilst mining in an ore field -* \param Mining_Sound +* \param miningSound * An optional sound effect to be played each time the ore load level increases -* \param Idle_Animation +* \param idleAnimation * An optional animation to be played in a loop when the miner is not mining or docked * * \note @@ -272,27 +273,17 @@ * an instance of this base class script. */ -class dp88_Ore_Miner : public JFW_Key_Hook_Base // Inherit from keyhook base for chrono miner +class dp88_AR_Miner : public JFW_Key_Hook_Base // Inherit from keyhook base for chrono miner { protected: - int m_aiState; //!< Current AI state - - int m_oreMined; //!< Current number of mined ore loads onboard - int m_oreValue; //!< Cumulative value of all ore loads onboard - - int m_oreFieldId; //!< ID of the ore field we are currently mining ore from - int m_oreFieldRand; //!< Used to prevent glitching by entering/exiting an ore field rapidly. 0 = not in ore field - - /*! \name Cached Script Parameters */ - /*! @{ */ - bool m_bUseAI; //!< Is AI enabled? - int m_oreCapacity; //!< Maximum number of mined ore units onboard - float m_oreMiningTime; //!< Time required to mine one ore unit - float m_oreDumpTime; //!< Time required to dump ore at a refinery - - const char* m_animations[3]; - const char* m_animSounds[3]; - /*! @} */ + int oreFieldRand; // Used to prevent glitching by entering/exiting an ore field rapidly. 0 = not in ore field + int oreFieldValue; + int oreLoadLevel; + int oreValue; + + bool useAI; // Is AI enabled? + bool animating; // Used to identify if the harvest animation is running so it doesn't start it a second time + int aiState; // Current AI state public: // Default event handlers for the AI miners @@ -302,9 +293,9 @@ virtual void KeyHook() {}; protected: - // These functions implement standard drive to ore field, harvest some ore, return to refinery, - // dock and unload ore functionlity for an AI miner. They can be overloaded to provide custom - // functionality in derived classes. + // These functions implement standard drive to ore field, harvest some ore, + // return to refinery, dock and unload ore functionlity for an AI miner. They + // can be overloaded to provide custom functionality in derived classes. virtual void DriveToOreField ( GameObject *obj ); virtual void EnteredOreField ( GameObject *obj, GameObject* oreField ); virtual void ExitedOreField ( GameObject *obj, GameObject* oreField ); @@ -317,7 +308,6 @@ enum MINER_AISTATES { MINER_AISTATE_IDLE, - MINER_AISTATE_SEARCH_FOR_ORE, MINER_AISTATE_DRIVE_TO_ORE, MINER_AISTATE_COLLECTING_ORE, MINER_AISTATE_RETURN_TO_REFINERY, @@ -331,34 +321,18 @@ MINER_ACTIONID_RETURN_TO_REFINERY, MINER_ACTIONID_DOCK_AT_REFINERY }; - - enum MINER_ANIMID - { - MINER_ANIM_IDLE, - MINER_ANIM_MINING, - MINER_ANIM_DUMPING }; - void UpdateAnimation ( GameObject* pObj, MINER_ANIMID animId ); - MINER_ANIMID m_currentAnimId; -}; -// ------------------------------------------------------------------------------------------------- +/*------------------------ +Chrono Miner +--------------------------*/ -/*! -* \brief AR Chrono Miner -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \arscript -* -* \todo Write Documentation -*/ -class dp88_AR_Chrono_Miner : public dp88_Ore_Miner +class dp88_AR_Chrono_Miner : public dp88_AR_Miner { -protected: - int objectId; //!< ID of the object we are running on, since Keyhook() does not include the GameObject... - int driverId; //!< ID of our current driver, or NULL + int objectId; // ID of the object we are running on, since Keyhook() does not include the GameObject... + int driverId; // ID of our current driver, or NULL -public: void Created ( GameObject *obj ); void Damaged ( GameObject *obj, GameObject *damager, float amount ); void Custom ( GameObject *obj, int type, int param, GameObject *sender ); @@ -370,23 +344,13 @@ void Do_Chronoshift( GameObject *obj, int target_zone_id ); void Complete_Chronoshift( GameObject *obj ); - bool CanChronoshiftToLocation ( GameObject* obj, Vector3& location ); - enum CMINER_AISTATES { CMINER_AISTATE_CHRONOSHIFTING = MINER_AISTATE_UNLOADING_ORE+1 }; }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief AR Chrono Miner Chronoshift Zone -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \arscript -* -* \todo Write Documentation -*/ class dp88_AR_Chrono_Miner_Chronozone : public ScriptImpClass { void Created( GameObject *obj ); @@ -397,207 +361,14 @@ int chronominer_id; }; -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Ore Field -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* Attach this script to an object which represents an ore (or gem) field on the map, or to a Daves -* arrow if you do not want animation support for growing / shrinking the field. A script zone will -* be created at the center of this object (it's local 0,0,0 position) which defines the area miners -* must enter to be considered 'inside' the ore field. This zone can grow and shrink with the ore -* field animation if desired. -* -* Used on it's own this script can either create an ore field with infinite capacity or one which is -* gradually depleted until it is empty. If you want the ore field to re-grow you must add one or -* more objects with the dp88_Ore_Extractor script attached. -* -* To visually show the current size of an ore field you can use an animation on the object this -* script is attached to which will animate from the full frame to an empty frame as the field is -* depleted. If an ore extractor is present it will also animate in reverse as the field is refilled. -* -* \pre -* A preset with the name "Script_Zone_All" must exist to allow the miner zone to be created. This -* preset should have CheckStarsOnly disabled to allow AI miners to use this ore field -* -* \param Ore_Value -* The value of each unit of 'ore' mined from this field. Multiply this by the capacity of a miner -* to get the total credits per dump from a fully loaded miner. -* \param Ore_Capacity -* The maximum capacity of this ore field, in units. Set this to 0 to create an infinite ore field -* which never shrinks or grows. -* \param Ore_Units -* If Ore_Capacity is not 0 this defines the number of units in the ore field when it is created -* \param Animation_Name -* The name of an animation containing the frames to show ore capacity -* \param Animation_Full_Frame -* The frame number for the ore field when it is at maximum capacity -* \param Animation_Empty_Frame -* The frame number for the ore field when it is empty -* \param Zone_Size -* The size of the zone which miners must enter to mine ore from this field. This size is used when -* the field is at maximum capacity. When the zone is empty the zone will despawn. -* \param Zone_Anim_Step_X -* How much to shrink the miner zone in the X axis by for each frame in the animation -* \param Zone_Anim_Step_Y -* How much to shrink the miner zone in the Y axis by for each frame in the animation -*/ -class dp88_Ore_Field : public ScriptImpClass -{ -public: - void Created ( GameObject* pObj ); - void Detach ( GameObject* pObj ); - void Entered ( GameObject* pZoneObj, GameObject* pEnterer ); - void Exited ( GameObject* pZoneObj, GameObject* pExiter ); - - /*! - * Add one or more units of ore to this field, if there is additional capacity available - * - * \param[in] nUnits - * Number of ore units to be added - */ - void AddOre ( unsigned int nUnits ); - - /*! - * Attempt to remove one or more units of ore from this field, if they are available - * - * \param[in] nUnits - * Number of ore units to try and remove - * - * \return Number of units actually removed, which will be <= nUnits - */ - unsigned int RemoveOre ( unsigned int nUnits = 1 ); - - /*! - * Check the number of ore units currently available in this field - * - * \return Number of ore units available in this field, or 0 if this field has infinite capacity - */ - unsigned int NumOreUnits() { return m_nOreUnits; } - - /*! Get the value of the ore in this field */ - unsigned int GetOreValue() { return m_oreValue; } - - /*! Check if this ore field is infinite */ - bool IsInfinite() { return m_oreCapacity == 0; } - - -protected: - void UpdateAnimationFrame(); - void UpdateAnimationFrame( GameObject* pObj ); - - - unsigned int m_myObjId; //!< My own GameObject ID, used by the zone observer callbacks - unsigned int m_nOreUnits; - int m_minerZoneId; - - /*! \name Cached Script Parameters */ - /*! @{ */ - unsigned int m_oreValue; - unsigned int m_oreCapacity; - - const char* m_strAnimation; - unsigned int m_nAnimationFullFrame; - unsigned int m_nAnimationEmptyFrame; - - Vector3 m_zoneSizeFull; - float m_zoneStepX; - float m_zoneStepY; - /*! @} */ - - - /*! Class to observe the script zone - don't need an extra script for this */ - class dp88_Ore_Field_Observer : public GameObjObserverClass - { - public: - dp88_Ore_Field_Observer(dp88_Ore_Field* pParent) - { m_pParent = pParent; } - - protected: - dp88_Ore_Field* m_pParent; - - // These are observer events we actually use - void Entered( GameObject* pObj, GameObject* pEnterer ) { m_pParent->Entered(pObj, pEnterer); } - void Exited( GameObject* pObj, GameObject* pExiter ) { m_pParent->Exited(pObj, pExiter); } - - private: - // These are observer events we don't use but have to provide an implementation for to compile - void Attach ( GameObject* pObj ) {}; - void Detach ( GameObject* pObj ) {}; - void Animation_Complete ( GameObject *pObj, const char *animation_name ) {}; - void Created(GameObject* pObj) {}; - void Destroyed(GameObject* pObj) {}; - void Killed(GameObject* pObj,GameObject* pKiller) {}; - void Damaged(GameObject* pObj,GameObject* pDamager,float amount) {}; - void Custom(GameObject* pObj,int type,int param,GameObject* pSender) {}; - void Sound_Heard(GameObject* pObj,const CombatSound & sound) {}; - void Enemy_Seen(GameObject* pObj,GameObject* pEnemy) {}; - void Action_Complete(GameObject* pObj,int action_id,ActionCompleteReason complete_reason) {}; - void Timer_Expired(GameObject* pObj,int number) {}; - void Poked(GameObject* pObj,GameObject* pPoker) {}; - - - // We also need to provide an implementation for Get_Name to compile - const char* Get_Name() { return "dp88_Ore_Field_Observer"; } - }; - - dp88_Ore_Field_Observer* m_pZoneObserver; -}; - -// ------------------------------------------------------------------------------------------------- - -/*! -* \brief Ore Extractor -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* Attach this script to an object which is inside an ore field created with dp88_Ore_Field to allow -* the object to refill the ore field. -* -* \note -* If you do not make the object this is attached to indestructable players can strategically -* destroy ore extractors close to the enemy base to force their miners to venture further out into -* the map to find ore. You should have at least one indestructable extractor or infinite ore field -* on a map if you want to guarantee credit income for the entire match... -* -* \param Ore_Units -* The number of ore units produced per extraction -* \param Extraction_Interval -* The number of seconds between each ore extraction, not including the time required to play the -* extraction animation if one is used -* \param Extraction_Animation -* An animation to be played when ore extraction is taking place - the ore will be created once the -* animation is completed -*/ -class dp88_Ore_Extractor : public ScriptImpClass -{ -public: - void Created ( GameObject* pObj ); - void Timer_Expired ( GameObject* pObj, int number ); - void Animation_Complete ( GameObject* pObj, const char* animationName ); - -protected: - int m_oreFieldId; - - /*! \name Cached Script Parameters */ - /*! @{ */ - unsigned int m_nOreUnits; - unsigned int m_interval; - const char* m_strAnimation; - /*! @} */ +class dp88_AR_Ore_Field_Zone : public ScriptImpClass { + void Entered( GameObject *obj, GameObject *enterer ); + void Exited ( GameObject *obj, GameObject *exiter ); }; -// ------------------------------------------------------------------------------------------------- -/*! -* \brief Ore Dump Zone -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* -* \todo Write Documentation -*/ -class dp88_Ore_Dump_Zone : public ScriptImpClass -{ -public: +class dp88_AR_Ore_Deposit_Zone : public ScriptImpClass { void Entered( GameObject *obj, GameObject *enterer ); }; @@ -647,10 +418,6 @@ * \param require_landing_zone * Whether to enforce the pilot only exiting inside a landing zone. 1 to enable, 0 to disable * -* \note -* If require_landing_zone is enabled the pilot will be killed if the aircraft is destroyed -* outside of a landing zone -* * \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 @@ -659,7 +426,6 @@ class dp88_Aircraft_LandingZone_Aircraft : public ScriptImpClass { void Created ( GameObject *obj ); - void Killed ( GameObject *obj, GameObject* killed ); void Custom ( GameObject *obj, int type, int param, GameObject *sender ); private: @@ -946,17 +712,15 @@ * 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 +* 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 +* 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 -* \param Detects_Stealth -* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable +* useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable. * * \todo * Decide on a mechanism to ensure each firing sequence fires one bullet per assisting tower, diff -uwr source/scripts/dp88_ar_unitScripts.cpp sourceold/scripts/dp88_ar_unitScripts.cpp --- source/scripts/dp88_ar_unitScripts.cpp 2013-02-19 19:54:31.516601500 +0800 +++ sourceold/scripts/dp88_ar_unitScripts.cpp 2013-01-13 12:06:54.563539100 +0800 @@ -327,7 +327,7 @@ // Setup tank variables Commands->Enable_Stealth ( obj, true ); // Disable targeting box Commands->Set_Is_Rendered ( obj, false ); // Disables rendering - Set_Vehicle_Is_Visible(obj, false); // Prevents AI seeing tank + Commands->Set_Is_Visible ( obj, false ); // Prevents AI seeing tank Commands->Enable_Engine ( obj, false ); // Disable engine sounds hidden = true; @@ -343,7 +343,7 @@ // Setup tank variables Commands->Enable_Engine ( obj, true ); - Set_Vehicle_Is_Visible(obj, true); + Commands->Set_Is_Visible ( obj, true ); Commands->Set_Is_Rendered ( obj, true ); Commands->Enable_Stealth ( obj, false ); @@ -823,8 +823,7 @@ "Modifier_Target_Damage=0.1:float," "Modifier_Target_Value=0.05:float," "Requires_Power=1:int," - "Debug=0:int," - "Detects_Stealth=1:int" + "Debug=0:int" ); diff -uwr source/scripts/dp88_ar_unitScripts.h sourceold/scripts/dp88_ar_unitScripts.h --- source/scripts/dp88_ar_unitScripts.h 2013-02-19 19:54:31.485351500 +0800 +++ sourceold/scripts/dp88_ar_unitScripts.h 2013-01-13 12:06:54.688539100 +0800 @@ -216,17 +216,15 @@ * 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 +* 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 +* 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 -* \param Detects_Stealth -* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable +* 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 diff -uwr source/scripts/dp88_customAI.cpp sourceold/scripts/dp88_customAI.cpp --- source/scripts/dp88_customAI.cpp 2013-02-20 18:24:27.157226500 +0800 +++ sourceold/scripts/dp88_customAI.cpp 2013-01-13 12:06:54.641664100 +0800 @@ -29,36 +29,6 @@ Init(obj); } -// ------------------------------------------------------------------------------------------------- - -void dp88_customAI::Custom ( GameObject* pObj, int message, int param, GameObject* pSender ) -{ - if ( message == CUSTOM_AI_DISABLEAI && m_bAiEnabled ) - { - m_bAiEnabled = false; - AIStateChanged(pObj, false); - } - - else if ( message == CUSTOM_AI_ENABLEAI && !m_bAiEnabled ) - { - m_bAiEnabled = true; - AIStateChanged(pObj, true); - } -} - -// ------------------------------------------------------------------------------------------------- - -void dp88_customAI::AIStateChanged( GameObject* pObj, bool bEnabled ) -{ - if ( bEnabled ) - Commands->Innate_Enable( pObj ); - else - Commands->Innate_Disable( pObj ); - Commands->Enable_Enemy_Seen( pObj, bEnabled ); -} - -// ------------------------------------------------------------------------------------------------- - void dp88_customAI::Action_Complete( GameObject *obj, int action_id, ActionCompleteReason complete_reason ) { if ( action_id == 2 ) @@ -69,12 +39,9 @@ } } -// ------------------------------------------------------------------------------------------------- - void dp88_customAI::Init( GameObject *obj ) { // Set default values - m_bAiEnabled = true; targetID = 0; targetLastSeen = 0; targetPriority = 0.0f; @@ -87,8 +54,6 @@ Commands->Enable_Vehicle_Transitions( obj, false ); } -// ------------------------------------------------------------------------------------------------- - void dp88_customAI::loadSettings ( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ) { // Load base target type priorities @@ -119,8 +84,6 @@ secondary_minRange = ( loadSecondaryFireSettings ) ? Get_Int_Parameter ( "Min_Attack_Range_Secondary" ) : 0; secondary_maxRange = ( loadSecondaryFireSettings ) ? Get_Int_Parameter ( "Max_Attack_Range_Secondary" ) : 0; - // Load other settings - m_bCanDetectStealth = (Get_Int_Parameter("Detects_Stealth")>0); // If debugging is enabled open the debug file debug = ( Get_Int_Parameter("Debug") == 1 ); @@ -132,16 +95,12 @@ } } -// ------------------------------------------------------------------------------------------------- - float dp88_customAI::getDistance ( GameObject *obj1, GameObject *obj2 ) { // Gets distance between two objects return Commands->Get_Distance ( Commands->Get_Position ( obj1 ), Commands->Get_Position ( obj2 ) ); } -// ------------------------------------------------------------------------------------------------- - float dp88_customAI::getPriority( GameObject *obj, GameObject *target ) { if ( !obj || !target ) @@ -163,12 +122,6 @@ return 0.0; } - if ( !m_bCanDetectStealth && target->As_SmartGameObj() && target->As_SmartGameObj()->Is_Stealthed() ) - { - if ( debug ) fprintf ( debugFile, "Target %d is currently stealthed and stealth detection is disabled\n", Commands->Get_ID(target)); - return 0.0; - } - float priority = 0.0; @@ -235,7 +188,6 @@ return priority; } -// ------------------------------------------------------------------------------------------------- float dp88_customAI::getPriority ( GameObject *obj, int target_id ) { @@ -243,7 +195,6 @@ return getPriority ( obj, Commands->Find_Object ( target_id ) ); } -// ------------------------------------------------------------------------------------------------- bool dp88_customAI::getPrimary ( GameObject *target ) { @@ -258,7 +209,6 @@ return true; } -// ------------------------------------------------------------------------------------------------- bool dp88_customAI::IsVehicleEmpty( VehicleGameObj* vobj ) { @@ -269,7 +219,6 @@ return (vobj->Get_Occupant_Count() == 0); } -// ------------------------------------------------------------------------------------------------- bool dp88_customAI::IsVehicleAIEnabled( VehicleGameObj* vobj ) { @@ -280,11 +229,6 @@ - - - - - /*------------------------ Offensive Tank AI --------------------------*/ @@ -516,10 +460,13 @@ "Modifier_Distance=0.25:float," "Modifier_Target_Damage=0.1:float," "Modifier_Target_Value=0.05:float," - "Debug=0:int," - "Detects_Stealth=1:int" + "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"); + @@ -539,8 +486,6 @@ Commands->Start_Timer ( obj, this, 1.0, TIMER_CUSTOMAI_THINK ); } -// ------------------------------------------------------------------------------------------------- - void dp88_AI_Turret::loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ) { dp88_customAI::loadSettings(obj, loadSecondaryFireSettings, loadBuildingTargetSettings); @@ -549,8 +494,6 @@ splashInfantry = (Get_Int_Parameter("Splash_Infantry") > 0 ) ? true: false; } -// ------------------------------------------------------------------------------------------------- - void dp88_AI_Turret::Enemy_Seen ( GameObject *obj, GameObject *enemy ) { // If we saw a soldier in a vehicle, switch the GameObject to that of the vehicle @@ -615,8 +558,6 @@ else if ( debug ) fprintf ( debugFile, "Current target has a higher priority than new enemy, continuing to attack current target\n" ); } -// ------------------------------------------------------------------------------------------------- - void dp88_AI_Turret::Timer_Expired( GameObject *obj, int number ) { // Check target is still alive, still an enemy (eg: stolen vehicles) and in range @@ -650,17 +591,8 @@ } } -// ------------------------------------------------------------------------------------------------- -void dp88_AI_Turret::AIStateChanged( GameObject* pObj, bool bEnabled ) -{ - dp88_customAI::AIStateChanged(pObj, bEnabled); - if ( !bEnabled ) - stopAttacking(pObj); -} - -// ------------------------------------------------------------------------------------------------- // Returns true if the target is on the enemy team, false otherwise bool dp88_AI_Turret::checkTeam ( GameObject* obj, GameObject* target ) @@ -668,7 +600,8 @@ return !( Commands->Get_Player_Type ( target ) == 2 || Commands->Get_Player_Type ( target ) == Commands->Get_Player_Type ( obj ) ); } -// ------------------------------------------------------------------------------------------------- + + // Returns true if the target is between our minimum and maximum range for either primary // or secondary weapons @@ -690,7 +623,6 @@ return true; } -// ------------------------------------------------------------------------------------------------- // Returns true if the base is powered or the defence does not require power bool dp88_AI_Turret::checkPowerState ( GameObject* obj ) @@ -698,7 +630,8 @@ return ( !requiresPower || Is_Base_Powered(Get_Object_Type(obj)) ); } -// ------------------------------------------------------------------------------------------------- + + // These is called when a valid target has been identified and selected as the highest priority // target, the turret should begin attacking in this function. Note that this may be called @@ -717,8 +650,6 @@ Commands->Action_Attack( obj, params ); } -// ------------------------------------------------------------------------------------------------- - // This is called instead of attackTarget when we are set to splash infantry instead of shooting // at them directly. Whilst we are attacking an infantry unit with splash this will be called // regularly on a timer to update the location of the target. Note that this may be called @@ -752,8 +683,6 @@ } } -// ------------------------------------------------------------------------------------------------- - // This is called when the target is no longer valid and the turret should stop attacking, this // is called to stop both attackTarget and splashLocation attacks. void dp88_AI_Turret::stopAttacking ( GameObject* obj ) @@ -767,7 +696,6 @@ - // ------------------------------------------------------------------------------------------------- // Popup Turret AI // ------------------------------------------------------------------------------------------------- @@ -1345,8 +1273,8 @@ // 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,Detects_Stealth=1: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,Detects_Stealth=1: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=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_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,Detects_Stealth=1: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_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-02-21 19:28:09.908203100 +0800 +++ sourceold/scripts/dp88_customAI.h 2013-01-13 11:33:13.581117200 +0800 @@ -25,15 +25,6 @@ * * This class contains the core logic used in custom AI scripts, such as the target prioritisation * mechanism. It is not an actual script in it's own right and cannot be used in LevelEdit directly. -* -* \note -* AI scripts derived from this class support being disabled and enabled on the fly by sending the -* following custom messages to the object the script is attached to.
-* -* -* -* -*
Custom Message Effect
-637140989 Disable the AI
-637140988 Enable the AI
*/ class dp88_customAI : public ScriptImpClass { @@ -73,10 +64,6 @@ float targetPriority; bool primary_target; - // Other settings - bool m_bAiEnabled; - bool m_bCanDetectStealth; - // Debug state bool debug; FILE* debugFile; @@ -89,14 +76,11 @@ ----- */ virtual void Created( GameObject *obj ); - virtual void Custom ( GameObject* pObj, int message, int param, GameObject* pSender ); virtual void Action_Complete( GameObject *obj, int action_id, ActionCompleteReason complete_reason ); //virtual void Enemy_Seen ( GameObject *obj, GameObject *enemy ); //virtual void Timer_Expired( GameObject *obj, int number ); - - /* ---- Functions ----- */ @@ -104,8 +88,6 @@ virtual void Init( GameObject *obj ); virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ); - virtual void AIStateChanged( GameObject* pObj, bool bEnabled ); - float getDistance ( GameObject *obj1, GameObject *obj2 ); virtual float getPriority( GameObject *obj, GameObject *target ); virtual float getPriority( GameObject *obj, int target_id ); @@ -224,23 +206,19 @@ * 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 +* 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 +* 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 -* \param Detects_Stealth -* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable +* 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
-*
-* The turret can be disabled using custom messages, see the note about this in dp88_customAI +* script attached to them. * * \warning * Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones @@ -253,13 +231,10 @@ virtual void Enemy_Seen ( GameObject *obj, GameObject *enemy ); virtual void Timer_Expired( GameObject *obj, int number ); - // Custom AI initialisation script overrides + // Custom AI initialisation script overloads virtual void Init( GameObject *obj ); virtual void loadSettings( GameObject *obj, bool loadSecondaryFireSettings, bool loadBuildingTargetSettings ); - // Custom AI event overrides - virtual void AIStateChanged( GameObject* pObj, bool bEnabled ); - protected: bool requiresPower, splashInfantry; @@ -354,23 +329,19 @@ * 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 +* 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 +* 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 -* \param Detects_Stealth -* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable +* 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
-*
-* The turret can be disabled using custom messages, see the note about this in dp88_customAI +* script attached to them. * * \warning * Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones @@ -521,23 +492,19 @@ * 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 +* 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 +* 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 -* \param Detects_Stealth -* Determine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable +* 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
-*
-* The turret can be disabled using custom messages, see the note about this in dp88_customAI +* script attached to them. * * \warning * Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones diff -uwr source/scripts/dp88_custom_timer_defines.h sourceold/scripts/dp88_custom_timer_defines.h --- source/scripts/dp88_custom_timer_defines.h 2013-02-20 18:24:27.157226500 +0800 +++ sourceold/scripts/dp88_custom_timer_defines.h 2013-01-13 12:06:54.844789100 +0800 @@ -31,10 +31,8 @@ #define BUILDINGSCRIPTS 0x00020000 #define CONQUEST 0x00030000 #define REMOTECONTROL 0x00040000 -#define OREMINING 0x00050000 -#define AI 0x00060000 -//#define AR_MINER 0x00A00000 // Avaiable for re-use +#define AR_MINER 0x00A00000 #define AR_IFV 0x00A10000 // ------------------------------------------------------------------------------------------------- @@ -108,28 +106,16 @@ #define TIMER_REMOTECONTROL_CHARGETICK (DP88_TIMER|REMOTECONTROL|0x04) //!< Timer to count down charge time // ------------------------------------------------------------------------------------------------- -// Ore Fields and Miners script group +// AR Miner group // ------------------------------------------------------------------------------------------------- -#define CUSTOM_MINER_ENTERED_ORE_FIELD (DP88_CUSTOM|OREMINING|0x01) //!< Sent by ore field zone to miners on entry -#define CUSTOM_MINER_EXITED_ORE_FIELD (DP88_CUSTOM|OREMINING|0x02) //!< Sent by ore field zone to miners on exit -#define CUSTOM_MINER_ENTERED_DUMP_ZONE (DP88_CUSTOM|OREMINING|0x03) //!< Sent by ore dump zone to miners on entry -#define CUSTOM_MINER_INCREASE_ORE_LOAD (DP88_CUSTOM|OREMINING|0x04) //!< Sent by miners to themselves on a delay to increase their ore load -#define CUSTOM_MINER_UNLOAD_ORE_COMPLETE (DP88_CUSTOM|OREMINING|0x05) //!< Sent by miners to themselves on a delay to finish unloading ore -#define CUSTOM_MINER_AI_SEARCH_FOR_ORE (DP88_CUSTOM|OREMINING|0x06) //!< Sent by AI miners to search for an ore field -#define CUSTOM_CHRONO_MINER_DO_CHRONOSHIFT (DP88_CUSTOM|OREMINING|0x07) //!< Sent by Chrono Miner to itself to trigger chronoshift -#define CUSTOM_CHRONO_MINER_RETRY_CHRONOSHIFT (DP88_CUSTOM|OREMINING|0x08) //!< Sent by Chrono Miner to itself to retry a failed chronoshift - -#define TIMER_OREMINING_EXTRACTOR (DP88_TIMER|OREMINING|0x01) //!< Timer for the ore extractor - -// ------------------------------------------------------------------------------------------------- -// Custom AI group -// ------------------------------------------------------------------------------------------------- - -#define CUSTOM_TURRETAI_ENEMYSEEN (DP88_CUSTOM|AI|0x01) //!< Sent from dp88_AI_PopupTurret_Spotter to dp88_AI_PopupTurret -#define CUSTOM_TURRETAI_ANIMATIONCOMPLETE (DP88_CUSTOM|AI|0x02) //!< Sent from dp88_AI_ChargeTurret_Animation to dp88_AI_ChargeTurret -#define CUSTOM_AI_DISABLEAI (DP88_CUSTOM|AI|0x03) //!< Custom message that can be sent to a turret AI to disable it -#define CUSTOM_AI_ENABLEAI (DP88_CUSTOM|AI|0x04) //!< Custom message that can be sent to a turret AI to enable it +#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 @@ -174,7 +160,8 @@ #define CUSTOM_PRISMTOWER_STOP_CHARGING 1144060002 // 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 diff -uwr source/scripts/dp88_misc.cpp sourceold/scripts/dp88_misc.cpp --- source/scripts/dp88_misc.cpp 2013-02-19 09:30:47.855468700 +0800 +++ sourceold/scripts/dp88_misc.cpp 2013-01-21 11:44:47.533070300 +0800 @@ -927,7 +927,7 @@ GameObject* shifted_vehicle = Commands->Find_Object(shifted_vehicle_object_id); // Make the shifted vehicle invisible to base defences - Set_Vehicle_Is_Visible(shifted_vehicle,false); + Commands->Set_Is_Visible(shifted_vehicle,false); // Move the shifted vehicle to this location Set_Transform(shifted_vehicle, Get_Transform(obj) ); @@ -1623,6 +1623,7 @@ 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); } diff -uwr source/scripts/dp88_veterancy.cpp sourceold/scripts/dp88_veterancy.cpp --- source/scripts/dp88_veterancy.cpp 2013-02-19 09:30:47.839843700 +0800 +++ sourceold/scripts/dp88_veterancy.cpp 2013-01-21 11:44:47.544789100 +0800 @@ -13,7 +13,7 @@ #include "general.h" #include "dp88_veterancy.h" #include "dp88_custom_timer_defines.h" -#include "VehicleGameObjDef.h" +#include "VehicleGameObjDef.h" // For VEHICLE_TYPE_TURRET #include "ScriptableGameObj.h" /****************************** @@ -161,10 +161,8 @@ give nothing Points given: (pointsValue / total hit points) * damage */ - if ( amount > 0 && Get_Object_Type(damager) != Get_Object_Type(obj) && abs(Get_Object_Type(obj)) < 2 ) - { + if ( amount > 0 && Get_Object_Type(damager) != Get_Object_Type(obj) && Get_Object_Type(obj) < 2 ) grantVeterancyPoints ( damager, (pointsValue/totalHitPoints)*amount ); - } /* Otherwise if damage is < 0 then it is repairs, grant veterancy points if the repairer is on the same team (and we are not an empty vehicle). diff -uwr source/scripts/engine_obj2.h sourceold/scripts/engine_obj2.h --- source/scripts/engine_obj2.h 2013-02-12 09:36:05.831054600 +0800 +++ sourceold/scripts/engine_obj2.h 2012-07-28 09:11:05.887695300 +0800 @@ -45,12 +45,7 @@ bool SCRIPTS_API PointInZone(GameObject *obj,const Vector3 &v); //Is a point in a zone bool SCRIPTS_API Is_Available_For_Purchase(GameObject *factory); //Is it possible to purchase a vehicle from this factory GameObject SCRIPTS_API *Get_Vehicle_Gunner_Pos(GameObject *obj); //Get the vehicle gunner, returns zero if there is no gunner - -/*! -* Set whether a VehicleGameObj is visible to AIs utilising the Enemy_Seen logic. For soldiers use -* the ScriptCommands::Set_Is_Visible function instead. -*/ -void SCRIPTS_API Set_Vehicle_Is_Visible(GameObject *obj,bool visible); +void SCRIPTS_API Set_Vehicle_Is_Visible(GameObject *obj,bool visible); //works like Set_Is_Visible but for vehicles, makes them be ignored by Enemy_Seen void SCRIPTS_API Set_Vehicle_Gunner(GameObject *obj,int seat); //set gunner for this vehicle bool SCRIPTS_API Is_Spy(GameObject *obj); //Is this soldier object a spy SCRIPTS_API int Get_Player_Count_In_Zone(GameObject *obj,int Team); //Get the player count in a zone diff -uwr source/scripts/engine_pt.cpp sourceold/scripts/engine_pt.cpp --- source/scripts/engine_pt.cpp 2013-02-12 09:35:51.448242100 +0800 +++ sourceold/scripts/engine_pt.cpp 2012-07-28 09:11:05.862304600 +0800 @@ -201,21 +201,3 @@ } return icon; } - -void SCRIPTS_API Disable_All_Presets_By_Factory_Tech(BuildingType type,unsigned int team,bool disable) -{ - for (unsigned int i = 0;i < 5;i++) - { - PurchaseSettingsDefClass *p = PurchaseSettingsDefClass::Find_Definition((PurchaseSettingsDefClass::TYPE)i,(PurchaseSettingsDefClass::TEAM)PTTEAM(team)); - if (p) - { - for (unsigned int j = 0;j < 10;j++) - { - if ((p->Get_Factory_Building(j) == type) || (p->Get_Tech_Building(j) == type)) - { - p->Set_Disabled(j,disable); - } - } - } - } -} diff -uwr source/scripts/engine_pt.h sourceold/scripts/engine_pt.h --- source/scripts/engine_pt.h 2013-02-12 09:35:51.370117100 +0800 +++ sourceold/scripts/engine_pt.h 2012-07-28 09:11:06.918945300 +0800 @@ -11,8 +11,7 @@ */ #ifndef SCRIPTS_INCLUDE__ENGINE_PT_H #define SCRIPTS_INCLUDE__ENGINE_PT_H -#include "BuildingGameObjDef.h" -using namespace BuildingConstants; + unsigned int SCRIPTS_API Get_Team_Cost(const char *preset,unsigned int team); //Get the cost of a preset for a given team. Returns zero if the preset is not found in any of the purchase terminal data or if it is one of the free units. unsigned int SCRIPTS_API Get_Cost(const char *preset); //Get the cost of a preset. Returns zero if the preset is not found in any of the purchase terminal data or if it is one of the free units. void SCRIPTS_API Disable_Preset_By_Name(unsigned int Team,const char *Name, bool enable); //Disable a preset by name @@ -20,5 +19,4 @@ void SCRIPTS_API Busy_Preset_By_Name(unsigned int Team,const char *Name, bool enable); //Marks a preset as busy by name const char SCRIPTS_API *Get_Team_Icon(const char *preset,unsigned int team); //Get the icon texture name for a given preset of a given team. Returns NULL if it cant find that preset in the PT data. const char SCRIPTS_API *Get_Icon(const char *preset); //Get the icon texture name for a given preset. Returns NULL if it cant find that preset in the PT data. -void SCRIPTS_API Disable_All_Presets_By_Factory_Tech(BuildingType type,unsigned int team,bool disable); //Iterate all PT data for that team and disable/enable all presets who's factory or tech building matches the specified type. #endif diff -uwr source/scripts/engine_script.cpp sourceold/scripts/engine_script.cpp --- source/scripts/engine_script.cpp 2013-02-19 09:30:47.839843700 +0800 +++ sourceold/scripts/engine_script.cpp 2013-01-13 11:33:13.721742200 +0800 @@ -479,50 +479,6 @@ } } -SCRIPTS_API void Find_All_Objects_With_Script_By_Distance(const char *script, SList& objects, Vector3 position) -{ - objects.Remove_All(); - - // Internal list of distances, in the same order as GameObjects in objects - SList distances; - - for ( SLNode* objNode = GameObjManager::GameObjList.Head(); objNode != NULL; objNode = objNode->Next() ) - { - ScriptableGameObj* obj = (objNode->Data()) ? objNode->Data()->As_ScriptableGameObj() : NULL; - if ( obj && Is_Script_Attached(obj,script) ) - { - // SList cannot contain non-pointer types... stupid thing! - float* distance = new float; - *distance = Commands->Get_Distance(Commands->Get_Position(obj), position); - - SLNode* d = distances.Head(); - for ( SLNode* o = objects.Head(); - d != NULL; - d = d->Next(), o = o->Next() ) - { - if ( *distance < *d->Data() ) - { - objects.insertBefore(obj, *o); - distances.insertBefore(distance, *d); - distance = NULL; - break; - } - } - - // OK, all existing objects are closer than this one so add it to the end of the list - if ( distance != NULL ) - { - objects.Add_Tail(obj); - distances.Add_Tail(distance); - } - } - } - - // Clean up memory since SList insists on having heap objects... - for ( SLNode* d = distances.Head(); d != NULL; d = d->Next() ) - delete d->Data(); -} - SCRIPTS_API void Send_Custom_Event_To_Objects_With_Script( GameObject *sender, const char *script, int message, int param, float delay ) { if (!sender) diff -uwr source/scripts/engine_script.h sourceold/scripts/engine_script.h --- source/scripts/engine_script.h 2013-02-12 09:36:05.815429600 +0800 +++ sourceold/scripts/engine_script.h 2013-01-13 11:33:13.549867200 +0800 @@ -35,24 +35,6 @@ SCRIPTS_API GameObject *Find_Object_With_Script(const char *script); //Find the first object with this script on it SCRIPTS_API GameObject *Find_Closest_Object_With_Script(const char *script, Vector3 pos); //Find the closest object to pos with this script on it SCRIPTS_API void Find_All_Objects_With_Script(const char *script, SList& objects); // Find all objects with this script on it - -/*! -* \brief Find Objects With Script - Distance Sorted -* \author Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup api_objectfind -* -* Finds all GameObjects with one or more instances of the specified script attached and returns them -* in a list which is sorted by the distance from that object to a specified position -* -* \param[in] script -* Name of the script to search for on the object -* \param[out] objects -* Reference to an SList in which the results should be stored -* \param[in] position -* The position to calculate distance from -*/ -SCRIPTS_API void Find_All_Objects_With_Script_By_Distance(const char *script, SList& objects, Vector3 position); - SCRIPTS_API void Send_Custom_Event_To_Objects_With_Script( GameObject *sender, const char *script, int message, int param, float delay ); // Script to send a custom to all objects with a specific script 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 diff -uwr source/scripts/jfwdmg.h sourceold/scripts/jfwdmg.h --- source/scripts/jfwdmg.h 2013-02-12 09:36:05.784179600 +0800 +++ sourceold/scripts/jfwdmg.h 2012-07-28 09:11:05.329101500 +0800 @@ -80,8 +80,6 @@ * * \param Time * Number of seconds to wait before triggering -* \param TimerNum -* Internal ID to use for the timer to avoid clashing with any other timers on the same object * \param Amount * Amount of damage to apply to the object the script is attached to * \param Warhead diff -uwr source/scripts/jfwgame.cpp sourceold/scripts/jfwgame.cpp --- source/scripts/jfwgame.cpp 2013-02-16 11:40:53.371093700 +0800 +++ sourceold/scripts/jfwgame.cpp 2012-07-28 09:11:05.383789000 +0800 @@ -16,8 +16,6 @@ #include "jfwgame.h" #include "TeamPurchaseSettingsDefClass.h" #include "VehicleGameObj.h" -#include "BuildingGameObj.h" -#include "BuildingGameObjDef.h" #include "WeaponClass.h" void JFW_Team_DM_Zone::Exited(GameObject *obj,GameObject *exiter) @@ -3140,7 +3138,7 @@ void JFW_Hijacker_Vehicle::Damaged(GameObject *obj,GameObject *damager,float amount) { - if (damager && !HijackerID) + if (damager) { if (!_stricmp(Get_Current_Weapon(damager),Get_Parameter("Weapon")) && (!Get_Vehicle(damager))) { @@ -3165,95 +3163,6 @@ } } -void JFW_Hijacker_Vehicle_2::Created(GameObject *obj) -{ - HijackerID = 0; - jacking = false; -} - -void JFW_Hijacker_Vehicle_2::Damaged(GameObject *obj,GameObject *damager,float amount) -{ - if (damager && !HijackerID && !jacking) - { - if (!_stricmp(Get_Current_Weapon(damager),Get_Parameter("Weapon")) && (!Get_Vehicle(damager))) - { - Commands->Create_Sound(Get_Parameter("Sound"),Commands->Get_Position(damager),damager); - Force_Occupants_Exit(obj); - Commands->Start_Timer(obj,this,0.5,1); - HijackerID = Commands->Get_ID(damager); - jacking = true; - } - } -} - -void JFW_Hijacker_Vehicle_2::Custom(GameObject *obj,int type,int param,GameObject *sender) -{ - if ((type == CUSTOM_EVENT_VEHICLE_ENTERED) && (sender == Commands->Find_Object(HijackerID))) - { - if (Get_Int_Parameter("Disable_Transitions")) - { - Commands->Enable_Vehicle_Transitions(obj,false); - } - if (Get_Int_Parameter("Single_Hijack")) - { - Remove_Weapon(sender,Get_Parameter("Weapon")); - } - } - if ((type == CUSTOM_EVENT_VEHICLE_EXITED) && (sender == Commands->Find_Object(HijackerID))) - { - HijackerID = 0; - } -} - -void JFW_Hijacker_Vehicle_2::Timer_Expired(GameObject *obj,int number) -{ - jacking = false; - Soldier_Transition_Vehicle(Commands->Find_Object(HijackerID)); -} - -void JFW_Hijacker_Vehicle_2::Killed(GameObject *obj,GameObject *killer) -{ -} - -void JFW_Building_Preset_Disable::Created(GameObject *obj) -{ - count = 0; -} -void JFW_Building_Preset_Disable::Custom(GameObject *obj,int type,int param,GameObject *sender) -{ - if (type == Get_Int_Parameter("Disable_Custom")) - { - if (count == 0) - { - if (obj->As_BuildingGameObj()) - { - BuildingType type = obj->As_BuildingGameObj()->Get_Definition().Get_Type(); - int team = obj->As_BuildingGameObj()->Get_Player_Type(); - Disable_All_Presets_By_Factory_Tech(type,team,true); - } - } - count++; - } - if (type == Get_Int_Parameter("Enable_Custom")) - { - count--; - if (count == 0) - { - if (obj->As_BuildingGameObj()) - { - BuildingType type = obj->As_BuildingGameObj()->Get_Definition().Get_Type(); - int team = obj->As_BuildingGameObj()->Get_Player_Type(); - Disable_All_Presets_By_Factory_Tech(type,team,false); - } - } - } -} - -void JFW_Building_Preset_Disable::Killed(GameObject *obj,GameObject *killer) -{ - Destroy_Script(); -} - ScriptRegistrant JFW_Domination_Controler_End_Game_Registrant("JFW_Domination_Controler_End_Game","NeutralMessage:int,OwnedMessage:int,Time:float,TimerNum:int,PointsToGive:float,PointsToTake:float,GDIObjectID:int,NodObjectID:int,ZoneCount:int"); ScriptRegistrant JFW_Carryable_Vehicle_Registrant("JFW_Carryable_Vehicle","Only_Empty:int,Control_ID:int"); ScriptRegistrant JFW_CarryAll_Registrant("JFW_CarryAll","Bone_Name:string,Cost:int,Control_ID:int"); @@ -3314,5 +3223,3 @@ ScriptRegistrant JFW_Submarine_Registrant("JFW_Submarine","Message:int,Submerge_Armor:string,Surface_Armor:string,Block_Weapon:int,Ping_Sound:string,Surface_Sound:string,Ping_Time:float,Surface_Z_Offset:float,Dive_Z_Offset:float,Powerup:string,Weapon:string"); ScriptRegistrant JFW_Reaper_Web_Registrant("JFW_Reaper_Web","Weapon:string,Time:float,WebModel:string,HumanAnimation:string"); ScriptRegistrant JFW_Hijacker_Vehicle_Registrant("JFW_Hijacker_Vehicle","Weapon:string,Warhead:string,Damage:float,Sound:string"); -ScriptRegistrant JFW_Hijacker_Vehicle_2_Registrant("JFW_Hijacker_Vehicle_2","Weapon:string,Sound:string,Disable_Transitions:int,Single_Hijack:int"); -ScriptRegistrant JFW_Building_Preset_Disable_Registrant("JFW_Building_Preset_Disable","Disable_Custom:int,Enable_Custom:int"); diff -uwr source/scripts/jfwgame.h sourceold/scripts/jfwgame.h --- source/scripts/jfwgame.h 2013-02-16 11:14:41.923828100 +0800 +++ sourceold/scripts/jfwgame.h 2012-07-28 09:11:05.332031200 +0800 @@ -435,20 +435,3 @@ void Killed(GameObject *obj,GameObject *killer); int HijackerID; }; - -class JFW_Hijacker_Vehicle_2 : public ScriptImpClass { - void Created(GameObject *obj); - void Damaged(GameObject *obj,GameObject *damager,float amount); - void Custom(GameObject *obj,int type,int param,GameObject *sender); - void Timer_Expired(GameObject *obj,int number); - void Killed(GameObject *obj,GameObject *killer); - int HijackerID; - bool jacking; -}; - -class JFW_Building_Preset_Disable : public ScriptImpClass { - void Created(GameObject *obj); - void Custom(GameObject *obj,int type,int param,GameObject *sender); - void Killed(GameObject *obj,GameObject *killer); - unsigned int count; -}; diff -uwr source/scripts/jfwmisc.cpp sourceold/scripts/jfwmisc.cpp --- source/scripts/jfwmisc.cpp 2013-02-21 20:32:40.789062500 +0800 +++ sourceold/scripts/jfwmisc.cpp 2012-07-28 09:11:06.352539000 +0800 @@ -1376,7 +1376,7 @@ void JFW_EMP::Damaged(GameObject *obj,GameObject *damager,float amount) { - if (Warhead == Get_Damage_Warhead()) + //if (Warhead == Get_Damage_Warhead()) { VehicleGameObj *o = obj->As_VehicleGameObj(); if (o && o->Get_Is_Scripts_Visible() && !o->Is_Immovable()) @@ -1490,7 +1490,9 @@ } else if (type == CUSTOM_EVENT_VEHICLE_OWNER) { - Commands->Start_Timer(obj,this,5,Commands->Get_ID(sender)); + Commands->Set_Position(obj,Commands->Get_Position(sender)); + Soldier_Transition_Vehicle(sender); + driverid = Commands->Get_ID(sender); } } @@ -1499,20 +1501,6 @@ Commands->Attach_Script(Commands->Find_Object(driverid),"RA_DriverDeath", "0"); } -void JFW_Cyborg_Reaper::Timer_Expired(GameObject *obj,int number) -{ - if (Commands->Find_Object(number)) - { - Commands->Set_Position(Commands->Find_Object(number),Commands->Get_Position(obj)); - Soldier_Transition_Vehicle(Commands->Find_Object(number)); - driverid = Commands->Get_ID(Commands->Find_Object(number)); - } - else - { - Commands->Destroy_Object(obj); - } -} - void JFW_Limpet_Drone::Created(GameObject *obj) { stealth = false; @@ -1620,7 +1608,7 @@ } float timer = Commands->Get_Random(min,max); Commands->Start_Timer(obj,this,timer,2); - Commands->Send_Custom_Event(obj,obj,Get_Int_Parameter("On_Weather_Custom"),0,0); + Commands->Set_Lightning(Get_Float_Parameter("Lightning_Intensity"),Get_Float_Parameter("Lightning_Start_Distance"),Get_Float_Parameter("Lightning_End_Distance"),Get_Float_Parameter("Lightning_Heading"),Get_Float_Parameter("Lightning_Distribution"),0); if (Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER)) { Commands->Send_Custom_Event(obj,Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Disable_Custom"),0,0); @@ -1649,7 +1637,7 @@ else if (number == 2) //storm ended { storm = false; - Commands->Send_Custom_Event(obj,obj,Get_Int_Parameter("Off_Weather_Custom"),0,0); + Commands->Set_Lightning(Get_Float_Parameter("Lightning_Off_Intensity"),Get_Float_Parameter("Lightning_Off_Start_Distance"),Get_Float_Parameter("Lightning_Off_End_Distance"),Get_Float_Parameter("Lightning_Off_Heading"),Get_Float_Parameter("Lightning_Off_Distribution"),0); if (Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER)) { Commands->Send_Custom_Event(obj,Find_Building_By_Type(0,BuildingConstants::TYPE_COM_CENTER),Get_Int_Parameter("Enable_Custom"),0,0); @@ -1700,17 +1688,6 @@ } } -void JFW_Ion_Storm_Weather::Custom(GameObject *obj,int type,int param,GameObject *sender) -{ - if (type == Get_Int_Parameter("Message")) - { - Commands->Set_Lightning(Get_Float_Parameter("Lightning_Intensity"),Get_Float_Parameter("Lightning_Start_Distance"),Get_Float_Parameter("Lightning_End_Distance"),Get_Float_Parameter("Lightning_Heading"),Get_Float_Parameter("Lightning_Distribution"),0); - Commands->Set_Clouds(Get_Float_Parameter("Cloud_Cover"),Get_Float_Parameter("Cloud_Gloominess"),0); - Commands->Set_Screen_Fade_Color(Get_Float_Parameter("Screen_Red"),Get_Float_Parameter("Screen_Green"),Get_Float_Parameter("Screen_Blue"),0); - Commands->Set_Screen_Fade_Opacity(Get_Float_Parameter("Screen_Opacity"),0); - } -} - void JFW_Tech_Level_Custom::Custom(GameObject *obj,int type,int param,GameObject *sender) { if (type == Get_Int_Parameter("Message")) @@ -1960,8 +1937,7 @@ ScriptRegistrant JFW_Forward_Custom_Object_Registrant("JFW_Forward_Custom_Object","Object_ID:int"); ScriptRegistrant JFW_Death_Send_Custom_Self_Registrant("JFW_Death_Send_Custom_Self","Message:int"); ScriptRegistrant JFW_Hunter_Seeker_Registrant("JFW_Hunter_Seeker","Key:string,Explosion:string"); -ScriptRegistrant JFW_Ion_Storm_Registrant("JFW_Ion_Storm","Min_Delay:float,Max_Delay:float,Min_Time:float,Max_Time:float,Disable_Custom:int,Enable_Custom:int,Announcement_Sound_Nod:string,Announcement_Sound_GDI:string,Announcement_String:string,Red:int,Green:int,Blue:int,Ion_Effect_Sound:string,Ion_Effect_Time:float,End_Announcement_Sound_Nod:string,End_Announcement_Sound_GDI:string,End_Announcement_String:string,On_Weather_Custom:int,Off_Weather_Custom:int"); -ScriptRegistrant JFW_Ion_Storm_Weather_Registrant("JFW_Ion_Storm_Weather","Lightning_Intensity:float,Lightning_Start_Distance:float,Lightning_End_Distance:float,Lightning_Heading:float,Lightning_Distribution:float,Cloud_Cover:float,Cloud_Gloominess:float,Screen_Red:float,Screen_Green:float,Screen_Blue:float,Screen_Opacity:float,Message:int"); +ScriptRegistrant JFW_Ion_Storm_Registrant("JFW_Ion_Storm","Min_Delay:float,Max_Delay:float,Min_Time:float,Max_Time:float,Disable_Custom:int,Enable_Custom:int,Announcement_Sound_Nod:string,Announcement_Sound_GDI:string,Announcement_String:string,Red:int,Green:int,Blue:int,Ion_Effect_Sound:string,Ion_Effect_Time:float,Lightning_Intensity:float,Lightning_Start_Distance:float,Lightning_End_Distance:float,Lightning_Heading:float,Lightning_Distribution:float,Lightning_Off_Intensity:float,Lightning_Off_Start_Distance:float,Lightning_Off_End_Distance:float,Lightning_Off_Heading:float,Lightning_Off_Distribution:float,End_Announcement_Sound_Nod:string,End_Announcement_Sound_GDI:string,End_Announcement_String:string"); ScriptRegistrant JFW_Change_Character_Created_Registrant("JFW_Change_Character_Created","Character:string"); ScriptRegistrant JFW_Change_Model_Created_Registrant("JFW_Change_Model_Created","Model1:string,Model2:string,Model3:string,Model4:string,Model5:string"); ScriptRegistrant JFW_Spawn_Object_Created_Registrant("JFW_Spawn_Object_Created","Object:string"); diff -uwr source/scripts/jfwmisc.h sourceold/scripts/jfwmisc.h --- source/scripts/jfwmisc.h 2013-02-21 20:26:02.560546800 +0800 +++ sourceold/scripts/jfwmisc.h 2013-01-11 22:37:51.769531200 +0800 @@ -520,7 +520,6 @@ void Created(GameObject *obj); void Custom(GameObject *obj,int type,int param,GameObject *sender); void Killed(GameObject *obj,GameObject *killer); - void Timer_Expired(GameObject *obj,int number); }; class JFW_Limpet_Drone : public ScriptImpClass { @@ -551,10 +550,6 @@ void Timer_Expired(GameObject *obj,int number); }; -class JFW_Ion_Storm_Weather : public ScriptImpClass { - void Custom(GameObject *obj,int type,int param,GameObject *sender); -}; - class JFW_Tech_Level_Custom : public ScriptImpClass { void Custom(GameObject *obj,int type,int param,GameObject *sender); }; diff -uwr source/scripts/jfwveh.cpp sourceold/scripts/jfwveh.cpp --- source/scripts/jfwveh.cpp 2013-02-21 19:28:09.923828100 +0800 +++ sourceold/scripts/jfwveh.cpp 2012-07-28 09:11:05.615234300 +0800 @@ -93,54 +93,6 @@ Commands->Create_Explosion(Get_Parameter("Explosion_Preset"),tmb,0); } -void JFW_Turret_Spawn_3::Created(GameObject *obj) -{ - Vector3 sp; - GameObject *object; - sp.X = 0; - sp.Y = 0; - sp.Z = 0; - object = Commands->Create_Object(Get_Parameter("Turret_Preset"),sp); - Commands->Attach_To_Object_Bone(object,obj,Get_Parameter("Bone_Name")); - turID = Commands->Get_ID(object); - Commands->Send_Custom_Event(obj,Commands->Find_Object(turID),Get_Int_Parameter("Driver_Exited_Custom"),0,0); - Attach_Script_Once_V(object,"dp88_linkHealth","%d",Commands->Get_ID(obj)); - m_bHasDriver = false; -} - -void JFW_Turret_Spawn_3::Custom(GameObject *obj,int type,int param,GameObject *sender) -{ - if (type == CUSTOM_EVENT_VEHICLE_ENTERED) - { - if ( !m_bHasDriver ) - { - m_bHasDriver = true; - Commands->Set_Player_Type(Commands->Find_Object(turID),Commands->Get_Player_Type(sender)); - Commands->Send_Custom_Event(obj,Commands->Find_Object(turID),Get_Int_Parameter("Driver_Entered_Custom"),0,0); - } - } - if (type == CUSTOM_EVENT_VEHICLE_EXITED) - { - if ( m_bHasDriver && obj->As_VehicleGameObj() && obj->As_VehicleGameObj()->Get_Occupant(0) == NULL ) - { - m_bHasDriver = false; - Commands->Send_Custom_Event(obj,Commands->Find_Object(turID),Get_Int_Parameter("Driver_Exited_Custom"),0,0); - } - } -} - -void JFW_Turret_Spawn_3::Register_Auto_Save_Variables() -{ - Auto_Save_Variable(&turID,4,1); -} - -void JFW_Turret_Spawn_3::Killed(GameObject *obj,GameObject *killer) -{ - Vector3 tmb; - tmb = Commands->Get_Bone_Position(obj,Get_Parameter("Explosion_Bone")); - Commands->Create_Explosion(Get_Parameter("Explosion_Preset"),tmb,0); -} - void JFW_Drive_To_Player::Created(GameObject *obj) { ActionParamsStruct params; @@ -1089,7 +1041,6 @@ ScriptRegistrant JFW_Vechicle_Animation_Trigger_Registrant("JFW_Vechicle_Animation_Trigger","Animation:string,Subobject:string,FirstFrame:float,LastFrame:float,Blended:int,Time:float,TimerNum:int,UpAnimation:string,UpSubobject:string,UpFirstFrame:float,UpLastFrame:float,UpBlended:int,DownAnimation:string,DownSubobject:string,DownFirstFrame:float,DownLastFrame:float,DownBlended:int,UpTrigger:int,DownTrigger:int"); ScriptRegistrant JFW_Vechicle_Animation_2_Registrant("JFW_Vechicle_Animation_2","Animation:string,Subobject:string,FirstFrame:float,LastFrame:float,Blended:int,Time:float,TimerNum:int,UpAnimation:string,UpSubobject:string,UpFirstFrame:float,UpLastFrame:float,UpBlended:int,DownAnimation:string,DownSubobject:string,DownFirstFrame:float,DownLastFrame:float,DownBlended:int"); ScriptRegistrant JFW_Turret_Spawn_2_Registrant("JFW_Turret_Spawn_2","Turret_Preset:string,Bone_Name=Tur_Mount:string,Explosion_Preset:string,Explosion_Bone:string"); -ScriptRegistrant JFW_Turret_Spawn_3_Registrant("JFW_Turret_Spawn_3","Turret_Preset:string,Bone_Name=Tur_Mount:string,Explosion_Preset:string,Explosion_Bone:string,Driver_Entered_Custom:int,Driver_Exited_Custom:int"); ScriptRegistrant JFW_Drive_To_Player_Registrant("JFW_Drive_To_Player","Speed:float,Arrive_Distance:float"); ScriptRegistrant JFW_Vechicle_Animation_Registrant("JFW_Vechicle_Animation","Animation:string,Subobject:string,FirstFrame:float,LastFrame:float,Blended:int,Time:float,TimerNum:int"); ScriptRegistrant JFW_Visible_Person_In_Vechicle_Registrant("JFW_Visible_Person_In_Vechicle","BoneName:string,ModelName:string,Animation:string,SubObject:string,FirstFrame:float,LastFrame:float,Blended:int"); diff -uwr source/scripts/jfwveh.h sourceold/scripts/jfwveh.h --- source/scripts/jfwveh.h 2013-02-21 19:28:09.939453100 +0800 +++ sourceold/scripts/jfwveh.h 2012-07-28 09:11:06.392578100 +0800 @@ -26,43 +26,6 @@ public: void Register_Auto_Save_Variables(); }; - -/*! -* \brief Vehicle Turret Spawner Variant (Enter/Exit Customs & Health Link) -* \author jonwil, Daniel Paul (danpaul88@yahoo.co.uk) -* \ingroup custom_generator -* -* This is a variant of the basic JFW_Turret_Spawn_2 script with the added ability to send custom -* messages to the turret object when a driver enters or exits the vehicle. Additionally it links -* the health of the turrets with that of the vehicle body so any damage taken is applied to both. -* -* \param Turret_Preset -* Name of the preset to be spawned -* \param Bone_Name -* Name of the bone on the object to attach the spawned preset to -* \param Explosion_Preset -* Name of an explosion preset to create when the object is destroyed, this is used to destroy -* the spawned turret -* \param Explosion_Bone -* Name of the bone on the object to create the explosion at -* \param Driver_Entered_Custom -* ID of the custom message to be sent when a driver enters the vehicle -* \param Driver_Exited_Custom -* ID of the custom message to be sent when the driver leaves the vehicle -* -* \note -* The Driver_Exited_Custom custom will be sent to the spawned turret as soon as it is created -*/ -class JFW_Turret_Spawn_3 : public ScriptImpClass -{ - int turID; - bool m_bHasDriver; - void Created(GameObject *obj); - void Custom(GameObject *obj,int type,int param,GameObject *sender); - void Killed(GameObject *obj,GameObject *killer); - public: void Register_Auto_Save_Variables(); -}; - class JFW_Drive_To_Player : public ScriptImpClass { void Created(GameObject *obj); }; diff -uwr source/scripts/jfwweap.cpp sourceold/scripts/jfwweap.cpp --- source/scripts/jfwweap.cpp 2013-02-13 17:17:24.747070300 +0800 +++ sourceold/scripts/jfwweap.cpp 2013-01-13 12:06:54.797914100 +0800 @@ -1430,7 +1430,6 @@ { LastSwitch = 0; Weapon2 = true; - InTimer = false; InstallHook(Get_Parameter("Keyhook"),obj); } @@ -1443,10 +1442,6 @@ Send_Message_Player(Owner(),153,204,25,str); return; } - if (InTimer) - { - return; - } LastSwitch = time(NULL); if (Weapon2) { @@ -1456,7 +1451,6 @@ { Remove_Weapon(Owner(),Get_Powerup_Weapon(Get_Parameter("WeaponPowerup2"))); } - InTimer = true; Commands->Start_Timer(Owner(),this,Get_Float_Parameter("SwitchTime"),1); } @@ -1473,7 +1467,6 @@ Commands->Select_Weapon(obj,Get_Powerup_Weapon(Get_Parameter("WeaponPowerup1"))); } Weapon2 = !Weapon2; - InTimer = false; } ScriptRegistrant JFW_Nod_Turret_Registrant("JFW_Nod_Turret",""); diff -uwr source/scripts/jfwweap.h sourceold/scripts/jfwweap.h --- source/scripts/jfwweap.h 2013-02-13 17:17:24.637695300 +0800 +++ sourceold/scripts/jfwweap.h 2013-01-11 22:37:51.988281200 +0800 @@ -276,7 +276,6 @@ class JFW_Char_Weapon_Switcher : public JFW_Key_Hook_Base { time_t LastSwitch; bool Weapon2; - bool InTimer; void Created( GameObject *obj ); void KeyHook(); void Timer_Expired( GameObject *obj,int number ); diff -uwr source/scripts/scripts.h sourceold/scripts/scripts.h --- source/scripts/scripts.h 2013-02-12 09:36:05.784179600 +0800 +++ sourceold/scripts/scripts.h 2012-07-28 09:11:06.085937500 +0800 @@ -727,11 +727,6 @@ void (* Unlock_Soldier_Facing)( GameObject * object ); void (* Apply_Damage)( GameObject * object, float amount, const char * warhead_name, GameObject * damager); void (* Set_Loiters_Allowed)( GameObject * object, bool allowed ); - - /*! - * Set whether a SoldierGameObj is visible to AIs utilising the Enemy_Seen logic. For vehicles use - * the Set_Vehicle_Is_Visible function instead. - */ void (* Set_Is_Visible)( GameObject * object, bool visible ); void (* Set_Is_Rendered)( GameObject * object, bool rendered ); float (* Get_Points)( GameObject * object ); diff -uwr source/scripts/z_misc.cpp sourceold/scripts/z_misc.cpp --- source/scripts/z_misc.cpp 2013-02-23 18:39:30.091796800 +0800 +++ sourceold/scripts/z_misc.cpp 2013-01-11 22:37:52.769531200 +0800 @@ -804,202 +804,7 @@ } } -void z_Capturable_Helipad::Created(GameObject *obj) -{ - owner = Get_Int_Parameter("Owner"); - if (owner > -2) - { - Set_Damage_Points(obj,0.300f); - playdmg = true; - playkilled = true; - } - else - { - Set_Damage_Points(obj,0.0f); - Commands->Set_Health(obj,2.0f); - playdmg = false; - playkilled = false; - } - Commands->Set_Player_Type(obj,owner); -} -void z_Capturable_Helipad::Damaged(GameObject *obj, GameObject *damager, float damage) -{ - if (damage >= Commands->Get_Health(obj)) - { - Commands->Set_Health(obj,1.0f);//prevent destruction - Commands->Set_Player_Type(obj,-2);//unteamed - if (playkilled) - { - if (owner == 0)//nod helipad killed - { - Create_2D_WAV_Sound_Team("m00bnhp_kill0001i1evan_snd.wav",0); - Create_2D_WAV_Sound_Team("m00bnhp_kill0002i1evag_snd.wav",1); - Send_Message(255,255,255,"Nod Helicopter Pad destroyed"); - } - else if (owner == 1)//gdi helipad killed - { - Create_2D_WAV_Sound_Team("m00bghp_kill0002i1evan_snd.wav",0); - Create_2D_WAV_Sound_Team("m00bghp_kill0001i1evag_snd.wav",1); - Send_Message(255,255,255,"GDI Helicopter Pad destroyed"); - } - Set_Damage_Points(obj,0.0f); - Commands->Give_Points(damager,150.0f,false); - } - owner = -2; - playdmg = false; - playkilled = false; - } - - if (owner == -2)//neutral silo - { - if (damage < 0.0) //its repaired - { - if (Commands->Get_Health(obj) == Commands->Get_Max_Health(obj))//fully repaired - { - owner = Commands->Get_Player_Type(damager);//whoever repaired it owns it now - Commands->Set_Player_Type(obj,owner); - if (owner == 0) - { - Create_2D_WAV_Sound_Team("m00bnhp_dsgn0002i1evan_snd.wav",0); - Send_Message_Team(0,255,0,0,"Nod Helicopter Pad repaired"); - } - else if (owner == 1) - { - Create_2D_WAV_Sound_Team("m00bghp_dsgn0001i1evag_snd.wav",1); - Send_Message_Team(1,255,204,0,"GDI Helicopter Pad repaired"); - } - playdmg = true; - playkilled = true; - Set_Damage_Points(obj,0.300f); - } - } - } - else if (owner == 0)//nod helipad - { - if (damage > 0.5f) - { - if (playdmg) - { - Create_2D_WAV_Sound_Team("m00bnhp_tdfe0001i1evan_snd.wav",0); - Send_Message_Team(0,255,255,255,"Warning Nod Helicopter Pad under attack"); - Create_2D_WAV_Sound_Team("m00bnhp_tdfe0002i1evag_snd.wav",1); - Send_Message_Team(1,255,255,255,"Nod Helicopter Pad under attack"); - playdmg = false; Commands->Start_Timer(obj,this,25.0f,155); - } - } - } - else if (owner == 1)//gdi helipad - { - if (damage > 0.5f) - { - if (playdmg) - { - Create_2D_WAV_Sound_Team("m00bghp_tdfe0002i1evan_snd.wav",0); - Send_Message_Team(0,255,255,255,"GDI Helicopter Pad under attack"); - Create_2D_WAV_Sound_Team("m00bghp_tdfe0001i1evag_snd.wav",1); - Send_Message_Team(1,255,255,255,"Warning GDI Helicopter Pad under attack"); - playdmg = false; Commands->Start_Timer(obj,this,25.0f,155); - } - } - } -} -void z_Capturable_Helipad::Timer_Expired(GameObject *obj, int number) -{ - if (number == 155) - { - playdmg = true; - } -} - -void z_Capturable_Helipad_Terminal::Created(GameObject *obj) -{ - Commands->Enable_HUD_Pokable_Indicator(obj,true); - HelipadID = Get_Int_Parameter("HelipadID"); - Cost = Get_Float_Parameter("Cost"); - Preset = Get_Parameter("Preset"); - LocationID = Get_Int_Parameter("LocationID"); - Team = Commands->Get_Player_Type(Commands->Find_Object(HelipadID)); - Allowpoke = true; - Commands->Set_Player_Type(obj,Team); - Commands->Start_Timer(obj,this,10.0f,102031);//set the team of the console to that of the associated helipad -} -void z_Capturable_Helipad_Terminal::Poked(GameObject *obj, GameObject *poker) -{ - if (Allowpoke) - { - Commands->Enable_HUD_Pokable_Indicator(obj,false); - Team = Commands->Get_Player_Type(Commands->Find_Object(HelipadID));//request the helipad team again and check it against poker - Allowpoke = false; Commands->Start_Timer(obj,this,15.0f,102030);//No poking for 15s to prevent them getting stuck in each other - if (Get_Player_Type(poker) == Team) - { - if (!Is_Base_Powered(Team)) Cost = Cost+Cost; - if (Commands->Get_Money(poker) >= Cost) - { - Vector3 Loc = Commands->Get_Position(Commands->Find_Object(LocationID)); - GameObject *heli = Commands->Create_Object(Preset,Loc); - Commands->Set_Facing(heli,Commands->Get_Facing(Commands->Find_Object(LocationID))); - Commands->Set_Player_Type(heli,Team); - if (Is_Base_Powered(Team)) - { - Commands->Give_Money(poker,-Cost,false); - } - else if (!Is_Base_Powered(Team)) - { - Commands->Give_Money(poker,-Cost,false); - Commands->Give_Money(poker,-Cost,false); - } - - if (Team == 0) - { - char buymsg[512]; - sprintf(buymsg,"%s purchased a %s",Get_Player_Name(poker),Get_Translated_Preset_Name(heli)); - Send_Message_Team(0,0,192,192,buymsg); - - } - else if (Team == 1) - { - char buymsg[512]; - sprintf(buymsg,"%s purchased a %s",Get_Player_Name(poker),Get_Translated_Preset_Name(heli)); - Send_Message_Team(1,0,192,192,buymsg); - } - } - else - { - if (Team == 0) - { - Create_2D_WAV_Sound_Player(poker,"m00evan_dsgn0024i1evan_snd.wav"); - } - else if (Team == 1) - { - Create_2D_WAV_Sound_Player(poker,"m00evag_dsgn0028i1evag_snd.wav"); - } - if (Is_Base_Powered(Team)) Send_Message_Player(poker,255,255,255,"Insufficient Funds"); - else if (!Is_Base_Powered(Team)) Send_Message_Player(poker,255,255,255,"Insufficient Funds: Power is Down = Double Cost"); - } - } - else - { - Send_Message_Player(poker,255,255,255,"Go awai n00b!"); - } - } -} -void z_Capturable_Helipad_Terminal::Timer_Expired(GameObject *obj, int number) -{ - if (number == 102030) - { - Allowpoke = true; - Commands->Enable_HUD_Pokable_Indicator(obj,true); - } - else if (number == 102031) - { - Team = Commands->Get_Player_Type(Commands->Find_Object(HelipadID)); - Commands->Set_Player_Type(obj,Team); - Commands->Start_Timer(obj,this,10.0f,102031);//re-set the team of the console to that of the associated helipad - } -} -ScriptRegistrant z_Capturable_Helipad_Terminal_Registrant("z_Capturable_Helipad_Terminal","HelipadID=0:int,Preset=bla:string,Cost=10000:float,LocationID=0:int"); -ScriptRegistrant z_Capturable_Helipad_Registrant("z_Capturable_Helipad","Owner=0:int"); 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"); diff -uwr source/scripts/z_misc.h sourceold/scripts/z_misc.h --- source/scripts/z_misc.h 2013-02-21 19:28:09.923828100 +0800 +++ sourceold/scripts/z_misc.h 2013-01-11 22:37:51.628906200 +0800 @@ -134,23 +134,3 @@ void Custom(GameObject *obj, int message, int param, GameObject *sender); }; -class z_Capturable_Helipad : public ScriptImpClass { - void Created(GameObject *obj); - void Damaged(GameObject *obj, GameObject *damager, float damage); - void Timer_Expired(GameObject *obj, int number); - int owner; - bool playdmg; - bool playkilled; -}; - -class z_Capturable_Helipad_Terminal : public ScriptImpClass { - void Created(GameObject *obj); - void Poked(GameObject *obj, GameObject *poker); - void Timer_Expired(GameObject *obj, int number); - int HelipadID; - int Team; - int LocationID; - bool Allowpoke; - float Cost; - const char *Preset; -};