| 07-26-2007, 09:44 AM | #1 |
This is for a map im making, each player controls a 'Time Monk' able to split time, ie not stop it, so that seems simple enough, when they cast the spell slow all units except the caster, but i want to have various levels, the levels will be something like 10%/20%/30%/40%/50%/60%/70%/78%/85%/90%/93%/95% and thats the end (lots of levels because this is what the game is all about) and if you try cast when you havent fully learent the skill you have a chance to take damage/die/fail/you lose a 'time level' (effectiveley speeding the others back up a bit). But i also want a PvP element to be brought into the game, so i was thinking a system which slows non-time monk characters down by the full amount, but the others down only by the difference between their current 'time level' and their opponents. I.e. a low level time monk (monk A) casts up to 30%, and then a higher level monk (monk B) casts 50%, all other units are slowed by 50%, monk A is slowed by only 20% (50 - 30), monk B moves at full speed. This is what i have so far (written in GUI then converted to custom text, attatched below is the actual triggers in GUI, in a map, but dont try play the map coz it wont work...) --This bit takes 1 from the players 'time level' when they cast fuse time-- JASS:function Trig_Fuse_time_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A000' ) ) then return false endif return true endfunction function Trig_Fuse_time_Func001001 takes nothing returns boolean return ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) endfunction function Trig_Fuse_time_Actions takes nothing returns nothing if ( Trig_Fuse_time_Func001001() ) then set udg_Playerone = ( udg_Playerone - 1 ) else call DoNothing( ) endif set udg_PoolIndex = ( udg_PoolIndex - 1 ) endfunction //=========================================================================== function InitTrig_Fuse_time takes nothing returns nothing set gg_trg_Fuse_time = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Fuse_time, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Fuse_time, Condition( function Trig_Fuse_time_Conditions ) ) call TriggerAddAction( gg_trg_Fuse_time, function Trig_Fuse_time_Actions ) endfunction ----------------NEXT BIT-------------------------------------- --This bit adds 1 to a players 'Time level' when they cast split time-- JASS:function Trig_Split_time_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A001' ) ) then return false endif return true endfunction function Trig_Split_time_Func001001 takes nothing returns boolean return ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) endfunction function Trig_Split_time_Actions takes nothing returns nothing if ( Trig_Split_time_Func001001() ) then set udg_Playerone = ( udg_Playerone + 1 ) else call DoNothing( ) endif set udg_PoolIndex = ( udg_PoolIndex + 1 ) endfunction //=========================================================================== function InitTrig_Split_time takes nothing returns nothing set gg_trg_Split_time = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Split_time, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Split_time, Condition( function Trig_Split_time_Conditions ) ) call TriggerAddAction( gg_trg_Split_time, function Trig_Split_time_Actions ) endfunction --------------------------NEXT BIT------------------------- --This bit sets how slow the units should be at different times-- JASS:function Trig_Set_slow_Actions takes nothing returns nothing set udg_TimePool[0] = 100.00 set udg_TimePool[1] = 90.00 set udg_TimePool[2] = 80.00 set udg_TimePool[3] = 70.00 set udg_TimePool[4] = 60.00 set udg_TimePool[5] = 50.00 set udg_TimePool[6] = 40.00 set udg_TimePool[7] = 30.00 set udg_TimePool[8] = 22.00 set udg_TimePool[9] = 15.00 set udg_TimePool[10] = 10.00 set udg_TimePool[11] = 5.00 endfunction //=========================================================================== function InitTrig_Set_slow takes nothing returns nothing set gg_trg_Set_slow = CreateTrigger( ) call TriggerAddAction( gg_trg_Set_slow, function Trig_Set_slow_Actions ) endfunction ----------------------------NEXT BIT---------------------------- --This bit does the actual slowing effect-- JASS:if ( ( GetSpellAbilityId() == 'A001' ) ) then return true endif if ( ( GetSpellAbilityId() == 'A000' ) ) then return true endif return false endfunction function Trig_Effect_Conditions takes nothing returns boolean if ( not Trig_Effect_Func003C() ) then return false endif return true endfunction function Trig_Effect_Func002A takes nothing returns nothing call GroupRemoveUnitSimple( GetTriggerUnit(), GetLastCreatedGroup() ) call SetUnitTimeScalePercent( GetEnumUnit(), udg_TimePool[udg_PoolIndex] ) endfunction function Trig_Effect_Actions takes nothing returns nothing // This is the bit that actualy slows stuff call ForGroupBJ( GetUnitsInRectAll(GetPlayableMapRect()), function Trig_Effect_Func002A ) endfunction //=========================================================================== function InitTrig_Effect takes nothing returns nothing set gg_trg_Effect = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Effect, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Effect, Condition( function Trig_Effect_Conditions ) ) call TriggerAddAction( gg_trg_Effect, function Trig_Effect_Actions ) endfunction So as you may have noticed, the missing bit is the bit that finds out who has the highes 'Time level' At that point in time, thats the bit i need, this bit is here for people to tell me what im doing wrong/how it could be better. So thank you for your time, please leave a comment if you can help me. |
| 07-26-2007, 09:52 AM | #2 |
Did you post JASS as GUI triggers or did you really do that all in custom text fields? |
| 07-26-2007, 10:13 AM | #3 |
Why the hell did you convert the triggers to Jass anyway? |
| 07-26-2007, 11:11 AM | #4 |
When posting converted GUI code, use [jass][/ jass] tags, not trigger tags. |
| 07-26-2007, 11:43 AM | #5 | |
Quote:
|
| 07-26-2007, 02:03 PM | #6 | |
Quote:
Everyone has to start somewhere. Converted GUI is the quickest way to see how things are done. To poster: if you want the maximum of an array, you loop through it while storing the maximum seen so far. |
| 07-26-2007, 04:15 PM | #7 | |
Quote:
But i think that is a good way to start with Jass. I would do a loop and formula for your time pool: JASS:function Trig_Set_slow_Actions takes nothing returns nothing local integer i=0 loop exitwhen i==11 set udg_TimePool[i] = 100-i*8 set i=i+1 endloop endfunction I recommed you to read Vex´s beginner Jass tutorials http://www.wc3campaigns.net/showthread.php?t=74894 http://www.wc3campaigns.net/showthread.php?t=80002 |
| 07-27-2007, 08:33 AM | #8 |
Sorry if i confused u, but i didnt actualy write it in custom text, nor did i convert it to try and learn jass, i converted it so i could post it, i dont think u can copy and paste the actual GUI trigger... so i dont understand custom text or jass, but i kinda assumed u guys understood it better if i posted it like that. so i want to make a function that is runs through the current 'time levels' of the players and selects the highest value and adds it to a seperate variable, 'time pool'? (ie the current highest value of a set of intergers is stored as an interger) can someone please tell me how to do this in GUI? EDIT: i cant find the 'loop' action... is it Jass/custom text only? This is my action Actions Trigger: If (Playerone Greater than Playertwo) then do (Set Playerone = PoolIndex) else do (Do nothing)Trigger: If ((Playerone Greater than Playertwo) and ((Playerone Greater than Playethree) and (Playerone Greater than Playerfour))) then do (Set Playerone = PoolIndex) else do (Do nothing) |
| 07-27-2007, 08:36 AM | #9 |
You can C 'n' P the trigger. In the window where you can edit stuff like actions, etc., click the little icon that has the name of the trigger on it and and click "copy as text", then come here, setup [trigger][/ trigger] (no space between / and trigger), and plug the text between the 2 tags. |
| 07-27-2007, 08:58 AM | #10 | |
Quote:
In GUI, looping is done with the "for each integer A do actions" in the general category. |
| 07-27-2007, 10:26 AM | #11 | |
Quote:
what do u mean? what bit do i change for this? im not stupid but i realy dont get why they dont just hav a natural that says "loop actions" Trigger: For each (Integer A) from 1 to 10, do (Do nothing)This is the action you refer to? (u wrote "for each integer A do actions" and the only options are "do action" and "do multiple actions") so what does the (interger A/b) bit do exactly? does it matter which it is? what is the from 1 to 10 refering to? and how exactly does this make it loop? can you use it in an example so i can use it as a reference? |
| 07-27-2007, 01:47 PM | #12 |
| 07-27-2007, 05:26 PM | #13 |
Gorman, loops are basically ways of doing complex things much more easily, and sometimes can be used to do things you never would have been able to do without them. If you have "for each integer A from 1 to 10 do actions", it basically does what it says. It runs the functions in the "actions" once for each integer. For 1 to 10, that means it is run 10 times. However, that is not all. Each time it is run, the "Integer A" variable is set to the next number in succession. The first run has Integer A meaning 1, the next time Integer A would be 2, etc... You can use Integer A in place of an integer when you are forming the functions in the "actions" section. This is incredibly useful for many reasons, all of which you must figure out yourself. As for Integer B and Integer Variable, you can have an Integer B loop inside an Integer A loop, running the actions 100 times if they are both 1 to 10, each with two integer variables. The amount of loops you can have nested is more than just two, however, as you can replace the integer "variable" with any integer variable you make, then call for it instead of Integer A or B in your actions. |
| 07-28-2007, 10:32 AM | #14 |
i do know wat loops are... just not how to trigger them, thanks Dark, i think i know how i can do it now. |
| 07-29-2007, 03:24 AM | #15 |
Turns out i still cant finish the whole thing, because i dont know how to slow units with a trigger, and i cant create a dummy unit and make it slow them because i dont know how to trigger custom spells in GUI, so could some1 please tell me how to? This is the very last problem im having with the trigger, after this i just gotta go through see if i can simplifiy anything. |
