| 08-15-2006, 11:38 PM | #1 |
Can you animate a missile or special effect on creation? That doesnt really make sense. Could you make a missile or special effect play a certain animation? |
| 08-16-2006, 12:00 AM | #2 |
not really... you could rename the animation you want with war3 model editor for example and that way change attack for example to stand thus making the editor use this animation for that missile. or you could "emulate" the missile using a dummy unit and a trigger to move it. however if you have no experience with these things i really recommend renaming the animation. |
| 08-16-2006, 12:02 AM | #3 |
Hrmm... well thanks for the reply. I think my limited scope on triggering may let me do the second thing. As I dont have war3 model editor right now, that wouldnt work. I suppose I could get it... |
| 08-16-2006, 12:07 AM | #4 |
| 08-16-2006, 12:08 AM | #5 |
Oh nothing in particular. I was just wondering if there was a way. If you mean in relation to my other problems recently, nothing. Most of them arent connected. I cant really work on one project. |
| 08-16-2006, 12:11 AM | #6 |
I dont think you should, but you could use my CF engine. Its not working great recently, but its working. Its mainly towards effects, so it could come in handy. The lastest function added is a projectile, which has been reworked alot of times. It moves effects around. It cant make a effect play a specific animation, but it can do alot of things. List: JASS:function CF_CreateGroundEffect takes real X, real Y, real Z, real facing, real sizeFactor, string modelPath, integer red, integer green, integer blue, integer alpha returns effect function CF_GetLastCreatedEffect takes nothing returns effect function CF_GetEffectCarryingUnit takes effect whichEffect returns unit function CF_GetEffectX takes effect whichEffect returns real function CF_GetEffectY takes effect whichEffect returns real function CF_GetEffectZ takes effect whichEffect returns real function CF_GetEffectFacing takes effect whichEffect returns real function CF_GetEffectSize takes effect whichEffect returns real function CF_GetEffectModelPath takes effect whichEffect returns string function CF_GetEffectRedColour takes effect whichEffect returns integer function CF_GetEffectGreenColour takes effect whichEffect returns integer function CF_GetEffectBlueColour takes effect whichEffect returns integer function CF_GetEffectAlphaColour takes effect whichEffect returns integer function CF_IsEffectLocked takes effect whichEffect returns boolean function CF_IsEffectInRect takes effect whichEffect, real minX, real minY, real maxX, real maxY returns boolean function CF_IsEffectInRectEx takes effect whichEffect, rect whichRect returns boolean function CF_IsEffectInRange takes effect whichEffect, real X, real Y, real radius returns boolean function CF_IsEffectInRangeEx takes effect whichEffect, location whichLocation, real radius returns boolean function CF_SetEffectX takes effect whichEffect, real X returns nothing function CF_SetEffectY takes effect whichEffect, real Y returns nothing function CF_SetEffectLoc takes effect whichEffect, real X, real Y returns nothing function CF_SetEffectLocEx takes effect whichEffect, location whichLocation returns nothing function CF_SetEffectZ takes effect whichEffect, real newZ returns nothing function CF_SetEffectFacing takes effect whichEffect, real facing returns nothing function CF_SetEffectSize takes effect whichEffect, real sizeFactor returns nothing function CF_EffectAddExpirationTime_Destroy takes nothing returns nothing function CF_EffectAddExpirationTime takes effect whichEffect, real time returns nothing function CF_SetEffectColour takes effect whichEffect, integer red, integer green, integer blue, integer alpha returns nothing function CF_SetEffectRedColour takes effect whichEffect, integer red returns nothing function CF_SetEffectGreenColour takes effect whichEffect, integer green returns nothing function CF_SetEffectBlueColour takes effect whichEffect, integer blue returns nothing function CF_SetEffectAlphaColour takes effect whichEffect, integer alpha returns nothing function CF_CopyEffect takes effect whichEffect returns effect function CF_CopyEffectLoc takes effect whichEffect, real X, real Y returns effect function CF_CopyEffectLocEx takes effect whichEffect, location whichLocation returns effect function CF_LockEffect takes effect whichEffect returns nothing function CF_UnlockEffect takes effect whichEffect returns nothing function CF_LockEffectEdit takes effect whichEffect, boolean lock returns nothing function CF_ShowEffectForPlayer takes effect whichEffect, player whichPlayer returns nothing function CF_HideEffectForPlayer takes effect whichEffect, player whichPlayer returns nothing function CF_DisplayEffectForPlayer takes effect whichEffect, player whichPlayer, boolean show returns nothing function CF_LaunchTargetProjectile_Update takes nothing returns nothing function CF_LaunchTargetProjectileSimple takes unit Credit, unit Target, real Damage, real Speed, string ModelPath returns nothing function CF_LaunchTargetProjectileCustom takes unit Credit, unit Target, real Damage, real Speed, string ModelPath, integer Red, integer Green, integer Blue, integer Alpha, real Height, real Size, real Duration returns nothing If your interested, heres the CF engine: Copy and Paste it, and remove the global/endglobal part, and add a global Gamecache called GC. JASS:// Casual Functions Engine // Created and Updated by The)TideHunter( // Creation Began: 28/05/06 // Last Updated: 06/08/06 //================================================== // Global, the gamecache is needed for CS Functions to work globals gamecache udg_GC = null endglobals //================================================== // This is the GameCache return function function CF_GC takes nothing returns gamecache if(udg_GC == null) then call FlushGameCache(InitGameCache("GC")) set udg_GC = InitGameCache("GC") endif return udg_GC endfunction //================================================== // Constants:- // You may edit these to fit what you want. constant function CF_Constant_CollisionDetectionRange takes nothing returns real return 25. // This is the value used in functions that use a collision method. // When the functions collision comes in this range, the function // will do whats its meant to do. endfunction constant function CF_Constant_MinTimerUpdate takes nothing returns real return 0.04 // This looks convincing, and isent lag friendly. // Credit: Vexorian // This was the value I used from his Caster System. endfunction constant function CF_Constant_DummyUnitRawcode takes nothing returns integer return '????' // Dummy rawcode or your dummy. // This 'MUST' be Vexorian's custom created dummy model. // ~It has the correct attachment points. endfunction constant function CF_Constant_MorphUnitFlyAbilityRawcode takes nothing returns integer return 'Amrf' // Rawcode of the Morph ability in your map. endfunction constant function CF_Constant_SimpleProjectileHeight takes nothing returns real return 5. endfunction //================================================== // Variable Switches function CF_B2I takes boolean B returns integer if(B) then return 1 endif return 0 endfunction function CF_I2B takes integer I returns boolean if(I == 1) then return true endif return false endfunction function CF_B2S takes boolean B returns string return I2S(CF_B2I(B)) endfunction function CF_S2B takes string S returns boolean return CF_I2B(S2I(S)) endfunction //================================================== // Return Bug function CF_H2I takes handle H returns integer return H return 0 endfunction function CF_H2S takes handle H returns string return I2S(CF_H2I(H)) endfunction function CF_I2Ability takes integer I returns ability return I return null endfunction function CF_I2AIDifficulty takes integer I returns aidifficulty return I return null endfunction function CF_I2AillianceType takes integer I returns alliancetype return I return null endfunction function CF_I2AttackType takes integer I returns attacktype return I return null endfunction function CF_I2Blendmode takes integer I returns blendmode return I return null endfunction function CF_I2BooleanExpression takes integer I returns boolexpr return I return null endfunction function CF_I2Buff takes integer I returns buff return I return null endfunction function CF_I2Button takes integer I returns button return I return null endfunction function CF_I2Camerafield takes integer I returns camerafield return I return null endfunction function CF_I2CameraSetup takes integer I returns camerasetup return I return null endfunction function CF_I2ConditionFunction takes integer I returns conditionfunc return I return null endfunction function CF_I2DamageType takes integer I returns damagetype return I return null endfunction function CF_I2DefeatCondition takes integer I returns defeatcondition return I return null endfunction function CF_I2SDestructable takes integer I returns destructable return I return null endfunction function CF_I2Dialog takes integer I returns dialog return I return null endfunction function CF_I2DialogEvent takes integer I returns dialogevent return I return null endfunction function CF_I2Effect takes integer I returns effect return I return null endfunction function CF_I2EffectType takes integer I returns effecttype return I return null endfunction function CF_I2Event takes integer I returns event return I return null endfunction function CF_I2EffectID takes integer I returns eventid return I return null endfunction function CF_I2FGameState takes integer I returns fgamestate return I return null endfunction function CF_I2FilterFunction takes integer I returns filterfunc return I return null endfunction function CF_I2FogModifier takes integer I returns fogmodifier return I return null endfunction function CF_I2FogState takes integer I returns fogstate return I return null endfunction function CF_I2Force takes integer I returns force return I return null endfunction function CF_I2GameCache takes integer I returns gamecache return I return null endfunction function CF_I2GameDifficulty takes integer I returns gamedifficulty return I return null endfunction function CF_I2GameEvent takes integer I returns gameevent return I return null endfunction function CF_I2GameSpeed takes integer I returns gamespeed return I return null endfunction function CF_I2GameState takes integer I returns gamestate return I return null endfunction function CF_I2GameType takes integer I returns gametype return I return null endfunction function CF_I2Group takes integer I returns group return I return null endfunction function CF_I2IGameState takes integer I returns igamestate return I return null endfunction function CF_I2Image takes integer I returns image return I return null endfunction function CF_I2Item takes integer I returns item return I return null endfunction function CF_I2ItemPool takes integer I returns itempool return I return null endfunction function CF_I2ItemType takes integer I returns itemtype return I return null endfunction function CF_I2Leaderboard takes integer I returns leaderboard return I return null endfunction function CF_I2Lightning takes integer I returns lightning return I return null endfunction function CF_I2Limitop takes integer I returns limitop return I return null endfunction function CF_I2Location takes integer I returns location return I return null endfunction function CF_I2MapControl takes integer I returns mapcontrol return I return null endfunction function CF_I2MapDensity takes integer I returns mapdensity return I return null endfunction function CF_I2MapFlag takes integer I returns mapflag return I return null endfunction function CF_I2MapSetting takes integer I returns mapsetting return I return null endfunction function CF_I2MapVisability takes integer I returns mapvisibility return I return null endfunction function CF_I2Multiboard takes integer I returns multiboard return I return null endfunction function CF_I2MultiboardItem takes integer I returns multiboarditem return I return null endfunction function CF_I2PathingType takes integer I returns pathingtype return I return null endfunction function CF_I2Placement takes integer I returns placement return I return null endfunction function CF_I2Player takes integer I returns player return I return null endfunction function CF_I2PlayerColor takes integer I returns playercolor return I return null endfunction function CF_I2PlayerEvent takes integer I returns playerevent return I return null endfunction function CF_I2PlayerGameResult takes integer I returns playergameresult return I return null endfunction function CF_I2PlayerScore takes integer I returns playerscore return I return null endfunction function CF_I2PlayerSlotState takes integer I returns playerslotstate return I return null endfunction function CF_I2PlayerState takes integer I returns playerstate return I return null endfunction function CF_I2PlayerUnitEvent takes integer I returns playerunitevent return I return null endfunction function CF_I2Quest takes integer I returns quest return I return null endfunction function CF_I2QuestItem takes integer I returns questitem return I return null endfunction function CF_I2Race takes integer I returns race return I return null endfunction function CF_I2RacePreference takes integer I returns racepreference return I return null endfunction function CF_I2RarityControl takes integer I returns raritycontrol return I return null endfunction function CF_I2Rect takes integer I returns rect return I return null endfunction function CF_I2Region takes integer I returns region return I return null endfunction function CF_I2Sound takes integer I returns sound return I return null endfunction function CF_I2SoundType takes integer I returns soundtype return I return null endfunction function CF_I2StartLocPrio takes integer I returns startlocprio return I return null endfunction function CF_I2TerrainDeformation takes integer I returns terraindeformation return I return null endfunction function CF_I2TexMapFlags takes integer I returns texmapflags return I return null endfunction function CF_I2TextTag takes integer I returns texttag return I return null endfunction function CF_I2Timer takes integer I returns timer return I return null endfunction function CF_I2TimerDialog takes integer I returns timerdialog return I return null endfunction function CF_I2Trackable takes integer I returns trackable return I return null endfunction function CF_I2Trigger takes integer I returns trigger return I return null endfunction function CF_I2TriggerAction takes integer I returns triggeraction return I return null endfunction function CF_I2TriggerCondition takes integer I returns triggercondition return I return null endfunction function CF_I2Ubersplat takes integer I returns ubersplat return I return null endfunction function CF_I2Unit takes integer I returns unit return I return null endfunction function CF_I2UnitEvent takes integer I returns unitevent return I return null endfunction function CF_I2UnitPool takes integer I returns unitpool return I return null endfunction function CF_I2UnitState takes integer I returns unitstate return I return null endfunction function CF_I2UnitType takes integer I returns unittype return I return null endfunction function CF_I2Version takes integer I returns version return I return null endfunction function CF_I2VolumeGroup takes integer I returns volumegroup return I return null endfunction function CF_I2WeaponType takes integer I returns weapontype return I return null endfunction function CF_I2WeatherEffect takes integer I returns weathereffect return I return null endfunction function CF_I2Widget takes integer I returns widget return I return null endfunction function CF_I2WidgetEvent takes integer I returns widgetevent return I return null endfunction //================================================== // Attach and Store Variables:- // Allows the attaching and storing of game data. function CF_StoreInteger takes integer whichInteger, string label returns nothing if(whichInteger != 0) then call StoreInteger(CF_GC(), label, "Integer", whichInteger) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_StoreReal takes real whichReal, string label returns nothing if(whichReal != 0.) then call StoreReal(CF_GC(), label, "Real", whichReal) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_StoreString takes string whichString, string label returns nothing if(whichString != "") then call StoreString(CF_GC(), label, "String", whichString) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_StoreBoolean takes boolean whichBoolean, string label returns nothing local integer i = CF_B2I(whichBoolean) if(i == 1) then call StoreInteger(CF_GC(), label, "Boolean", i) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_StoreHandle takes handle whichHandle, string label, string HandleType returns nothing local integer i = CF_H2I(whichHandle) if(i != 0) then call StoreInteger(CF_GC(), label, HandleType, i) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_LoadInteger takes string label returns integer return GetStoredInteger(CF_GC(), label, "Integer") endfunction function CF_LoadReal takes string label returns real return GetStoredReal(CF_GC(), label, "Real") endfunction function CF_LoadString takes string label returns string return GetStoredString(CF_GC(), label, "String") endfunction function CF_LoadBoolean takes string label returns boolean return CF_I2B(GetStoredInteger(CF_GC(), label, "Boolean")) endfunction function CF_LoadUnit takes string label returns unit return CF_I2Unit(GetStoredInteger(CF_GC(), label, "Unit")) endfunction function CF_LoadEffect takes string label returns effect return CF_I2Effect(GetStoredInteger(CF_GC(), label, "Effect")) endfunction function CF_LoadPlayer takes string label returns player return CF_I2Player(GetStoredInteger(CF_GC(), label, "Player")) endfunction function CF_LoadTrigger takes string label returns trigger return CF_I2Trigger(GetStoredInteger(CF_GC(), label, "Trigger")) endfunction function CF_LoadTimer takes string label returns timer return CF_I2Timer(GetStoredInteger(CF_GC(), label, "Timer")) endfunction function CF_LoadDialog takes string label returns dialog return CF_I2Dialog(GetStoredInteger(CF_GC(), label, "Dialog")) endfunction function CF_LoadButton takes string label returns button return CF_I2Button(GetStoredInteger(CF_GC(), label, "Button")) endfunction function CF_AttachInteger takes integer whichInteger, string label, handle KeyHandle returns nothing local integer i = CF_H2I(KeyHandle) if(i != 0) then call StoreInteger(CF_GC(), label, I2S(i), whichInteger) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_AttachReal takes real whichReal, string label, handle KeyHandle returns nothing local integer i = CF_H2I(KeyHandle) if(i != 0) then call StoreReal(CF_GC(), label, I2S(i), whichReal) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_AttachString takes string whichString, string label, handle KeyHandle returns nothing local integer i = CF_H2I(KeyHandle) if(i != 0) then call StoreString(CF_GC(), label, I2S(i), whichString) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_AttachBoolean takes boolean whichBoolean, string label, handle KeyHandle returns nothing local integer b = CF_B2I(whichBoolean) local integer i = CF_H2I(KeyHandle) if(i != 0) then call StoreInteger(CF_GC(), label, I2S(i), b) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_AttachHandle takes handle whichHandle, string label, handle KeyHandle returns nothing local integer h = CF_H2I(whichHandle) local integer i = CF_H2I(KeyHandle) if(i+h != 0) then call StoreInteger(CF_GC(), label, I2S(i), h) else call FlushStoredMission(CF_GC(), label) endif endfunction function CF_GetAttachedInteger takes handle KeyHandle, string label returns integer return GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle)) endfunction function CF_GetAttachedReal takes handle KeyHandle, string label returns real return GetStoredReal(CF_GC(), label, CF_H2S(KeyHandle)) endfunction function CF_GetAttachedString takes handle KeyHandle, string label returns string return GetStoredString(CF_GC(), label, CF_H2S(KeyHandle)) endfunction function CF_GetAttachedBoolean takes handle KeyHandle, string label returns boolean return CF_I2B(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_GetAttachedUnit takes handle KeyHandle, string label returns unit return CF_I2Unit(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_GetAttachedEffect takes handle KeyHandle, string label returns effect return CF_I2Effect(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_GetAttachedPlayer takes handle KeyHandle, string label returns player return CF_I2Player(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_GetAttachedTrigger takes handle KeyHandle, string label returns trigger return CF_I2Trigger(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_GetAttachedTimer takes handle KeyHandle, string label returns timer return CF_I2Timer(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_GetAttachedDialog takes handle KeyHandle, string label returns dialog return CF_I2Dialog(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_GetAttachedButton takes handle KeyHandle, string label returns button return CF_I2Button(GetStoredInteger(CF_GC(), label, CF_H2S(KeyHandle))) endfunction function CF_FlushInteger takes handle KeyHandle, string label returns nothing call FlushStoredInteger(CF_GC(), label, CF_H2S(KeyHandle)) endfunction function CF_FlushReal takes handle KeyHandle, string label returns nothing call FlushStoredReal(CF_GC(), label, CF_H2S(KeyHandle)) endfunction function CF_FlushString takes handle KeyHandle, string label returns nothing call FlushStoredString(CF_GC(), label, CF_H2S(KeyHandle)) endfunction function CF_FlushBoolean takes handle KeyHandle, string label returns nothing call FlushStoredBoolean(CF_GC(), label, CF_H2S(KeyHandle)) endfunction //==================================================================================================== // Simple Functions:- // These are used for advanced functions, but can also be used seperatly. // Check Co-ordinates function CF_IsXSafe takes real X returns boolean return (X > GetRectMinX(bj_mapInitialPlayableArea)) and (X < GetRectMaxX(bj_mapInitialPlayableArea)) endfunction function CF_IsYSafe takes real Y returns boolean return (Y > GetRectMinY(bj_mapInitialPlayableArea)) and (Y < GetRectMaxY(bj_mapInitialPlayableArea)) endfunction function CF_IsLocSafe takes real X, real Y returns boolean if(CF_IsXSafe(X) and CF_IsYSafe(Y)) then return true endif return false endfunction function CF_IsLocSafeEx takes location whichLocation returns boolean return CF_IsLocSafe(GetLocationX(whichLocation), GetLocationY(whichLocation)) endfunction //================================================== // Remove Attachments function CF_RemoveAttachments takes handle KeyHandle returns nothing call FlushStoredMission(CF_GC(), CF_H2S(KeyHandle)) endfunction function CF_RemoveStoredData takes string label returns nothing call FlushStoredMission(CF_GC(), label) endfunction //================================================== // Remove Handles function CF_DestroyTimer takes timer whichTimer returns nothing call PauseTimer(whichTimer) call CF_RemoveAttachments(whichTimer) call DestroyTimer(whichTimer) endfunction function CF_RemoveUnit takes unit whichUnit returns nothing call CF_RemoveAttachments(whichUnit) call RemoveUnit(whichUnit) endfunction function CF_DestroyEffect takes effect whichEffect returns nothing local unit CarryingUnit = CF_GetAttachedUnit(whichEffect, "Effect_CarryingUnit") call CF_RemoveAttachments(whichEffect) call DestroyEffect(whichEffect) call CF_RemoveAttachments(CarryingUnit) call RemoveUnit(CarryingUnit) set CarryingUnit = null endfunction function CF_DestroyTrigger takes trigger whichTrigger returns nothing call CF_RemoveAttachments(whichTrigger) call DestroyTrigger(whichTrigger) endfunction //================================================== // Get a Dummy Unit, ready for anything function CF_GetADummy takes real X, real Y returns unit local unit u if(CF_IsLocSafe(X, Y)) then set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), CF_Constant_DummyUnitRawcode(), X, Y, 90.) call UnitAddAbility(u, CF_Constant_MorphUnitFlyAbilityRawcode()) call UnitRemoveAbility(u, CF_Constant_MorphUnitFlyAbilityRawcode()) call UnitAddAbility(u, 'Avul') call UnitAddAbility(u, 'Aloc') call SetUnitMoveSpeed(u, 522) endif return u endfunction //================================================== // Change a colour value into a percent and vis-versa function CF_PercentTo255 takes real percent returns real local real r = (percent / 100) * 255 if(r > 255.) then set r = 255. elseif(r < 0.) then set r = 0. endif return r endfunction function CF_255ToPercent takes real amount returns real local real r = (amount / 255) * 100 if(r > 100.) then set r = 100. elseif(r < 0.) then set r = 0. endif return r endfunction //================================================== // Hide or Show a Multiboard for a single player. function CF_HideMultiboardForPlayer takes multiboard whichMultiboard, player whichPlayer returns nothing if(GetLocalPlayer() == whichPlayer) then call MultiboardDisplay(whichMultiboard, false) endif endfunction function CF_ShowMultiboardForPlayer takes multiboard whichMultiboard, player whichPlayer returns nothing if(GetLocalPlayer() == whichPlayer) then call MultiboardDisplay(whichMultiboard, true) endif endfunction function CF_MultiboardDisplayForPlayer takes multiboard whichMultiboard, player whichPlayer, boolean show returns nothing if(GetLocalPlayer() == whichPlayer) then call MultiboardDisplay(whichMultiboard, show) endif endfunction //================================================== // Damage function thats uses index's instead of attack and damage type. function CF_DamageWidget takes unit Credit, widget Target, real Damage, integer AttackIndex, integer DamageIndex returns nothing call UnitDamageTarget(Credit, Target, Damage, true, false, ConvertAttackType(AttackIndex), ConvertDamageType(DamageIndex), WEAPON_TYPE_WHOKNOWS) endfunction //================================================== // Hide or Show a unit for a player function CF_ShowUnitForPlayer takes unit whichUnit, player whichPlayer returns nothing if(GetLocalPlayer() == whichPlayer) then call ShowUnit(whichUnit, true) endif endfunction function CF_HideUnitForPlayer takes unit whichUnit, player whichPlayer returns nothing if(GetLocalPlayer() == whichPlayer) then call ShowUnit(whichUnit, false) endif endfunction function CF_UnitDisplayForPlayer takes unit whichUnit, player whichPlayer, boolean show returns nothing if(GetLocalPlayer() == whichPlayer) then call ShowUnit(whichUnit, show) endif endfunction //================================================== // Run a function after a certain amount of time in a new thread. function CF_RunFunctionTimed_Run takes nothing returns nothing local timer t = GetExpiredTimer() local trigger run = CF_GetAttachedTrigger(t, "RunFunctionTimer_Code") call TriggerExecute(run) call CF_DestroyTimer(t) call CF_DestroyTrigger(run) set run = null endfunction function CF_RunFunctionTimed takes code Function, real Wait returns nothing // This function runs a different // function after a certain amount of // time, it will also open a new // thread. local timer t = CreateTimer() local trigger run = CreateTrigger() call TriggerAddAction(run, Function) call TimerStart(t, Wait, false, function CF_RunFunctionTimed_Run) endfunction //================================================== // Say Functions function CF_SayMessage takes string Message, real Duration returns nothing call DisplayTimedTextFromPlayer(GetLocalPlayer(), 0., 0., Duration, Message) endfunction function CF_SayMessageLoc takes string Message, real Duration, real X, real Y returns nothing call DisplayTimedTextFromPlayer(GetLocalPlayer(), X, Y, Duration, Message) endfunction function CF_WisperMessage takes string Message, player whichPlayer, real Duration returns nothing call DisplayTimedTextFromPlayer(whichPlayer, 0., 0., Duration, Message) endfunction function CF_WisperMessageLoc takes string Message, player whichPlayer, real Duration, real X, real Y returns nothing call DisplayTimedTextFromPlayer(whichPlayer, X, Y, Duration, Message) endfunction function CF_AnnounceMessage takes string Message, force whichForce, real Duration returns nothing if(IsPlayerInForce(GetLocalPlayer(), whichForce)) then call DisplayTimedTextFromPlayer(GetLocalPlayer(), 0., 0., Duration, Message) endif endfunction function CF_AnnounceMessageLoc takes string Message, force whichForce, real Duration, real X, real Y returns nothing if(IsPlayerInForce(GetLocalPlayer(), whichForce)) then call DisplayTimedTextFromPlayer(GetLocalPlayer(), X, Y, Duration, Message) endif endfunction //================================================== // Move a item from 1 slot to another function CF_MoveItemSlot takes unit MovingUnit, integer CurrentItemSlot, integer NewItemSlot returns nothing call IssueTargetOrderById(MovingUnit, 852001+NewItemSlot, UnitItemInSlot(MovingUnit, CurrentItemSlot)) endfunction //================================================== // Move unit Functions function CF_SetUnitX takes unit whichUnit, real X returns nothing if(CF_IsXSafe(X)) then call SetUnitX(whichUnit, X) endif endfunction function CF_SetUnitY takes unit whichUnit, real Y returns nothing if(CF_IsYSafe(Y)) then call SetUnitY(whichUnit, Y) endif endfunction function CF_SetUnitLoc takes unit whichUnit, real X, real Y returns nothing if(CF_IsLocSafe(X, Y)) then call SetUnitX(whichUnit, X) call SetUnitY(whichUnit, Y) endif endfunction function CF_SetUnitLocEx takes unit whichUnit, location whichLocation returns nothing if(CF_IsLocSafeEx(whichLocation)) then call SetUnitX(whichUnit, GetLocationX(whichLocation)) call SetUnitY(whichUnit, GetLocationY(whichLocation)) endif endfunction //================================================== // Get Casted Ability level function CF_GetSpellLevel takes nothing returns integer return GetUnitAbilityLevel(GetSpellAbilityUnit(), GetSpellAbilityId()) endfunction //================================================== // Order Immediate stop function CF_Stop takes unit whichUnit returns nothing call PauseUnit(whichUnit, true) call IssueImmediateOrder(whichUnit, "stop") call PauseUnit(whichUnit, false) endfunction // Get the Host of a game function CF_GetHost takes nothing returns player local player Host = Player(CF_LoadInteger("Player_HostID")) if(Host == null) then call StoreInteger(CF_GC(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1) call TriggerSyncStart() call SyncStoredInteger(CF_GC(), "missionKey", "key") call TriggerSyncReady() set Host = Player(GetStoredInteger(CF_GC(), "missionKey", "key") - 1) call CF_StoreInteger(GetPlayerId(Host), "Player_HostID") endif return Host endfunction //================================================== // Defeat Player Properly function CF_DefeatPlayer_Trig_Actions takes nothing returns nothing local trigger t = GetTriggeringTrigger() local dialog d = CF_GetAttachedDialog(t, "CF_DefeatPlayer_Dialog") local boolean SS = CF_GetAttachedBoolean(t, "CF_DefeatPlayer_SS") local player p = Player(CF_GetAttachedInteger(t, "CF_DefeatPlayer_Id")) call CustomVictoryBJ(p, false, SS) call CF_DestroyTrigger(t) call DialogDestroy(d) set t = null set d = null set p = null endfunction function CF_DefeatPlayer takes player whichPlayer, string Msg, string ButtonMsg, boolean ShowScores returns nothing local dialog d = DialogCreate() local button b = DialogAddButton(d, ButtonMsg, 0) local trigger t = CreateTrigger() call DialogSetMessage(d, Msg) if(GetLocalPlayer() != whichPlayer) then call DialogDisplay(whichPlayer, d, false) endif call DialogDisplay(whichPlayer, d, true) call CF_AttachHandle(d, "CF_DefeatPlayer_Dialog", t) call CF_AttachHandle(b, "CF_DefeatPlayer_Button", t) call CF_AttachBoolean(ShowScores, "CF_DefeatPlayer_SS", t) call CF_AttachInteger(GetPlayerId(whichPlayer), "CF_DefeatPlayer_Id", t) call TriggerRegisterDialogButtonEvent(t, b) call TriggerAddAction(t, function CF_DefeatPlayer_Trig_Actions) endfunction //================================================== // Checks if a unit has a buff/ability function CF_UnitHasAbility takes unit whichUnit, integer AbilRawcode returns boolean return (GetUnitAbilityLevel(whichUnit, AbilRawcode) > 0) endfunction //================================================== // Add a ability to a unit with a level function CF_UnitAddAbilityLevel takes unit whichUnit, integer AbilRawcode, integer level returns nothing if(not CF_UnitHasAbility(whichUnit, AbilRawcode)) then call UnitAddAbility(whichUnit, AbilRawcode) endif call SetUnitAbilityLevel(whichUnit, AbilRawcode, level) endfunction //================================================== // Freeze the Time of day for a certain amount of Seconds function CF_FreezeTimeOfDay_Expire takes nothing returns nothing call DestroyTimer(GetExpiredTimer()) call SetTimeOfDayScale(1.) endfunction function CF_FreezeTimeOfDay takes real Duration returns nothing local timer t = CreateTimer() call SetTimeOfDayScale(0.) call TimerStart(t, Duration, false, function CF_FreezeTimeOfDay_Expire) endfunction //================================================== // Set time of day for a certain amount of time then set it to a different time function CF_SetCustomTime_Expire takes nothing returns nothing local timer t = GetExpiredTimer() local real r = CF_GetAttachedReal(t, "CF_SetCustomTime_EndTime") call SetTimeOfDayScale(1.) call SetTimeOfDay(r) call CF_DestroyTimer(t) endfunction function CF_SetCustomTime takes real StartTime, real Duration, real FinishTime returns nothing local timer t = CreateTimer() call SetTimeOfDay(StartTime) call SetTimeOfDayScale(0.) call CF_AttachReal(FinishTime, "CF_SetCustomTime_EndTime", t) call TimerStart(t, Duration, false, function CF_SetCustomTime_Expire) endfunction //================================================== // Calculate armor reduction function CF_CalculatePositiveReduction takes integer Armor returns real return (Armor*0.06)/(1+0.06*Armor) endfunction function CF_CalculateNegativeReduction takes integer Armor returns real return 2-Pow(0.94, -Armor) endfunction function CF_CalculateArmorReduction takes integer Armor returns real if(Armor < 0) then return CF_CalculateNegativeReduction(Armor) endif return CF_CalculatePositiveReduction(Armor) endfunction // Special Functions:- // Consists of things that the standard W/E dosent not let you do. // Effect function CF_CreateGroundEffect takes real X, real Y, real Z, real facing, real sizeFactor, string modelPath, integer red, integer green, integer blue, integer alpha returns effect local effect NewEffect local unit CarryingUnit if(CF_IsLocSafe(X, Y)) then set CarryingUnit = CF_GetADummy(X, Y) set NewEffect = AddSpecialEffectTarget(modelPath, CarryingUnit, "origin") call SetUnitFlyHeight(CarryingUnit, Z, 0.) call SetUnitFacing(CarryingUnit, facing) call SetUnitScalePercent(CarryingUnit, sizeFactor, sizeFactor, sizeFactor) // This uses scaling factor. // 1. would be the same size. // 1.1 would be 10% bigger than // usual. // 2. would be 100% bigger than // usual. call SetUnitVertexColor(CarryingUnit, red, green, blue, alpha) call CF_AttachHandle(CarryingUnit, "Effect_CarryingUnit", NewEffect) call CF_AttachReal(X, "Effect_XCoord", NewEffect) call CF_AttachReal(Y, "Effect_YCoord", NewEffect) call CF_AttachReal(Z, "Effect_ZCoord", NewEffect) call CF_AttachReal(facing, "Effect_FacingDegrees", NewEffect) call CF_AttachReal(sizeFactor, "Effect_Size", NewEffect) call CF_AttachInteger(red, "Effect_RedColour", NewEffect) call CF_AttachInteger(green, "Effect_GreenColour", NewEffect) call CF_AttachInteger(blue, "Effect_BlueColour", NewEffect) call CF_AttachInteger(alpha, "Effect_AlphaColour", NewEffect) call CF_AttachString(modelPath, "Effect_ModelPath", NewEffect) call CF_StoreHandle(NewEffect, "CF_MEMORY_LASTCREATED_EFFECT", "Effect") return NewEffect endif set NewEffect = null set CarryingUnit = null return null endfunction function CF_GetLastCreatedEffect takes nothing returns effect return CF_LoadEffect("CF_MEMORY_LASTCREATED_EFFECT") endfunction function CF_GetEffectCarryingUnit takes effect whichEffect returns unit return CF_GetAttachedUnit(whichEffect, "Effect_CarryingUnit") endfunction function CF_GetEffectX takes effect whichEffect returns real return CF_GetAttachedReal(whichEffect, "Effect_XCoord") endfunction function CF_GetEffectY takes effect whichEffect returns real return CF_GetAttachedReal(whichEffect, "Effect_YCoord") endfunction function CF_GetEffectZ takes effect whichEffect returns real return CF_GetAttachedReal(whichEffect, "Effect_ZCoord") endfunction function CF_GetEffectFacing takes effect whichEffect returns real return CF_GetAttachedReal(whichEffect, "Effect_FacingDegrees") endfunction function CF_GetEffectSize takes effect whichEffect returns real return CF_GetAttachedReal(whichEffect, "Effect_Size") endfunction function CF_GetEffectModelPath takes effect whichEffect returns string return CF_GetAttachedString(whichEffect, "Effect_ModelPath") endfunction function CF_GetEffectRedColour takes effect whichEffect returns integer return CF_GetAttachedInteger(whichEffect, "Effect_RedColour") endfunction function CF_GetEffectGreenColour takes effect whichEffect returns integer return CF_GetAttachedInteger(whichEffect, "Effect_GreenColour") endfunction function CF_GetEffectBlueColour takes effect whichEffect returns integer return CF_GetAttachedInteger(whichEffect, "Effect_BlueColour") endfunction function CF_GetEffectAlphaColour takes effect whichEffect returns integer return CF_GetAttachedInteger(whichEffect, "Effect_AlphaColour") endfunction function CF_IsEffectLocked takes effect whichEffect returns boolean if(CF_GetAttachedBoolean(whichEffect, "Effect_Locked")) then return true endif return false endfunction function CF_IsEffectInRect takes effect whichEffect, real minX, real minY, real maxX, real maxY returns boolean local real X = CF_GetEffectX(whichEffect) local real Y = CF_GetEffectY(whichEffect) if(X > minX) and (X < maxX) and (Y > minY) and (Y < maxY) then return true endif return false endfunction function CF_IsEffectInRectEx takes effect whichEffect, rect whichRect returns boolean local real X local real Y if(X > GetRectMinX(whichRect)) and (X < GetRectMaxX(whichRect)) and (Y > GetRectMinY(whichRect)) and (Y < GetRectMaxY(whichRect)) then return true endif return false endfunction function CF_IsEffectInRange takes effect whichEffect, real X, real Y, real radius returns boolean return IsUnitInRangeXY(CF_GetEffectCarryingUnit(whichEffect), X, Y, radius) endfunction function CF_IsEffectInRangeEx takes effect whichEffect, location whichLocation, real radius returns boolean return IsUnitInRangeXY(CF_GetEffectCarryingUnit(whichEffect), GetLocationX(whichLocation), GetLocationY(whichLocation), radius) endfunction function CF_SetEffectX takes effect whichEffect, real X returns nothing if(CF_IsXSafe(X) and (CF_IsEffectLocked(whichEffect) == false)) then call SetUnitX(CF_GetEffectCarryingUnit(whichEffect), X) call CF_AttachReal(X, "Effect_XCoord", whichEffect) endif endfunction function CF_SetEffectY takes effect whichEffect, real Y returns nothing if(CF_IsYSafe(Y) and (CF_IsEffectLocked(whichEffect) == false)) then call SetUnitY(CF_GetEffectCarryingUnit(whichEffect), Y) call CF_AttachReal(Y, "Effect_YCoord", whichEffect) endif endfunction function CF_SetEffectLoc takes effect whichEffect, real X, real Y returns nothing local unit CarryingUnit = CF_GetEffectCarryingUnit(whichEffect) if(CF_IsLocSafe(X, Y) and (not CF_IsEffectLocked(whichEffect))) then call SetUnitX(CarryingUnit, X) call SetUnitY(CarryingUnit, Y) call CF_AttachReal(X, "Effect_XCoord", whichEffect) call CF_AttachReal(Y, "Effect_YCoord", whichEffect) endif set CarryingUnit = null endfunction function CF_SetEffectLocEx takes effect whichEffect, location whichLocation returns nothing call CF_SetEffectLoc(whichEffect, GetLocationX(whichLocation), GetLocationY(whichLocation)) endfunction function CF_SetEffectZ takes effect whichEffect, real newZ returns nothing if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitFlyHeight(CF_GetEffectCarryingUnit(whichEffect), newZ, 0.) call CF_AttachReal(newZ, "Effect_ZCoord", whichEffect) endif endfunction function CF_SetEffectFacing takes effect whichEffect, real facing returns nothing if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitFacing(CF_GetEffectCarryingUnit(whichEffect), facing) call CF_AttachReal(facing, "Effect_FacingDegrees", whichEffect) endif endfunction function CF_SetEffectSize takes effect whichEffect, real sizeFactor returns nothing local real oldFactor = CF_GetEffectSize(whichEffect) if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitScalePercent(CF_GetEffectCarryingUnit(whichEffect), sizeFactor, sizeFactor, sizeFactor) call CF_AttachReal(oldFactor + sizeFactor - 1., "Effect_Size", whichEffect) endif endfunction function CF_EffectAddExpirationTime_Destroy takes nothing returns nothing local timer t = GetExpiredTimer() local effect e = CF_GetAttachedEffect(t, "Timer_Expiration_Effect") call CF_DestroyTimer(t) call CF_DestroyEffect(e) set e = null endfunction function CF_EffectAddExpirationTime takes effect whichEffect, real time returns nothing local timer t = CreateTimer() if(CF_IsEffectLocked(whichEffect) == false) then call CF_AttachHandle(whichEffect, "Timer_Expiration_Effect", t) call TimerStart(t, time, false, function CF_EffectAddExpirationTime_Destroy) endif endfunction function CF_SetEffectColour takes effect whichEffect, integer red, integer green, integer blue, integer alpha returns nothing if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitVertexColor(CF_GetEffectCarryingUnit(whichEffect), red, green, blue, alpha) endif endfunction function CF_SetEffectRedColour takes effect whichEffect, integer red returns nothing local integer green = CF_GetEffectGreenColour(whichEffect) local integer blue = CF_GetEffectBlueColour(whichEffect) local integer alpha = CF_GetEffectAlphaColour(whichEffect) if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitVertexColor(CF_GetEffectCarryingUnit(whichEffect), red, green, blue, alpha) endif endfunction function CF_SetEffectGreenColour takes effect whichEffect, integer green returns nothing local integer red = CF_GetEffectRedColour(whichEffect) local integer blue = CF_GetEffectBlueColour(whichEffect) local integer alpha = CF_GetEffectAlphaColour(whichEffect) if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitVertexColor(CF_GetEffectCarryingUnit(whichEffect), red, green, blue, alpha) endif endfunction function CF_SetEffectBlueColour takes effect whichEffect, integer blue returns nothing local integer red = CF_GetEffectRedColour(whichEffect) local integer green = CF_GetEffectGreenColour(whichEffect) local integer alpha = CF_GetEffectAlphaColour(whichEffect) if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitVertexColor(CF_GetEffectCarryingUnit(whichEffect), red, green, blue, alpha) endif endfunction function CF_SetEffectAlphaColour takes effect whichEffect, integer alpha returns nothing local integer red = CF_GetEffectRedColour(whichEffect) local integer green = CF_GetEffectGreenColour(whichEffect) local integer blue = CF_GetEffectBlueColour(whichEffect) if(CF_IsEffectLocked(whichEffect) == false) then call SetUnitVertexColor(CF_GetEffectCarryingUnit(whichEffect), red, green, blue, alpha) endif endfunction function CF_CopyEffect takes effect whichEffect returns effect return CF_CreateGroundEffect(CF_GetEffectX(whichEffect), CF_GetEffectY(whichEffect), CF_GetEffectZ(whichEffect), CF_GetEffectFacing(whichEffect), CF_GetEffectSize(whichEffect), CF_GetEffectModelPath(whichEffect), CF_GetEffectRedColour(whichEffect), CF_GetEffectGreenColour(whichEffect), CF_GetEffectBlueColour(whichEffect), CF_GetEffectAlphaColour(whichEffect)) endfunction function CF_CopyEffectLoc takes effect whichEffect, real X, real Y returns effect local effect e = CF_CopyEffect(whichEffect) local integer Ie = CF_H2I(e) call CF_SetEffectLoc(e, X, Y) set e = null return Ie return null endfunction function CF_CopyEffectLocEx takes effect whichEffect, location whichLocation returns effect return CF_CopyEffectLoc(whichEffect, GetLocationX(whichLocation), GetLocationY(whichLocation)) endfunction function CF_LockEffect takes effect whichEffect returns nothing call CF_AttachBoolean(true, "Effect_Locked", whichEffect) // If a effect is locked, nothing can be changed, // Only things like copy and getting values is // possible. endfunction function CF_UnlockEffect takes effect whichEffect returns nothing call CF_AttachBoolean(false, "Effect_Locked", whichEffect) // Allows the effect to be changed again endfunction function CF_LockEffectEdit takes effect whichEffect, boolean lock returns nothing call CF_AttachBoolean(lock, "Effect_Locked", whichEffect) endfunction function CF_ShowEffectForPlayer takes effect whichEffect, player whichPlayer returns nothing if(GetLocalPlayer() == whichPlayer) then call ShowUnit(CF_GetEffectCarryingUnit(whichEffect), true) endif endfunction function CF_HideEffectForPlayer takes effect whichEffect, player whichPlayer returns nothing if(GetLocalPlayer() == whichPlayer) then call ShowUnit(CF_GetEffectCarryingUnit(whichEffect), false) endif endfunction function CF_DisplayEffectForPlayer takes effect whichEffect, player whichPlayer, boolean show returns nothing if(GetLocalPlayer() == whichPlayer) then call ShowUnit(CF_GetEffectCarryingUnit(whichEffect), show) endif endfunction // Lightning function CF_CreateLightningGroundEffect takes real X1, real Y1, real Z1, real X2, real Y2, real Z2, string codeName, integer red, integer green, integer blue, integer alpha returns lightning local lightning NewLightning if(CF_IsLocSafe(X1, Y1) and CF_IsLocSafe(X2, Y2)) then set NewLightning = AddLightningEx(codeName, true, X1, Y1, Z2, X2, Y2, Z2) call SetLightningColor(NewLightning, red, green, blue, alpha) call CF_AttachReal(X1, "Lightning_CoordX1", NewLightning) call CF_AttachReal(Y1, "Lightning_CoordY1", NewLightning) call CF_AttachReal(Z1, "Lightning_CoordZ1", NewLightning) call CF_AttachReal(X2, "Lightning_CoordX2", NewLightning) call CF_AttachReal(Y2, "Lightning_CoordY2", NewLightning) call CF_AttachReal(Z2, "Lightning_CoordZ2", NewLightning) call CF_AttachString(codeName, "Lightning_CodeName", NewLightning) call CF_AttachInteger(red, "Lightning_RedColour", NewLightning) call CF_AttachInteger(green, "Lightning_GreenColour", NewLightning) call CF_AttachInteger(blue, "Lightning_BlueColour", NewLightning) call CF_AttachInteger(alpha, "Lightning_AlphaColour", NewLightning) return NewLightning endif set NewLightning = null return null endfunction function CF_GetLightningX1 takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_CoordX1") endfunction function CF_GetLightningY1 takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_CoordY1") endfunction function CF_GetLightningZ1 takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_CoordZ1") endfunction function CF_GetLightningX2 takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_CoordX2") endfunction function CF_GetLightningY2 takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_CoordY2") endfunction function CF_GetLightningZ2 takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_CoordZ2") endfunction function CF_GetLightningLoc1 takes lightning whichLightning returns location return Location(CF_GetLightningX1(whichLightning), CF_GetLightningY1(whichLightning)) endfunction function CF_GetLightningLoc2 takes lightning whichLightning returns location return Location(CF_GetLightningX2(whichLightning), CF_GetLightningY2(whichLightning)) endfunction function CF_GetLightningCenter takes lightning whichLightning returns location local location Loc1 = CF_GetLightningLoc1(whichLightning) local real X1 = CF_GetLightningX1(whichLightning) local real Y1 = CF_GetLightningY1(whichLightning) local real X2 = CF_GetLightningX2(whichLightning) local real Y2 = CF_GetLightningY2(whichLightning) local real angle = bj_RADTODEG * Atan2(Y2 - Y1, X2 - X1) local real distance = SquareRoot(X2 - X1 * X2 - X1 + Y2 - Y1 * Y2 - Y1) local real HDistance = distance / 2 local real DestX = GetLocationX(Loc1) + HDistance * Cos(angle * bj_DEGTORAD) local real DestY = GetLocationY(Loc1) + HDistance * Sin(angle * bj_DEGTORAD) call RemoveLocation(Loc1) set Loc1 = null return Location(DestX, DestY) endfunction function CF_GetLightningColourRed takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_RedColour") endfunction function CF_GetLightningColourGreen takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_GreenColour") endfunction function CF_GetLightningColourBlue takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_BlueColour") endfunction function CF_GetLightningColourAlpha takes lightning whichLightning returns real return CF_GetAttachedReal(whichLightning, "Lightning_AlphaColour") endfunction function CF_SetLightningToGround takes lightning whichLightning returns nothing local real X1 = CF_GetLightningX1(whichLightning) local real Y1 = CF_GetLightningY1(whichLightning) local real X2 = CF_GetLightningX2(whichLightning) local real Y2 = CF_GetLightningY2(whichLightning) call MoveLightningEx(whichLightning, true, X1, Y2, GetTerrainCliffLevel(X1, Y1), X2, Y2, GetTerrainCliffLevel(X2, Y2)) endfunction //==================================================================================================== // Advanced functions:- // Not more than 100 of these should be running at the same time. If their is, it will // most likely cause severe lag. // Target Projectiles function CF_LaunchTargetProjectile_Update takes nothing returns nothing local timer t = GetExpiredTimer() local unit Credit = CF_GetAttachedUnit(t, "CF_LaunchTargetProjectileSimple_Credit") local unit Target = CF_GetAttachedUnit(t, "CF_LaunchTargetProjectileSimple_Target") local effect v = CF_GetAttachedEffect(t, "CF_LaunchTargetProjectileSimple_Visual") local real CurrentX = CF_GetEffectX(v) local real CurrentY = CF_GetEffectY(v) local real TargetX = GetUnitX(Target) local real TargetY = GetUnitY(Target) local real Speed = CF_GetAttachedReal(t, "CF_LaunchTargetProjectileSimple_Speed") local real Angle = bj_RADTODEG * Atan2(TargetY - CurrentY, TargetX - CurrentX) local real NewX = CurrentX + Speed * Cos(Angle * bj_DEGTORAD) local real NewY = CurrentY + Speed * Sin(Angle * bj_DEGTORAD) local timer Duration = CF_GetAttachedTimer(t, "CF_LaunchTargetProjectileCustom_Duration") local boolean UseDur = false if(Duration != null) then set UseDur = true endif if(IsUnitInRangeXY(Target, CurrentX, CurrentY, CF_Constant_CollisionDetectionRange()) or (UseDur and TimerGetRemaining(Duration) == 0)) then call CF_DamageWidget(Credit, Target, CF_GetAttachedReal(t, "CF_LaunchTargetProjectileSimple_Damage"), 5, 0) call CF_DestroyTimer(t) call CF_DestroyEffect(v) if(UseDur) then call DestroyTimer(Duration) endif set v = null else call CF_SetEffectLoc(v, NewX, NewY) call TimerStart(t, CF_Constant_MinTimerUpdate(), false, function CF_LaunchTargetProjectile_Update) endif endfunction //================================================== function CF_LaunchTargetProjectileSimple takes unit Credit, unit Target, real Damage, real Speed, string ModelPath returns nothing local timer t = CreateTimer() local real CreditX = GetUnitX(Credit) local real CreditY = GetUnitY(Credit) local real TargetX = GetUnitX(Target) local real TargetY = GetUnitY(Target) local real Angle = bj_RADTODEG * Atan2(TargetY - CreditY, TargetX - CreditX) local effect v = CF_CreateGroundEffect(CreditX, CreditY, CF_Constant_SimpleProjectileHeight(), Angle, 1., ModelPath, 255, 255, 255, 255) call CF_AttachHandle(Credit, "CF_LaunchTargetProjectileSimple_Credit", t) call CF_AttachHandle(Target, "CF_LaunchTargetProjectileSimple_Target", t) call CF_AttachHandle(v, "CF_LaunchTargetProjectileSimple_Visual", t) call CF_AttachReal(Damage, "CF_LaunchTargetProjectileSimple_Damage", t) call CF_AttachReal(Speed / 100, "CF_LaunchTargetProjectileSimple_Speed", t) call TimerStart(t, CF_Constant_MinTimerUpdate(), false, function CF_LaunchTargetProjectile_Update) endfunction //================================================== function CF_LaunchTargetProjectileCustom takes unit Credit, unit Target, real Damage, real Speed, string ModelPath, integer Red, integer Green, integer Blue, integer Alpha, real Height, real Size, real Duration returns nothing local timer t = CreateTimer() local timer DurationT = CreateTimer() local real CreditX = GetUnitX(Credit) local real CreditY = GetUnitY(Credit) local real TargetX = GetUnitX(Target) local real TargetY = GetUnitY(Target) local real Angle = bj_RADTODEG * Atan2(TargetY - CreditY, TargetX - CreditX) local effect v = CF_CreateGroundEffect(CreditX, CreditY, Height, Angle, Size, ModelPath, Red, Green, Blue, Alpha) local real MinTimerUpdate = CF_Constant_MinTimerUpdate() if(Duration <= MinTimerUpdate) then call DestroyTimer(DurationT) else call TimerStart(DurationT, Duration, false, null) endif call CF_AttachHandle(Credit, "CF_LaunchTargetProjectileCustom_Credit", t) call CF_AttachHandle(Target, "CF_LaunchTargetProjectileCustom_Target", t) call CF_AttachHandle(v, "CF_LaunchTargetProjectileCustom_Visual", t) call CF_AttachReal(Damage, "CF_LaunchTargetProjectileCustom_Damage", t) call CF_AttachReal(Speed / 100, "CF_LaunchTargetProjectileCustom_Speed", t) call CF_AttachHandle(DurationT, "CF_LaunchTargetProjectileCustom_Duration", t) call TimerStart(t, MinTimerUpdate, false, function CF_LaunchTargetProjectile_Update) endfunction Its not perfect, it needs improving alot. |
| 08-16-2006, 12:18 AM | #7 |
Oh. Thanks a lot! Dont know if I'll need it right away, this was more of a just wondering question. But I'll definatly keep that in mind. |
| 08-18-2006, 12:10 AM | #8 |
Ok, new question, on the same subject. Can you scale missiles? |
| 08-18-2006, 12:38 AM | #9 |
without model editing, no. however it should be a simple edit afaik... |
| 08-18-2006, 12:45 AM | #10 | |
Quote:
|
