| 12-27-2008, 06:08 AM | #1 |
Tropical Tag was passed on to me and it came to my attention that Tropical Tag crashes upon start on Macs only. The game freezes when reaching the "Press any key to continue" screen. My guess is it is related to the code and not a model or something else. Here is the custom script code. GetHost is run upon initialization. JASS:function SuperCache takes nothing returns gamecache if udg_Cache==null then call FlushGameCache(InitGameCache("supercachebtj")) set udg_Cache=InitGameCache("supercachebtj") endif return udg_Cache endfunction constant function H2I takes handle h returns integer return h return 0 endfunction function StoreHandle takes gamecache g,string mk,string k,handle h returns nothing if h==null then call FlushStoredInteger(g,mk,k) else call StoreInteger(g,mk,k,H2I(h)) endif endfunction function StorePlayer takes gamecache g,string mk,string k,player p returns nothing if p==null then call FlushStoredInteger(g,mk,k) else call StoreInteger(g,mk,k,GetPlayerId(p)+1) endif endfunction function GetStoredButton takes gamecache g,string mk,string k returns button return GetStoredInteger(g,mk,k) return null endfunction function GetStoredLocation takes gamecache g,string mk,string k returns location return GetStoredInteger(g,mk,k) return null endfunction function GetStoredTimer takes gamecache g,string mk,string k returns timer return GetStoredInteger(g,mk,k) return null endfunction function GetStoredTimerDialog takes gamecache g,string mk,string k returns timerdialog return GetStoredInteger(g,mk,k) return null endfunction function GetStoredTrigger takes gamecache g,string mk,string k returns trigger return GetStoredInteger(g,mk,k) return null endfunction function GetStoredTriggerAction takes gamecache g,string mk,string k returns triggeraction return GetStoredInteger(g,mk,k) return null endfunction function GetStoredTriggerCondition takes gamecache g,string mk,string k returns triggercondition return GetStoredInteger(g,mk,k) return null endfunction function GetStoredLightning takes gamecache g,string mk,string k returns lightning return GetStoredInteger(g,mk,k) return null endfunction function GetStoredWidget takes gamecache g,string mk,string k returns widget return GetStoredInteger(g,mk,k) return null endfunction function GetStoredDestructable takes gamecache g,string mk,string k returns destructable return GetStoredInteger(g,mk,k) return null endfunction function GetStoredEffect takes gamecache g,string mk,string k returns effect return GetStoredInteger(g,mk,k) return null endfunction function GetStoredEffectType takes gamecache g,string mk,string k returns effecttype return GetStoredInteger(g,mk,k) return null endfunction function GetStoredLeaderboard takes gamecache g,string mk,string k returns leaderboard return GetStoredInteger(g,mk,k) return null endfunction function GetStoredMultiboard takes gamecache g,string mk,string k returns multiboard return GetStoredInteger(g,mk,k) return null endfunction function GetStoredMultiboardItem takes gamecache g,string mk,string k returns multiboarditem return GetStoredInteger(g,mk,k) return null endfunction function GetStoredItem takes gamecache g,string mk,string k returns item return GetStoredInteger(g,mk,k) return null endfunction function GetStoredItemPool takes gamecache g,string mk,string k returns itempool return GetStoredInteger(g,mk,k) return null endfunction function GetStoredUnitPool takes gamecache g,string mk,string k returns unitpool return GetStoredInteger(g,mk,k) return null endfunction function GetStoredUnit takes gamecache g,string mk,string k returns unit return GetStoredInteger(g,mk,k) return null endfunction function GetStoredGroup takes gamecache g,string mk,string k returns group return GetStoredInteger(g,mk,k) return null endfunction function GetStoredForce takes gamecache g,string mk,string k returns force return GetStoredInteger(g,mk,k) return null endfunction function GetStoredPlayer takes gamecache g,string mk,string k returns player local integer id=GetStoredInteger(g,mk,k) if id>0 then return Player(id-1) endif return null endfunction function GetStoredAttackType takes gamecache g,string mk,string k returns attacktype return ConvertAttackType(GetStoredInteger(g,mk,k)) endfunction function GetStoredDamageType takes gamecache g,string mk,string k returns damagetype return ConvertDamageType(GetStoredInteger(g,mk,k)) endfunction function GetStoredWeaponType takes gamecache g,string mk,string k returns weapontype return ConvertWeaponType(GetStoredInteger(g,mk,k)) endfunction // //**************************************************************************** //* * //* Spells By: emjlr3 * //* * //**************************************************************************** function CasterUnitId takes nothing returns integer return 'n00L' // Dummy Caster type rawcode endfunction function FlyTrickId takes nothing returns integer return 'A00Z' // Fly Trick ability type rawcode endfunction //############################## Local Handle Vars By: Kattana //============================================================================= function LocalVars takes nothing returns gamecache if udg_Cache == null then call FlushGameCache(InitGameCache("somename")) set udg_Cache = InitGameCache("somename") endif return udg_Cache endfunction function SetHandleHandle takes handle subject, string name, handle value returns nothing if value==null then call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name) else call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value)) endif endfunction function SetHandleInt takes handle subject, string name, integer value returns nothing if value==0 then call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name) else call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function SetHandleBoolean takes handle subject, string name, boolean value returns nothing if value==false then call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name) else call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function SetHandleReal takes handle subject, string name, real value returns nothing if value==0 then call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name) else call StoreReal(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function SetHandleString takes handle subject, string name, string value returns nothing if value==null then call FlushStoredString(LocalVars(), I2S(H2I(subject)), name) else call StoreString(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function GetHandleHandle takes handle subject, string name returns handle return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleInt takes handle subject, string name returns integer return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleBoolean takes handle subject, string name returns boolean return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleReal takes handle subject, string name returns real return GetStoredReal(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleString takes handle subject, string name returns string return GetStoredString(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleUnit takes handle subject, string name returns unit return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandlePlayer takes handle subject, string name returns player return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleLocation takes handle subject, string name returns location return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleTimer takes handle subject, string name returns timer return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleTrigger takes handle subject, string name returns trigger return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleTriggerAction takes handle subject, string name returns triggeraction return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleTriggerCondition takes handle subject, string name returns triggercondition return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleEffect takes handle subject, string name returns effect return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleGroup takes handle subject, string name returns group return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleLightning takes handle subject, string name returns lightning return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleWidget takes handle subject, string name returns widget return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function FlushHandleLocals takes handle subject returns nothing call FlushStoredMission(LocalVars(), I2S(H2I(subject)) ) endfunction //############################## //****************************************************** //emjlr3's Caster System //****************************************************** //Author: emjlr3 //Decided to keep track of all the utility functions I make/use to keep my spell making simpler! :) //****************************************************** //############################## //**A few simple functions that are used by the bigger ones farther down //Cleans the timer so I don't have to do it manually every time function ClearTimer takes timer t returns nothing if t!= null then call PauseTimer(t) call TriggerSleepAction(0) call FlushHandleLocals(t) call DestroyTimer(t) endif endfunction //============================================================================= //Simple angle between x/y coordinates function AngleBetweenPointsXY takes real x1, real y1, real x2, real y2 returns real return Atan2BJ((y2-y1),(x2-x1)) endfunction //============================================================================= //Simple distance between x/y coordinates function DistanceBetweenPointsXY takes real x1, real y1, real x2, real y2 returns real return SquareRoot((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) endfunction //============================================================================= //I kill trees often, so I just threw this in here so I got it function KillTrees_Child takes nothing returns nothing call KillDestructable(GetEnumDestructable()) endfunction function KillTrees takes real x, real y, real radius returns nothing local rect r=Rect(x - radius,y - radius,x + radius,y + radius) call EnumDestructablesInRect(r,null,function KillTrees_Child) call RemoveRect(r) set r = null endfunction //============================================================================= //Simple unit move for slides and such function MoveUnitToPolarProjection takes unit tomove, real dist, real angle returns nothing call SetUnitPosition(tomove, GetUnitX(tomove) + dist * Cos(angle * bj_DEGTORAD) , GetUnitY(tomove) + dist * Sin(angle * bj_DEGTORAD)) endfunction //**Now to the big guys //============================================================================= //Add effects to a enemies in an area function AddEffectEnemyAreaFilter takes nothing returns boolean return IsUnitEnemy(GetFilterUnit(), bj_groupEnumOwningPlayer) and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0 endfunction function AddEffectEnemyArea takes unit caster, string sfx, string attachpoint, real radius, real x, real y returns nothing local group g = CreateGroup() local boolexpr b = Condition(function AddEffectEnemyAreaFilter) local unit u set bj_groupEnumOwningPlayer = GetOwningPlayer(caster) call GroupEnumUnitsInRange(g, x, y, radius, b) call DestroyBoolExpr(b) loop set u = FirstOfGroup(g) exitwhen u == null call GroupRemoveUnit(g,u) call DestroyEffect(AddSpecialEffectTarget(sfx,u,attachpoint)) endloop call DestroyGroup(g) set g = null set b = null endfunction //============================================================================= //Add timed effects to a target or at an x/y function AddEffectTimed_Child takes nothing returns nothing local timer t=GetExpiredTimer() call DestroyEffect(GetHandleEffect(t, "e")) call ClearTimer(t) endfunction function AddEffectUnitTimed takes widget target, string modelname, string attachmentpoint, real duration returns nothing local timer t=CreateTimer() local widget w = target local effect e=AddSpecialEffectTarget(modelname, w, attachmentpoint) call SetHandleHandle(t, "e", e) call TimerStart(t, duration, false, function AddEffectTimed_Child) loop exitwhen TimerGetRemaining(t)<=.01 if GetWidgetLife(w)<=0 then call DestroyEffect(e) call ClearTimer(t) endif call TriggerSleepAction(0) endloop set e=null set w = null endfunction function AddEffectTimed takes real x, real y, string modelname, real duration returns nothing local timer t=CreateTimer() local effect e=AddSpecialEffect(modelname, x,y) call SetHandleHandle(t, "e", e) call TimerStart(t, duration, false, function AddEffectTimed_Child) set e=null endfunction //============================================================================= //Add effects in a line function AddEffectsLine_Child takes nothing returns nothing local timer t = GetExpiredTimer() local integer i = GetHandleInt(t,"i") local real dist = GetHandleReal(t,"distance") local real angle = GetHandleReal(t,"angle") local real x = GetHandleReal(t,"x") local real y = GetHandleReal(t,"y") if i <= GetHandleInt(t,"counter") then if GetHandleBoolean(t,"timed")==true then call AddEffectTimed(x,y,GetHandleString(t,"sfx"),GetHandleReal(t,"duration")) else call DestroyEffect(AddSpecialEffect(GetHandleString(t,"sfx"),x,y)) endif else call ClearTimer(t) endif call SetHandleInt(t,"i",i+1) call SetHandleReal(t,"x",x + dist * Cos(angle * bj_DEGTORAD)) call SetHandleReal(t,"y",y + dist * Sin(angle * bj_DEGTORAD)) endfunction function AddEffectsLine takes real x, real y, real distance, real timeout, string sfx, real angle, integer counter, boolean timed, real duration returns nothing local timer t = CreateTimer() call SetHandleReal(t,"x",x) call SetHandleReal(t,"y",y) call SetHandleReal(t,"distance",distance) call SetHandleReal(t,"duration",duration) call SetHandleReal(t,"angle",angle) call SetHandleString(t,"sfx",sfx) call SetHandleInt(t,"counter",counter) call SetHandleInt(t,"i",1) call SetHandleBoolean(t,"timed",timed) call TimerStart(t,timeout,true,function AddEffectsLine_Child) endfunction //============================================================================= //Create dummy caster for use, this sets everything up, then all you have to do is order it to cast/attack function CreateCaster takes player owner, real x, real y, real facing, integer abilid, integer level returns unit local unit u=CreateUnit(owner,CasterUnitId(),x,y,facing) call UnitAddAbility( u, abilid) call SetUnitAbilityLevel(u,abilid,level) call UnitApplyTimedLife(u,'BTLF',2) return u endfunction //============================================================================= //Damage enemies in an area function FilterIsEnemy takes nothing returns boolean return IsUnitEnemy(GetFilterUnit(), bj_groupEnumOwningPlayer) endfunction function DamageEnemiesArea takes unit damageUnit, real radius, real x, real y, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns nothing local group g = CreateGroup() local boolexpr b = Condition(function FilterIsEnemy) local unit u set bj_groupEnumOwningPlayer = GetOwningPlayer(damageUnit) call GroupEnumUnitsInRange(g, x, y, radius, b) call DestroyBoolExpr(b) loop set u = FirstOfGroup(g) exitwhen u == null call GroupRemoveUnit(g,u) call UnitDamageTarget(damageUnit,u,amount,attack, ranged,attackType,damageType,weaponType) endloop call DestroyGroup(g) set g = null set b = null endfunction //============================================================================= //Damage a unit over time function DamageOverTime_Child takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = GetHandleUnit(t, "whichUnit") local widget target = GetHandleWidget(t, "target") call SetHandleReal(t, "total", (GetHandleReal(t, "total" ) + GetHandleReal(t, "timeout"))) if (GetHandleReal(t, "total") > GetHandleReal(t, "duration")) then call ClearTimer(t) else call UnitDamageTarget(u, target, GetHandleReal(t, "amount"), GetHandleBoolean(t, "attack"), GetHandleBoolean(t, "ranged"), ConvertAttackType(GetHandleInt(t, "attacktype")), ConvertDamageType(GetHandleInt(t, "damagetype")), ConvertWeaponType(GetHandleInt(t, "weapontype"))) endif set u = null set target = null endfunction function DamageOverTime takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType, real duration, real timeout returns nothing local timer t = CreateTimer( ) call SetHandleHandle(t, "whichUnit", whichUnit) call SetHandleHandle(t, "target", target) call SetHandleReal(t, "amount", amount) call SetHandleReal(t, "duration", duration) call SetHandleReal(t, "timeout", timeout) call SetHandleInt(t, "attacktype", H2I(attackType)) call SetHandleInt(t, "damagetype", H2I(damageType)) call SetHandleInt(t, "weapontype", H2I(weaponType)) call SetHandleBoolean(t, "attack", attack) call SetHandleBoolean(t, "ranged", ranged) call TimerStart(t, timeout, true, function DamageOverTime_Child) endfunction //============================================================================= //Fades a unit from one transparency to another over the alloted time at the speed wanted //Use values from 0-100 for transparency function FadeUnit_Child takes nothing returns nothing local timer t=GetExpiredTimer() local unit u=GetHandleUnit(t, "target") local real inittransparency=GetHandleReal(t, "inittransparency") local real fadeout=GetHandleReal(t, "fadeout") local real finaltransparency=GetHandleReal(t, "finaltransparency") set inittransparency= (inittransparency - fadeout) if GetUnitState(u,UNIT_STATE_LIFE)<=0 then call ClearTimer(t) else call SetUnitVertexColor(u, 255, 255, 255, PercentTo255(inittransparency)) call SetHandleReal(t, "inittransparency", inittransparency) endif set u=null endfunction function FadeUnit_End takes nothing returns nothing local timer t2 = GetExpiredTimer() local timer t = GetHandleTimer(t2,"t") call ClearTimer(t) call ClearTimer(t2) endfunction function FadeUnit takes unit target, real inittransparency, real finaltransparency, real duration, real timeout returns nothing local timer t=CreateTimer() local timer t2=CreateTimer() call SetHandleHandle(t, "target", target) call SetHandleReal(t, "inittransparency", inittransparency) call SetHandleReal(t, "fadeout", (inittransparency - finaltransparency) / (duration/timeout)) call SetHandleReal(t, "finaltransparency", finaltransparency) call SetHandleHandle(t2,"t",t) call TimerStart(t, timeout, true, function FadeUnit_Child) call TimerStart(t2,duration,false,function FadeUnit_End) endfunction //============================================================================= //A nice looking jump parabola for units from their location to an x/y function JumpUnit_Parabola takes real dist, real maxdist,real curve returns real local real t = (dist*2)/maxdist-1 return (-t*t+1)*(maxdist/curve) endfunction function JumpUnit_Child takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = GetHandleUnit(t,"u") local real maxdist = GetHandleReal(t,"maxdist") local real ang = GetHandleReal(t,"ang") local real movedist = GetHandleReal(t,"movedist") local real x = GetHandleReal(t,"x") local real y = GetHandleReal(t,"y") local real dist = SquareRoot((GetUnitX(u)-x)*(GetUnitX(u)-x) + (GetUnitY(u)-y)*(GetUnitY(u)-y)) local real height = JumpUnit_Parabola(dist,maxdist,GetHandleReal(t,"arc")) local integer i = GetHandleInt(t,"i") call SetUnitPosition(u, GetUnitX(u) + movedist * Cos(ang * bj_DEGTORAD) , GetUnitY(u) + movedist * Sin(ang * bj_DEGTORAD)) call SetUnitFlyHeight(u,height,null) call SetHandleInt(t,"i",i + 1) if i == 50 then call SetUnitTimeScalePercent(u, 100) elseif i == 100 then call PauseUnit( u,false ) call SetUnitPathing( u, true ) call SetUnitFlyHeight(u,GetUnitDefaultFlyHeight(u),9999) set x = GetUnitX(u) + 100. * Cos(ang * bj_DEGTORAD) set y = GetUnitY(u) + 100. * Sin(ang * bj_DEGTORAD) call DestroyEffect(AddSpecialEffect(GetHandleString(t,"sfx"), x,y)) call DamageEnemiesArea(u, 200, x, y, GetHandleReal(t,"damage"), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null) call QueueUnitAnimation(u, "stand ready") call ClearTimer(t) endif set u = null endfunction function JumpUnit takes unit tojump, real xdest, real ydest, real damage, string sfx, real arc, real timeout returns nothing local timer t = CreateTimer() local unit u = tojump local real ux = GetUnitX(u) local real uy = GetUnitY(u) local real ang = bj_RADTODEG * Atan2((ydest-uy),(xdest-ux)) local real x = xdest - 100. * Cos(ang * bj_DEGTORAD) local real y = ydest - 100. * Sin(ang * bj_DEGTORAD) call SetHandleHandle(t,"u",u) call SetHandleReal(t,"x",x) call SetHandleReal(t,"y",y) call SetHandleReal(t,"maxdist", SquareRoot((ux-x)*(ux-x) + (uy-y)*(uy-y))) call SetHandleReal(t,"ang",ang) call SetHandleReal(t,"movedist",SquareRoot((ux-x)*(ux-x) + (uy-y)*(uy-y))/100) call SetHandleReal(t,"damage",damage) call SetHandleReal(t,"arc",arc) call SetHandleString(t,"effect",sfx) call SetHandleInt(t,"i",0) call PauseUnit( u,true ) call SetUnitPathing( u, false ) call UnitAddAbility( u,FlyTrickId() ) call UnitRemoveAbility( u,FlyTrickId() ) call SetUnitAnimation(u, "attack slam") call SetUnitTimeScalePercent(u, 30) call TimerStart(t,timeout,true,function JumpUnit_Child) set u = null endfunction //============================================================================= //Slides a unit over a period of time, from an init speed to a final speed //if no effect is wanted just use "none.mdl" function SlideUnitTimed_Child takes nothing returns nothing local timer t=GetExpiredTimer() local unit toslide=GetHandleUnit(t, "toslide") local real initSpeed=GetHandleReal(t, "initSpeed") local real angle=GetHandleReal(t, "angle") local real x = GetUnitX(toslide)+initSpeed*Cos(angle*bj_DEGTORAD) local real y = GetUnitY(toslide)+initSpeed*Sin(angle*bj_DEGTORAD) if GetUnitState(toslide,UNIT_STATE_LIFE) >0 or initSpeed<=0 then call SetUnitPosition(toslide,x,y) call DestroyEffect(AddSpecialEffect(GetHandleString(t,"effect"),x,y)) if GetHandleBoolean(t,"killtrees")==true then call KillTrees(x,y,120) endif else call ClearTimer(t) endif call SetHandleReal(t, "initSpeed", initSpeed-GetHandleReal(t, "decrease")) set toslide=null endfunction function SlideUnitTimed_End takes nothing returns nothing local timer t2 = GetExpiredTimer() local timer t = GetHandleTimer(t2,"t") call ClearTimer(t) call ClearTimer(t2) endfunction function SlideUnitTimed takes unit toslide, real duration, real timeout, real initSpeed, real finalSpeed, real angle, boolean killtrees, string sfx returns nothing local timer t=CreateTimer() local timer t2=CreateTimer() call SetHandleHandle(t, "toslide", toslide) call SetHandleReal(t, "initSpeed", initSpeed) call SetHandleReal(t, "decrease", (initSpeed-finalSpeed)/R2I((duration/timeout))) call SetHandleReal(t, "angle", angle) call SetHandleBoolean(t, "killtrees", killtrees) call SetHandleString(t,"effect",sfx) call SetHandleHandle(t2,"t",t) call TimerStart(t, timeout, true, function SlideUnitTimed_Child) call TimerStart(t2,duration,false,function SlideUnitTimed_End) endfunction //============================================================================= //Preload dummy abilities to remove first cast lag function PreLoadAbility takes integer abilcode returns nothing local unit u=CreateUnit(Player(13), CasterUnitId(), 0, 0, 0) call UnitAddAbility(u, abilcode) call KillUnit(u) call RemoveUnit(u) set u=null endfunction //============================================================================= //Adds a fading text tag to an x/y or over a unit //Integers from 0-255 are to be used function TextTag takes string text, real x, real y, integer red, integer green, integer blue, integer alpha, real velocity, real duration returns nothing local texttag t = CreateTextTag() call SetTextTagText(t, text, 0.025) call SetTextTagPos(t, x, y, 0.) call SetTextTagColor(t, red, green, blue, alpha) call SetTextTagVelocity(t, 0, velocity) call SetTextTagVisibility(t, true) call SetTextTagFadepoint(t, 2) call SetTextTagLifespan(t, duration) call SetTextTagPermanent(t, false) set t = null endfunction function TextTagUnit takes string text, unit targ, integer red, integer green, integer blue, integer alpha, real velocity, real duration returns nothing local texttag t = CreateTextTag() call SetTextTagText(t, text, 0.025) call SetTextTagPosUnit(t, targ,15) call SetTextTagColor(t, red, green, blue, alpha) call SetTextTagVelocity(t, 0, velocity) call SetTextTagVisibility(t, true) call SetTextTagFadepoint(t, 2) call SetTextTagLifespan(t, duration) call SetTextTagPermanent(t, false) set t = null endfunction //============================================================================= //Slide Functions Below: constant function Slippery_Ish_WaterEffect takes nothing returns string return "SlideWater.mdx" // The effect used when the unit slides on water endfunction constant function Slippery_Ish_GroundEffect takes nothing returns string return "Dust.mdx" // The effect used when the unit slides on the ground endfunction //#####################################################// function Slippery_Ish_KillTrees takes nothing returns nothing call KillDestructable(GetEnumDestructable()) endfunction function Slippery_Ish_SlideUnitTimed_Child takes nothing returns nothing local timer t=GetExpiredTimer() local unit toslide=GetHandleUnit(t, "toslide") local real initSpeed=GetHandleReal(t, "initSpeed") local real angle=GetHandleReal(t, "angle") local real x = GetUnitX(toslide)+initSpeed*Cos(angle*bj_DEGTORAD) local real y = GetUnitY(toslide)+initSpeed*Sin(angle*bj_DEGTORAD) local rect r=Rect(x - 120,y - 120,x + 120,y + 120) if GetUnitState(toslide,UNIT_STATE_LIFE) >0 and initSpeed>0 then call SetUnitPosition(toslide,x,y) call EnumDestructablesInRect(r,null,function Slippery_Ish_KillTrees) else if t!= null then call PauseTimer(t) call TriggerSleepAction(0) call FlushHandleLocals(t) call DestroyTimer(t) endif endif call SetHandleReal(t, "initSpeed", initSpeed-GetHandleReal(t, "decrease")) call RemoveRect(r) set r = null set toslide=null endfunction function Slippery_Ish_SlideUnitTimed_End takes nothing returns nothing local timer t2 = GetExpiredTimer() local timer t = GetHandleTimer(t2,"t") local timer t3 = GetHandleTimer(t2,"t3") call PauseTimer(t) call PauseTimer(t2) call PauseTimer(t3) call DestroyEffect(GetHandleEffect(t3,"effect")) call TriggerSleepAction(0) if t!= null then call FlushHandleLocals(t) call DestroyTimer(t) endif if t2!= null then call FlushHandleLocals(t2) call DestroyTimer(t2) endif if t3!= null then call FlushHandleLocals(t3) call DestroyTimer(t3) endif endfunction function Slippery_Ish_SlideUnitTimed_Effect takes nothing returns nothing local timer t3 = GetExpiredTimer() local effect e = GetHandleEffect(t3,"effect") local unit u = GetHandleUnit(t3,"u") call DestroyEffect(e) if ( not ( IsTerrainPathable(GetUnitX(u),GetUnitY(u), PATHING_TYPE_FLOATABILITY) == true ) ) then set e = AddSpecialEffectTarget(Slippery_Ish_WaterEffect(),u,"origin") else set e = AddSpecialEffectTarget(Slippery_Ish_GroundEffect(),u,"origin") endif call SetHandleHandle(t3,"effect",e) set e = null set u = null endfunction function Slippery_Ish_SlideUnitTimed takes unit toslide, real duration, real timeout, real initSpeed, real finalSpeed, real angle returns nothing local timer t=CreateTimer() local timer t2=CreateTimer() local timer t3=CreateTimer() local unit u = toslide call SetHandleHandle(t, "toslide", u) call SetHandleReal(t, "initSpeed", initSpeed) call SetHandleReal(t, "decrease", (initSpeed-finalSpeed)/R2I((duration/timeout))) call SetHandleReal(t, "angle", angle) if GetTerrainType(GetUnitX(u),GetUnitY(u)) == 'Zsan' then set bj_lastCreatedEffect = AddSpecialEffectTarget(Slippery_Ish_WaterEffect(),u,"origin") else set bj_lastCreatedEffect = AddSpecialEffectTarget(Slippery_Ish_GroundEffect(),u,"origin") endif call SetHandleHandle(t2,"t",t) call SetHandleHandle(t2,"t3",t3) call SetHandleHandle(t3,"effect",bj_lastCreatedEffect) call SetHandleHandle(t3,"u",u) call TimerStart(t, timeout, true, function Slippery_Ish_SlideUnitTimed_Child) call TimerStart(t2,duration,false,function Slippery_Ish_SlideUnitTimed_End) call TimerStart(t3,.2, true, function Slippery_Ish_SlideUnitTimed_Effect) set u = null endfunction //Naga Radar function AddEffectsUnitHoming_Child takes nothing returns nothing local timer t = GetExpiredTimer() local real distance = GetHandleReal(t,"distance") local real x = GetHandleReal(t,"x") local real y = GetHandleReal(t,"y") local unit targ = GetHandleUnit(t,"targ") local real ang = bj_RADTODEG * Atan2(GetUnitY(targ) - y, GetUnitX(targ) - x) local real dx local real dy set x = x + distance * Cos(ang * bj_DEGTORAD) set y = y + distance * Sin(ang * bj_DEGTORAD) call DestroyEffect(AddSpecialEffect(GetHandleString(t,"sfx"),x,y)) set dx = GetUnitX(targ) - x set dy = GetUnitY(targ) - y if SquareRoot(dx * dx + dy * dy)<distance+distance then call PauseTimer(t) call FlushHandleLocals(t) call DestroyTimer(t) else call SetHandleReal(t,"x",x) call SetHandleReal(t,"y",y) endif set targ = null endfunction function AddEffectsUnitHoming takes unit cast, unit targ, real timeout, real distance, string sfx returns nothing local timer t = CreateTimer() local real x = GetUnitX(cast) local real y = GetUnitY(cast) local real ang = bj_RADTODEG * Atan2(GetUnitY(targ) - y, GetUnitX(targ) - x) set x = x + distance * Cos(ang * bj_DEGTORAD) set y = y + distance * Sin(ang * bj_DEGTORAD) call DestroyEffect(AddSpecialEffect(sfx,x,y)) call SetHandleReal(t,"x",x) call SetHandleReal(t,"y",y) call SetHandleReal(t,"distance",distance) call SetHandleString(t,"sfx",sfx) call SetHandleHandle(t,"targ",targ) call TimerStart(t,timeout,true,function AddEffectsUnitHoming_Child) endfunction //Host function GetHostId takes nothing returns integer //This stores the Id + 1 for each player. call StoreInteger(LocalVars(), "missionKey", "key", GetPlayerId(GetLocalPlayer()) + 1) //Setup the TriggerSyncReady call. call TriggerSyncStart() //Sync the value of the entry for each player. //Each value will sync to the value of the host. call SyncStoredInteger(LocalVars(), "missionKey", "key") //Wait until the Game Cache syncs the key for everyone. call TriggerSyncReady() //Return the synced value as a id. return GetStoredInteger(LocalVars(), "missionKey", "key") - 1 endfunction function GetHostAverage takes nothing returns nothing local integer array id local integer max = 0 local integer t = 0 local integer i = 0 set udg_Host = null loop exitwhen i > 11 set id[i] = 0 set i = i + 1 endloop set i = 0 loop exitwhen i > 5 set t = GetHostId() set id[t] = id[t] + 1 if id[t] > id[max] then set max = t endif set i = i + 1 call TriggerSleepAction(1) endloop set udg_Host = Player(max) endfunction If you can help me with this issue, I will give +rep. |
| 12-27-2008, 04:27 PM | #2 |
I have updated the thread. |
