HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Asking a unit to cast a stored spell

08-26-2009, 06:06 PM#1
PhoenixICE
Basically i have 2 variables, Spell_Level and Spell_type, i can add both spells to a dummy caster, but how do i make the dummy caster cast the spell, since it can be any preset spell i can't use the Unit - Order (Last Created Unit) to XXX Spell (Triggering Unit), is there any work around?


Also is there a global - A Player Selects a unit event?
08-26-2009, 06:22 PM#2
Themerion
Yes, use the custom script directly instead of using the triggeraction to do it. For instance, in the case of slow:

Trigger:
Unit - Order (Last created unit) to Human Sorceress - Slow (Target unit of ability being cast)
Collapse JASS:
call IssuePointOrder(bj_lastCreatedUnit,"slow",GetSpellTargetUnit())

-----------------

The script allows you to use variables:

Collapse JASS:
set udg_TempString = "clusterrockets"
call IssuePointOrder(bj_lastCreatedUnit,udg_TempString,GetSpellTargetUnit())
Trigger:
Set TempString = clusterrockets
Custom Script: call IssuePointOrder(bj_lastCreatedUnit,udg_TempString,GetSpellTargetUnit())

PS. All variables declared in the variable editor must always begin with udg_ when used directly by a script.
08-26-2009, 06:43 PM#3
PhoenixICE
Thnxs for the information, but for some reason its not registering who kills to unit correctly or i've made the bounty wrong.

Does it matter if the Dummy Caster is removed straight away? Or is it because i set the dice sides to 1 and number of dices 1 ?
08-26-2009, 07:33 PM#4
0zyx0
You should not remove the dummy caster, you could give it an ability that makes it expire (like summoned units has).
08-26-2009, 07:59 PM#5
Vulcano
-Give it negative regen so it dies from itself
or
-Add an expiration timer to the unit
08-26-2009, 09:34 PM#6
Themerion
If you tell a dummy caster to use (for instance) storm bolt, and the storm bolt kills a unit, the killing unit will of course be the dummy caster. There's no way around this.

However, as far as bounty is concerned, all you need to do is to set the dummy unit to the right player, before you cast.

Trigger:
Unit - Change Owner of (Last Created Unit) to (Owner of (Get Spell Casting Unit))
Set TempString = clusterrockets
Custom Script: call IssuePointOrder(bj_lastCreatedUnit,udg_TempString,GetSpellTargetUnit())
08-26-2009, 09:40 PM#7
PhoenixICE
But the dummy caster is created for a specific player, why would i need to change ownership?

Also another question, with the custom trigger where would the goblin landmine ability come in as, since its not a target unit spell i tried looking for it in the target a point drop down list and wasn't able to find it.

Another bug occurs as well, chain lightning doesn't bounce - i'm guessing this is cause the casting unit is dead, but that doesn't count for the bounty not being given, i'll test this some more.
08-27-2009, 01:53 AM#8
Zerzax
You can test the order for goblin land mine by registering a unit casting the spell and using OrderId2String(GetUnitCurrentOrder(GetTriggerUnit())). The spell itself is probably a point target spell.

I checked in the object editor and the order string of the lay mine ability isnt shown.
08-27-2009, 05:07 AM#9
Themerion
If they are already created for the player, it's cool...

Woaah! I'm terribly sorry! If you are to target a unit, IssuePointOrder won't do. You need IssueTargetOrder...

Collapse JASS:
// For targeting units
  call IssueTargetOrder( caster, "orderstring", target )

// For targeting points
  call IssuePointOrderLoc( caster, "orderstring", point )

// For instant spells
  call IssueImmediateOrder( caster, "orderstring")

Example with point/location (including leak-cleaning):

Trigger:
Set TempPoint = (Get Spell Target Point)
Custom Script: call IssuePointOrderLoc(bj_lastCreatedUnit, "earthquake", udg_TempPoint )
Custom Script: call RemoveLocation(udg_TempPoint)

Example with instant spells (like thunderclap):

Trigger:
Custom Script: call IssueImmediateOrder(bj_lastCreatedUnit, "stomp")

Example with unit target spells:

Trigger:
Custom Script: call IssueTargetOrder(bj_lastCreatedUnit, "thunderbolt",GetSpellTargetUnit())

---------------------

Also, what Zerzax sais is really useful. It allows you to try for OrderIds!

Trigger:
Collapse Event
Unit Is Given an order (targeting what the ability targets: point/unit)
Collapse Actions
Custom Script: call BJDebugMsg( OrderId2String(GetIssuedOrder()) )

This may for instance output: 825068. Use it like so:

Trigger:
Custom Script: set udg_MyStringVariable = OrderId2String( 825068 )
--- Now your variable MyStringVariable contains the order string ---

Edited according to what Anitarf says below.
08-27-2009, 01:14 PM#10
Anitarf
If you're using GUI locations, you need to use IssuePointOrderLoc, the code you currently have wouldn't even compile.