Hallo Leute
ich hätte ein kleines Script-Problem: Ich habe mal versucht, im Script den Souvereign-Kreuzer automatisch seinen Phaser abzufeuern, egal ob KI oder menschlicher Spieler. Es feuert aber nicht, was mich zu schaffen macht, und deshalb wende ich mich an euch. Könnt ihr mein Problem lösen?
Hier der Script (Souvereign.lua):
Spoiler:
Und hier die entsprechende Einheit:
Spoiler:
ich hätte ein kleines Script-Problem: Ich habe mal versucht, im Script den Souvereign-Kreuzer automatisch seinen Phaser abzufeuern, egal ob KI oder menschlicher Spieler. Es feuert aber nicht, was mich zu schaffen macht, und deshalb wende ich mich an euch. Könnt ihr mein Problem lösen?
Hier der Script (Souvereign.lua):
Spoiler:
Code:
require("PGStateMachine") function Definitions() Define_State("State_Init", State_Init); unit_trigger_number = 1 force_trigger_number = 5 ability_range = 900 min_threat_to_use_ability = 1000 ability_name = "ENERGY_BEAM" area_of_effect = 600 end function State_Init(message) if message == OnEnter then --MessageBox("%s--Object:%s", tostring(Script), tostring(Object)) -- prevent this from doing anything in galactic and ground mode --MessageBox("%s, mode %s", tostring(Script), Get_Game_Mode()) if Get_Game_Mode() ~= "Space" then return end -- -- Bail out if this is a human player -- if Object.Get_Owner().Is_Human() then -- ScriptExit() -- end -- Wir brauchen diesen Vorgang, auch wenn es ein menschlicher Spieler ist -- Register a proximity around this unit rebel_player = Find_Player("EMPIRE") Register_Prox(Object, Unit_Prox, ability_range, rebel_player) elseif message == OnUpdate then -- reset tracked units each service. nearby_unit_count = 0 recent_enemy_units = {} end end -- If an enemy enters the prox, the unit may want to use the ability function Unit_Prox(self_obj, trigger_obj) DebugMessage("%s -- In Prox", tostring(Script)) -- Note: we're explicitly tracking individual infantry here (as opposed to their parents, the squads) if not trigger_obj then DebugMessage("Warning: prox received a nil trigger_obj .") return end -- If we haven't seen this unit recently, track him if recent_enemy_units[trigger_obj] == nil then recent_enemy_units[trigger_obj] = trigger_obj nearby_unit_count = nearby_unit_count + 1 DebugMessage("%s -- Nearby unit count %d", tostring(Script), nearby_unit_count) if Object.Is_Ability_Ready(ability_name) then DebugMessage("%s -- ability ready: %s", tostring(Script), ability_name) if (nearby_unit_count >= unit_trigger_number) then DebugMessage("%s -- met min trigger number", tostring(Script)) aoe_pos, aoe_victim_threat = Find_Best_Local_Threat_Center(recent_enemy_units, area_of_effect) if (aoe_pos ~= nil) then if (aoe_victim_threat > min_threat_to_use_ability) then DebugMessage("%s -- met min threat triggered; activating ability", tostring(Script)) Try_Ability(Object, ability_name, aoe_pos) end if (nearby_unit_count >= force_trigger_number) then DebugMessage("%s -- an excess of units nearby; activating ability", tostring(Script)) Try_Ability(Object, ability_name, aoe_pos) end end end end end end
Und hier die entsprechende Einheit:
Spoiler:
Code:
<SpaceUnit Name="Souvereign_Destroyer"> <Text_ID>TEXT_UNIT_SOUVEREIGN</Text_ID> <Encyclopedia_Good_Against> Tartan_Patrol_Cruiser IPV1_System_Patrol_Craft </Encyclopedia_Good_Against> <Encyclopedia_Vulnerable_To> TIE_Bomber Star_Destroyer Victory_Destroyer </Encyclopedia_Vulnerable_To> <GUI_Row> 2 </GUI_Row> <Space_Model_Name>FED_SOUVEREIGN.ALO</Space_Model_Name> <No_Colorization_Color> 182, 182, 182, 255 </No_Colorization_Color> <Mass>0.8</Mass> <Scale_Factor>2.5</Scale_Factor> <Dense_FOW_Reveal_Range_Multiplier>0.2</Dense_FOW_Reveal_Range_Multiplier> <Damage>40</Damage> <Autoresolve_Health>3600</Autoresolve_Health> <Shield_Points>3500</Shield_Points> <Tactical_Health>6000</Tactical_Health> <Shield_Refresh_Rate>100</Shield_Refresh_Rate> <Energy_Capacity>5000</Energy_Capacity> <Energy_Refresh_Rate>500</Energy_Refresh_Rate> <Lua_Script>Souvereign</Lua_Script> <Ranking_In_Category>6</Ranking_In_Category> <Max_Speed>3.5</Max_Speed> <Max_Rate_Of_Turn>1.2</Max_Rate_Of_Turn> <MovementClass> Space </MovementClass> <Space_Layer> Frigate </Space_Layer> <Layer_Z_Adjust>-90.0</Layer_Z_Adjust> <Max_Rate_Of_Roll>0.6</Max_Rate_Of_Roll> <Bank_Turn_Angle>25</Bank_Turn_Angle> <OverrideAcceleration> .04 </OverrideAcceleration> <OverrideDeceleration> .04 </OverrideDeceleration> <Armor_Type> Armor_Nebulon_B </Armor_Type> <Shield_Armor_Type>Shield_Frigate</Shield_Armor_Type> <Max_Thrust>1.5</Max_Thrust> <Hyperspace>Yes</Hyperspace> <Select_Box_Scale>290</Select_Box_Scale> <Select_Box_Z_Adjust>-30</Select_Box_Z_Adjust> <Ranged_Target_Z_Adjust>35.0</Ranged_Target_Z_Adjust> <Hyperspace_Speed>1.1</Hyperspace_Speed> <Maintenance_Cost>0.1</Maintenance_Cost> <Affiliation>Rebel</Affiliation> <Build_Initially_Locked>No</Build_Initially_Locked> <Build_Can_Be_Unlocked_By_Slicer>Yes</Build_Can_Be_Unlocked_By_Slicer> <Slice_Cost_Credits>400</Slice_Cost_Credits> <Tech_Level>0</Tech_Level> <Required_Timeline>0</Required_Timeline> <Required_Ground_Base_Level>0</Required_Ground_Base_Level> <Required_Star_Base_Level>2</Required_Star_Base_Level> <Required_Special_Structures /> <Required_Planets /> <Ship_Class>frigate</Ship_Class> <Formation_Priority>3</Formation_Priority> <Is_Escort>yes</Is_Escort> <Is_Bomber>no</Is_Bomber> <Political_Control>0</Political_Control> <Squadron_Capacity>10</Squadron_Capacity> <Transport_Capacity>16</Transport_Capacity> <Number_per_Squadron>1</Number_per_Squadron> <Build_Cost_Credits>15000</Build_Cost_Credits> <AI_Combat_Power>2200</AI_Combat_Power> <Build_Time_Seconds>30</Build_Time_Seconds> <Build_Tab_Space_Units>Yes</Build_Tab_Space_Units> <Size_Value>8</Size_Value> <Behavior> DUMMY_STARSHIP, SELECTABLE, POWERED, SHIELDED </Behavior> <SpaceBehavior>ABILITY_COUNTDOWN, SIMPLE_SPACE_LOCOMOTOR, TARGETING, REVEAL, HIDE_WHEN_FOGGED, UNIT_AI, ASTEROID_FIELD_DAMAGE, DAMAGE_TRACKING, ION_STUN_EFFECT, NEBULA, SPAWN_SQUADRON</SpaceBehavior> <Space_FOW_Reveal_Range>1200.0</Space_FOW_Reveal_Range> <Targeting_Max_Attack_Distance>1000.0</Targeting_Max_Attack_Distance> <Collidable_By_Projectile_Living>Yes</Collidable_By_Projectile_Living> <Death_Explosions>Large_Explosion_Space</Death_Explosions> <Death_Leave_Hulk_Behind> No </Death_Leave_Hulk_Behind> <Asteroid_Damage_Hit_Particles>Large_Damage_Space</Asteroid_Damage_Hit_Particles> <HardPoints> HP_Destroyer_00, HP_Destroyer_01, HP_Destroyer_05, HP_Destroyer_06, HP_Destroyer_03, HP_Destroyer_07, HP_Destroyer_Photon </HardPoints> <CategoryMask> Frigate | AntiCorvette</CategoryMask> <Icon_Name>Souvereign.tga</Icon_Name> <GUI_Model_Name>FED_SOUVEREIGN.ALO</GUI_Model_Name> <GUI_Distance>1000</GUI_Distance> <GUI_Offset>0 0 0</GUI_Offset> <GUI_Velocity>45</GUI_Velocity> <Victory_Relevant>yes</Victory_Relevant> <Has_Space_Evaluator>True</Has_Space_Evaluator> <SFXEvent_Build_Started>RHD_Build_Vehicle</SFXEvent_Build_Started> <SFXEvent_Build_Cancelled>RHD_Unit_Canceled</SFXEvent_Build_Cancelled> <SFXEvent_Build_Complete>Unit_Complete_Alpha10X</SFXEvent_Build_Complete> <SFXEvent_Ambient_Loop></SFXEvent_Ambient_Loop> <SFXEvent_Select>Unit_Select_Alpha10X</SFXEvent_Select> <SFXEvent_Move>Unit_Move_Alpha10X</SFXEvent_Move> <SFXEvent_Fleet_Move>Unit_Fleet_Move_Alpha10X</SFXEvent_Fleet_Move> <SFXEvent_Attack>Unit_Attack_Alpha10X</SFXEvent_Attack> <SFXEvent_Guard>Unit_Guard_Alpha10X</SFXEvent_Guard> <SFXEvent_Stop>Unit_Stop_Alpha10X</SFXEvent_Stop> <SFXEvent_Barrage>Unit_Barrage_Alpha10X</SFXEvent_Barrage> <SFXEvent_Move_Into_Asteroid_Field> Unit_Asteroids_Alpha10X </SFXEvent_Move_Into_Asteroid_Field> <SFXEvent_Move_Into_Nebula> Unit_Nebula_Alpha10X </SFXEvent_Move_Into_Nebula> <SFXEvent_Damaged_By_Asteroid> SFX_Asteroid_Detonation </SFXEvent_Damaged_By_Asteroid> <SFXEvent_Attack_Hardpoint> HARD_POINT_WEAPON_LASER, Unit_HP_LASER_Alpha10X </SFXEvent_Attack_Hardpoint> <SFXEvent_Attack_Hardpoint> HARD_POINT_WEAPON_MISSILE, Unit_HP_MISSILE_Alpha10X </SFXEvent_Attack_Hardpoint> <SFXEvent_Attack_Hardpoint> HARD_POINT_WEAPON_TORPEDO, Unit_HP_TORP_Alpha10X </SFXEvent_Attack_Hardpoint> <SFXEvent_Attack_Hardpoint> HARD_POINT_WEAPON_ION_CANNON, Unit_HP_ION_Alpha10X </SFXEvent_Attack_Hardpoint> <SFXEvent_Attack_Hardpoint> HARD_POINT_SHIELD_GENERATOR, Unit_HP_SHIELDS_Alpha10X </SFXEvent_Attack_Hardpoint> <SFXEvent_Attack_Hardpoint> HARD_POINT_ENGINE, Unit_HP_ENGINES_Alpha10X </SFXEvent_Attack_Hardpoint> <SFXEvent_Attack_Hardpoint> HARD_POINT_GRAVITY_WELL, Unit_HP_GRAV_Alpha10X </SFXEvent_Attack_Hardpoint> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_WEAPON_LASER, Unit_Lost_Laser_Alpha10X </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_WEAPON_MISSILE, </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_WEAPON_TORPEDO, </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_WEAPON_ION_CANNON, </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_SHIELD_GENERATOR, Unit_Lost_Shields_Alpha10X </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_ENGINE, Unit_Lost_Engines_Alpha10X </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_GRAVITY_WELL, </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_FIGHTER_BAY, </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_TRACTOR_BEAM, </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Hardpoint_Destroyed> HARD_POINT_ENABLE_SPECIAL_ABILITY, </SFXEvent_Hardpoint_Destroyed> <SFXEvent_Engine_Idle_Loop> </SFXEvent_Engine_Idle_Loop> <SFXEvent_Engine_Moving_Loop> </SFXEvent_Engine_Moving_Loop> <SFXEvent_Engine_Cinematic_Focus_Loop> </SFXEvent_Engine_Cinematic_Focus_Loop> <Death_SFXEvent_Start_Die></Death_SFXEvent_Start_Die> <Space_Full_Stop_Command> Yes </Space_Full_Stop_Command> <Is_Visible_On_Radar>Yes</Is_Visible_On_Radar> <Radar_Icon_Scale_Land>1.0</Radar_Icon_Scale_Land> <Radar_Icon_Scale_Space>1.0</Radar_Icon_Scale_Space> <Guard_Chase_Range>1000.0</Guard_Chase_Range> <Idle_Chase_Range>0.0</Idle_Chase_Range> <Attack_Move_Response_Range>400.0</Attack_Move_Response_Range> <Targeting_Stickiness_Time_Threshold>5.0</Targeting_Stickiness_Time_Threshold> <Targeting_Priority_Set>Frigate</Targeting_Priority_Set> <Unit_Abilities_Data SubObjectList="Yes"> <Unit_Ability> <Type>ENERGY_WEAPON</Type> <Energy_Beam_Texture>w_XIIPhaser_tex.tga</Energy_Beam_Texture> <Energy_Beam_Color>0, 230, 255</Energy_Beam_Color> <GUI_Activated_Ability_Name> Piet_Energy_Weapon_Attack_Ability </GUI_Activated_Ability_Name> <!-- GUI Command Bar support --> <Recharge_Seconds>1</Recharge_Seconds> <Expiration_Seconds>1</Expiration_Seconds> <SFXEvent_Target_Ability> Unit_Energy_Blast_Piett </SFXEvent_Target_Ability> <SFXEvent_Special_Ability_Loop> Unit_Star_Destroyer_Energy_Blast </SFXEvent_Special_Ability_Loop> </Unit_Ability> </Unit_Abilities_Data> <Abilities SubObjectList="Yes"> <Energy_Weapon_Attack_Ability Name="Piet_Energy_Weapon_Attack_Ability"> <Activation_Style> Space_Automatic </Activation_Style> <Applicable_Unit_Categories>Capital | Corvette | Frigate | Fighter | Bomber | Transport</Applicable_Unit_Categories> <Applicable_Unit_Types /> <Owner_Particle_Effect>Piet_Powerup_Particle_Effect</Owner_Particle_Effect> <Owner_Particle_Bone_Name>HP_main_phaser</Owner_Particle_Bone_Name> <Activation_Min_Range>0</Activation_Min_Range> <Activation_Max_Range>1000</Activation_Max_Range> <Energy_Beam_Texture>w_XIIPhaser_tex.tga</Energy_Beam_Texture> <Energy_Beam_Color>0, 230, 255</Energy_Beam_Color> <!-- Modifiers. If 0 - no modifier is applied, 1 - "100% increase or decrease" --> <Damage_Per_Frame>50</Damage_Per_Frame> </Energy_Weapon_Attack_Ability> </Abilities> <Encyclopedia_Text> TEXT_TOOLTIP_SOUVEREIGN</Encyclopedia_Text> <Encyclopedia_Unit_Class> TEXT_ENCYCLOPEDIA_CLASS_CRUISER </Encyclopedia_Unit_Class> <Score_Cost_Credits> 2250</Score_Cost_Credits> <!--<MULTIPLAYER SKIRMISH VALUES BEGIN>--> <Tactical_Build_Cost_Multiplayer>200</Tactical_Build_Cost_Multiplayer> <Tactical_Build_Time_Seconds>1</Tactical_Build_Time_Seconds> <Tactical_Build_Prerequisites /> <Tactical_Production_Queue>Tactical_Units</Tactical_Production_Queue> <!--<Build_Limit_Current_Per_Player>0</Build_Limit_Current_Per_Player>--> <!--<Build_Limit_Lifetime_Per_Player>0</Build_Limit_Lifetime_Per_Player>--> <!--<MULTIPLAYER SKIRMISH VALUES END>--> <Population_Value>220</Population_Value> </SpaceUnit>
Kommentar