• 🏆 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!

Get ordering player

Status
Not open for further replies.
Level 12
Joined
Mar 13, 2012
Messages
1,121
Hi Guys, another small question.

When I have e.g. the event 'A unit is issued an order targeting an object' GetTriggerPlayer() just gives back the owner of the unit.
Is it possible to get the player which gives the order to the unit?
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Hi Guys, another small question.

When I have e.g. the event 'A unit is issued an order targeting an object' GetTriggerPlayer() just gives back the owner of the unit.
Is it possible to get the player which gives the order to the unit?

GetTriggerPlayer give the ordered unit owner, so if u order your unit then its you, if u order your unit to attack somebody else this also you, so overall ordered unit is that unit what get the order from player, order target is that unit what ordered unit/player targeted (so if u select ur unit and right click to enemy unit, then order target is enemy unit, ordered unit is ur unit who going for attack your target).


if u want get the owner of order target then use this

  • Game - Display to (All players) the text: (Name of (Owner of (Target unit of issued order)))
 
Last edited:
Level 12
Joined
Mar 13, 2012
Messages
1,121
if u want get the owner of order target then use this

Thats not what I want. That was my question:

Is it possible to get the player which gives the order to the unit?
So when e.g. I have shared control with my allies I want to detect which player is actually ordering them something
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
So the answer is no, I can live with that. I just need a unit for every player then :)

Thanks!

e: when am I supposed to give this +rep thing? For extraordinary stuff or also for answers like 'no' ^^?
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Sure. I am building a new GUI shop system. If my question was possible then one unit would be enough. Now I need more.

maybe if it is like seller in house like in alot rpg, then maybe u can try make lets say 5 similiar place, example 5 pharmacist house (inside), where everything same,

with boolean you check what room is free and out there who want buy something, and if another player want buy something then put to another room what is exactly same, if 3rd player want buy then same.

ok this sound mad, well, but its look like only 1 npc exist, because all place is same, and u can just generetae a neutral passive unit each time when a player want buy something

something like:

player 1 buy atm moment in room 1, player 2 also want buy something going into house, he will teleported to room 2 but same time u create a unit what look like player 1 hero to room 2, to room 1 create a same unit than what player 2 got,m when player 2 or 1 leave from his room then destory the clone, theory is when 1 room is changed by entering player then change every room, and keep the rooms like mirror to each other
.

sorry kinda i am sucks in english also this is a mad ideea but i dont got better ideea how can u make this thing visual (visually) with 1 npc :)
 

Attachments

  • 1.jpg
    1.jpg
    53.6 KB · Views: 61
Level 26
Joined
Aug 18, 2009
Messages
4,097
Well maybe you could use sell unit/item orders. The normal Mercenary Camp creates a unit for the player who clicks rather than the shop owner and similarly with items it will prefer to give those items to your own units, so you may consider deploying dummy units that catch them. Or you check the players' account balances before and after.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Thx for the hint but my thing is different. You can shop with rigthclick and I dont need seller houses. Im gonna just select for every player his own dummy unit when he selects the main shop unit.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Well maybe you could use sell unit/item orders. The normal Mercenary Camp creates a unit for the player who clicks rather than the shop owner and similarly with items it will prefer to give those items to your own units, so you may consider deploying dummy units that catch them. Or you check the players' account balances before and after.

ok i also make trick with order train dummy unit for detect who is the buyer player but with that still the item list is same at shop npc to every player

ok this work if u dont want change the item list but else no :/

i made with this, but for make crafting time when u buy item

basically how its work?

1. trigger detect if my shop unit sell item,
-if he sell then:
1. enable to buyer player a dummy unit type
2. order seller unit for train this dummy unit type for buyer player (seller = market neutral npc)
3. disable this dummy unit type for buyer player
4. save buyer unit & bought item type to variable array this way(Craft_Client unit array):
//cv = the seller unit (market) unit custom value
Craft_Client[cv] = buyer unit
Craft_Item[cv] = the sold item type
5. remove the bought item

2.nd trigger
Event trained unit is done
Condition trained unit type is same than dummy unit type
Action:
Trigger unit=Trainer building(market)
//cv = the trigger unit - trianer build (market) unit custom value
add this item Craft_Item[cv] to Craft_Client[cv]. since same time cant craft 2 thing this market npc the Craft_Client owner is that player who bought item in 1st trigger

JASS:
function Trig_PotionCraft_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetSellingUnit()) == 'n000'
endfunction

function Trig_PotionCraft_Actions takes nothing returns nothing
local item it = GetSoldItem()
local integer id = GetItemTypeId(it)
local unit u = GetBuyingUnit()
local unit s = GetSellingUnit()
local integer cv = GetUnitUserData(s)
local integer ilv = GetItemLevel(it)
local player p = GetOwningPlayer(u)
call RemoveItem( it )
set udg_Craft_Client[cv] = u
        if CountCharge(u,udg_H_Items[0]) >= 1 and CountCharge(u,udg_H_Items[1]) >= 1 and CountCharge(u,udg_H_Items[2]) >= 1 and ilv >= 2000 and ilv < 2011  then
            call SetPlayerTechMaxAllowed( p, 'h00O', 1 )
            call IssueImmediateOrderById( s, 'h00O' )
            call SetPlayerTechMaxAllowed( p, 'h00O', 0)
            call DecreaseCharge(u,udg_H_Items[0], 1)
            call DecreaseCharge(u,udg_H_Items[1], 1)
            call DecreaseCharge(u,udg_H_Items[2], 1)
            set udg_Craft_Item[cv] = id
        else
            call DisplayTextToPlayer( p, 0, 0, "Missing from components. This item need 1 lumber, 1 iron, 1 stone.")
        endif
set it = null
set u = null
set s = null
set p = null
endfunction

//===========================================================================
function InitTrig_Training_for_potion takes nothing returns nothing
    set gg_trg_Training_for_potion = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Training_for_potion, EVENT_PLAYER_UNIT_SELL_ITEM )
    call TriggerAddCondition( gg_trg_Training_for_potion, Condition( function Trig_PotionCraft_Conditions ) )
    call TriggerAddAction( gg_trg_Training_for_potion, function Trig_PotionCraft_Actions )
endfunction

JASS:
function Trig_Finish_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTrainedUnit()) == 'h00N' or GetUnitTypeId(GetTrainedUnit()) == 'h00O'
endfunction

function Trig_Finish_Actions takes nothing returns nothing
local unit s = GetTriggerUnit()
local integer cv = GetUnitUserData(s)
    call UnitAddItemById( udg_Craft_Client[cv], udg_Craft_Item[cv] )
    call RemoveUnit( GetTrainedUnit() )
set s = null
set udg_Craft_Client[cv] = null
endfunction

//===========================================================================
function InitTrig_Finish_craft takes nothing returns nothing
    set gg_trg_Finish_craft = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Finish_craft, EVENT_PLAYER_UNIT_TRAIN_FINISH )
    call TriggerAddCondition( gg_trg_Finish_craft, Condition( function Trig_Finish_Conditions ) )
    call TriggerAddAction( gg_trg_Finish_craft, function Trig_Finish_Actions )
endfunction
 
Status
Not open for further replies.
Top