• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Spell-making problems.

Status
Not open for further replies.
Level 2
Joined
Sep 17, 2012
Messages
11
Hello there, I'm new here, and I've been attempting to create a simple map of which the goal is to survive through several levels of a dungeon.
Well, that's not the essence; I've attempted to make a spell [Please note - I'm only an amateur at triggering] which could transform the caster (any caster) into a bear, otherwise known as "Bear Form".
The trigger goes as simply as this;

Event - A unit begins the effect of a spell
Condition - Spell casted is equal to Bear Form
Action (and this is obviously where it gets loopy)
If (all conditions are true) then (actions) or else (actions)
-If; Conditions:
Unit type of (Casting unit) different of (Feral bear)
-Then; Actions:
Set BearFormCaster = (Unit type of (Casting Unit))
Unit - Replace (Casting unit) with a Feral Bear using new Max HP
-Else; Actions:
If (all conditions are true) then (actions) or else (actions)
-If; Conditions:
Unit-type of (casting unit) is equal to Feral bear
-Then; Actions:
Replace (casting unit) with BearFormCaster using Old unit HP and Mana
-Else; Actions:
Do nothing

So, yes, that's the simple trigger. The fact of the matter is, is that it works for 1 unit transforming in-and-out if it wishes so. Although, if 1 unit(#1) transforms in, another unit(#2) transforms in, the variable BearFormCaster is then changed to unit-type of unit(#2), and thus if unit(#1) transforms back, then it is changed into a unit-type equa to unit(#2).
At least, that's what I believe is the error.
And thus I am asking for help; how could I make this spell work so that one unit casting it, no matter how many units cast the same spell in between the first unit's transform in and transform out, be able to transform back to its original unit-type?

Thank you in advance,
CnP
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Convert BearFormCaster into an Array variable. (Enable "Array" in the variable creator)

Then, when you try to use the varible it will prompt you to select an index:
Set BearFormCaster[Index] = xxxx

That index will be the "Player Number of Owner of (Triggering Unit)"

You'll use the same value for conditions.

So, each variable will change based on the player number, wich means, every player transformation will be independent from the others.

Also, to post triggers, use
  • tags.
 
Level 2
Joined
Sep 17, 2012
Messages
11
Convert BearFormCaster into an Array variable. (Enable "Array" in the variable creator)

Then, when you try to use the varible it will prompt you to select an index:
Set BearFormCaster[Index] = xxxx

That index will be the "Player Number of Owner of (Triggering Unit)"

You'll use the same value for conditions.

So, each variable will change based on the player number, wich means, every player transformation will be independent from the others.

Also, to post triggers, use
  • tags.[/QUOTE]
  • Spartipilo;
  • Thank you. I've tried it, using arrays and it works. Albeit (just for the sake), if we wanted to make the spell unit-type independant (for example, if a player had multiple heroes with the same spell), how would we go on about it?
  • Thanks in advance,
  • CnP.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
For that you would have to replace the Array with a Hashtable and base everything on the unit ID, instead of the Array.

It's basically the same, but instead of using the PlayerId (Player number) in the Array, you use the UnitId (GetHandleId(unit)) in a Hashtable.
 
Level 2
Joined
Sep 17, 2012
Messages
11
I've tried so, although it would seem we cannot save unit-types directly to a hashtable, and instead, with the use of custom scripts, can save integers to a unit-type (?)

  • Set UnitType = Medivh
  • Custom script: set udg_TempInteger = udg_UnitType
  • Hashtable - Save 100 as 0 of TempInteger in YourHashtable
  • Set TempUnit = (Triggering unit) or any other event-response
  • Custom script: udg_TempInteger = GetUnitTypeId(udg_TempUnit)
  • Custom script: call BJDebugMsg(I2S(udg_TempInteger))
[Credit to defskull for posting this]
And as I attempt to save the map, I receive the error message;
Line 167; Wrong argument type (integer)
Linked directly to udg_TempInteger = GetUnitTypeId(udg_BearFormCaster)

And so now I don't know what I have done wrong, or perhaps I'm just that bad at creating hashtables.



EDIT:--
For better understanding, I will post here the full trigger of my spell;

  • Events:
    • A unit begins the effect of a spell
  • Condition:
    • (Spell being cast) Equal to (Bear Form)
  • Actions:
    • If (All conditions are true) then (Actions) or else (Actions)
      • Conditions If, Conditions:
        • Unit-type of (casting unit) different of (Feral bear)
      • Actions Then, Actions:
        • Hashtable - Create a hashtable
        • Set (BearFormCaster) = (Unit-typ of (Casting unit))
        • Custom script: set udg_TempInteger = udg_BearFormCaster
        • Hashtable - Save 100 as 0 of TempInteger
        • Unit - Replace (Casting unit) with a (Feral Bear) using the new Max HP and mana
    • Actions Else, Actions:
      • If (All conditions are true) then (Actions) or else (Actions)
        • Conditions If, Conditions:
          • Unit-type of (Casting unit) equal to (Feral Bear)
        • Actions Then, Actions:
          • Custom script: udg_TempInteger = GetUnitTypeId(udg_BearFormCaster)
          • Unit - Replace (Casting unit) with a (BearFormCaster) using the new Max HP and mana
        • Actions Else, Actions:
          • Do nothing
Thanks in advance,
CnP
 
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Unit types are integers, and anything in the game has an ID (GetHandleId(Widget)) It can be a unit, an item, an ability, a destructable, a location, a doodad, a region, a rect, a code, or anything else.

It doesn't work because you're addding a unit-type (udg_BearFormCaster) to an Integer Variable (udg_TempInteger). You would have to make GetUnitTypeID (wich is an integer) and save it as an integer.

UnitType and UnitTypeID is not the same :)

I would rather use Hide/Unhide thing.

When a unit enters Playable map area, and that unit has the Feral Beast ability, create the Bear (the unit you will replace that one with), then store the ID of the Unit that will turn into that bear in the bear ID, and store the bear that unit will transform to into that unit. Then, if the bear uses the ability, hide it, and unhide your unit. When your unit uses the ability, hide it, and unhide the bear. You have to update the location every time you do this.

  • t
    • Events
      • A unit enters playable map area
    • Conditions
      • Unit has ability (Transform)
    • Actions
      • Unit - Create the Bear
      • Custom script: set udg_BearID = GetHandleId(bj_lastCreatedUnit)
      • Custom script: set udg_UnitID = GetHandleId(GetTriggeringUnit())
      • Hasthable - Save BearID as 0 of UnitID in Hash
      • Hasthable - Save UnitID as 0 of BearID in Hash
      • Unit - Hide (last created unit)
  • transform
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • Ability being cast is (Your transformation ability)
    • Actions
      • Set LocationVariable = Position of (Triggering Unit)
      • Custom script: set udg_UnitID = GetHandleId(GetTriggeringUnit())
      • Custom script: set udg_TempUnit = LoadUnitHandle(udg_Hash, udg_UnitID, 0)
      • Unit - Unhide TempUnit
      • Unit - Move TempUnit to LocationVariable
      • Unit - Hide (Triggering Unit)
      • Custom script: call RemoveLocation(udg_LocationVariable)
 
Level 2
Joined
Sep 17, 2012
Messages
11
All right, thanks, Spartipilo.
I wasn't able to do what I was attempting to do, although I've resolved to it and I still have a lot of spells that I can do, and probably will need help with in the future. In the meanwhile, I can get better in triggering, for you have taught me what the Array actually allowed doing. Thus, well, that's good.

I guess we can call this close now.
 
Status
Not open for further replies.
Top