Wc3C.net (http://www.wc3c.net/forums.php)
-   Triggers & Scripts (http://www.wc3c.net/forumdisplay.php?f=8)
-   -   Item help (http://www.wc3c.net/showthread.php?t=88066)

aidan_124 10-10-2006 09:20 PM

Item help
Okay, I've made a map where most effects are done using items (don't ask why).
Most of this items abilities need triggering to work, and I can't work out how to affect the unit targeted by an items effect:eg
Unit - Unit Uses an Item

(Item-type of (Item being manipulated)) Equal to Staff of Silence

(This is the bit i can't work out how to do)
Set Mana of Targeted Unit = Mana of Targeted Unit-25.00
Is the Event Response - Targeted Unit the correct response to use for this trigger?!
If not how can i work it, or will I need to ask for help using JASS to do this?

Chuckle_Brother 10-10-2006 09:36 PM

Use a spellcast event(Starts the Effects of an Ability).

aidan_124 10-10-2006 09:39 PM

so like this?:
Clutch of The Undercity
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Clutch of the Undercity (item)
Collapse Actions
Unit - Move (Target unit of ability being cast) instantly to (Center of (Playable map area))

I'm also trying to use JASS. This is a trigger i wrote using JASS for a different ability. Can you check what i'm doing works and it does what i want it to?
Collapse JASS:

endfunctionfunction Trig_Dimir_Machinations_Conditions takes nothing returns boolean
      if ( not ( GetSpellAbilityId() == 'A00M' ) ) then
          return false
//** Checks that correct ability is used.

Function Trig_Dimir_Machinations_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 2
//** Sets effect to loop twice
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call UnitRemoveItemFromSlotSwapped( GetRandomInt(1, 6), null )
//** Removes an Item from a unit (not decided on a variable yet) in a random slot 1-6
        call RemoveItem( GetLastRemovedItem() )
//** Removes the dropped item from the game
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
function InitTrig_Dimir_Machinations takes nothing returns nothing
    set gg_trg_Dimir_Machinations = CreateTrigger(  )
//** Creates the Trigger (at initialization) with the name "gg_trg_Dimir_Machinations"
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dimir_Machinations, EVENT_PLAYER_UNIT_SPELL_CAST )
//** Triggeres the ability whenever someone casts a spell
    call TriggerAddCondition( gg_trg_Dimir_Machinations, Condition( function Trig_Dimir_Machinations_Conditions ) )
//** Causes the trigger to use the above condition   
    call TriggerAddAction( gg_trg_Dimir_Machinations, function Trig_Dimir_Machinations_Actions )
//** Causes the trigger to use the above actions


Chuckle_Brother 10-10-2006 10:48 PM

Well the first is okay, aside from that you don't want it to move him to map center.

As for second, you are dropping the item from a null unit(call UnitRemoveItemFromSlotSwapped( GetRandomInt(1, 6), null ))

Collapse JASS:
function UnitRemoveItemFromSlotSwapped takes integer itemSlot, unit whichHero returns item

aidan_124 10-10-2006 11:07 PM

Could i use this as that part of the trigger then? (again check i'm using the right commands etc.):
Collapse JASS:
function Trig_help_with_jass_Func001 takes nothing returns boolean
    return ( IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) == true )
//** Checks every to unit to see if its a hero

function Trig_help_with_jass_Func001A takes nothing returns nothing
    if ( Trig_help_with_jass_Func001() ) then
        set udg_Player_Hero[GetForLoopIndexB()] = GetEnumUnit()
//** If the condition was correct then it sets variable Player_Hero to that //** unit

function Trig_help_with_jass_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsOfPlayerAll(ConvertedPlayer(GetForLoopIndexB())), function Trig_help_with_jass_Func001A )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 2
//** Loops twice
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call UnitRemoveItemFromSlotSwapped( GetRandomInt(1, 6), udg_Player_Hero[GetConvertedPlayerId(GetOwningPlayer(GetSpellTargetUnit()))] )
//** removes an item from a random slot 1-6 from the Player_Hero with
//** Player number equal to the owner of triggering unit
        call RemoveItem( GetLastRemovedItem() )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1

function InitTrig_help_with_jass takes nothing returns nothing
    set gg_trg_help_with_jass = CreateTrigger(  )
    call TriggerAddAction( gg_trg_help_with_jass, function Trig_help_with_jass_Actions )

Or is there an easier way to do it. Also if I use the new trigger-->custom text as a place to write my code in the trigger editor (not using GUI obv) do I need to declare the variables I use, or can I use the variable editor?
Can I set the variables in a different trigger and still use them is this trigger?

Chuckle_Brother 10-11-2006 02:37 PM

Before I can really answer that....what is firing off this code? Currently its a map init or un-fired trigger that sits inert.

Also, using a BJ loop is silly, replace bj_forLoopAIndex and bj_forLoopAIndexEnd with locals:

Collapse JASS:
local integer i = 1

  exitwhen i > 2  //Replace 2 with however many times you want the loop to fire
    // **Your code goes here** //
  set i = i + 1

aidan_124 10-11-2006 04:07 PM

Thanks for the help, got this function sorted out (what it needs to say) only problem is compiling now, but thats a topic for different thread.

All times are GMT. The time now is 12:54 PM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services