| 05-12-2005, 06:07 PM | #1 |
I did try looking around for this, but I couldn't find anything--so hopefully this actually is a new topic. Blizzard has functions to damage units and areas, but there's still no innate function to cast a spell through triggers. Below is what I made to hopefully accomplish this: Code:
function CastSpellOnUnit takes player owner, unit target, integer spell, integer level returns nothing local unit LocustSpellCastingUnit local location LocationOfTarget set LocationOfTarget = GetUnitLoc( target ) call CreateNUnitsAtLoc( 1, 'h00D', owner, LocationOfTarget, bj_UNIT_FACING ) set LocustSpellCastingUnit = GetLastCreatedUnit() call RemoveLocation( LocationOfTarget ) call UnitAddAbilityBJ( spell, LocustSpellCastingUnit ) call SetUnitAbilityLevelSwapped( spell, LocustSpellCastingUnit, level ) call IssueTargetOrder( LocustSpellCastingUnit, AbilityId2String( spell ), target ) call PolledWait( 10.00 ) call RemoveUnit( LocustSpellCastingUnit ) endfunction The problem is in the IssueTargetOrder function. It takes a string as a paramater to what order to use, and I can't find one that takes an integer (the ability ID). I tried the AbilityId2String function since it seemed to make sense for that, but a test of the return value showed that it's returning an empty string. If need be, I could pass the order string as an additional argument to the function, but I'm hoping that's not necessary. So does anyone know how to cast an ability with just the ability ID? |
| 05-12-2005, 06:30 PM | #2 |
These are the native functions for this purpose: Code:
native IssueImmediateOrderById takes unit whichUnit, integer order returns boolean native IssuePointOrderByIdLoc takes unit whichUnit, integer order, location whichLocation returns boolean native IssueTargetOrderById takes unit whichUnit, integer order, widget targetWidget returns boolean |
| 05-12-2005, 07:54 PM | #3 |
And if it still doesn't work? I changed that line to: Code:
call IssueTargetOrderById( LocustSpellCastingUnit, spell, target ) The casting unit is being created at the right location with the right spell, but just not using it. For testing purposes, the unit is currently visible and selectable and I can order it to cast the spell, so it's not an improper target issue either. |
| 05-12-2005, 08:54 PM | #4 |
Are you sure you got the right OrderID? You can doublecheck it by manually ordering the unit to cast it with the following trigger on: Code:
Events
A unit is issued an order targeting a point
A unit is issued an order targeting an object
A unit is issued an order with no target
Conditions
Actions:
Custom SCript: call BJDebugMsg(I2S(GetIssuedOrderId())) |
| 05-12-2005, 09:14 PM | #5 |
Oi.. well the ID of the ability is very different from the ID to cast it. I'll have to go back to my original function call and pass an extra parameter to the function to use as the order string then. |
| 05-12-2005, 09:41 PM | #6 | |
Quote:
I begged blizzard for a GetAbilityOrderId function, but they always ignore that. |
