The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Mounting
Posted by: Mounting | February 8, 2010 @ 9:26am
PHP Code
[
Download
]
globals constant integer MOUNT_UNIT_ID = 'n001' constant integer MOUNT_ABILITY_ID = 'A002' constant integer UNMOUNT_ABILITY_ID = 'A001' constant integer MOUNTED_BUFF_ID = 'B000' constant integer FLY_ABILITY_ID = 'Amrf' endglobals function Trig_Mount_Conditions takes nothing returns boolean return GetSpellAbilityId() == MOUNT_ABILITY_ID endfunction struct MountingData unit mounter unit mount timer time static method create takes unit caster, unit created returns MountingData local MountingData d = MountingData.allocate() set d.mounter = caster set d.mount = created return d endmethod method onDestroy takes nothing returns nothing set .mounter = null set .mount = null call ReleaseTimer(.time) endmethod endstruct function MoveMounter takes nothing returns nothing local MountingData d = GetTimerData(GetExpiredTimer()) local real x = GetWidgetX(d.mount) + 20 * Cos(GetUnitFacing(d.mount) * bj_DEGTORAD) local real y = GetWidgetY(d.mount) + 20 * Sin(GetUnitFacing(d.mount) * bj_DEGTORAD) call SetUnitX(d.mounter,x) call SetUnitY(d.mounter,y) call SetUnitFacing(d.mounter,GetUnitFacing(d.mount)) endfunction function Trig_Mount_Actions takes nothing returns nothing local unit mounter = GetSpellAbilityUnit() local unit mount = CreateUnit(GetOwningPlayer(mounter), MOUNT_UNIT_ID, GetWidgetX(mounter), GetWidgetY(mounter), GetUnitFacing(mounter)) local MountingData d = MountingData.create(mounter,mount) set d.time = NewTimer() call SetTimerData(d.time,d) if GetLocalPlayer() == GetOwningPlayer(mounter) then call ClearSelection() call SelectUnit(mount, true) endif call SetUnitPathing(mounter, false) call UnitAddAbility(mounter, FLY_ABILITY_ID) call SetUnitFlyHeight(mounter, 50.0, 0) call PauseUnit(mounter, true) set mounter = null set mount = null call TimerStart(d.time,0.03,true,function MoveMounter) endfunction //=========================================================================== function InitTrig_Mount takes nothing returns nothing local trigger mount = CreateTrigger() local trigger unmount = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(mount, EVENT_PLAYER_UNIT_SPELL_FINISH) call TriggerAddCondition(mount, Condition(function Trig_Mount_Conditions)) call TriggerAddAction(mount, function Trig_Mount_Actions) endfunction
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.60 / 8
58 Votes
http://codebin.yi.org/490
page generated in 0.01 seconds