• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

RoC City Capture Trigger?

Status
Not open for further replies.
Level 11
Joined
Aug 6, 2009
Messages
697
Hello,I want to know how to create a trigger of city capturing for RoC.
Like,a unit is attacked,its health is less then 500,give city to attacking unit.
Can you make a trigger for me that is ROC compatible to do this please?Thanks!P.S. yes it is possible,just look at WWZ and Rise Of Empires!
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
function Trig_Trigger_Conditions takes nothing returns boolean
if ( not ( IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_TOWNHALL) == true ) ) then
return false
endif
if ( not ( R2I(GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ())) <= 500 ) ) then
return false
endif
return true
endfunction

function Trig_Trigger_Actions takes nothing returns nothing
call SetUnitOwner( GetAttackedUnitBJ(), GetOwningPlayer(GetAttacker()), true )
call SetUnitLifePercentBJ( GetAttackedUnitBJ(), 100 )
endfunction

//===========================================================================
function InitTrig_Trigger takes nothing returns nothing
set gg_trg_Trigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Trigger, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Trigger, Condition( function Trig_Trigger_Conditions ) )
call TriggerAddAction( gg_trg_Trigger, function Trig_Trigger_Actions )
endfunction

Just copy and paste that into a open trigger or something. This is the Gui ver turned into jass and is therefore compatable with roc. im not sure if this is leakless or not.
 
Level 11
Joined
Aug 6, 2009
Messages
697
function Trig_Trigger_Conditions takes nothing returns boolean
if ( not ( IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_TOWNHALL) == true ) ) then
return false
endif
if ( not ( R2I(GetUnitStateSwap(UNIT_STATE_LIFE, GetAttackedUnitBJ())) <= 500 ) ) then
return false
endif
return true
endfunction

function Trig_Trigger_Actions takes nothing returns nothing
call SetUnitOwner( GetAttackedUnitBJ(), GetOwningPlayer(GetAttacker()), true )
call SetUnitLifePercentBJ( GetAttackedUnitBJ(), 100 )
endfunction

//===========================================================================
function InitTrig_Trigger takes nothing returns nothing
set gg_trg_Trigger = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Trigger, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Trigger, Condition( function Trig_Trigger_Conditions ) )
call TriggerAddAction( gg_trg_Trigger, function Trig_Trigger_Actions )
endfunction

Just copy and paste that into a open trigger or something. This is the Gui ver turned into jass and is therefore compatable with roc. im not sure if this is leakless or not.

THANK YOU!!! Dare I say I love you?
+rep
 
Status
Not open for further replies.
Top