diff -uwrN source/scripts/BuildingGameObj.h sourceold/scripts/BuildingGameObj.h --- source/scripts/BuildingGameObj.h 2015-11-15 22:30:35.335062500 +1000 +++ sourceold/scripts/BuildingGameObj.h 2015-10-11 13:18:52.119336000 +1000 @@ -105,8 +105,7 @@ static bool Get_Can_Repair_Buildings(void) {return CanRepairBuildings;} #endif #endif - SCRIPTS_API void Find_Closest_Poly (const Vector3 &pos, float *distance2); - float Find_Closest_Poly(const Vector3 &pos) { float distance2; Find_Closest_Poly(pos,&distance2); return distance2; } + void Find_Closest_Poly (const Vector3 &pos, float *distance2); int Building_In_Range(const Vector3 &point, float range); //return 0 for no, 1 for yes and 2 for MCT in range bool Is_In_Range_Coarse(const Vector3& point, float range_sq); bool Cast_Ray(RayCollisionTestClass& raytest); diff -uwrN source/scripts/JMGRenetBuster.h sourceold/scripts/JMGRenetBuster.h --- source/scripts/JMGRenetBuster.h 2015-11-15 22:30:35.550882800 +1000 +++ sourceold/scripts/JMGRenetBuster.h 2015-10-12 09:58:40.301882800 +1000 @@ -1456,13 +1456,14 @@ { if (!ObjectsList || !object) return *this; - AnObject *Current = ObjectsList; + AnObject *Current = ObjectsList,*Prev = NULL; while (Current) { if (Current->Object == object) { Current->AllowReplaceTime = 1; } + Prev = Current; Current = Current->next; } return *this; @@ -1495,6 +1496,8 @@ }; bool DoesCollide(AnObject *Obj,AnObject *OtherObj) { + __try + { if (!Obj || !OtherObj || Obj->AllowReplaceTime || OtherObj->AllowReplaceTime) return false; GameObject *Hitter = Obj->Object; @@ -1614,6 +1617,11 @@ } return true; } + } + __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + { + Console_Input("msg DoesCollide ERROR: Crash caught successfully!"); + } return false; } bool PickupPowerup(AnObject *Obj,AnObject *OtherObj) @@ -1631,23 +1639,18 @@ } void UpdateCollisions() { +CollisionCheckStart: AnObject *Current = ObjectsList; +UpdateCollisions: while (Current) { if (Current->AllowReplaceTime) { if (Current->AllowReplaceTime < 30 && Current->AllowReplaceTime != -1) Current->AllowReplaceTime++; - } Current = Current->next; + goto UpdateCollisions; } -CollisionCheckStart: - Current = ObjectsList; -UpdateCollisions: - while (Current) - { - if (!Current->AllowReplaceTime) - { if (Current->Type == CargoShip || Current->Type == TheMoon || Current->Type == NormalPlayerShip || Current->Type == PlayerShield || Current->Type == PlayerCloak || Current->Type == PlayerSuper || Current->Type == PlayerShipJumpable || Current->Type == PlayerShipDisrupter) { AnObject *OtherObjs = ObjectsList; @@ -1698,7 +1701,6 @@ OtherObjs = OtherObjs->next; } } - } Current = Current->next; } } @@ -1807,7 +1809,13 @@ { Temp = Current; if (!Current->AllowReplaceTime) + __try + { Commands->Apply_Damage(Current->Object,99999.99f,"BlamoKiller",0); + } + __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION || GetExceptionCode() == STATUS_PRIVILEGED_INSTRUCTION || GetExceptionCode() == STATUS_ILLEGAL_INSTRUCTION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + { + } Current = Current->next; delete Temp; } @@ -2120,7 +2128,6 @@ void Destroyed(GameObject *obj); void Create_Player_Ship(GameObject *obj,int PlayerNumber); void DisableGun(GameObject *obj); - void FadeMusic(const char *music); public: static int MoonHolderID; }; diff -uwrN source/scripts/JMGRenetBusters.cpp sourceold/scripts/JMGRenetBusters.cpp --- source/scripts/JMGRenetBusters.cpp 2015-11-15 22:30:35.557718700 +1000 +++ sourceold/scripts/JMGRenetBusters.cpp 2015-10-12 09:05:30.831179700 +1000 @@ -804,12 +804,6 @@ { if (!Commands->Find_Object(MiniGamePlayerControlSystem[param].GamePlayerID)) { - switch (CurrentMusic) - { - case MusicGameOver:Set_Background_Music_Player(sender,"Thunder.mp3");break; - case MusicNormal:Set_Background_Music_Player(sender,"Android.mp3");break; - case MusicBoss:Set_Background_Music_Player(sender,"Escape.mp3");break; - } MiniGamePlayerControlSystem[param].GamePlayerID = Commands->Get_ID(sender); MiniGamePlayerControlSystem[param].PlayerID = Get_Player_ID(sender); MiniGamePlayerControlSystem[param].isReady = false; @@ -824,7 +818,6 @@ FakeSoldier = Commands->Create_Object("CnC_Nod_MinigunnerN",SoldierPosition); Commands->Innate_Disable(FakeSoldier); Commands->Set_Model(FakeSoldier,Get_Model(sender)); - Commands->Set_Model(sender,"invisibleChar"); Commands->Set_Facing(FakeSoldier,Commands->Get_Facing(sender)); Commands->Set_Health(FakeSoldier,Commands->Get_Health(sender)); Commands->Set_Shield_Strength(FakeSoldier,Commands->Get_Shield_Strength(sender)); @@ -1012,13 +1005,13 @@ if (CurrentMusic != MusicNormal) { CurrentMusic = MusicNormal; - FadeMusic("Android.mp3"); + Commands->Fade_Background_Music("Android.mp3",2000,2000); } } else if (CurrentMusic != MusicBoss) { CurrentMusic = MusicBoss; - FadeMusic("Escape.mp3"); + Commands->Fade_Background_Music("Escape.mp3",2000,2000); } NextLevelDelay = 40; } @@ -1173,7 +1166,7 @@ Set_HUD_Help_Text_Player_Text(Player,7233,"Game Over!",Vector3(0.19599999f,1.0f,0.19599999f)); } CurrentMusic = MusicGameOver; - FadeMusic("Thunder.mp3"); + Commands->Fade_Background_Music("Thunder.mp3",2000,2000); NextLevelDelay = -1; } } @@ -1228,7 +1221,6 @@ if (!Current->AllowReplaceTime && Current->Type != TheMoon && Current->Type != CargoShip) if (JmgUtility::SimpleDistance(Pos,Commands->Get_Position(Current->Object)) > 28000.00) { - Current->AllowReplaceTime = 1; Commands->Apply_Damage(Current->Object,9999.9f,"BlamoKiller",obj); goto OutOfBoundsObjectsCheck; } @@ -1431,18 +1423,6 @@ Commands->Select_Weapon(obj,""); Commands->Select_Weapon(obj,Weapon); } -void JMG_CMTB_Main_Game_Control::FadeMusic(const char *music) -{ - for (int x = 0;x < MaxGamePlayerCount;x++) - { - if (MiniGamePlayerControlSystem[x].GamePlayerID) - { - GameObject *player = Commands->Find_Object(MiniGamePlayerControlSystem[x].GamePlayerID); - if (player) - Fade_Background_Music_Player(player,music,2000,2000); - } - } -} void JMG_CMTB_UFO_Random_Fire_Control::Created(GameObject *obj) { if (Get_Int_Parameter("UFOBoss")) @@ -2891,11 +2871,9 @@ MiniGamePlayerControlSystem[MachineNumber].FakeSoldierID = 0; if (!FakeSoldier) return; - Commands->Set_Model(sender,Get_Model(FakeSoldier)); Commands->Set_Shield_Strength(sender,Commands->Get_Shield_Strength(FakeSoldier)); Commands->Set_Health(sender,Commands->Get_Health(FakeSoldier)); Commands->Destroy_Object(FakeSoldier); - Fade_Background_Music_Player(sender,"null.mp3",2000,2000); } if (message == CUSTOM_EVENT_VEHICLE_ENTERED) { @@ -3028,8 +3006,6 @@ GameObject *Player = Commands->Find_Object(Get_Int_Parameter("MySoldierID")); if (!Player) return; - Fade_Background_Music_Player(Player,"null.mp3",2000,2000); - Commands->Set_Model(Player,Get_Model(obj)); MiniGamePlayerControlSystem[Get_Int_Parameter("Number")].FakeSoldierID = 0; MiniGamePlayerControlSystem[Get_Int_Parameter("Number")].PlayerID = 0; MiniGamePlayerControlSystem[Get_Int_Parameter("Number")].GamePlayerID = 0; diff -uwrN source/scripts/dllmain.cpp sourceold/scripts/dllmain.cpp --- source/scripts/dllmain.cpp 2015-11-15 22:30:36.068460900 +1000 +++ sourceold/scripts/dllmain.cpp 2015-10-11 13:18:52.791211000 +1000 @@ -356,7 +356,6 @@ Unlock_Soldier_Collision_Group = (ulscg)Address(tt,"Unlock_Soldier_Collision_Group"); Stop_Timer = (ss)Address(tt,"Stop_Timer"); Create_2D_Wave_Sound_Dialog_Player = (cwsdp)Address(tt,"Create_2D_Wave_Sound_Dialog_Player"); - Force_Position_Update_Player = (fpup)Address(tt,"Force_Position_Update_Player"); #ifdef SSGM SSGMGameManager::Init(); #endif diff -uwrN source/scripts/engine_tt.cpp sourceold/scripts/engine_tt.cpp --- source/scripts/engine_tt.cpp 2015-11-15 22:30:36.251078100 +1000 +++ sourceold/scripts/engine_tt.cpp 2015-10-11 13:18:52.978711000 +1000 @@ -206,7 +206,6 @@ SCRIPTS_API ulscg Unlock_Soldier_Collision_Group; SCRIPTS_API ss Stop_Timer; SCRIPTS_API cwsdp Create_2D_Wave_Sound_Dialog_Player; -SCRIPTS_API fpup Force_Position_Update_Player; SCRIPTS_API bool Can_Team_Build_Vehicle(int Team) { @@ -1053,11 +1052,6 @@ RENEGADE_FUNCTION void BuildingGameObj::Collect_Building_Components() AT2(0x006843E0,0x00683C80); - -RENEGADE_FUNCTION -void BuildingGameObj::Find_Closest_Poly(const Vector3 &pos, float *distance2) -AT2(0x00685630,0x00684ED0); - RENEGADE_FUNCTION void BaseControllerClass::Enable_Radar(bool Enable) AT3(0x006EFD00,0x006EF2C0,0x00558ED0); diff -uwrN source/scripts/engine_tt.h sourceold/scripts/engine_tt.h --- source/scripts/engine_tt.h 2015-11-15 22:30:36.255960900 +1000 +++ sourceold/scripts/engine_tt.h 2015-10-11 13:18:52.978711000 +1000 @@ -161,7 +161,6 @@ typedef void (*lscg) (GameObject *obj,Collision_Group_Type collisionGroupType); typedef void (*ulscg) (GameObject *obj); typedef int (*cwsdp) (GameObject *obj,const char *soundname); -typedef void (*fpup) (GameObject *player,GameObject *obj); SCRIPTS_API extern gpl Get_Player_List; SCRIPTS_API extern gcmi Get_Current_Map_Index; SCRIPTS_API extern gm Get_Map; @@ -326,7 +325,6 @@ SCRIPTS_API extern ulscg Unlock_Soldier_Collision_Group; SCRIPTS_API extern ss Stop_Timer; SCRIPTS_API extern cwsdp Create_2D_Wave_Sound_Dialog_Player; -SCRIPTS_API extern fpup Force_Position_Update_Player; class SCRIPTS_API JFW_Key_Hook_Base : public ScriptImpClass { public: diff -uwrN source/scripts/jmgBearHunter.cpp sourceold/scripts/jmgBearHunter.cpp --- source/scripts/jmgBearHunter.cpp 2015-11-15 22:30:36.475687500 +1000 +++ sourceold/scripts/jmgBearHunter.cpp 2015-10-11 13:18:53.150586000 +1000 @@ -776,7 +776,7 @@ sprintf(currentSong,"SpecForce_Sneak_02.mp3"); Commands->Fade_Background_Music("SpecForce_Sneak_02.mp3",10000,10000); objective = 12694; - JmgUtility::SetHUDHelpText(objective,Vector3(0,1,0)); + Set_HUD_Help_Text_Player(player,objective,Vector3(0,1,0)); Commands->Set_Objective_HUD_Info_Position(2,1,"PogBear.tga",12700,Vector3(15.593f,-93.453f,-0.166f)); Commands->Start_Timer(obj,this,0.1f,16); return; @@ -789,7 +789,7 @@ if (gameTime) { gameTime--; - if (JMG_Bear_Hunter_Power_Transformer::online && JMG_Bear_Hunter_Game_Control::turretsDestroyed < 4 && gameTime > 60) + if (JMG_Bear_Hunter_Power_Transformer::online) attackSubstationChance = (gameTime/300.0f)*JmgUtility::MathClamp(Get_Player_Count()*Get_Player_Count()/100.00f,0.01f,1.0f); else attackSubstationChance = 0.0f; @@ -1297,7 +1297,7 @@ for (int x = 1;x < 128;x++) if (PlayerData.players[x] && PlayerData.players[x]->deaths) PlayerData.players[x]->deaths--; - Commands->Start_Timer(obj,this,60.0,7); + Commands->Start_Timer(obj,this,30.0,7); } if (number == 9) { @@ -3026,7 +3026,7 @@ if (message == CUSTOM_EVENT_VEHICLE_EXITED && !Get_Vehicle_Driver(obj) && (JMG_Bear_Hunter_Game_Control::gameTime > 775 || JMG_Bear_Hunter_Game_Control::truckTimeExtended) && !JMG_Bear_Hunter_Game_Control::hasGotTurrets) { NewObjectiveSystemControl.Set_Radar_Blip(10,obj); - JmgUtility::DisplayChatMessage(sender,127,127,255,"Bear Rug Co: Get back in that truck, it must make it back to base!"); + JmgUtility::MessageAllPlayers(127,127,255,"Bear Rug Co: Get back in that truck, it must make it back to base!"); } if (message == CUSTOM_EVENT_VEHICLE_ENTERED && (JMG_Bear_Hunter_Game_Control::gameTime > 775 || JMG_Bear_Hunter_Game_Control::truckTimeExtended) && !JMG_Bear_Hunter_Game_Control::hasGotTurrets) { @@ -3036,7 +3036,7 @@ NewObjectiveSystemControl.Set_Objective_Status(14,NewObjectiveSystem::Failed); } else - JmgUtility::DisplayChatMessage(sender,127,127,255,"Bear Rug Co: Now all you have to do is return the truck to base."); + JmgUtility::MessageAllPlayers(127,127,255,"Bear Rug Co: Now all you have to do is return the truck to base."); if (firstTime) { firstTime = false; @@ -3150,7 +3150,6 @@ Commands->Set_Animation(jump,"rabbitJump.rabbitJump",false,0,0.0f,90.0f,false); Commands->Attach_To_Object_Bone(obj,jump,"Bunny"); jumperId = Commands->Get_ID(jump); - obj->As_SoldierGameObj()->Set_Scale_Across_Network(2.0f); Commands->Start_Timer(obj,this,3.0f,1); } void JMG_Bear_Hunt_Final_Boss::Enemy_Seen(GameObject *obj,GameObject *seen) @@ -3255,19 +3254,17 @@ if (target && JmgUtility::SimpleDistance(Commands->Get_Position(target),bossPos) < 4.0f) { int playerId = JmgUtility::JMG_Get_Player_ID(target); - if (Commands->Get_Health(target) && !PlayerData.players[playerId]->displayedKillMessage) + if (Commands->Is_A_Star(target) && Commands->Get_Health(target) && !PlayerData.players[playerId]->displayedKillMessage) { char deathMsg[220]; - if (Commands->Is_A_Star(target)) sprintf(deathMsg,"%s was eaten alive by the giant Mutant Rabbit!",Get_Player_Name(target)); - else - sprintf(deathMsg,"A %s was eaten alive by the giant Mutant Rabbit!",Get_Translated_Preset_Name(target)); JmgUtility::MessageAllPlayers(255,255,0,deathMsg); PlayerData.players[playerId]->displayedKillMessage = true; Commands->Apply_Damage(target,9999.9f,"BlamoKiller",obj); Commands->Apply_Damage(obj,-100.0f,"None",target); moveSpeed = JmgUtility::MathClamp(moveSpeed+0.05f,0.5f,1.0f); rabbitSize = JmgUtility::MathClamp(rabbitSize+0.1f,1.0f,2.0f); + obj->As_SoldierGameObj()->Set_Scale_Across_Network(rabbitSize); BearHunterScoreSystem::BHScoreNode *node = bearHunterScoreSystem.Get_Current_Player_Score_Node(JmgUtility::JMG_Get_Player_ID(target)); if (node) node->EatenByRabbit++; @@ -4622,10 +4619,7 @@ Vector3 pos = Commands->Get_Position(obj); GameObject *lastRep = Commands->Find_Object(lastRepairTargetId); if (!lastRep || Get_Hitpoints(lastRep) >= Get_Max_Hitpoints(lastRep) || !Commands->Get_Health(lastRep)) - { lastRep = NULL; - lastRepairTargetId = 0; - } float nearestObject = lastRep ? JmgUtility::SimpleDistance(pos,Commands->Get_Position(lastRep)) : 0.0f; GameObject *repairTarget = lastRep; for (SLNode *current = GameObjManager::SmartGameObjList.Head();current;current = current->Next()) @@ -5505,7 +5499,6 @@ Set_Screen_Fade_Opacity_Player(enterer,0.9f,0.0f); JMG_Bear_Hunter_Game_Control::diedInWater[JmgUtility::JMG_Get_Player_ID(enterer)] = true; } - if (Commands->Is_A_Star(enterer) || !obj->As_SoldierGameObj()) Commands->Apply_Damage(enterer,9999.9f,"Death",0); } void JMG_Bear_Hunter_Guardian_Aircraft::Created(GameObject *obj) @@ -7301,19 +7294,6 @@ return false; } *position = node->position; - return true; -} -bool JMG_Utility_AI_Guardian_Aircraft::Get_A_Defense_Point(Vector3 *position) -{ - Rp2SimplePositionSystem::SimplePositionNode *node = NULL; - if (Get_Int_Parameter("WanderingAIGroupID") != -1) - node = JMG_Wandering_AI_Controller::wanderPoints.GetRandomFromGroup(Get_Int_Parameter("WanderingAIGroupID")); - if (!node) - { - Console_Input("msg JMG_Utility_AI_Guardian_Aircraft ERROR: No wander points could be found for that group!"); - return false; - } - *position = node->position; return true; } ScriptRegistrant JMG_Bear_Hunter_Player_Soldier_Registrant("JMG_Bear_Hunter_Player_Soldier",""); diff -uwrN source/scripts/jmgMetroid.cpp sourceold/scripts/jmgMetroid.cpp --- source/scripts/jmgMetroid.cpp 2015-11-15 22:30:36.490335900 +1000 +++ sourceold/scripts/jmgMetroid.cpp 2015-10-11 13:18:53.166211000 +1000 @@ -1723,15 +1723,15 @@ } float Random = Commands->Get_Random(0.0f,1.0f); const char *PowerupName; - if (Random < 0.2)//.3 + if (Random < 0.45)//.3 PowerupName = "POW_Imperialist"; - else if (Random < 0.4)//.55 + else if (Random < 0.75)//.55 PowerupName = "POW_Machinegun"; //else if (Random < 0.75) // PowerupName = "POW_Lazershotgun"; - else if (Random < 0.6) + else if (Random < 0.9) PowerupName = "POW_Shock_coil"; - else if (Random < 0.8) + else if (Random < 0.975) PowerupName = "POW_Flame_Upgrade"; else PowerupName = "POW_Supergrenade"; @@ -3595,12 +3595,6 @@ { if (number == 2) { - if (enemyID) - { - GameObject *enemy = Commands->Find_Object(enemyID); - if (!enemy || !Commands->Get_Health(enemy)) - enemyID = 0; - } if (resetTime) { resetTime -= 0.1f; @@ -5100,112 +5094,6 @@ } } } -void JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom::Created(GameObject *obj) -{ - reloadComplete = true; - Commands->Disable_All_Collisions(obj); - Commands->Start_Timer(obj,this,1.0f,1); -} -void JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom::Custom(GameObject *obj,int message,int param,GameObject *sender) -{ - if (Get_Int_Parameter("TargetCustom") == message && reloadComplete) - { - GameObject *seen = Commands->Find_Object(param); - if (!seen) - seen = sender; - if (Get_Vehicle_Driver(seen)) - seen = Get_Vehicle_Driver(seen); - Vector3 myPos = Commands->Get_Position(obj),enemyPos = Commands->Get_Position(seen); - float targetDist = JmgUtility::SimpleDistance(myPos,enemyPos),targetFlatDistance = JmgUtility::SimpleFlatDistance(myPos,enemyPos),minDistanceSquared = Get_Float_Parameter("MinDistance")*Get_Float_Parameter("MinDistance"); - if (targetDist < minDistanceSquared) - return; - bool useHighAngle = true; - if (targetDist <= Get_Float_Parameter("UseLowAngleMaxDistance")*Get_Float_Parameter("UseLowAngleMaxDistance")) - useHighAngle = false; - else if (Get_Int_Parameter("UseLowAngleWhenAboveMinDistance") && targetFlatDistance <= minDistanceSquared) - useHighAngle = false; - else if (Get_Float_Parameter("UseLowAngleTargetAboveHeight") && Commands->Get_Position(obj).Z+Get_Float_Parameter("UseLowAngleTargetAboveHeight") < Commands->Get_Position(seen).Z) - useHighAngle = false; - double height = enemyPos.Z-myPos.Z,angle; - myPos.Z = enemyPos.Z = 0.0f; - if (!CalculateAngle(&angle,Commands->Get_Distance(enemyPos,myPos),height,useHighAngle)) - return; - double zRotation = atan2(enemyPos.Y-myPos.Y,enemyPos.X-myPos.X); - FireProjectile(obj,zRotation,angle); - reloadComplete = false; - Commands->Start_Timer(obj,this,Get_Float_Parameter("ReloadTime"),1); - } -} -void JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1) - reloadComplete = true; -} -bool JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom::CalculateAngle(double *returnAngle,double distance,double height,bool highAngle) -{ - double velocitySquared = Get_Float_Parameter("FireVelocity")*Get_Float_Parameter("FireVelocity"); - double calculatedGravity = Get_Float_Parameter("GravityScale")*9.8; - if (distance <= 0.0) - return false; - double x = velocitySquared*velocitySquared-calculatedGravity*(calculatedGravity*(distance*distance)+2*height*velocitySquared); - if (x < 0) - return false; - *returnAngle = atan((velocitySquared+(highAngle ? 1 : -1)*sqrt(x))/(calculatedGravity*distance)); - if (*returnAngle*180.0/PI < Get_Float_Parameter("MinAngle") || *returnAngle*180.0/PI > Get_Float_Parameter("MaxAngle")) - return false; - return true; -} -void JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom::FireProjectile(GameObject *obj,double zAngle,double aimAngle) -{ - Commands->Create_3D_Sound_At_Bone(Get_Parameter("FireSound"),obj,"MuzzleA0"); - GameObject *projectile = Commands->Create_Object(Get_Parameter("VehicleProjectilePreset"),Commands->Get_Bone_Position(obj,"muzzleA0")); - char params[220]; - sprintf(params,"%d,%s",Commands->Get_ID(obj),Get_Parameter("ProjectileExplosion")); - Commands->Attach_Script(projectile,"JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_Attach",params); - Commands->Attach_Script(projectile,"JMG_Utility_Sync_Object_Periodically","0.1"); - Vector3 normalizedVector = Vector3((float)cos(zAngle),(float)sin(zAngle),(float)tan(aimAngle)); - normalizedVector.Normalize(); - normalizedVector.X *= Get_Float_Parameter("FireVelocity"); - normalizedVector.Y *= Get_Float_Parameter("FireVelocity"); - normalizedVector.Z *= Get_Float_Parameter("FireVelocity"); - Set_Velocity(projectile,normalizedVector); -} -void JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_Attach::Created(GameObject *obj) -{ - Commands->Start_Timer(obj,this,0.025f,1); -} -void JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_Attach::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1) - { - Force_Position_Update(obj); - Commands->Start_Timer(obj,this,0.025f,1); - } -} -void JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_Attach::Destroyed(GameObject *obj) -{ - GameObject *launcher = Commands->Find_Object(Get_Int_Parameter("LauncherId")); - if (launcher) - Commands->Create_Explosion(Get_Parameter("ExplosionPreset"),Commands->Get_Position(obj),launcher); - else - Commands->Create_Explosion(Get_Parameter("ExplosionPreset"),Commands->Get_Position(obj),obj); -} -void JMG_Metroid_Miniboss_Turret::Created(GameObject *obj) -{ - Commands->Enable_Spawner(603561,true); - Commands->Enable_Spawner(603567,true); -} -void JMG_Metroid_Miniboss_Turret::Destroyed(GameObject *obj) -{ - Commands->Enable_Spawner(603561,false); - Commands->Enable_Spawner(603567,false); - for (SLNode *current = GameObjManager::SmartGameObjList.Head();current;current = current->Next()) - { - SmartGameObj* o = current->Data(); - if (o && Commands->Get_Preset_ID(o) == 82080178) - Commands->Apply_Damage(o,1000.0f,"None",o); - } -} ScriptRegistrant JMG_Metroid_Hide_On_Enter_Registrant("JMG_Metroid_Hide_On_Enter",""); ScriptRegistrant JMG_Metroid_Gibs_On_Enter_Registrant("JMG_Metroid_Gibs_On_Enter","DeathMessage=falling into a spiky pit:string,PerkID=0:int"); ScriptRegistrant JMG_Metroid_Increase_Perk_Unlock_On_Enter_Registrant("JMG_Metroid_Increase_Perk_Unlock_On_Enter","PerkID:int"); @@ -5321,9 +5209,6 @@ ScriptRegistrant JMG_AI_Artillery_Targeting_Fire_At_Custom_Registrant("JMG_AI_Artillery_Targeting_Fire_At_Custom","TargetCustom:int,MinDistance=0.0:float,MaxDistance=999999.0:float,MinAngle=-90.0:float,MaxAngle=90.0:float,UseLowAngleMaxDistance=0.0:float,UseLowAngleWhenAboveMinDistance=1:int,UseLowAngleTargetAboveHeight=9999.9:float"); ScriptRegistrant JMG_Metroid_AI_Forest_Mini_Boss_Registrant("JMG_Metroid_AI_Forest_Mini_Boss",""); ScriptRegistrant JMG_Metroid_SpawnRoom_Objective_Update_On_Enter_Registrant("JMG_Metroid_SpawnRoom_Objective_Update_On_Enter","NewObjectiveID:int,NewObjectiveStringID:int,ObjectiveMarkerObjectID:int,CompleteObjectiveID:int,Delay:float,NewObjectivePriority=1:int"); -ScriptRegistrant JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom_Registrant("JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom","TargetCustom:int,MinDistance=0.0:float,MaxDistance=999999.0:float,MinAngle=-90.0:float,MaxAngle=90.0:float,UseLowAngleMaxDistance=0.0:float,UseLowAngleWhenAboveMinDistance=1:int,UseLowAngleTargetAboveHeight=9999.9:float,VehicleProjectilePreset:string,FireVelocity=1.0:float,GravityScale=1.0:float,FireSound=null:string,ProjectileExplosion=null:string,ReloadTime=1.0:float"); -ScriptRegistrant JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_Attach_Registrant("JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_Attach","LauncherId:int,ExplosionPreset:string"); -ScriptRegistrant JMG_Metroid_Miniboss_Turret_Registrant("JMG_Metroid_Miniboss_Turret",""); diff -uwrN source/scripts/jmgMetroid.h sourceold/scripts/jmgMetroid.h --- source/scripts/jmgMetroid.h 2015-11-15 22:30:36.496195300 +1000 +++ sourceold/scripts/jmgMetroid.h 2015-10-11 13:18:53.166211000 +1000 @@ -4488,24 +4488,3 @@ triggered = false; } }; - -class JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_At_Custom : public ScriptImpClass { - bool reloadComplete; - void Created(GameObject *obj); - void Custom(GameObject *obj,int message,int param,GameObject *sender); - void Timer_Expired(GameObject *obj,int number); - bool CalculateAngle(double *returnAngle,double distance,double height,bool highAngle); - void FireProjectile(GameObject *obj,double zAngle,double aimAngle); -}; - - -class JMG_AI_Artillery_Targeting_Fire_Vehicle_Projectile_Attach : public ScriptImpClass { - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); - void Destroyed(GameObject *obj); -}; - -class JMG_Metroid_Miniboss_Turret : public ScriptImpClass { - void Created(GameObject *obj); - void Destroyed(GameObject *obj); -}; \ No newline at end of file diff -uwrN source/scripts/jmgUtility.cpp sourceold/scripts/jmgUtility.cpp --- source/scripts/jmgUtility.cpp 2015-11-15 22:30:36.502054600 +1000 +++ sourceold/scripts/jmgUtility.cpp 2015-10-11 13:18:53.181836000 +1000 @@ -6,9 +6,6 @@ #include "VehicleGameObj.h" #include "WeaponClass.h" #include "VehicleGameObjDef.h" -#include "OffenseObjectClass.h" -#include "SoldierGameObj.h" -#include "BuildingGameObj.h" bool JmgUtility::hasStatedDeathMessage[128] = {false}; void JMG_Utility_Check_If_Script_Is_In_Library::Created(GameObject *obj) @@ -29,6 +26,7 @@ } } } + void JMG_Send_Custom_When_Custom_Sequence_Matched::Created(GameObject *obj) { depth = 0; @@ -40,6 +38,7 @@ enabled = false; } } + void JMG_Send_Custom_When_Custom_Sequence_Matched::Custom(GameObject *obj,int message,int param,GameObject *sender) { if (message == Get_Int_Parameter("Custom_0") || message == Get_Int_Parameter("Custom_1") || message == Get_Int_Parameter("Custom_2") || message == Get_Int_Parameter("Custom_3") || message == Get_Int_Parameter("Custom_4") || message == Get_Int_Parameter("Custom_5") || message == Get_Int_Parameter("Custom_6") || message == Get_Int_Parameter("Custom_7") || message == Get_Int_Parameter("Custom_8") || message == Get_Int_Parameter("Custom_9")) @@ -312,7 +311,6 @@ ClientNetworkObjectPositionSync *clientNetworkObjectPositionSyncControl = NULL; void JMG_Utility_Sync_System_Object::Created(GameObject *obj) { - Force_Position_Update(obj); Commands->Start_Timer(obj,this,2.5f,1); } void JMG_Utility_Sync_System_Object::Timer_Expired(GameObject *obj,int number) @@ -327,11 +325,6 @@ syncNode = clientNetworkObjectPositionSyncControl->addNode(obj); } } -void JMG_Utility_Sync_System_Object::Killed(GameObject *obj,GameObject *killer) -{ - if (syncNode) - syncNode->id = 0; -} void JMG_Utility_Sync_System_Object::Destroyed(GameObject *obj) { if (The_Game()->Is_Game_Over()) @@ -463,20 +456,14 @@ if (spawner) Commands->Send_Custom_Event(obj,spawner,6873521,0,0.0f); } -void JMG_Utility_AI_Engineer::Created(GameObject *obj) +void JMG_Utility_Engineer_AI::Created(GameObject *obj) { centerLocation = (JmgUtility::SimpleDistance(Get_Vector3_Parameter("BaseCenterPoint"),Vector3()) <= 0.0f ? Commands->Get_Position(obj) : Get_Vector3_Parameter("BaseCenterPoint")); maxRange = Get_Float_Parameter("PatrolRange")*Get_Float_Parameter("PatrolRange"); if (!Has_Weapon(obj,Get_Parameter("RepaiarGun_Preset"))) Grant_Weapon(obj,Get_Parameter("RepaiarGun_Preset"),true,-1,true); - if (_stricmp(Get_Parameter("Weapon_Preset"),"null")) - { if (!Has_Weapon(obj,Get_Parameter("Weapon_Preset"))) Grant_Weapon(obj,Get_Parameter("Weapon_Preset"),true,-1,true); - canFight = true; - } - else - canFight = false; const AmmoDefinitionClass *ammo = Get_Weapon_Ammo_Definition(Get_Parameter("RepaiarGun_Preset"),true); if (ammo) repairGunRange = ammo->Range; @@ -501,10 +488,8 @@ Commands->Start_Timer(obj,this,1.0f,6); Commands->Enable_Enemy_Seen(obj,true); } -void JMG_Utility_AI_Engineer::Enemy_Seen(GameObject *obj,GameObject *seen) +void JMG_Utility_Engineer_AI::Enemy_Seen(GameObject *obj,GameObject *seen) { - if (!canFight) - return; if (seen->As_SmartGameObj() && seen->As_SmartGameObj()->Is_Stealthed() && JmgUtility::SimpleDistance(Commands->Get_Position(obj),Commands->Get_Position(seen)) > 900) return; if (targetId && targetUpdate) @@ -516,7 +501,7 @@ targetId = Commands->Get_ID(seen); targetUpdate = 20; } -void JMG_Utility_AI_Engineer::Timer_Expired(GameObject *obj,int number) +void JMG_Utility_Engineer_AI::Timer_Expired(GameObject *obj,int number) { if (number == 1) { @@ -527,10 +512,7 @@ Vector3 pos = Commands->Get_Position(obj); GameObject *lastRep = Commands->Find_Object(lastRepairTargetId); if (!lastRep || Get_Hitpoints(lastRep) >= Get_Max_Hitpoints(lastRep) || !Commands->Get_Health(lastRep)) - { lastRep = NULL; - lastRepairTargetId = 0; - } float nearestObject = lastRep ? JmgUtility::SimpleDistance(pos,Commands->Get_Position(lastRep)) : 0.0f; GameObject *repairTarget = lastRep; for (SLNode *current = GameObjManager::SmartGameObjList.Head();current;current = current->Next()) @@ -539,33 +521,7 @@ if (Valid_Repair_Target(obj,o,playerType)) { float tempDistance = JmgUtility::SimpleDistance(pos,Commands->Get_Position(o)); - if ((!repairTarget || tempDistance < nearestObject) && inRange(o)) - { - repairTarget = o; - nearestObject = tempDistance; - } - } - } - for (SLNode *current = GameObjManager::C4GameObjList.Head();current;current = current->Next()) - { - GameObject *o = (GameObject *)current->Data(); - if (Valid_Repair_Target_C4(obj,o,playerType)) - { - float tempDistance = JmgUtility::SimpleDistance(pos,Commands->Get_Position(o)); - if ((!repairTarget || tempDistance < nearestObject) && inRange(o)) - { - repairTarget = o; - nearestObject = tempDistance; - } - } - } - for (SLNode *current = GameObjManager::BeaconGameObjList.Head();current;current = current->Next()) - { - GameObject *o = (GameObject *)current->Data(); - if (Valid_Repair_Target_C4(obj,o,playerType)) - { - float tempDistance = JmgUtility::SimpleDistance(pos,Commands->Get_Position(o)); - if ((!repairTarget || tempDistance < nearestObject) && inRange(o)) + if ((!repairTarget || tempDistance < nearestObject) && inRange(o) && !Is_Script_Attached(o,"JMG_Bear_Hunter_Engineer_Ignore")) { repairTarget = o; nearestObject = tempDistance; @@ -664,10 +620,8 @@ Commands->Start_Timer(obj,this,repeatTime,6); } } -void JMG_Utility_AI_Engineer::Damaged(GameObject *obj,GameObject *damager,float damage) +void JMG_Utility_Engineer_AI::Damaged(GameObject *obj,GameObject *damager,float damage) { - if (!canFight) - return; if (damage <= 0 || !damager || obj == damager || (targetId && targetUpdate) || targetId == Commands->Get_ID(damager) || Commands->Get_Player_Type(damager) == Commands->Get_Player_Type(obj)) return; if (aiIgnorePlayers[JmgUtility::JMG_Get_Player_ID(damager)]) @@ -677,7 +631,7 @@ targetId = Commands->Get_ID(damager); targetUpdate = 40; } -void JMG_Utility_AI_Engineer::Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason) +void JMG_Utility_Engineer_AI::Action_Complete(GameObject *obj,int action_id,ActionCompleteReason reason) { if (reason == ACTION_COMPLETE_PATH_BAD_DEST) { @@ -689,7 +643,7 @@ aiIgnorePlayers[playerId] = 30; } } -void JMG_Utility_AI_Engineer::AttackTarget(GameObject *obj,GameObject *target,GameObject *secondaryTarget,bool repairTarget,bool useRepairGun) +void JMG_Utility_Engineer_AI::AttackTarget(GameObject *obj,GameObject *target,GameObject *secondaryTarget,bool repairTarget,bool useRepairGun) { if (useRepairGun != repairGun) { @@ -726,34 +680,24 @@ Commands->Action_Attack(obj,params); } } -bool JMG_Utility_AI_Engineer::inRange(GameObject *obj) +bool JMG_Utility_Engineer_AI::inRange(GameObject *obj) { Vector3 pos = Commands->Get_Position(obj); if (JmgUtility::SimpleFlatDistance(pos,centerLocation) < maxRange) return true; return false; } -bool JMG_Utility_AI_Engineer::Valid_Repair_Target(GameObject *obj,GameObject *target,int playerType) +bool JMG_Utility_Engineer_AI::Valid_Repair_Target(GameObject *obj,GameObject *target,int playerType) { if (!target || target == obj || Commands->Get_Player_Type(target) != playerType || Get_Hitpoints(target) >= Get_Max_Hitpoints(target)) return false; - if (Get_Vector3_Parameter("MinHP[EngineerTarget|C4|Beacon]").X && Is_Script_Attached(target,"JMG_Utility_AI_Engineer_Repair_Target") && Get_Hitpoints(target) < Get_Max_Hitpoints(target)*Get_Vector3_Parameter("MinHP[EngineerTarget|C4|Beacon]").X) - return true; - if (Get_Vector3_Parameter("MinHP[Soldiers|Vehicles|Turrets]").X && target->As_SoldierGameObj() && Get_Hitpoints(target) < Get_Max_Hitpoints(target)*Get_Vector3_Parameter("MinHP[Soldiers|Vehicles|Turrets]").X) - return true; - if (Get_Vector3_Parameter("MinHP[Soldiers|Vehicles|Turrets]").Y && target->As_VehicleGameObj() && Get_Vehicle_Mode(target) != VEHICLE_TYPE_TURRET && Get_Hitpoints(target) < Get_Max_Hitpoints(target)*Get_Vector3_Parameter("MinHP[Soldiers|Vehicles|Turrets]").Y) - return true; - if (Get_Vector3_Parameter("MinHP[Soldiers|Vehicles|Turrets]").Z && target->As_VehicleGameObj() && Get_Vehicle_Mode(target) == VEHICLE_TYPE_TURRET && Get_Hitpoints(target) < Get_Max_Hitpoints(target)*Get_Vector3_Parameter("MinHP[Soldiers|Vehicles|Turrets]").Z) - return true; + if (target->As_SoldierGameObj() && Get_Hitpoints(target) > Get_Max_Hitpoints(target)*0.5f) return false; -} -bool JMG_Utility_AI_Engineer::Valid_Repair_Target_C4(GameObject *obj,GameObject *target,int playerType) -{ - if (!target || target == obj || Commands->Get_Player_Type(target) == playerType) + if (target->As_VehicleGameObj() && Get_Vehicle_Mode(target) != VEHICLE_TYPE_TURRET && Get_Hitpoints(target) > Get_Max_Hitpoints(target)*0.75f) return false; - if (Get_Vector3_Parameter("MinHP[EngineerTarget|C4|Beacon]").Y < 1.0 && target->As_PhysicalGameObj() && target->As_PhysicalGameObj()->As_C4GameObj() && Get_Hitpoints(target) > Get_Max_Hitpoints(target)*Get_Vector3_Parameter("MinHP[EngineerTarget|C4|Beacon]").Y) - return true; - if (Get_Vector3_Parameter("MinHP[EngineerTarget|C4|Beacon]").Z < 1.0 && target->As_PhysicalGameObj() && target->As_PhysicalGameObj()->As_BeaconGameObj() && Get_Hitpoints(target) > Get_Max_Hitpoints(target)*Get_Vector3_Parameter("MinHP[EngineerTarget|C4|Beacon]").Z) + if (target->As_VehicleGameObj() && Get_Vehicle_Mode(target) == VEHICLE_TYPE_TURRET && Get_Hitpoints(target) > Get_Max_Hitpoints(target)*0.9f) + return false; + if (!target->As_SoldierGameObj() || (target->As_SoldierGameObj() && !Get_Vehicle(target))) return true; return false; } @@ -782,8 +726,7 @@ drivingBackward = false; badDestAttempt = 0; doNotUsePathfind = 0; - maxHuntRangeSquared = Get_Float_Parameter("MaxHuntRange")*Get_Float_Parameter("MaxHuntRange"); - lastWanderPointSpot = currentAction.position = retreatPos = homepos = Commands->Get_Position(obj); + currentAction.position = retreatPos = homepos = Commands->Get_Position(obj); myteam = Commands->Get_Player_Type(obj); Commands->Enable_Enemy_Seen(obj,true); if (obj->As_VehicleGameObj()) @@ -858,10 +801,7 @@ } void JMG_Utility_AI_Vehicle::Enemy_Seen(GameObject *obj,GameObject *seen) { - Vector3 enemyPos = Commands->Get_Position(seen); - float dist = JmgUtility::SimpleDistance(Commands->Get_Position(obj),enemyPos); - if (Get_Float_Parameter("MaxHuntRange") > 0.0f && JmgUtility::SimpleDistance(lastWanderPointSpot,enemyPos) > maxHuntRangeSquared) - return; + float dist = JmgUtility::SimpleDistance(Commands->Get_Position(obj),Commands->Get_Position(seen)); if (Get_Float_Parameter("MinAttackRange") && dist < minDistanceSquared) return; if (seen->As_SmartGameObj() && seen->As_SmartGameObj()->Is_Stealthed()) @@ -897,7 +837,6 @@ if (GetRandomPosition(&wanderPos) && (!Get_Int_Parameter("FollowTarget") || !currentAction.targetId)) { moving = true; - lastWanderPointSpot = wanderPos; AttackMove(obj,Commands->Find_Object(currentAction.targetId),false,wanderPos,currentAction.useAmmo,0.0f,false,2.5f); } Commands->Start_Timer(obj,this,Get_Float_Parameter("MinRandWander") == Get_Float_Parameter("MaxRandWander") ? Get_Float_Parameter("MaxRandWander") : Commands->Get_Random(Get_Float_Parameter("MinRandWander"),Get_Float_Parameter("MaxRandWander")),2); @@ -971,16 +910,12 @@ if (Get_Int_Parameter("WanderingAIGroupID") != -1 && GetRandomPosition(&wanderPos) && (!Get_Int_Parameter("FollowTarget") || !currentAction.targetId)) { moving = true; - lastWanderPointSpot = wanderPos; AttackMove(obj,Commands->Find_Object(currentAction.targetId),false,wanderPos,currentAction.useAmmo,0.0f,false,2.5f); } else - { - lastWanderPointSpot = homepos; AttackMove(obj,Commands->Find_Object(currentAction.targetId),false,homepos,currentAction.useAmmo,0.0f,false,2.5f); } } - } Commands->Start_Timer(obj,this,0.1f,8); } } @@ -998,7 +933,6 @@ AttackMove(obj,Commands->Find_Object(lastAction.targetId),false,pos,lastAction.useAmmo,0.0f,false,2.5f); else AttackMove(obj,Commands->Find_Object(lastAction.targetId),false,homepos,lastAction.useAmmo,0.0f,false,2.5f); - lastWanderPointSpot = homepos; } void JMG_Utility_AI_Vehicle::RunAttack(GameObject *obj,GameObject *target) { @@ -1234,7 +1168,6 @@ { targetLocation = Commands->Get_Position(target); targetLocation.Z += Get_Float_Parameter("VTOLHover"); - params.AttackFaceTarget = false; } params.Set_Movement(targetLocation,JmgUtility::MathClamp(dist,1.0f,100.0f),arriveDistance,false); params.MoveFollow = false; @@ -1701,809 +1634,7 @@ Destroy_Script(); } } -void JMG_Utility_AI_Aggressive_Melee::Created(GameObject *obj) -{ - LastSeen = 0; - currentTargetID = 0; - secondaryTargetId = 0; - lastSeenSecondary = 0; - huntorattack = 0; - waitcount = 0; - speed = 2.0f; - stuckTime = 0; - togglePathfind = 0; - pathfindOn = false; - forcePathfindOverride = false; - stuckReturnHome = 0; - lastPos = homelocation = Commands->Get_Position(obj); - noPathfindRange = Get_Float_Parameter("NoPathfindDistance")*Get_Float_Parameter("NoPathfindDistance"); - minVisibilityTime = Get_Int_Parameter("MinLooseVisibilityTime")*10; - maxVisibilityTime = Get_Int_Parameter("MaxLooseVisibilityTime")*10; - maxHuntDistance = Get_Float_Parameter("MaxHuntDistance")*Get_Float_Parameter("MaxHuntDistance"); - Commands->Enable_Enemy_Seen(obj,true); - Commands->Start_Timer(obj,this,0.1f,92562343); -} -void JMG_Utility_AI_Aggressive_Melee::Enemy_Seen(GameObject *obj,GameObject *seen) -{ - int SeenID = Commands->Get_ID(seen); - if (!currentTargetID || !LastSeen) - { - LastSeen = minVisibilityTime == maxVisibilityTime ? maxVisibilityTime : Commands->Get_Random_Int(minVisibilityTime,maxVisibilityTime); - huntorattack = 0; - currentTargetID = SeenID; - } - else if (currentTargetID == SeenID) - LastSeen = minVisibilityTime == maxVisibilityTime ? maxVisibilityTime : Commands->Get_Random_Int(minVisibilityTime,maxVisibilityTime); - else if (!secondaryTargetId || !lastSeenSecondary) - { - lastSeenSecondary = maxVisibilityTime; - secondaryTargetId = SeenID; - } - else if (secondaryTargetId == SeenID) - lastSeenSecondary = maxVisibilityTime; -} -void JMG_Utility_AI_Aggressive_Melee::Timer_Expired(GameObject *obj,int number) -{ - if (92562343 == number) - { - if (LastSeen) - { - LastSeen--; - if (!LastSeen) - currentTargetID = 0; - } - if (lastSeenSecondary) - { - lastSeenSecondary--; - if (!lastSeenSecondary) - secondaryTargetId = 0; - } - if (currentTargetID) - { - GameObject *target = Commands->Find_Object(currentTargetID); - GameObject *target2 = Commands->Find_Object(secondaryTargetId); - if (!target2 || Commands->Get_Health(target2) == 0.0f) - secondaryTargetId = 0; - if (!target || Commands->Get_Health(target) == 0.0f) - { - if (target2) - { - currentTargetID = secondaryTargetId; - LastSeen = maxVisibilityTime; - } - else - { - waitcount = 0; - currentTargetID = 0; - Commands->Action_Reset(obj,10); - ActionParamsStruct params; - params.Set_Basic(this,999,10); - params.MovePathfind = forcePathfindOverride ? pathfindOn : true; - params.Set_Movement(homelocation,Get_Float_Parameter("ReturnHomeSpeed"),Get_Float_Parameter("ReturnHomeArriveDistance"),false); - Commands->Action_Goto(obj,params); - } - } - else if (Get_Float_Parameter("MaxHuntDistance") && JmgUtility::SimpleDistance(homelocation,Commands->Get_Position(target)) > maxHuntDistance) - { - currentTargetID = 0; - waitcount = 0; - if (huntorattack == 1) - Commands->Action_Reset(obj,10); - } - else - { - waitcount++; - if (waitcount > 2) - { - waitcount = 0; - ActionParamsStruct params; - params.Set_Movement(target,Get_Float_Parameter("ChaseSpeed"),Get_Float_Parameter("AttackArriveDistance"),false); - params.MovePathfind = forcePathfindOverride ? pathfindOn : JmgUtility::SimpleDistance(Commands->Get_Position(target),Commands->Get_Position(obj)) <= noPathfindRange ? false : true; - Commands->Action_Goto(obj,params); - params.Set_Basic(this,999,10); - params.Set_Attack(target,Get_Float_Parameter("StartAttackDistance"),1,true); - Commands->Action_Attack(obj,params); - } - } - Vector3 pos = Commands->Get_Position(obj); - if (JmgUtility::SimpleDistance(pos,lastPos) < 1.0) - { - stuckReturnHome++; - if (stuckReturnHome > 150) - { - stuckTime = 0; - togglePathfind = 0; - pathfindOn = false; - forcePathfindOverride = false; - stuckReturnHome = 0; - Commands->Set_Position(obj,homelocation); - } - if (stuckTime < 30) - stuckTime++; - if (stuckTime == 30) - { - forcePathfindOverride = true; - togglePathfind++; - if (togglePathfind >= 30) - { - pathfindOn = !pathfindOn; - togglePathfind = 0; - } - } - lastPos = Commands->Get_Position(obj); - } - else - { - stuckReturnHome = 0; - stuckTime--; - if (!stuckTime) - forcePathfindOverride = false; - } - } - Commands->Start_Timer(obj,this,0.1f,92562343); - } -} -void JMG_Utility_AI_Aggressive_Melee::Damaged(GameObject *obj,GameObject *damager,float damage) -{ - if (!damager || Commands->Get_Player_Type(damager) != 1 || currentTargetID || Commands->Get_Player_Type(damager) == Commands->Get_Player_Type(obj)) - return; - if (!chooseTarget(obj,damager,¤tTargetID,&LastSeen)) - chooseTarget(obj,damager,&secondaryTargetId,&lastSeenSecondary); - else - { - huntorattack = 0; - waitcount = 0; - } -} -bool JMG_Utility_AI_Aggressive_Melee::chooseTarget(GameObject *obj,GameObject *damager,int *compareId,int *seenTimer) -{ - GameObject *target = Commands->Find_Object(*compareId); - if (target) - { - float targetDistance = JmgUtility::SimpleDistance(Commands->Get_Position(obj),Commands->Get_Position(target)); - float damagerDistance = JmgUtility::SimpleDistance(Commands->Get_Position(obj),Commands->Get_Position(damager)); - if (targetDistance < damagerDistance) - return false; - } - *seenTimer = minVisibilityTime == maxVisibilityTime ? maxVisibilityTime : Commands->Get_Random_Int(minVisibilityTime,maxVisibilityTime); - *compareId = Commands->Get_ID(damager); - return true; -} -void JMG_Utility_Infantry_Placed_Buildable_Object::Created(GameObject *obj) -{ - canRegen = false; - previewObjectId = 0; - reloadTime = 0; - if (!Has_Weapon(obj,Get_Parameter("WeaponPreset")) && Get_Int_Parameter("GrantWeapon")) - Grant_Weapon(obj,Get_Parameter("WeaponPreset"),true,1,0); - Commands->Start_Timer(obj,this,0.25f,1); - Commands->Start_Timer(obj,this,1.0f,2); -} -void JMG_Utility_Infantry_Placed_Buildable_Object::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1) - { - if (!Commands->Get_Health(obj)) - return; - const char *weap = Get_Current_Weapon(obj); - if (weap && !_stricmp(weap,Get_Parameter("WeaponPreset")) && !Get_Vehicle(obj) && !reloadTime) - { - if (!previewObjectId) - { - GameObject *preview = Commands->Create_Object(Get_Parameter("PreviewPreset"),Commands->Get_Position(obj)); - previewObjectId = Commands->Get_ID(preview); - Update_Network_Object(preview); - Set_Object_Visibility(previewObjectId,false); - if ((int)Get_Vector3_Parameter("MatchTeam[Preview|Deployed|Repaired]").X) - Commands->Set_Player_Type(preview,Commands->Get_Player_Type(obj)); - Commands->Attach_To_Object_Bone(preview,obj,"origin"); - if (!placementBlocked) - Commands->Set_Model(preview,Get_Parameter("PlaceablePreview")); - else - Commands->Set_Model(preview,Get_Parameter("UnPlaceablePreview")); - Set_Object_Visibility_For_Player(obj,previewObjectId,true); - } - } - else if (previewObjectId) - DestroyPreview(); - Commands->Start_Timer(obj,this,0.25f,1); - } - if (number == 2) - { - if (reloadTime && canRegen) - { - reloadTime--; - if (!reloadTime) - { - Set_Bullets(obj,Get_Parameter("WeaponPreset"),1); - JmgUtility::DisplayChatMessage(obj,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").X,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Y,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Z,Get_Parameter("PlacementMessage")); - } - } - Commands->Start_Timer(obj,this,1.0f,2); - } -} -void JMG_Utility_Infantry_Placed_Buildable_Object::Custom(GameObject *obj,int message,int param,GameObject *sender) -{ - if (message == Get_Int_Parameter("DeployCustom")) - { - if (Get_Vehicle(obj)) - return; - const char *weap = Get_Current_Weapon(obj); - if (!weap || _stricmp(weap,Get_Parameter("WeaponPreset"))) - return; - if (obj->As_SoldierGameObj() && obj->As_SoldierGameObj()->Is_Airborne()) - { - JmgUtility::DisplayChatMessage(obj,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").X,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Y,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Z,"You must be on the ground to place this!"); - return; - } - if (obj->As_SoldierGameObj() && obj->As_SoldierGameObj()->Is_On_Ladder()) - { - JmgUtility::DisplayChatMessage(obj,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").X,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Y,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Z,"You cannot place this while climbing ladders!"); - return; - } - if (placementBlocked) - { - JmgUtility::DisplayChatMessage(obj,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").X,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Y,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Z,Get_Parameter("DeploymentBlockedMessage")); - return; - } - if (!canRegen && reloadTime) - { - JmgUtility::DisplayChatMessage(obj,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").X,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Y,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Z,"You must repair the last one you placed before you can place another."); - return; - } - if (reloadTime) - { - char reloadTimeMessage[220]; - sprintf(reloadTimeMessage,"You must wait another %d seconds before you can place this.",reloadTime); - JmgUtility::DisplayChatMessage(obj,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").X,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Y,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Z,reloadTimeMessage); - return; - } - if (Get_Float_Parameter("Cost") && Commands->Get_Money(obj) < Get_Float_Parameter("Cost")) - { - char costMessage[220]; - sprintf(costMessage,"You need $%s to place this.",JmgUtility::formatDigitGrouping(Get_Float_Parameter("Cost"))); - JmgUtility::DisplayChatMessage(obj,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").X,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Y,(int)Get_Vector3_Parameter("MessageColor[R|G|B]").Z,costMessage); - return; - } - if (Get_Float_Parameter("Cost")) - Commands->Give_Money(obj,-Get_Float_Parameter("Cost"),false); - canRegen = Get_Int_Parameter("RegenStartsAfterRepair") ? false : true; - reloadTime = Get_Int_Parameter("RegainTimer"); - Set_Bullets(obj,Get_Parameter("WeaponPreset"),0); - GameObject *preview = Commands->Find_Object(previewObjectId); - if (preview) - Commands->Destroy_Object(preview); - previewObjectId = 0; - GameObject *placed = Commands->Create_Object(Get_Parameter("DeployPreset"),Commands->Get_Position(obj)); - if ((int)Get_Vector3_Parameter("MatchTeam[Preview|Deployed|Repaired]").Y) - Commands->Set_Player_Type(placed,Commands->Get_Player_Type(obj)); - Commands->Set_Facing(placed,Commands->Get_Facing(obj)); - char params[220]; - sprintf(params,"%d,%d,%s,%d,%d",this->Get_ID(),Commands->Get_ID(obj),Get_Parameter("RepairedPreset"),Get_Vector3_Parameter("MatchTeam[Preview|Deployed|Repaired]").Z,Commands->Get_Player_Type(obj)); - Commands->Attach_Script(placed,"JMG_Utility_Infantry_Placed_Buildable_Object_Attached",params); - } - if (message == Get_Int_Parameter("EnableCustom")) - { - if (placementBlocked) - placementBlocked--; - if (!placementBlocked) - { - GameObject *preview = Commands->Find_Object(previewObjectId); - if (preview) - Commands->Set_Model(preview,Get_Parameter("PlaceablePreview")); - } - } - if (message == Get_Int_Parameter("DisableCustom")) - { - if (!placementBlocked) - { - GameObject *preview = Commands->Find_Object(previewObjectId); - if (preview) - Commands->Set_Model(preview,Get_Parameter("UnPlaceablePreview")); - } - placementBlocked++; - } - if (message == 9117115 && param == this->Get_ID()) - { - reloadTime = Get_Int_Parameter("DestroyedRegenTime"); - canRegen = true; - } - if (message == 9117116 && param == this->Get_ID()) - { - reloadTime = 0; - Set_Bullets(obj,Get_Parameter("WeaponPreset"),1); - } - if (message == 9117117 && param == this->Get_ID()) - { - canRegen = true; - } - if (message == 9117118 && param == this->Get_ID()) - { - if (Get_Float_Parameter("Cost")) - Commands->Give_Money(obj,Get_Float_Parameter("Cost"),false); - } -} -void JMG_Utility_Infantry_Placed_Buildable_Object::Killed(GameObject *obj,GameObject *killer) -{ - DestroyPreview(); -} -void JMG_Utility_Infantry_Placed_Buildable_Object::Destroyed(GameObject *obj) -{ - DestroyPreview(); -} -void JMG_Utility_Infantry_Placed_Buildable_Object::DestroyPreview() -{ - GameObject *preview = Commands->Find_Object(previewObjectId); - if (preview) - Commands->Destroy_Object(preview); - previewObjectId = 0; -} -void JMG_Utility_Infantry_Placed_Buildable_Object_Attached::Damaged(GameObject *obj,GameObject *damager,float damage) -{ - if (damage < 0 && Get_Hitpoints(obj) == Get_Max_Hitpoints(obj)) - { - GameObject *placed = Commands->Create_Object(Get_Parameter("RepairedPreset"),Commands->Get_Position(obj)); - if (Get_Int_Parameter("MatchTeam")) - Commands->Set_Player_Type(placed,Get_Int_Parameter("Team")); - Commands->Set_Facing(placed,Commands->Get_Facing(obj)); - Commands->Destroy_Object(obj); - GameObject *placer = Commands->Find_Object(Get_Int_Parameter("PlacerId")); - if (placer) - Commands->Send_Custom_Event(obj,placer,9117117,Get_Int_Parameter("ScriptId"),0); - } -} -void JMG_Utility_Infantry_Placed_Buildable_Object_Attached::Killed(GameObject *obj,GameObject *killer) -{ - GameObject *placer = Commands->Find_Object(Get_Int_Parameter("PlacerId")); - if (Commands->Get_Player_Type(placer) == Commands->Get_Player_Type(killer)) - Commands->Send_Custom_Event(obj,placer,9117116,Get_Int_Parameter("ScriptId"),0); - else if (placer) - Commands->Send_Custom_Event(obj,placer,9117115,Get_Int_Parameter("ScriptId"),0); - Commands->Send_Custom_Event(obj,placer,9117118,Get_Int_Parameter("ScriptId"),0); -} -void JMG_Utility_Lock_Weapon_Selection_While_Script_Attached::Created(GameObject *obj) -{ - Commands->Start_Timer(obj,this,0.1f,1); -} -void JMG_Utility_Lock_Weapon_Selection_While_Script_Attached::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1) - { - const char *weap = Get_Current_Weapon(obj); - if (Has_Weapon(obj,Get_Parameter("WeaponPreset")) && (!weap || _stricmp(weap,Get_Parameter("WeaponPreset")))) - Commands->Select_Weapon(obj,Get_Parameter("WeaponPreset")); - Commands->Start_Timer(obj,this,0.1f,1); - } -} -float JMG_Utility_Swimming_Zone::fogMinDistance = 200.0f; -float JMG_Utility_Swimming_Zone::fogMaxDistance = 300.0f; -void JMG_Utility_Swimming_Zone::Created(GameObject *obj) -{ - Get_Fog_Range(fogMinDistance,fogMaxDistance); -} -void JMG_Utility_Swimming_Zone::Entered(GameObject *obj,GameObject *enter) -{ - if (!enter->As_SoldierGameObj()) - return; - if (!Is_Script_Attached(enter,"JMG_Utility_Swimming_Infantry")) - { - Commands->Apply_Damage(enter,9999.9f,"Death",obj); - return; - } - waterNode[JmgUtility::JMG_Get_Player_ID(enter)] = PlayerWaterNode(Get_Vector3_Parameter("WaterColor[R|G|B]"),Get_Float_Parameter("WaterOpacity"),Get_Float_Parameter("WaterMinViewDistance"),Get_Float_Parameter("WaterMaxViewDistance")); - Commands->Send_Custom_Event(obj,enter,347341,0,0); -} -void JMG_Utility_Swimming_Zone::Exited(GameObject *obj,GameObject *exiter) -{ - if (!Commands->Is_A_Star(exiter) || !exiter->As_SoldierGameObj()) - return; - Commands->Send_Custom_Event(obj,exiter,347340,0,0); -} -JMG_Utility_Swimming_Zone::PlayerWaterNode JMG_Utility_Swimming_Zone::waterNode[128] = {JMG_Utility_Swimming_Zone::PlayerWaterNode()}; -bool JMG_Utility_Swimming_Infantry::underwater[128] = {false}; -int JMG_Utility_Swimming_Infantry::waterZoneCount[128] = {0}; -void JMG_Utility_Swimming_Infantry::Created(GameObject *obj) -{ - heartBeatSoundId = 0; - pantSoundId = 0; - playerId = JmgUtility::JMG_Get_Player_ID(obj); - underwater[playerId] = false; - waterZoneCount[playerId] = 0; - startedFadeRed = false; - drownTime = 0.0f; - for (SLNode* node = GameObjManager::ScriptZoneGameObjList.Head(); node; node = node->Next()) - { - GameObject *zone = (GameObject *)node->Data(); - if (Is_Script_Attached(zone,"JMG_Utility_Swimming_Zone") && IsInsideZone(zone,obj)) - Commands->Send_Custom_Event(obj,obj,347341,347341,0.25f); - } - Commands->Start_Timer(obj,this,0.1f,1); -} -void JMG_Utility_Swimming_Infantry::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1 && Commands->Get_Health(obj)) - { - if (obj->As_SoldierGameObj()->Is_Crouched() && !obj->As_SoldierGameObj()->Is_Airborne() && waterZoneCount[playerId]) - { - if (!underwater[playerId]) - { - underwater[playerId] = true; - DestroySoundEmitter(&pantSoundId); - if (startedFadeRed) - { - Set_Screen_Fade_Color_Player(obj,1.0f,0.0f,0.0f,JmgUtility::MathClamp(Get_Float_Parameter("DrownTime")-drownTime,0,Get_Float_Parameter("StarDrownSequence"))); - CreateSoundEmitter(obj,Get_Parameter("HeartBeatSoundEmitterModel"),&heartBeatSoundId); - } - else - Set_Screen_Fade_Color_Player(obj,JMG_Utility_Swimming_Zone::waterNode[playerId].waterColor.X,JMG_Utility_Swimming_Zone::waterNode[playerId].waterColor.Y,JMG_Utility_Swimming_Zone::waterNode[playerId].waterColor.Z,0.0f); - Set_Screen_Fade_Opacity_Player(obj,JMG_Utility_Swimming_Zone::waterNode[playerId].waterColorOpacity,0.1f); - Set_Fog_Range_Player(obj,JMG_Utility_Swimming_Zone::waterNode[playerId].waterMinViewDistance,JMG_Utility_Swimming_Zone::waterNode[playerId].waterMaxViewDistance,0.1f); - } - drownTime += 0.1f; - if (!startedFadeRed && drownTime >= Get_Float_Parameter("DrownTime")-Get_Float_Parameter("StarDrownSequence")) - { - startedFadeRed = true; - Set_Screen_Fade_Color_Player(obj,1.0f,0.0f,0.0f,Get_Float_Parameter("StarDrownSequence")); - CreateSoundEmitter(obj,Get_Parameter("HeartBeatSoundEmitterModel"),&heartBeatSoundId); - } - if (drownTime >= Get_Float_Parameter("DrownTime")) - Commands->Apply_Damage(obj,Get_Float_Parameter("DrownDamageRate"),"None",obj); - } - else - { - if (underwater[playerId]) - { - underwater[playerId] = false; - Set_Screen_Fade_Opacity_Player(obj,0.0f,0.1f); - Set_Fog_Range_Player(obj,JMG_Utility_Swimming_Zone::fogMinDistance,JMG_Utility_Swimming_Zone::fogMaxDistance,0.1f); - DestroySoundEmitter(&heartBeatSoundId); - if (drownTime > 1.0f) - CreateSoundEmitter(obj,Get_Parameter("PantingSoundEmitterModel"),&pantSoundId); - if (drownTime > Get_Float_Parameter("DrownTime")) - Commands->Create_3D_Sound_At_Bone(Get_Parameter("GaspForBreath"),obj,"c head"); - } - if (drownTime) - { - drownTime -= Get_Float_Parameter("CatchBreathRate"); - if (startedFadeRed && drownTime < Get_Float_Parameter("DrownTime")-Get_Float_Parameter("StarDrownSequence")) - startedFadeRed = false; - if (drownTime <= 0) - { - drownTime = 0.0f; - DestroySoundEmitter(&pantSoundId); - } - } - } - if (waterZoneCount[playerId]) - { - const char *weap = Get_Current_Weapon(obj); - if (Has_Weapon(obj,Get_Parameter("WeaponPreset")) && (!weap || _stricmp(weap,Get_Parameter("WeaponPreset")))) - Commands->Select_Weapon(obj,Get_Parameter("WeaponPreset")); - } - Commands->Start_Timer(obj,this,0.1f,1); - } -} -void JMG_Utility_Swimming_Infantry::Custom(GameObject *obj,int message,int param,GameObject *sender) -{ - if (message == 347340) - { - Commands->Send_Custom_Event(sender,obj,347342,param,0.25f); - } - if (message == 347342) - { - if (obj->As_SoldierGameObj()->Is_Airborne()) - { - Commands->Send_Custom_Event(sender,obj,message,param,0.25f); - return; - } - waterZoneCount[playerId]--; - if (!waterZoneCount[playerId]) - { - obj->As_SoldierGameObj()->Set_Can_Play_Damage_Animations(true); - obj->As_SoldierGameObj()->Set_Movement_Loiters_Allowed(true); - if (Has_Weapon(obj,enterWeapon)) - Commands->Select_Weapon(obj,enterWeapon); - if (Has_Weapon(obj,Get_Parameter("WeaponPreset"))) - Remove_Weapon(obj,Get_Parameter("WeaponPreset")); - } - } - if (message == 347341) - { - if (!waterZoneCount[playerId]) - { - sprintf(enterWeapon,"%s",Get_Current_Weapon(obj) ? Get_Current_Weapon(obj) : ""); - Grant_Weapon(obj,Get_Parameter("WeaponPreset"),true,-1,1); - obj->As_SoldierGameObj()->Set_Can_Play_Damage_Animations(false); - obj->As_SoldierGameObj()->Set_Movement_Loiters_Allowed(false); - Commands->Set_Loiters_Allowed(obj,false); - } - waterZoneCount[playerId]++; - } -} -void JMG_Utility_Swimming_Infantry::Killed(GameObject *obj,GameObject *killer) -{ - DestroySoundEmitter(&heartBeatSoundId); - DestroySoundEmitter(&pantSoundId); -} -void JMG_Utility_Swimming_Infantry::Destroyed(GameObject *obj) -{ - Set_Screen_Fade_Opacity_Player(obj,0.0f,0.0f); - Set_Fog_Range_Player(obj,JMG_Utility_Swimming_Zone::fogMinDistance,JMG_Utility_Swimming_Zone::fogMaxDistance,0.0f); - DestroySoundEmitter(&heartBeatSoundId); - DestroySoundEmitter(&pantSoundId); -} -void JMG_Utility_Swimming_Infantry::Detach(GameObject *obj) -{ - Destroyed(obj); -} -void JMG_Utility_Swimming_Infantry::CreateSoundEmitter(GameObject *obj,const char *model,int *soundId) -{ - GameObject *soundEmitter = Commands->Find_Object(*soundId); - if (!soundEmitter) - { - soundEmitter = Commands->Create_Object("Daves Arrow",Commands->Get_Position(obj)); - *soundId = Commands->Get_ID(soundEmitter); - Commands->Attach_To_Object_Bone(soundEmitter,obj,"c head"); - } - Commands->Set_Model(soundEmitter,model); -} -void JMG_Utility_Swimming_Infantry::DestroySoundEmitter(int *soundId) -{ - GameObject *soundEmitter = Commands->Find_Object(*soundId); - if (soundEmitter) - Commands->Destroy_Object(soundEmitter); - *soundId = 0; -} -void JMG_Utility_Zone_Enable_Spawners_In_Range::Entered(GameObject *obj,GameObject *enter) -{ - if (CheckPlayerType(enter,Get_Int_Parameter("PlayerType"))) - return; - for (int x = Get_Int_Parameter("StartID");x <= Get_Int_Parameter("EndID");x++) - Commands->Enable_Spawner(x,Get_Int_Parameter("Enable") ? true : false); -} -void JMG_Utility_Display_Message_On_Vehicle_Enter::Created(GameObject *obj) -{ - for (int x = 0;x < 128;x++) - hasShownMessage[x] = false; -} -void JMG_Utility_Display_Message_On_Vehicle_Enter::Custom(GameObject *obj,int type,int param,GameObject *sender) -{ - if (type == CUSTOM_EVENT_VEHICLE_ENTERED) - { - int playerId = JmgUtility::JMG_Get_Player_ID(sender); - if (!playerId) - return; - if (CheckPlayerType(sender,Get_Int_Parameter("PlayerType"))) - return; - if (Get_Int_Parameter("DriverOnly") && Get_Vehicle_Driver(obj) != sender) - return; - if (!Get_Int_Parameter("ShowOnce") || !hasShownMessage[playerId]) - { - hasShownMessage[playerId] = true; - if (_stricmp(Get_Parameter("MessageOverride"),"null")) - Set_HUD_Help_Text_Player_Text(sender,Get_Int_Parameter("StringId"),Get_Parameter("MessageOverride"),Get_Vector3_Parameter("Color[R|G|B]")); - else - Set_HUD_Help_Text_Player(sender,Get_Int_Parameter("StringId"),Get_Vector3_Parameter("Color[R|G|B]")); - } - } -} -void JMG_Utility_Zone_Apply_Damage_On_Enter::Entered(GameObject *obj,GameObject *enter) -{ - if (CheckPlayerType(enter,Get_Int_Parameter("PlayerType"))) - return; - GameObject *target = Get_Int_Parameter("ID") ? Commands->Find_Object(Get_Int_Parameter("ID")) : enter; - if (target) - { - VehicleGameObj *vehicleGameObj = target->As_VehicleGameObj(); - if (vehicleGameObj && Get_Int_Parameter("DamageOccupants")) - { - int x = vehicleGameObj->Get_Definition().Get_Seat_Count(); - PhysicalGameObj *physicalGameObj = enter->As_PhysicalGameObj(); - OffenseObjectClass offenseObjectClass = OffenseObjectClass(Get_Float_Parameter("DamageAmount"),ArmorWarheadManager::Get_Warhead_Type(Get_Parameter("Warhead")),physicalGameObj ? physicalGameObj->As_ArmedGameObj() : NULL); - for (int i = 0;i < x;i++) - { - SoldierGameObj *soldierGameObj = vehicleGameObj->Get_Occupant(i); - if (soldierGameObj) - { - soldierGameObj->Apply_Damage_IgnoreVehicleCheck(offenseObjectClass,1,-1); - if (!Commands->Get_Health(soldierGameObj)) - { - if (Get_Vehicle_Driver(target) == soldierGameObj) - Commands->Enable_Engine(target,false); - Toggle_Fly_Mode(soldierGameObj); - Commands->Apply_Damage(soldierGameObj,1.0,"BlamoKiller",enter); - } - } - } - } - Commands->Apply_Damage(target,Get_Float_Parameter("DamageAmount"),Get_Parameter("Warhead"),enter); - } - if (Get_Int_Parameter("OnlyOnce")) - this->Destroy_Script(); -} -void JMG_Utility_AI_Guardian_Aircraft::Created(GameObject *obj) -{ - dpPosition = Commands->Get_Position(obj); - EnemyID = 0; - EnemyTimeOutTime = 0; - LastPos = Commands->Get_Position(obj); - Commands->Enable_Enemy_Seen(obj,true); - Commands->Enable_Engine(obj,true); - Commands->Start_Timer(obj,this,1.0f,1); -} -void JMG_Utility_AI_Guardian_Aircraft::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1) - { - if (EnemyTimeOutTime) - EnemyTimeOutTime--; - if (!EnemyTimeOutTime) - { - EnemyID = 0; - Goto_Location(obj); - } - if (EnemyID) - { - GameObject *Target = Commands->Find_Object(EnemyID); - if (!Target || !Commands->Get_Health(Target) || Commands->Get_Player_Type(Target) == Commands->Get_Player_Type(obj)) - EnemyID = 0; - } - Vector3 Pos = Commands->Get_Position(obj); - if (JmgUtility::SimpleDistance(Pos,LastPos) < 25.0) - { - if (Get_A_Defense_Point(&dpPosition)) - Goto_Location(obj); - } - LastPos = Pos; - Commands->Start_Timer(obj,this,1.0f,1); - } -} -void JMG_Utility_AI_Guardian_Aircraft::Enemy_Seen(GameObject *obj,GameObject *seen) -{ - if (!EnemyID || !EnemyTimeOutTime) - { - EnemyID = Commands->Get_ID(seen); - EnemyTimeOutTime = 2; - Goto_Location(obj); - } - else if (EnemyID == Commands->Get_ID(seen)) - EnemyTimeOutTime = 2; -} -void JMG_Utility_AI_Guardian_Aircraft::Damaged(GameObject *obj,GameObject *damager,float damage) -{ - if (!Commands->Is_A_Star(damager)) - return; - if (Commands->Get_Player_Type(damager) != Commands->Get_Player_Type(obj)) - return; - Commands->Give_Money(damager,-damage*Get_Damage_Points(obj),false); - if (Commands->Get_Money(damager) < 0.0f) - Set_Money(JmgUtility::JMG_Get_Player_ID(damager),0.0f); -} -void JMG_Utility_AI_Guardian_Aircraft::Goto_Location(GameObject *obj) -{ - ActionParamsStruct params; - Commands->Action_Reset(obj,100); - Vector3 GoToPos = dpPosition; - GoToPos.Z += Get_Float_Parameter("FlightHeight"); - params.Set_Movement(GoToPos,1.0f,1.0f,false); - params.MovePathfind = false; - params.Set_Basic(this,100,10); - GameObject *Target = Commands->Find_Object(EnemyID); - if (Target) - { - if (Get_Int_Parameter("FaceTarget")) - params.Set_Face_Location(Commands->Get_Position(Target),5.0f); - else - params.AttackFaceTarget = false; - params.Set_Attack(Target,Get_Float_Parameter("FireRange"),0,true); - Commands->Action_Attack(obj,params); - } - else - { - if (Get_Int_Parameter("FaceTarget")) - params.Set_Face_Location(GoToPos,5.0f); - else - params.AttackFaceTarget = false; - Commands->Action_Goto(obj,params); - } -} -void JMG_Utility_Switch_Weapon_While_Primary_Empty::Created(GameObject *obj) -{ - if (Get_Float_Parameter("SecondaryToPrimaryTime") != -1.0) - Commands->Set_Animation(obj,Get_Parameter("IdlePrimaryAnim"),true,0,0.0,-1,false); - Commands->Start_Timer(obj,this,0.25f,1); -} -void JMG_Utility_Switch_Weapon_While_Primary_Empty::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1) - { - const char *weap = Get_Current_Weapon(obj); - if (!Get_Bullets(obj,Get_Parameter("PrimaryWeapon")) && !_stricmp(weap,Get_Parameter("PrimaryWeapon"))) - { - Commands->Select_Weapon(obj,Get_Parameter("SecondaryWeapon")); - Commands->Start_Timer(obj,this,Get_Float_Parameter("ReloadTime"),2); - if (Get_Float_Parameter("PrimaryToSecondaryTime") != -1.0) - Commands->Start_Timer(obj,this,Get_Float_Parameter("PrimaryToSecondaryTime"),3); - else - Commands->Start_Timer(obj,this,0.0f,3); - if (Get_Float_Parameter("SecondaryToPrimaryTime") != -1.0) - Commands->Start_Timer(obj,this,Get_Float_Parameter("ReloadTime")-Get_Float_Parameter("SecondaryToPrimaryTime"),5); - else - Commands->Start_Timer(obj,this,Get_Float_Parameter("ReloadTime"),5); - if (_stricmp(Get_Parameter("PrimaryToSecondaryAnim"),"null")) - Commands->Set_Animation(obj,Get_Parameter("PrimaryToSecondaryAnim"),false,0,0.0,-1,false); - if (_stricmp(Get_Parameter("PrimaryToSecondarySound"),"null")) - Commands->Create_Sound(Get_Parameter("PrimaryToSecondarySound"),Commands->Get_Position(obj),obj); - } - Commands->Start_Timer(obj,this,0.25f,1); - } - if (number == 2) - { - Set_Bullets(obj,Get_Parameter("PrimaryWeapon"),Get_Max_Bullets(obj,Get_Parameter("PrimaryWeapon"))); - Commands->Select_Weapon(obj,Get_Parameter("PrimaryWeapon")); - } - if (number == 3 && _stricmp(Get_Parameter("IdleSecondaryAnim"),"null")) - { - Commands->Set_Animation(obj,Get_Parameter("IdleSecondaryAnim"),true,0,0.0,-1,false); - } - if (number == 4 && _stricmp(Get_Parameter("IdlePrimaryAnim"),"null")) - { - Commands->Set_Animation(obj,Get_Parameter("IdlePrimaryAnim"),true,0,0.0,-1,false); - } - if (number == 5) - { - if (_stricmp(Get_Parameter("SecondaryToPrimaryAnim"),"null")) - Commands->Set_Animation(obj,Get_Parameter("SecondaryToPrimaryAnim"),false,0,0.0,-1,false); - if (_stricmp(Get_Parameter("SecondaryToPrimarySound"),"null")) - Commands->Create_Sound(Get_Parameter("SecondaryToPrimarySound"),Commands->Get_Position(obj),obj); - if (Get_Float_Parameter("SecondaryToPrimaryTime") > -1.0f) - Commands->Start_Timer(obj,this,Get_Float_Parameter("SecondaryToPrimaryTime"),4); - else - Commands->Start_Timer(obj,this,0.0f,4); - } -} -void JMG_Utility_Send_Custom_When_Near_Building::Created(GameObject *obj) -{ - nearBuilding = false; - Commands->Start_Timer(obj,this,Get_Float_Parameter("CheckRate"),1); -} -void JMG_Utility_Send_Custom_When_Near_Building::Timer_Expired(GameObject *obj,int number) -{ - if (number == 1 && Commands->Get_Health(obj)) - { - Vector3 myPos = Commands->Get_Position(obj); - float ClosestDist = FLT_MAX; - for (SLNode *z = GameObjManager::BuildingGameObjList.Head();z;z = z->Next()) - { - if ((Get_Int_Parameter("BuildingPlayerType") == 2 || z->Data()->Get_Player_Type() == Get_Int_Parameter("BuildingPlayerType")) && (!Get_Int_Parameter("CheckDeadBuildings") || !z->Data()->Is_Destroyed())) - { - float Dist = z->Data()->Find_Closest_Poly(myPos); - if (Dist < ClosestDist) - ClosestDist = Dist; - } - } - if (ClosestDist < Get_Float_Parameter("CloseToBuildingDistance") && !nearBuilding) - { - nearBuilding = true; - if (Get_Int_Parameter("SendMessageObjectID")) - Commands->Send_Custom_Event(obj,Commands->Find_Object(Get_Int_Parameter("SendMessageObjectID")),Get_Int_Parameter("NearToBuildingMessage"),0,0); - else - Commands->Send_Custom_Event(obj,obj,Get_Int_Parameter("NearToBuildingMessage"),0,0); - } - if (ClosestDist > Get_Float_Parameter("CloseToBuildingDistance") && nearBuilding) - { - nearBuilding = false; - if (Get_Int_Parameter("SendMessageObjectID")) - Commands->Send_Custom_Event(obj,Commands->Find_Object(Get_Int_Parameter("SendMessageObjectID")),Get_Int_Parameter("FarFromBuildingMessage"),0,0); - else - Commands->Send_Custom_Event(obj,obj,Get_Int_Parameter("FarFromBuildingMessage"),0,0); - } - Commands->Start_Timer(obj,this,Get_Float_Parameter("CheckRate"),1); - } -} -void JMG_Utility_AI_Engineer_Repair_Target::Created(GameObject *obj) -{ -} + ScriptRegistrant JMG_Utility_Check_If_Script_Is_In_Library_Registrant("JMG_Utility_Check_If_Script_Is_In_Library","ScriptName:string,CppName:string"); ScriptRegistrant JMG_Send_Custom_When_Custom_Sequence_Matched_Registrant("JMG_Send_Custom_When_Custom_Sequence_Matched","Success_Custom=0:int,Correct_Step_Custom=0:int,Partial_Failure_Custom=0:int,Failure_Custom=0:int,Send_To_ID=0:int,Custom_0=0:int,Custom_1=0:int,Custom_2=0:int,Custom_3=0:int,Custom_4=0:int,Custom_5=0:int,Custom_6=0:int,Custom_7=0:int,Custom_8=0:int,Custom_9=0:int,Disable_On_Success=1:int,Disable_On_Failure=0:int,Starts_Enabled=1:int,Enable_Custom=0:int,Correct_Step_Safty=0:int,Failure_Safty=1:int,Max_Failures=1:int"); ScriptRegistrant JMG_Utility_Change_Model_On_Timer_Registrant("JMG_Utility_Change_Model_On_Timer","Model=null:string,Time=0:float"); @@ -2518,9 +1649,9 @@ ScriptRegistrant JMG_Utility_Sync_Object_Periodically_Registrant("JMG_Utility_Sync_Object_Periodically","Sync_Rate=1.0:float"); ScriptRegistrant JMG_Utility_Basic_Spawner_Registrant("JMG_Utility_Basic_Spawner","SpawnPreset:string,RespawnTime=0.0:float,RespawnTimeRandom=0:float,StartsEnabled=1:int,EnableMessage=0:int,SpawnLimit=-1:int,DelayOnStartup=0:int"); ScriptRegistrant JMG_Utility_Basic_Spawner_Attach_Registrant("JMG_Utility_Basic_Spawner_Attach","ControllerId:int"); -ScriptRegistrant JMG_Utility_AI_Engineer_Registrant("JMG_Utility_AI_Engineer","RepaiarGun_Preset=Weapon_RepairGun_Player:string,Weapon_Preset=Weapon_Pistol_Player:string,PatrolRange=50.0:float,BaseCenterPoint=0.0 0.0 0.0:vector3,MinHP[Soldiers|Vehicles|Turrets]=0.5 0.75 0.9:vector3,MinHP[EngineerTarget|C4|Beacon]=0.25 0.0 0.0:vector3"); +ScriptRegistrant JMG_Utility_Engineer_AI_Registrant("JMG_Utility_Engineer_AI","RepaiarGun_Preset=Weapon_RepairGun_Player:string,Weapon_Preset=Weapon_Pistol_Player:string,PatrolRange=50.0:float,BaseCenterPoint=0.0 0.0 0.0:vector3"); ScriptRegistrant JMG_Utility_Set_Object_Visibility_For_Player_On_Custom_Registrant("JMG_Utility_Set_Object_Visibility_For_Player_On_Custom","Message:int,PlayerID:int,Visible:int"); -ScriptRegistrant JMG_Utility_AI_Vehicle_Registrant("JMG_Utility_AI_Vehicle","MaxRange=25.0:float,MinAttackRange=0.0:float,FollowTarget=1:int,ReturnHome=1:int,ForceFire=0:int,VTOLHover=0.0:float,vsSoldier=1:int,vsVehicle=1:int,vsAircraft=1:int,WanderingAIGroupID=-1:int,MinRandWander=60.0:float,MaxRandWander=90.0:float,SquishInfantry=1:int,EnableTransitions=0:int,UsePathfind=1:int,DisableEngineOnArrival=1:int,WeaponError=-1.0:float,MaxHuntRange=0.0:float"); +ScriptRegistrant JMG_Utility_AI_Vehicle_Registrant("JMG_Utility_AI_Vehicle","MaxRange=25.0:float,MinAttackRange=0.0:float,FollowTarget=1:int,ReturnHome=1:int,ForceFire=0:int,VTOLHover=0.0:float,vsSoldier=1:int,vsVehicle=1:int,vsAircraft=1:int,WanderingAIGroupID=-1:int,MinRandWander=60.0:float,MaxRandWander=90.0:float,SquishInfantry=1:int,EnableTransitions=0:int,UsePathfind=1:int,DisableEngineOnArrival=1:int,WeaponError=-1.0:float"); ScriptRegistrant JMG_Utility_Dynamic_Clock_Control_Registrant("JMG_Utility_Dynamic_Clock_Control",""); ScriptRegistrant JMG_Utility_Dynamic_Clock_Object_Registrant("JMG_Utility_Dynamic_Clock_Object",""); ScriptRegistrant JMG_Utility_Change_Screen_Color_While_In_Zone_Registrant("JMG_Utility_Change_Screen_Color_While_In_Zone","Color[Red|Green|Blue]:vector3,Opacity:float,EnterFadeInTime:float,ExitFadeOutTime:float"); @@ -2537,19 +1668,4 @@ ScriptRegistrant JMG_Utility_Display_HUD_Info_Text_All_Players_Custom_2_Registrant("JMG_Utility_Display_HUD_Info_Text_All_Players_Custom_Replace_String","Custom:int,StringId:int,ReplaceString:string,ColorRGB:Vector3,Repeatable=1:int"); ScriptRegistrant JMG_Utility_Display_Text_Message_To_All_Players_On_Custom_Registrant("JMG_Utility_Display_Text_Message_To_All_Players_On_Custom","Custom:int,Message:string,ColorRGB:Vector3,Repeatable=1:int"); ScriptRegistrant JMG_Utility_Set_Team_On_Create_Registrant("JMG_Utility_Set_Team_On_Create","PlayerType:int,Delay=0.0:float"); -ScriptRegistrant JMG_Utility_AI_Aggressive_Melee_Registrant("JMG_Utility_AI_Aggressive_Melee","ReturnHomeSpeed=1.0:float,ReturnHomeArriveDistance=1.0:float,ChaseSpeed=1.0:float,AttackArriveDistance=0.0:float,StartAttackDistance=3.0:float,MaxHuntDistance=0.0:float,MinLooseVisibilityTime=3:int,MaxLooseVisibilityTime=6:int,NoPathfindDistance=5.0:float"); -ScriptRegistrant JMG_Utility_Infantry_Placed_Buildable_Object_Registrant("JMG_Utility_Infantry_Placed_Buildable_Object","WeaponPreset=null:string,PreviewPreset=Daves Arrow:string,DeployPreset=null:string,RepairedPreset=null:string,PlaceablePreview=null:string,UnPlaceablePreview=null:string,EnableCustom:int,DisableCustom:int,DeployCustom:int,RegainTimer:int,Cost:float,MessageColor[R|G|B]=255.0 255.0 255.0:vector3,DeploymentBlockedMessage=Cannot deploy when near buildings or swimming.:string,PlacementMessage=You can now place another :string,GrantWeapon=1:int,RegenStartsAfterRepair=1:int,MatchTeam[Preview|Deployed|Repaired]=0.0 0.0 1.0:vector3,DestroyedRegenTime=1:int"); -ScriptRegistrant JMG_Utility_Infantry_Placed_Buildable_Object_Attached_Registrant("JMG_Utility_Infantry_Placed_Buildable_Object_Attached","ScriptId:int,PlacerId:int,RepairedPreset:string,MatchTeam:int,Team:int"); -ScriptRegistrant JMG_Utility_Lock_Weapon_Selection_While_Script_Attached_Registrant("JMG_Utility_Lock_Weapon_Selection_While_Script_Attached","WeaponPreset:string"); -ScriptRegistrant JMG_Utility_Swim_While_In_Zone_Registrant("JMG_Utility_Swimming_Zone","WaterColor[R|G|B]=0.28 0.43 0.55:vector3,WaterOpacity=0.5:float,WaterMinViewDistance=5.0:float,WaterMaxViewDistance=15.0:float"); -ScriptRegistrant JMG_Utility_Swimming_Infantry_Registrant("JMG_Utility_Swimming_Infantry","WeaponPreset=Weapon_Swimming_Animations:string,DrownTime=10.0:float,StarDrownSequence=3.0:float,GaspForBreath=SFX.SwimmingGaspForBreath:string,PantingSoundEmitterModel=s_panting:string,HeartBeatSoundEmitterModel=s_heartBeat:string,DrownDamageRate=2.5:float,CatchBreathRate=0.33:float"); -ScriptRegistrant JMG_Utility_Zone_Enable_Spawners_In_Range_Registrant("JMG_Utility_Zone_Enable_Spawners_In_Range","StartID:int,EndID:int,PlayerType=2:int,Enable=1:int"); -ScriptRegistrant JMG_Utility_Display_Message_On_Vehicle_Enter_Registrant("JMG_Utility_Display_Message_On_Vehicle_Enter","StringId:int,MessageOverride=null:string,Color[R|G|B]=0.0 1.0 0.0:vector3,DriverOnly=1:int,ShowOnce=1:int,PlayerType=2:int"); -ScriptRegistrant JMG_Utility_Zone_Apply_Damage_On_Enter_Registrant("JMG_Utility_Zone_Apply_Damage_On_Enter","ID:int,DamageAmount:float,Warhead=None:string,DamageOccupants=1:int,PlayerType=2:int,OnlyOnce=0:int"); -ScriptRegistrant JMG_Utility_AI_Guardian_Aircraft_Registrant("JMG_Utility_AI_Guardian_Aircraft","WanderingAIGroupID:int,FlightHeight=25.0:float,FireRange=100.0:float,FaceTarget=1:int"); -ScriptRegistrant JMG_Utility_Switch_Weapon_While_Primary_Empty_Registrant("JMG_Utility_Switch_Weapon_While_Primary_Empty","PrimaryWeapon=null:string,SecondaryWeapon=null:string,ReloadTime=0.0:float,PrimaryToSecondaryTime=-1.0:float,SecondaryToPrimaryTime=-1.0:float,IdlePrimaryAnim=null:string,IdleSecondaryAnim=null:string,PrimaryToSecondaryAnim=null:string,SecondaryToPrimaryAnim=null:string,PrimaryToSecondarySound=null:string,SecondaryToPrimarySound=null:string"); -ScriptRegistrant JMG_Utility_Send_Custom_When_Near_Building_Registrant("JMG_Utility_Send_Custom_When_Near_Building","SendMessageObjectID=0:int,NearToBuildingMessage:int,FarFromBuildingMessage:int,CloseToBuildingDistance=1.0:float,BuildingPlayerType=2:int,CheckDeadBuildings=1:int,CheckRate=0.25:float"); -ScriptRegistrant JMG_Utility_AI_Engineer_Repair_Target_Registrant("JMG_Utility_AI_Engineer_Repair_Target",""); - - diff -uwrN source/scripts/jmgUtility.h sourceold/scripts/jmgUtility.h --- source/scripts/jmgUtility.h 2015-11-15 22:30:36.506937500 +1000 +++ sourceold/scripts/jmgUtility.h 2015-10-11 13:18:53.181836000 +1000 @@ -109,18 +109,10 @@ /*! * \brief Basic Engineer AI that will try to repair all OBJECTs in the patrol range, if an enemy gets close they will also shoot at them with their weapon preset. AI is granted the weapons if it does not have them. -* \RepaiarGun_Preset - Weapon preset to use to repair objects -* \Weapon_Preset - Weapon preset to use to attack enemies, if null the AI cannot attack enemies -* \PatrolRange - Area they can wander around in and search for things to repair -* \BaseCenterPoint - Center of the area they can wander in, if 0 0 0 it defaults to their create location -* \MinHP[Soldiers|Vehicles|Turrets] - HP must be below this value to be a repareable target 0 disables the category -* \MinHP[EngineerTarget|C4|Beacon] - EngineerTarget is designated by any object with the script JMG_Utility_AI_Engineer_Repair_Target attached HP percent must be below this value. Beacon C4 means that the engineer will -* \ repair enemy beacons and C4 that currently have over this much of their max health, 1 disables it (the reason for this is is that you can make more engineers attempt to repair c4 or beacons with higher health this way) * \author jgray * \ingroup JmgUtility */ -class JMG_Utility_AI_Engineer : public ScriptImpClass { - bool canFight; +class JMG_Utility_Engineer_AI : public ScriptImpClass { Vector3 centerLocation; float maxRange; int aiIgnorePlayers[128]; @@ -148,7 +140,6 @@ void Damaged(GameObject *obj,GameObject *damager,float damage); bool inRange(GameObject *obj); inline bool Valid_Repair_Target(GameObject *obj,GameObject *target,int playerType); - inline bool Valid_Repair_Target_C4(GameObject *obj,GameObject *target,int playerType); }; /*! * \brief Will change the visibility of an object on custom for the specified player id @@ -1102,18 +1093,37 @@ }; private: SyncObjectNode *syncObjectNodeList; + SyncObjectNode *currentSyncNodeListPosition; struct SyncControl { + bool playersSynced; bool syncedPlayers[128]; SyncObjectNode *lastSyncNode[128]; SyncControl() { + playersSynced = false; for (int x = 0;x < 128;x++) { syncedPlayers[x] = false; lastSyncNode[x] = NULL; } } + bool isSynced(int playerId,SyncObjectNode *currentSyncNode) + { + if (syncedPlayers[playerId]) + return true; + if (!syncedPlayers[playerId] && !lastSyncNode[playerId]) + { + lastSyncNode[playerId] = currentSyncNode; + return false; + } + if (!syncedPlayers[playerId] && lastSyncNode[playerId] == currentSyncNode) + { + syncedPlayers[playerId] = true; + return true; + } + return false; + } void clientNoLongerSynced(int playerId) { syncedPlayers[playerId] = false; @@ -1121,9 +1131,24 @@ } }; SyncControl syncControl; + void updateSyncStates() + { + bool allPlayersSynced = true; + for (int x = 1;x < 128;x++) + { + GameObject *player = Get_GameObj(x); + bool synced = syncControl.isSynced(x,currentSyncNodeListPosition); + if (!player && synced) + syncControl.clientNoLongerSynced(x); + if (player && !synced) + allPlayersSynced = false; + } + syncControl.playersSynced = allPlayersSynced; + } public: ClientNetworkObjectPositionSync() { + currentSyncNodeListPosition = NULL; syncObjectNodeList = NULL; syncControl = SyncControl(); } @@ -1159,40 +1184,33 @@ for (int x = 1;x < 128;x++) { GameObject *player = Get_GameObj(x); - if (!player) + if (!player && syncControl.lastSyncNode[x]) syncControl.clientNoLongerSynced(x); } } void triggerSingleNetworkSync() { - for (int x = 1;x < 128;x++) - { - if (syncControl.syncedPlayers[x]) - continue; - GameObject *player = Get_GameObj(x); - if (!player) - continue; - if (!syncControl.lastSyncNode[x]) - syncControl.lastSyncNode[x] = syncObjectNodeList; - if (syncControl.lastSyncNode[x]) - { - if (syncControl.lastSyncNode[x]->id) - Force_Position_Update_Player(player,syncControl.lastSyncNode[x]->obj); - syncControl.lastSyncNode[x] = syncControl.lastSyncNode[x]->next; - } - if (!syncControl.lastSyncNode[x]) - syncControl.syncedPlayers[x] = true; - } + updateSyncStates(); + if (syncControl.playersSynced) + return; + if (!currentSyncNodeListPosition) + currentSyncNodeListPosition = syncObjectNodeList; + else + currentSyncNodeListPosition = currentSyncNodeListPosition->next; + if (!currentSyncNodeListPosition) + return; + Force_Position_Update(currentSyncNodeListPosition->obj); } void Empty_List() { - SyncObjectNode *temp = syncObjectNodeList,*die; + SyncObjectNode *temp = currentSyncNodeListPosition,*die; while (temp) { die = temp; temp = temp->next; delete die; } + currentSyncNodeListPosition = NULL; syncObjectNodeList = NULL; syncControl = SyncControl(); } @@ -1208,7 +1226,6 @@ ClientNetworkObjectPositionSync::SyncObjectNode *syncNode; void Created(GameObject *obj); void Timer_Expired(GameObject *obj,int number); - void Killed(GameObject *obj,GameObject *killer); void Destroyed(GameObject *obj); public: JMG_Utility_Sync_System_Object() @@ -1332,8 +1349,6 @@ * \EnableTransitions - Whether or not players can get in and out of the vehicle. * \UsePathfind - Tells the unit whether or not to use pathfind. * \DisableEngineOnArrival - Tells the unit whether it should shutdown its engine when it finishes moving, useful for wheeled vehicles so they don't go rolling away. -* \WeaponError - This tells the max weapon error the vehicle can use, if weapon error is -1 it dynamically determines a weapon error to use, this calculation has to do with bullet speed and enemy distance. -* \MaxHuntRange - This variable makes it so the AI can't see anything that is further than x meters from the wander point (or home position) it is currently moving too, if 0 this setting is ignored. * \author jgray * \ingroup JmgUtility */ @@ -1359,8 +1374,6 @@ int myteam; bool inRange; bool drivingBackward; - float maxHuntRangeSquared; - Vector3 lastWanderPointSpot; void Created(GameObject *obj); void Action_Complete(GameObject *obj,int action,ActionCompleteReason reason); void Custom(GameObject *obj,int message,int param,GameObject *sender); @@ -1631,7 +1644,7 @@ */ class JMG_Utility_Set_Model_On_Damage_Percent_4_States : public ScriptImpClass { int damageState; - float healthThresholds[4]; + float healthThresholds[3]; void Created(GameObject *obj); void Damaged(GameObject *obj,GameObject *damager,float damage); void SetModel(GameObject *obj); @@ -1702,291 +1715,3 @@ void Created(GameObject *obj); void Timer_Expired(GameObject *obj,int number); }; - -/*! -* \brief Makes the AI run up to an enemy and attack it as close as possible, used for melee AI -* \ReturnHomeSpeed - How fast it runs home after all enemies are dead -* \ReturnHomeArriveDistance - How close it goes to its original home location before calling it a day -* \ChaseSpeed - The speed multiplier for how fast it runs after enemies -* \AttackArriveDistance - How close it gets to enemies when attempting to attack them -* \StartAttackDistance - The distance at which it can start attacking -* \MaxHuntDistance - The max distance it can hunt a target from its home location -* \MinLooseVisibilityTime - Min amount of time it takes it to forget a target it can't see -* \MaxLooseVisibilityTime - Max amount of time it takes it to forget a target it can't see -* \NoPathfindDistance - At what distance to quit using pathfind, useful for making it not take weird paths to get to the player when close -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_AI_Aggressive_Melee : public ScriptImpClass { - float noPathfindRange; - int LastSeen; - int lastSeenSecondary; - int currentTargetID; - int secondaryTargetId; - int huntorattack; - int waitcount; - Vector3 homelocation; - float speed; - int minVisibilityTime; - int maxVisibilityTime; - float maxHuntDistance; - Vector3 lastPos; - int stuckTime; - int togglePathfind; - bool pathfindOn; - bool forcePathfindOverride; - int stuckReturnHome; - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); - void Enemy_Seen(GameObject *obj,GameObject *seen); - void Damaged(GameObject *obj,GameObject *damager,float damage); - bool chooseTarget(GameObject *obj,GameObject *damager,int *compareId,int *seenTimer); -}; - -/*! -* \brief Script used to make placeable/building objects for infantry -* \WeaponPreset – Weapon that must be selected to deploy/preview -* \PreviewPreset – Preset that is used to display the preview -* \DeployPreset - Preset that is placed when the deploy key is pressed -* \RepairedPreset – Preset that is used when the deployed preset has been fully repaired -* \PlaceablePreview - 3d model used to show the object can be placed -* \UnPlaceablePreview - 3d model used to show the object cannot be placed -* \EnableCustom - Custom message used to enable placement -* \DisableCustom - Custom message used to disable placement (used by db building checking and water) -* \DeployCustom – Custom message that is used to place the deploy preset and sets the ammo to 0, also starts the regain time. -* \RegainTimer - Timer used to give the player the next deployable object after the last was placed -* \Cost - How much it costs the player to place this object -* \MessageColor[R|G|B] – Color of messages to display to the player -* \DeploymentBlockedMessage – Message to display when the object cannot be deployed -* \PlacementMessage – Message that appears when the reload time has finished -* \GrantWeapon - If 1 the weapon defined will be granted as soon as the script is attached. -* \RegenStartsAfterRepair - If 0 regen countdown starts the second you place the object, otherwise it can't start until you repair the object -* \MatchTeam[Preview|Deployed|Repaired] - Match team controls what teams everything is hooked too when placed, if 1 it matches the player teams, if 0 it keeps it set to whatever the preset has for team -* \DestroyedRegenTime - This parameter controls how long it takes to get the object back in inventory if its destroyed before being reparied -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Infantry_Placed_Buildable_Object : public ScriptImpClass { - bool canRegen; - int previewObjectId; - int placementBlocked; - int reloadTime; - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); - void Custom(GameObject *obj,int message,int param,GameObject *sender); - void Killed(GameObject *obj,GameObject *killer); - void Destroyed(GameObject *obj); - void DestroyPreview(); -public: - JMG_Utility_Infantry_Placed_Buildable_Object() - { - placementBlocked = 0; - } -}; -class JMG_Utility_Infantry_Placed_Buildable_Object_Attached : public ScriptImpClass { - void Damaged(GameObject *obj,GameObject *damager,float damage); - void Killed(GameObject *obj,GameObject *killer); -}; - - -/*! -* \brief While this script is attached it will select the weapon in the player's inventory as long as they have that weapon and it isn't selected -* \WeaponPreset - Weapon to select while this script is attached. -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Lock_Weapon_Selection_While_Script_Attached : public ScriptImpClass { - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); -}; - -/*! -* \brief Used to trigger the simple swimming animation system this is to be used along side JMG_Utility_Swimming_Infantry, -* \ any soldiers that enter the script zone without JMG_Utility_Swimming_Infantry attached will die. -* \WaterColor[R|G|B] - Color to fade the screen while in this swimming zone -* \WaterOpacity - How transparent the screen is while in this zone -* \WaterMinViewDistance - The min distance that the fog shows up when underwater -* \WaterMaxViewDistance - The max distance of the fog when underwater -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Swimming_Zone : public ScriptImpClass { - void Created(GameObject *obj); - void Entered(GameObject *obj,GameObject *enter); - void Exited(GameObject *obj,GameObject *exiter); -public: - struct PlayerWaterNode - { - Vector3 waterColor; - float waterColorOpacity; - float waterMinViewDistance; - float waterMaxViewDistance; - PlayerWaterNode() - { - this->waterColor = Vector3(0.28f,0.43f,0.55f); - this->waterColorOpacity = 0.5f; - this->waterMinViewDistance = 5.0f; - this->waterMaxViewDistance = 15.0f; - } - PlayerWaterNode(Vector3 waterColor,float waterColorOpacity,float waterMinViewDistance,float waterMaxViewDistance) - { - this->waterColor = waterColor; - this->waterColorOpacity = waterColorOpacity; - this->waterMinViewDistance = waterMinViewDistance; - this->waterMaxViewDistance = waterMaxViewDistance; - } - }; - static JMG_Utility_Swimming_Zone::PlayerWaterNode waterNode[128]; - static float fogMinDistance; - static float fogMaxDistance; -}; - -/*! -* \brief This script allows a soldier to swim when in a swimming zone. Weapon that is granted should use the Launcher position as -* \ Renegade never made use of that animation set. If using my swimming animations make sure there is a plane for infantry -* \ to stand on 1.466 meters below the water surface. The underwater[playerId] can be accessed from anywhere, allowing you to disable -* \ screen fading when underwater from other scripts. -* \WeaponPreset - Weapon to lock the player to while swimming, make sure its type launcher to make use of my animations -* \DrownTime - Time it takes before you start taking damage when crouched under water for long periods of time -* \StarDrownSequence - How long before you start taking damage to start fading the screen red and the heart beat sound -* \GaspForBreath - This sound is played when you surface from under water after long periods of time -* \PantingSoundEmitterModel - This 3d object is attached to the player and should be a looped sound effect, it exists while getting close to drowning -* \HeartBeatSoundEmitterModel - This 3d object is attached to the player and should be a looped sound effect, it exists while catching your breath -* \DrownDamageRate - Damage applied 10 times a second while drowning -* \CatchBreathRate - Rate at which a character catches its breath when out of the water, 0.1 would recover 1 second of air every second -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Swimming_Infantry : public ScriptImpClass { - int heartBeatSoundId; - int pantSoundId; - char enterWeapon[256]; - int playerId; - bool startedFadeRed; - float drownTime; - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); - void Custom(GameObject *obj,int message,int param,GameObject *sender); - void Killed(GameObject *obj,GameObject *killer); - void Destroyed(GameObject *obj); - void Detach(GameObject *obj); - void CreateSoundEmitter(GameObject *obj,const char *model,int *soundId); - void DestroySoundEmitter(int *soundId); -public: - static bool underwater[128]; - static int waterZoneCount[128]; -}; - -/*! -* \brief Used to enable or disable all spawners within an ID range on zone enter -* \StartID - ID to start at -* \EndID - ID to stop at -* \PlayerType - Player type the zone triggers for -* \Enable - Enable or disable all the spawners in the range -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Zone_Enable_Spawners_In_Range : public ScriptImpClass { - void Entered(GameObject *obj,GameObject *enterer); -}; - -/*! -* \brief Used to display a HUD message to a player that enters a vehicle -* \StringId - ID of the string to display the the player that entered -* \MessageOverride - Message to override the string with, leave null if you want to use the default string -* \Color[R|G|B] - Color of the string to display -* \DriverOnly - Only display this to the driver of the vehicle -* \ShowOnce - Only display this once to each player that enters this vehicle -* \PlayerType - Team required for message to display -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Display_Message_On_Vehicle_Enter : public ScriptImpClass { - bool hasShownMessage[128]; - void Created(GameObject *obj); - void Custom(GameObject *obj,int message,int param,GameObject *sender); -}; - -/*! -* \brief Used to apply damage to an object id or the object that entered the zone, damager is the script zone -* \ID - ID of the object to apply damage to, if ID is 0 damage will be applied to the object entering the zone -* \DamageAmount - Amount of damage to apply to the object -* \Warhead - Warhead to use to damage the object -* \DamageOccupants - If the object is a vehicle the the occupants of the vehicle will be damaged, useful for making a deathzone that kills everything that enters it. -* \PlayerType - Player type required to trigger the script -* \OnlyOnce - Does the script fire one time only -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Zone_Apply_Damage_On_Enter : public ScriptImpClass { - void Entered(GameObject *obj,GameObject *enter); -}; - -/*! -* \brief Makes an aircraft move between wander points, it'll strafe at the target while it has one -* \WanderingAIGroupID - Group of points to wander between -* \FlightHeight - How high it should stay above the points -* \FireRange - Max range that it can use it's guns -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_AI_Guardian_Aircraft : public ScriptImpClass { - Vector3 dpPosition; - int EnemyID; - int EnemyTimeOutTime; - Vector3 LastPos; - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); - void Enemy_Seen(GameObject *obj,GameObject *seen); - void Damaged(GameObject *obj,GameObject *damager,float damage); - void Goto_Location(GameObject *obj); - bool Get_A_Defense_Point(Vector3 *position); -}; - -/*! -* \brief Makes a unit switch its gun to a secondary gun whenever the ammo count in its primary clip runs out -* \PrimaryWeapon - Weapon that the game watches to see if its clip is empty -* \SecondaryWeapon - Weapon that is switched to while the primary weapon is "reloading" -* \ReloadTime - How long it takes to reload the primary weapon -* \PrimaryToSecondaryTime - Time it takes to play the animation to switch to the secondary weapon -* \SecondaryToPrimaryTime - Time it takes to play the animation to switch to the primary weapon -* \IdlePrimaryAnim - Animation to play while using the primary weapon -* \IdleSecondaryAnim - Animation to play while using the secondary weapon -* \PrimaryToSecondaryAnim - Animation to play while switching to the secondary weapon -* \SecondaryToPrimaryAnim - Animation to play while switching to the primary weapon -* \PrimaryToSecondarySound - Sound to play while switching to the secondary weapon -* \SecondaryToPrimarySound - Sound to play while switching to the primary weapon -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Switch_Weapon_While_Primary_Empty : public ScriptImpClass { - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); -}; - -/*! -* \brief Sends a custom when an object gets near a building or moves away from a building -* \SendMessageObjectID - ID of the object to send the message to, if 0 it sends the messages to itself -* \NearToBuildingMessage - Message to send when a building is within range -* \FarFromBuildingMessage - Message to send when buildings are no longer within range -* \CloseToBuildingDistance - Distance to the nearest POLYGONS CENTER POINT of the building to count as being in range -* \BuildingPlayerType - Player type required to detect the building -* \CheckDeadBuildings - If true dead buildings are also checked -* \CheckRate - How often should the range detection be preformend -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_Send_Custom_When_Near_Building : public ScriptImpClass { - bool nearBuilding; - void Created(GameObject *obj); - void Timer_Expired(GameObject *obj,int number); -}; - -/*! -* \brief Used to designate repair targets for the Engineer AI that are things other than vehicles, turrets, and soldiers -* \author jgray -* \ingroup JmgUtility -*/ -class JMG_Utility_AI_Engineer_Repair_Target : public ScriptImpClass { - void Created(GameObject *obj); -}; \ No newline at end of file