| 03-31-2005, 04:15 PM | #1 |
Code:
function Trig_Sell_Tower_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == 'A000' )
endfunction
function Trig_Sell_Tower_Actions takes nothing returns nothing
call AdjustPlayerStateBJ( 50000, Player(0), PLAYER_STATE_RESOURCE_GOLD )
call AdjustPlayerStateBJ( 50000, Player(0), PLAYER_STATE_RESOURCE_LUMBER )
call CreateNUnitsAtLoc( 1, 'hhou', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
call UnitAddAbilityBJ( 'Asud', GetLastCreatedUnit() )
call SetUnitFlyHeightBJ( GetLastCreatedUnit(), I2R(GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD)), 100000.00 )
call SetUnitUserData( GetLastCreatedUnit(), GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_LUMBER) )
call AddUnitToStockBJ( GetUnitTypeId(GetSpellAbilityUnit()), GetLastCreatedUnit(), 1, 1 )
call IssueTrainOrderByIdBJ( GetLastCreatedUnit(), GetUnitTypeId(GetSpellAbilityUnit()) )
call TriggerSleepAction( 0.00 )
call KillUnit( GetSpellAbilityUnit() )
endfunction
function Trig_Sells_Unit_Conditions takes nothing returns boolean
return ( GetUnitTypeId(GetSellingUnit()) == 'hhou' )
endfunction
function Trig_Sells_Unit_Actions takes nothing returns nothing
local real percent = 50
local integer gold = R2I(GetUnitFlyHeight(GetSellingUnit())) - GetPlayerState(GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_GOLD)
local integer lumber = GetUnitUserData(GetSellingUnit()) - GetPlayerState(GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_LUMBER)
call AdjustPlayerStateBJ( ( -50000 + gold + R2I(I2R(gold) * percent / 100) ), GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_GOLD )
call AdjustPlayerStateBJ( ( -50000 + lumber + R2I(I2R(lumber) * percent / 100) ), GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_LUMBER )
call RemoveUnit( GetSoldUnit() )
call RemoveUnit( GetSellingUnit() )
endfunction
//===========================================================================
function InitTrig_Sell_Tower takes nothing returns nothing
local trigger Sells_Unit = CreateTrigger( )
set gg_trg_Sell_Tower = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Sells_Unit, EVENT_PLAYER_UNIT_SELL )
call TriggerAddCondition( Sells_Unit, Condition( function Trig_Sells_Unit_Conditions ) )
call TriggerAddAction( Sells_Unit, function Trig_Sells_Unit_Actions )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Sell_Tower, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Sell_Tower, Condition( function Trig_Sell_Tower_Conditions ) )
call TriggerAddAction( gg_trg_Sell_Tower, function Trig_Sell_Tower_Actions )
endfunction
When any player sells a tower, the gold always goes to player red. Since I don't know JASS can anyone fix the code for me so it goes to the right player? Thanks in advance. Sincerely, Arkidas. |
| 03-31-2005, 04:25 PM | #2 |
I find it strange that selling a tower gives 50000 gold and lumber, and creates a unit at the center of the map. Anyway, this should give the gold to the owner of the tower. The unit will also be created for that player. Code:
function Trig_Sell_Tower_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == 'A000' )
endfunction
function Trig_Sell_Tower_Actions takes nothing returns nothing
local player p = GetOwningPlayer(GetSpellAbilityUnit())
call AdjustPlayerStateBJ( 50000, p, PLAYER_STATE_RESOURCE_GOLD )
call AdjustPlayerStateBJ( 50000, p, PLAYER_STATE_RESOURCE_LUMBER )
call CreateNUnitsAtLoc( 1, 'hhou', p, GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
call UnitAddAbilityBJ( 'Asud', GetLastCreatedUnit() )
call SetUnitFlyHeightBJ( GetLastCreatedUnit(), I2R(GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)), 100000.00 )
call SetUnitUserData( GetLastCreatedUnit(), GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) )
call AddUnitToStockBJ( GetUnitTypeId(GetSpellAbilityUnit()), GetLastCreatedUnit(), 1, 1 )
call IssueTrainOrderByIdBJ( GetLastCreatedUnit(), GetUnitTypeId(GetSpellAbilityUnit()) )
call TriggerSleepAction( 0.00 )
call KillUnit( GetSpellAbilityUnit() )
endfunction
function Trig_Sells_Unit_Conditions takes nothing returns boolean
return ( GetUnitTypeId(GetSellingUnit()) == 'hhou' )
endfunction
function Trig_Sells_Unit_Actions takes nothing returns nothing
local real percent = 50
local integer gold = R2I(GetUnitFlyHeight(GetSellingUnit())) - GetPlayerState(GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_GOLD)
local integer lumber = GetUnitUserData(GetSellingUnit()) - GetPlayerState(GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_LUMBER)
call AdjustPlayerStateBJ( ( -50000 + gold + R2I(I2R(gold) * percent / 100) ), GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_GOLD )
call AdjustPlayerStateBJ( ( -50000 + lumber + R2I(I2R(lumber) * percent / 100) ), GetOwningPlayer(GetSellingUnit()), PLAYER_STATE_RESOURCE_LUMBER )
call RemoveUnit( GetSoldUnit() )
call RemoveUnit( GetSellingUnit() )
endfunction
//================================================== =========================
function InitTrig_Sell_Tower takes nothing returns nothing
local trigger Sells_Unit = CreateTrigger( )
set gg_trg_Sell_Tower = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Sells_Unit, EVENT_PLAYER_UNIT_SELL )
call TriggerAddCondition( Sells_Unit, Condition( function Trig_Sells_Unit_Conditions ) )
call TriggerAddAction( Sells_Unit, function Trig_Sells_Unit_Actions )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Sell_Tower, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Sell_Tower, Condition( function Trig_Sell_Tower_Conditions ) )
call TriggerAddAction( gg_trg_Sell_Tower, function Trig_Sell_Tower_Actions )
endfunction |
| 03-31-2005, 04:27 PM | #3 |
Lol, it doesn't give that, Darky28 made this trigger though. But thanks! |
| 03-31-2005, 09:19 PM | #4 |
That's awfully obsolete and bugged, just create a hidden unit for the player you want to sell the tower and make it cast a Transmute based spell on the tower |
