Im pretty new to the map editor so i had a question about my trigger not working...
Its suppose to go off whenever a structure uses the specified sell ability for that structure.
Then in actions i get the cost of the triggerd building and the player which hads triggerd it, and take off 25% of the refund so the player gets 75% of spend minerals. And i didnt know how to use decimals so i used 3:4 = 0,75 for the refund.
I havent really created much triggers yet but i thought this would kinda work.
maybe someone can enlighten me?
All help is welcome!
I work in the GUI and sometimes add pieces of custom code, i think i did something wrong in the ability then, thx i was wondering how the heck i could see the code in the GUI . i used to just copy from Data > viewscript :p ill hit back when i found the problem
Hey, i made an ability to sell my barracks call SellBarracks
name: SellBarracks
ID: SellBarracks
Ability typ: Effect - Instant
Based On: Refund
Race: Terran
Field values: set to parent values
After that i went back to my code, tested it with a few message displays, when i press the salvage on my barracks it does trigger. It says the refund is 0 and the cost is 105 which is correct, so there must be something wrong with adding to the refund variable.
As you can see i copied the code downlow.. Any suggestions? (i tried it also with real number instead of 3/4 and it still says refund: 0)
Also the text message displays like 6 times at once when i activate the ability :/
RefundEventsTriggerAddEventUnitAbility((EventUnitTargetUnit()),"SellBarracks",0,c_unitAbilStageAll,false)LocalVariablesstructureCost=0<int>refund=0<int>ConditionsActionsUIDisplayMessage((PlayerGroupAll()),c_messageAreaChat,"Building is Being Salvaged!")SetVariable(structureCost,(FixedToInt((IntToFixed((UnitTypeGetCost((UnitGetType((EventUnit()))),c_unitCostMinerals)))))))SetVariable(refund,(ArithmeticInt(structureCost,*,(FixedToInt(0.75)))))UIDisplayMessage((PlayerGroupAll()),c_messageAreaDirective,(CombineText("Refund = ",(IntToText(refund)))))UIDisplayMessage((PlayerGroupAll()),c_messageAreaError,(CombineText("Structure cost:",(IntToText(structureCost)))))PlayerModifyPropertyInt((UnitGetOwner((EventUnit()))),c_playerPropMinerals,c_playerPropOperAdd,refund)
i changed all the integers to real and everything works now accept for that once it gets triggered, it hits multiple times so you get like 6 times the refund...
Any can explain?
i don't know why it triggers 6 times (you get 6 messages?) it's probably ability's fault then.
Btw for future , FixedToInt(0.75) = 0 because integer can't have decimals so he cuts .75 (or rounds to 1 maybe).
i don't know why it triggers 6 times (you get 6 messages?) it's probably ability's fault then.
Btw for future , FixedToInt(0.75) = 0 because integer can't have decimals so he cuts .75 (or rounds to 1 maybe).
nope. its not the ability's fault. Its in his events.
do you work in GUI btw? Im not familiar with plain script but your fix is to change it to a specific ability stage. such as Generic3 - Execute or Effect3 - Cast for example. Easily changed in GUI.
Whats happening is your event is triggering for every single ability stage, which i believe is plenty counting Approach, Prep, Cast, Channel, Finish etc2.
All you need is to set a specific stage in which your event will trigger. that is all :)
Wow i wwas just reposting while i read your post, you were right thx, i put the ability stage to execute, now its fine, only triggers 1 time :D
thx for all help, works perfectly now!
I had 1 last question which isnt really relevent to what i was fixing. How can i send such a text message of the refunded minerals to a specific player and not a plyer group? more like the player who triggered the unit
RefundEventsTriggerAddEventUnitAbility((EventUnitTargetUnit()),"SellBarracks",0,c_unitAbilStageExecute,false)LocalVariablesconstant=0.75<fixed>structureCost=0.0<fixed>refund=0.0<fixed>ConditionsActionsUIDisplayMessage((PlayerGroupAll()),c_messageAreaChat,"Building is Being Salvaged!")SetVariable(structureCost,(FixedToInt((IntToFixed((UnitTypeGetCost((UnitGetType((EventUnit()))),c_unitCostMinerals)))))))SetVariable(refund,(ArithmeticReal(constant,*,structureCost)))UIDisplayMessage((PlayerGroupAll()),c_messageAreaChat,(CombineText("Refund = ",(FixedToText(refund,c_fixedPrecisionAny)))))UIDisplayMessage((PlayerGroupAll()),c_messageAreaError,(CombineText("Structure cost:",(FixedToText(structureCost,c_fixedPrecisionAny)))))PlayerModifyPropertyInt((UnitGetOwner((EventUnit()))),c_playerPropMinerals,c_playerPropOperAdd,(FixedToInt(refund)))
Hey ppl.
Im pretty new to the map editor so i had a question about my trigger not working... Its suppose to go off whenever a structure uses the specified sell ability for that structure. Then in actions i get the cost of the triggerd building and the player which hads triggerd it, and take off 25% of the refund so the player gets 75% of spend minerals. And i didnt know how to use decimals so i used 3:4 = 0,75 for the refund. I havent really created much triggers yet but i thought this would kinda work.
maybe someone can enlighten me? All help is welcome!
Event
TriggerAddEventUnitAbility(gt_Refund, UnitRefFromUnit(EventUnitTargetUnit()), AbilityCommand("RefundSpecificBuilding", 7), c_unitAbilStageAll, false);
Variable Initialization
lv_structureCost = 0;
lv_refund = 0;
Actions
lv_structureCost = FixedToInt(IntToFixed(UnitTypeGetCost(UnitGetType(EventUnit()), c_unitCostMinerals)));
lv_refund = (lv_structureCost * (3 / 4));
PlayerModifyPropertyInt(UnitGetOwner(EventUnit()), c_playerPropMinerals, c_playerPropOperAdd,lv_refund);
return true;
decimals are reals, with math you will probably end using a lot of "convert real to integer" and vice versa.
your trigger 'seems' to be ok.
if you work in GUI (not code isself) you can select all inside your trigger, right click>copy as text and paste here inside
<<code>>here<</code>>
tagsrefound(int) = FixedToInt(IntToFixed(structureCost) * 0,75)
player add refound
@Rice87: Go
Thx for the fast reply!
I work in the GUI and sometimes add pieces of custom code, i think i did something wrong in the ability then, thx i was wondering how the heck i could see the code in the GUI . i used to just copy from Data > viewscript :p ill hit back when i found the problem
always best first thing to do is to add some sort of check is trigger even firing. simplest would be UI - Text message to chat
@Rice87: Go
Hey, i made an ability to sell my barracks call SellBarracks
name: SellBarracks
ID: SellBarracks
Ability typ: Effect - Instant
Based On: Refund
Race: Terran
Field values: set to parent values
After that i went back to my code, tested it with a few message displays, when i press the salvage on my barracks it does trigger. It says the refund is 0 and the cost is 105 which is correct, so there must be something wrong with adding to the refund variable. As you can see i copied the code downlow.. Any suggestions? (i tried it also with real number instead of 3/4 and it still says refund: 0) Also the text message displays like 6 times at once when i activate the ability :/
@Rice87: Go
Hey,
i changed all the integers to real and everything works now accept for that once it gets triggered, it hits multiple times so you get like 6 times the refund... Any can explain?
i don't know why it triggers 6 times (you get 6 messages?) it's probably ability's fault then.
Btw for future , FixedToInt(0.75) = 0 because integer can't have decimals so he cuts .75 (or rounds to 1 maybe).
nope. its not the ability's fault. Its in his events.
TriggerAddEventUnitAbility((EventUnitTargetUnit()), "SellBarracks", 0, c_unitAbilStageAll, false)
this is whats wrong.
@Rice87: Go
do you work in GUI btw? Im not familiar with plain script but your fix is to change it to a specific ability stage. such as Generic3 - Execute or Effect3 - Cast for example. Easily changed in GUI.
Whats happening is your event is triggering for every single ability stage, which i believe is plenty counting Approach, Prep, Cast, Channel, Finish etc2.
All you need is to set a specific stage in which your event will trigger. that is all :)
@Zolstice: Go
Wow i wwas just reposting while i read your post, you were right thx, i put the ability stage to execute, now its fine, only triggers 1 time :D
thx for all help, works perfectly now!
I had 1 last question which isnt really relevent to what i was fixing. How can i send such a text message of the refunded minerals to a specific player and not a plyer group? more like the player who triggered the unit
although spaming chat is not nice you can instead "AllPlayers" use Convert player to player group(Triggering player/owner of triggering unit)