[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > Triggers & Scripts


Triggers & Scripts In this forum you may ask for help on fixing a trigger or script. But if you need help getting started with a trigger, this is not the right place — use the World Editor Help Zone.

Closed Thread
 
Thread Tools
Old 04-08-2012, 05:11 PM   #1 (permalink)
Registered User Marine
User
 
Marine's Avatar
 
Join Date: Mar 2012
Posts: 34
Marine has little to show at this moment (6)
Very simple trigger fails to work?

CC
Events
Unit - Village 0050 <gen>'s life becomes Less than 50.00
Conditions
Actions
Unit - Change ownership of Village 0050 <gen> to (Owner of (Attacking unit)) and Change color

When tested, the Village remains in control of the original player once the health goes below 50. Why does this not work?
Marine is offline  
Old 04-08-2012, 05:33 PM   #2 (permalink)
Registered User khamarr3524
The Khamarr.
 
khamarr3524's Avatar
 
Join Date: Apr 2011
Posts: 451
khamarr3524 has little to show at this moment (50)
I believe since you aren't using an attacking event it wont register that the unit is attacked. Try changing the event to A Unit is Attacked. Then the condition unit is == your unit and life of attacked unit < 50. Then do your actions.
__________________
khamarr3524 is offline  
Old 04-08-2012, 05:34 PM   #3 (permalink)
Registered User Space_Ship
User
 
Space_Ship's Avatar
 
Join Date: Oct 2011
Posts: 223
Space_Ship has little to show at this moment (21)Space_Ship has little to show at this moment (21)Space_Ship has little to show at this moment (21)
Attacking unit wont exit the event doesnt refer to a unit attacking.
Here this is how you would do it a small test map.
let me know if you still have questions.

Edit: I used a unit takes damage because this can work for more then just attacking you might be wanting attackers only though.
Attached Files
File Type: w3x Health Test MAP.w3x (16.5 KB, 6 views)
Space_Ship is offline  
Old 04-08-2012, 06:05 PM   #4 (permalink)
Registered User khamarr3524
The Khamarr.
 
khamarr3524's Avatar
 
Join Date: Apr 2011
Posts: 451
khamarr3524 has little to show at this moment (50)
Here's a vJass script that should work for you. I can't test it because my World Editor is broken atm :/

Jass:
scope OwnerSwap initializer init
    private function SwapOwner takes unit u, real hp, player p returns nothing
        local integer spawnType = GetUnitTypeId(u)
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        local real f = GetUnitFacing(u)
        call RemoveUnit(u)
        call CreateUnit(p, spawnType, x, y, f)
        call SetUnitState(u, UNIT_STATE_LIFE, hp)
        set u = null
        set p = null
    endfunction
    private function ConditionRun takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local real hp = GetUnitState(u, UNIT_STATE_LIFE)
        local player p = GetOwningPlayer(GetAttacker())
        if GetUnitTypeId(u) == 'htow' and hp < 50. then
            call SwapOwner(u, hp, p)
        endif
        set u = null
        set p = null
    endfunction
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        loop
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
            set i = i + 1
            exitwhen i > 11
        endloop
        call TriggerAddAction(t, function ConditionRun)
        set t = null
    endfunction
endscope
__________________
khamarr3524 is offline  
Old 04-08-2012, 07:40 PM   #5 (permalink)
Registered User Spartipilo
User
 
Join Date: Jul 2011
Posts: 3,145
Spartipilo is just really nice (406)Spartipilo is just really nice (406)Spartipilo is just really nice (406)Spartipilo is just really nice (406)Spartipilo is just really nice (406)
Use the event "A unit is attacked" in the conditions check if "Attack Unit = Village 0050 <gen>" and in the conditions check if "Healt of Village 0050 <gen>" is less than or equal to 50" Then you can use the action to change ownership of the unit to the attacking unit.
Spartipilo is offline  
Old 04-08-2012, 08:55 PM   #6 (permalink)
Forum Moderator Maker
I...make things
 
Maker's Avatar
Resource Moderator
 
Join Date: Mar 2006
Posts: 8,961
Maker has been here far too long (2916)Maker has been here far too long (2916)Maker has been here far too long (2916)Maker has been here far too long (2916)Maker has been here far too long (2916)Maker has been here far too long (2916)Maker has been here far too long (2916)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
Untitled Trigger 007
Events
Unit - Archer 0023 <gen> Takes damage
Conditions
((Life of (Triggering unit)) - (Damage taken)) Less than or equal to 50.00
Actions
Unit - Change ownership of (Triggering unit) to (Owner of (Damage source)) and Change color
Maker is offline  
Closed Thread

Bookmarks

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 06:00 PM.




Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle