//=========================================================================== // // Just another Warcraft III map // // Warcraft III map script // Generated by the Warcraft III World Editor // Date: Fri Feb 08 10:48:25 2008 // Map Author: Unknown // //=========================================================================== //*************************************************************************** //* //* Global Variables //* //*************************************************************************** globals // Generated trigger gg_trg_Init = null trigger gg_trg_Damage_Taken = null trigger gg_trg_Animated_Text = null trigger gg_trg_Test_mit_Doku = null endglobals function InitGlobals takes nothing returns nothing endfunction //*************************************************************************** //* //* Unit Creation //* //*************************************************************************** //=========================================================================== function CreateUnitsForPlayer0 takes nothing returns nothing local player p = Player(0) local unit u local integer unitID local trigger t local real life set u = CreateUnit( p, 'otau', 707.3, 532.8, 348.969 ) set u = CreateUnit( p, 'otau', 239.2, 622.1, 288.015 ) set u = CreateUnit( p, 'otau', -308.3, 92.4, 170.843 ) set u = CreateUnit( p, 'hfoo', -77.9, 595.0, 143.826 ) set u = CreateUnit( p, 'hfoo', 505.5, 251.1, 134.806 ) set u = CreateUnit( p, 'Obla', 585.2, -110.1, 135.312 ) set u = CreateUnit( p, 'hfoo', 218.7, 147.9, 302.342 ) set u = CreateUnit( p, 'hfoo', 44.1, -42.3, 302.814 ) set u = CreateUnit( p, 'hfoo', -22.6, -233.3, 8.734 ) endfunction //=========================================================================== function CreatePlayerBuildings takes nothing returns nothing endfunction //=========================================================================== function CreatePlayerUnits takes nothing returns nothing call CreateUnitsForPlayer0( ) endfunction //=========================================================================== function CreateAllUnits takes nothing returns nothing call CreatePlayerBuildings( ) call CreatePlayerUnits( ) endfunction //*************************************************************************** //* //* Custom Script Code //* //*************************************************************************** //TESH.scrollpos=0 //TESH.alwaysfold=0 // By Vexorian globals integer N = 0 timer array T endglobals //========================================================================================== function NewTimer takes nothing returns timer if (N==0) then return CreateTimer() endif set N=N-1 return T[N] endfunction //========================================================================================== function ReleaseTimer takes timer t returns nothing call PauseTimer(t) if (N==8191) then debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!") //stack is full, the map already has much more troubles than the chance of bug call DestroyTimer(t) else set T[N]=t set N=N+1 endif endfunction // by Griffen function TimerAttach takes timer t, real time, real value, code func returns nothing call TimerStart(t, value, false, null) call PauseTimer(t) call TimerStart(t, time, false, func) endfunction // ONLY call on an expired timer. function GetTimerInt takes timer t returns integer return R2I(TimerGetRemaining(t) + 0.5) endfunction //*************************************************************************** //* //* Triggers //* //*************************************************************************** //=========================================================================== // Trigger: Init //=========================================================================== function Trig_Init_Func001A takes nothing returns nothing call TriggerRegisterUnitEvent( gg_trg_Damage_Taken, GetEnumUnit(), EVENT_UNIT_DAMAGED ) endfunction function Trig_Init_Actions takes nothing returns nothing call ForGroupBJ( GetUnitsInRectAll(GetPlayableMapRect()), function Trig_Init_Func001A ) endfunction //=========================================================================== function InitTrig_Init takes nothing returns nothing set gg_trg_Init = CreateTrigger( ) call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions ) endfunction //=========================================================================== // Trigger: Damage Taken //=========================================================================== //TESH.scrollpos=0 //TESH.alwaysfold=0 function Trig_Damage_Taken_Actions takes nothing returns nothing local real height = 10. local AnimatedText AT // Je nachdem, wie hoch der Damage war, soll der Text unterschiedlich gross erscheinen if GetEventDamage() > 15 then set height = 11. endif if GetEventDamage() > 20 then set height = 12. endif if GetEventDamage() > 30 then set height = 15. endif if GetEventDamage() > 40 then set height = 20. endif // Einen Text mit dem Schaden an der Position der Unit erstellen set AT = AnimatedText.create(I2S(R2I(GetEventDamage() + 0.5)), GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), height) // Den Text rot faerben call AT.SetColor(255, 0, 0, 255) set height = 0. endfunction //=========================================================================== function InitTrig_Damage_Taken takes nothing returns nothing set gg_trg_Damage_Taken = CreateTrigger( ) call TriggerAddAction( gg_trg_Damage_Taken, function Trig_Damage_Taken_Actions ) endfunction //=========================================================================== // Trigger: Animated Text //=========================================================================== //TESH.scrollpos=9 //TESH.alwaysfold=0 struct LinkedTextTags public texttag tt public string char private LinkedTextTags next static method create takes string s, real height returns LinkedTextTags local LinkedTextTags LTT = LinkedTextTags.allocate() local integer length = StringLength(s) debug call BJDebugMsg("LinkedTextTags Create Nr: " + I2S(LTT)) if LTT == 0 then set length = 0 return 0 endif set LTT.tt = CreateTextTag() set LTT.char = SubString(s, 0, 1) call SetTextTagText(LTT.tt, LTT.char, height) if length > 1 then set LTT.next = LinkedTextTags.create(SubString(s, 1, length), height) else set LTT.next = 0 endif set length = 0 return LTT endmethod private method onDestroy takes nothing returns nothing debug call BJDebugMsg("LinkedTextTags Destroy Nr: " + I2S(this)) if this.next != 0 then call this.next.destroy() set this.next = 0 endif call DestroyTextTag(this.tt) endmethod private static LinkedTextTags enumTextTag = 0 private static trigger enumTrigger = CreateTrigger() private static triggeraction enumTriggerAction = null public static method GetEnumTextTag takes nothing returns texttag if LinkedTextTags.enumTextTag == 0 then return null else return LinkedTextTags.enumTextTag.tt endif endmethod public static method GetEnumLinkedTextTags takes nothing returns LinkedTextTags return LinkedTextTags.enumTextTag endmethod public method ForLinkedTextTags takes code c returns nothing if LinkedTextTags.enumTriggerAction != null then call TriggerRemoveAction(LinkedTextTags.enumTrigger, LinkedTextTags.enumTriggerAction) endif set LinkedTextTags.enumTextTag = this set LinkedTextTags.enumTriggerAction = TriggerAddAction(LinkedTextTags.enumTrigger, c) call TriggerExecute(LinkedTextTags.enumTrigger) if this.next != 0 then call this.next.ForLinkedTextTags(c) endif endmethod endstruct struct AnimatedLinkedTextTags extends LinkedTextTags real x real y real size // The starting height of the floating text // this will affect only the first bounce. static constant real defaultHeight = 128. real height // the starting move speed of the floating text (in upwards direction) // increasing this will result in a stronger starting bounce static constant real startVelocity = 10. // the velocity of the bounces // increasing this will make the text more "bouncy" // DO NOT SET THIS TO ZERO (0). set it to 0.01 if you don't want // the text to bounce at all static constant real defaultVelocity = 12. real velocity // the rate at which the movespeed changes. -2.2 means, that the floating text is // dragged downwards faster, the longer it exists // decreasing this value will result in quicker bounces. // if you increase it above zero, it will reslt in balloon like behaviour static constant real defaultVelocityChange = -2.2 real velocityChange // the change of velocity between two bounces. // so if this is set to 2 and velocityChange is set to -1, // then the first bounce will have velocityChange of -1, the second of -2 // the third of -4 etc. // decreasing this will result in larger secondary bounces. // setting it between 0 and 1 will result in bounces that get larger // setting this to 1 will result in equally large bounces // setting this to a number greater than 1 will result small bounces. // I recommend something between 1.5 and 2 // I have no idea what happens if you set this below zero. static constant real bounceVelocityChange = 2 static constant real maxVelocityChangeRate = 1. public static method applyMove takes nothing returns nothing local AnimatedLinkedTextTags ALTT = LinkedTextTags.GetEnumLinkedTextTags() set ALTT.height = RMaxBJ(ALTT.height + ALTT.velocity, 0.) if ALTT.height > 0 then set ALTT.velocity = ALTT.velocity + ALTT.velocityChange else set ALTT.velocityChange = ALTT.velocityChange * AnimatedLinkedTextTags.bounceVelocityChange if RAbsBJ(ALTT.velocityChange / AnimatedLinkedTextTags.defaultVelocity) <= AnimatedLinkedTextTags.maxVelocityChangeRate then set ALTT.velocity = AnimatedLinkedTextTags.defaultVelocity else set ALTT.velocity = 0. set ALTT.velocityChange = 0. set ALTT.height = 0.001 endif endif call SetTextTagPos(ALTT.tt, ALTT.x, ALTT.y, ALTT.height) endmethod endstruct struct AnimatedText private AnimatedLinkedTextTags altt private timer t private real size private timer endTimer // the duration of the floating text. private static constant real duration = 1.5 // the fadepoint of the floating text private static constant real fadePoint = 1. // the variation between the letters of the text // values further away from zero will result in more random // behaviour. a value of zero means, that the letters look like a // single floating text private static constant real velocityRandomFactor = 0.2 private static method GetRandomStartVelocity takes nothing returns real local real randomFactor = AnimatedLinkedTextTags.startVelocity * AnimatedText.velocityRandomFactor local real result = GetRandomReal(AnimatedLinkedTextTags.startVelocity - randomFactor, AnimatedLinkedTextTags.startVelocity + randomFactor) set randomFactor = 0. return result endmethod private static method move takes nothing returns nothing local AnimatedText AT = GetTimerInt(GetExpiredTimer()) call AT.altt.ForLinkedTextTags(function AnimatedLinkedTextTags.applyMove) call TimerAttach(GetExpiredTimer(), 0.04, AT, function AnimatedText.move) set AT = 0 endmethod private static method GetSpecialCharacterOffset takes string char, real offset returns real if char == "i" then return 0.4 * offset elseif char == "j" or char == "l" then return 0.25 * offset elseif char == "f" or char == "1" then return 0.2 * offset elseif char == "m" or char == "w" then return -0.25 * offset endif return 0. endmethod private static AnimatedText tempAT private static real tempX private static real tempY private static real offset private static method InitTextTag takes nothing returns nothing local AnimatedLinkedTextTags ALTT = LinkedTextTags.GetEnumLinkedTextTags() local real specialCharacterOffset = AnimatedText.GetSpecialCharacterOffset(ALTT.char, AnimatedText.tempAT.size * 1.15) set ALTT.x = AnimatedText.tempX + AnimatedText.offset + specialCharacterOffset set ALTT.y = AnimatedText.tempY set ALTT.height = AnimatedLinkedTextTags.defaultHeight set ALTT.velocity = AnimatedText.GetRandomStartVelocity() set ALTT.velocityChange = AnimatedLinkedTextTags.defaultVelocityChange call SetTextTagPos(ALTT.tt, ALTT.x, ALTT.y, ALTT.height) call SetTextTagVisibility(ALTT.tt, true) call SetTextTagPermanent(ALTT.tt, false) call SetTextTagLifespan(ALTT.tt, AnimatedText.duration) call SetTextTagFadepoint(ALTT.tt, AnimatedText.fadePoint) set AnimatedText.offset = AnimatedText.offset + (AnimatedText.tempAT.size * 1.15) set ALTT = 0 set specialCharacterOffset = 0 endmethod private static method end takes nothing returns nothing local AnimatedText AT = GetTimerInt(GetExpiredTimer()) call AT.destroy() set AT = 0 endmethod private method onDestroy takes nothing returns nothing call this.altt.destroy() call ReleaseTimer(this.t) call ReleaseTimer(this.endTimer) endmethod public static method create takes string text, real x, real y, real size returns AnimatedText local AnimatedText AT = AnimatedText.allocate() if AT == 0 then return 0 endif set AT.size = size set AT.altt = LinkedTextTags.create(text, TextTagSize2Height(size)) set AnimatedText.tempX = x set AnimatedText.tempY = y set AT.t = NewTimer() set AnimatedText.tempAT = AT set AnimatedText.offset = 0. call AT.altt.ForLinkedTextTags(function AnimatedText.InitTextTag) set AT.endTimer = NewTimer() call TimerAttach(AT.endTimer, AnimatedText.duration, AT, function AnimatedText.end) call TimerAttach(AT.t, 0.04, AT, function AnimatedText.move) return AT endmethod private static integer tempRed private static integer tempGreen private static integer tempBlue private static integer tempAlpha private static method SetColorEnum takes nothing returns nothing local texttag tt = LinkedTextTags.GetEnumTextTag() call SetTextTagColor(tt, AnimatedText.tempRed, AnimatedText.tempGreen, AnimatedText.tempBlue, AnimatedText.tempAlpha) set tt = null endmethod public method SetColor takes integer red, integer green, integer blue, integer alpha returns nothing set AnimatedText.tempRed = red set AnimatedText.tempGreen = green set AnimatedText.tempBlue = blue set AnimatedText.tempAlpha = alpha call this.altt.ForLinkedTextTags(function AnimatedText.SetColorEnum) endmethod //! textmacro SetTextTag1 takes NAME, ARGTYPE, ARG private static $ARGTYPE$ $NAME$_temp_$ARG$ private static method Set$NAME$Enum takes nothing returns nothing local texttag tt = LinkedTextTags.GetEnumTextTag() call SetTextTag$NAME$(tt, AnimatedText.$NAME$_temp_$ARG$) set tt = null endmethod public method Set$NAME$ takes $ARGTYPE$ $ARG$ returns nothing set AnimatedText.$NAME$_temp_$ARG$ = $ARG$ call this.altt.ForLinkedTextTags(function AnimatedText.Set$NAME$Enum) endmethod //! endtextmacro //! textmacro SetTextTag2 takes NAME, ARGTYPE1, ARG1, ARGTYPE2, ARG2 private static $ARGTYPE1$ $NAME$_temp_$ARG1$ private static $ARGTYPE2$ $NAME$_temp_$ARG2$ private static method Set$NAME$Enum takes nothing returns nothing local texttag tt = LinkedTextTags.GetEnumTextTag() call SetTextTag$NAME$(tt, AnimatedText.$NAME$_temp_$ARG1$, AnimatedText.$NAME$_temp_$ARG2$) set tt = null endmethod public method Set$NAME$ takes $ARGTYPE1$ $ARG1$, $ARGTYPE2$ $ARG2$ returns nothing set AnimatedText.$NAME$_temp_$ARG1$ = $ARG1$ set AnimatedText.$NAME$_temp_$ARG2$ = $ARG2$ call this.altt.ForLinkedTextTags(function AnimatedText.Set$NAME$Enum) endmethod //! endtextmacro //! runtextmacro SetTextTag1("Visibility", "boolean", "flag") //! runtextmacro SetTextTag1("Suspended", "boolean", "flag") //! runtextmacro SetTextTag1("Permanent", "boolean", "flag") //! runtextmacro SetTextTag1("Age", "real", "age") //! runtextmacro SetTextTag1("Fadepoint", "real", "fadepoint") //! runtextmacro SetTextTag2("Velocity", "real", "xvel", "real", "yvel") private static real tempLifespan private static method SetLifespanEnum takes nothing returns nothing local texttag tt = LinkedTextTags.GetEnumTextTag() call SetTextTagLifespan(tt, AnimatedText.tempLifespan) set tt = null endmethod public method SetLifespan takes real lifespan returns nothing set AnimatedText.tempLifespan = lifespan call TimerAttach(this.endTimer, lifespan, this, function AnimatedText.end) // I realize this is terribly inprecise, but it should not produce any bugs call this.altt.ForLinkedTextTags(function AnimatedText.SetLifespanEnum) endmethod endstruct //=========================================================================== function InitTrig_Animated_Text takes nothing returns nothing endfunction//=========================================================================== // Trigger: Test mit Doku //=========================================================================== //TESH.scrollpos=0 //TESH.alwaysfold=0 function Trig_Test_Actions takes nothing returns nothing // etwas ausfuehrlicherer test, mit mehr Optionen // der Trigger feuert, wenn man ein "-" eingibt, und gibt den Text dahinter // als springenden Text an. also z.B. "-test" oder "-2345" local AnimatedText AT = AnimatedText.create(SubString(GetEventPlayerChatString(), 1, StringLength(GetEventPlayerChatString())), GetCameraTargetPositionX(), GetCameraTargetPositionY(), 10) // Farbe aendern call AT.SetColor(255, 204, 0, 255) // Dauer und Fadepoint der FloatingTexts aendern call AT.SetLifespan(5) call AT.SetFadepoint(4) // Nur fuer den TriggeringPlayer anzeigen call AT.SetVisibility(GetLocalPlayer() == GetTriggerPlayer()) // Ich stelle fast alle Funktionen zur Verfuegung, die es auch fuer Texttags gibt. // also z.B. SetColor ruft einfach SetTextTagColor auf die Member auf. // SetLifeSpan ist das selbe wie SetTextTagLifespan, SetVisibility das selbe // wie SetTextTagVisibility etc. // Die einzigen Methoden, die ich nicht zur Verfügung stelle sind // SetText, SetPos und SetPosUnit // Diese sind aufgrund des internen Aufbaus eines AnimatedText sehr schwer // umzusetzen. Tut mir leid endfunction //=========================================================================== function InitTrig_Test_mit_Doku takes nothing returns nothing set gg_trg_Test_mit_Doku = CreateTrigger( ) call TriggerRegisterPlayerChatEvent( gg_trg_Test_mit_Doku, Player(0), "-", false ) call TriggerAddAction( gg_trg_Test_mit_Doku, function Trig_Test_Actions ) endfunction //=========================================================================== function InitCustomTriggers takes nothing returns nothing call InitTrig_Init( ) call InitTrig_Damage_Taken( ) call InitTrig_Animated_Text( ) call InitTrig_Test_mit_Doku( ) endfunction //=========================================================================== function RunInitializationTriggers takes nothing returns nothing call ConditionalTriggerExecute( gg_trg_Init ) endfunction //*************************************************************************** //* //* Players //* //*************************************************************************** function InitCustomPlayerSlots takes nothing returns nothing // Player 0 call SetPlayerStartLocation( Player(0), 0 ) call SetPlayerColor( Player(0), ConvertPlayerColor(0) ) call SetPlayerRacePreference( Player(0), RACE_PREF_HUMAN ) call SetPlayerRaceSelectable( Player(0), true ) call SetPlayerController( Player(0), MAP_CONTROL_USER ) endfunction function InitCustomTeams takes nothing returns nothing // Force: TRIGSTR_002 call SetPlayerTeam( Player(0), 0 ) endfunction //*************************************************************************** //* //* Main Initialization //* //*************************************************************************** //=========================================================================== function main takes nothing returns nothing call SetCameraBounds( -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) ) call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" ) call NewSoundEnvironment( "Default" ) call SetAmbientDaySound( "LordaeronSummerDay" ) call SetAmbientNightSound( "LordaeronSummerNight" ) call SetMapMusic( "Music", true, 0 ) call CreateAllUnits( ) call InitBlizzard( ) call InitGlobals( ) call InitCustomTriggers( ) call RunInitializationTriggers( ) endfunction //*************************************************************************** //* //* Map Configuration //* //*************************************************************************** function config takes nothing returns nothing call SetMapName( "Just another Warcraft III map" ) call SetMapDescription( "Nondescript" ) call SetPlayers( 1 ) call SetTeams( 1 ) call SetGamePlacement( MAP_PLACEMENT_USE_MAP_SETTINGS ) call DefineStartLocation( 0, 128.0, 64.0 ) // Player setup call InitCustomPlayerSlots( ) call SetPlayerSlotAvailable( Player(0), MAP_CONTROL_USER ) call InitGenericPlayerSlots( ) endfunction