wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 10-10-2006, 09:20 PM   #1
aidan_124
User
 
Join Date: Oct 2006
Posts: 47

aidan_124 has little to show at this moment (1)

Default 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
Trigger:
Events
Unit - Unit Uses an Item

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


Actions
(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?

Last edited by aidan_124 : 10-10-2006 at 09:26 PM.
aidan_124 is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 10-10-2006, 09:36 PM   #2
Chuckle_Brother
Oh for the sake of fudge
 
Chuckle_Brother's Avatar


Respected User
 
Join Date: Dec 2005
Posts: 782

Submissions (2)

Chuckle_Brother will become famous soon enough (53)Chuckle_Brother will become famous soon enough (53)

Send a message via ICQ to Chuckle_Brother Send a message via AIM to Chuckle_Brother Send a message via MSN to Chuckle_Brother Send a message via Yahoo to Chuckle_Brother
Default

Use a spellcast event(Starts the Effects of an Ability).
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 10-10-2006, 09:39 PM   #3
aidan_124
User
 
Join Date: Oct 2006
Posts: 47

aidan_124 has little to show at this moment (1)

Default

so like this?:
Trigger:
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
      endif
      returntrue
//** Checks that correct ability is used.
endfunction

Function Trig_Dimir_Machinations_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 2
//** Sets effect to loop twice
    loop
        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
    endloop
endfunction
//===========================================================================
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
endfunction

Thanks

Last edited by aidan_124 : 10-10-2006 at 10:20 PM.
aidan_124 is offline   Reply With Quote
Old 10-10-2006, 10:48 PM   #4
Chuckle_Brother
Oh for the sake of fudge
 
Chuckle_Brother's Avatar


Respected User
 
Join Date: Dec 2005
Posts: 782

Submissions (2)

Chuckle_Brother will become famous soon enough (53)Chuckle_Brother will become famous soon enough (53)

Send a message via ICQ to Chuckle_Brother Send a message via AIM to Chuckle_Brother Send a message via MSN to Chuckle_Brother Send a message via Yahoo to Chuckle_Brother
Default

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
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 10-10-2006, 11:07 PM   #5
aidan_124
User
 
Join Date: Oct 2006
Posts: 47

aidan_124 has little to show at this moment (1)

Default

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
endfunction

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
    endif
endfunction

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
    loop
        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
    endloop
endfunction

//===========================================================================
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 )
endfunction


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?
aidan_124 is offline   Reply With Quote
Old 10-11-2006, 02:37 PM   #6
Chuckle_Brother
Oh for the sake of fudge
 
Chuckle_Brother's Avatar


Respected User
 
Join Date: Dec 2005
Posts: 782

Submissions (2)

Chuckle_Brother will become famous soon enough (53)Chuckle_Brother will become famous soon enough (53)

Send a message via ICQ to Chuckle_Brother Send a message via AIM to Chuckle_Brother Send a message via MSN to Chuckle_Brother Send a message via Yahoo to Chuckle_Brother
Default

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

loop
  exitwhen i > 2  //Replace 2 with however many times you want the loop to fire
    // **Your code goes here** //
  set i = i + 1
endloop
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 10-11-2006, 04:07 PM   #7
aidan_124
User
 
Join Date: Oct 2006
Posts: 47

aidan_124 has little to show at this moment (1)

Default

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.
aidan_124 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:01 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

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