| 07-04-2008, 09:17 PM | #1 |
Hey, I was wondering if there is a way to save a variable for use in another function while it's in the same trigger; here's how it's set up. JASS:function whatever1 takes nothing returns nothing does something (Required Variable Here) endfunction function whatever2 takes some stuff returns nothing does stuff Acquires variable here (ex. angle = GetAngleBetweenPoints(localpointa,localpointb) ) endfunction any help would be greatly appreciated, also; is there any additional cleaning that would have to be done to prevent leaks created by "saving" the variable? |
| 07-04-2008, 09:25 PM | #2 |
With a total lack of information on what you're actually trying to do, I can't really say how to do it, but yes, there is a way. |
| 07-04-2008, 10:09 PM | #3 |
As you currently describe it... :P lawl. I know this is not what you mean. Well... JASS:function B takes unit u returns nothing call KillUnit(u) endfunction function A takes something returns nothing call B( GetSpellAbilityUnit() ) endfunction What you really are looking for is an attachment system. Check ABC, HAIL, HSAS, TT, or CSData from CasterSystem (resources -> code) JASS:// Using CSData from the CasterSystem function B takes nothing returns nothing local integer i = GetCSData(GetExpiredTimer()) call BJDebugMsg(I2S(i)) call DestroyTimer(GetExpiredTimer()) endfunction function A takes something returns nothing local timer t=CreateTimer() call SetCSData(t,17) call TimerStart(t,1.0,false,function B) set t=null endfunction Calling the function A will print "17" after 1.0 seconds. |
| 07-04-2008, 10:34 PM | #4 |
Yea, I'm use the caster system to create a collision missile that calls a knockback function when it collides with the unit; and I wanted to call back the angle at which i sent the missile flying, since that is the angle I want it to knock the unit back at. What would I attach the variable to, the local unit that acts as the collision missile? |
| 07-04-2008, 10:49 PM | #5 |
Wouldn't it make more sense to knock the unit back at the angle between the missile and the unit, which can be calculated without any attached data? |
| 07-04-2008, 10:54 PM | #6 | |
Quote:
Yea, I thought that at first but I've no idea what's wrong with my code so I decided to see if I could do it the other way, maybe you can spot my error, like I said I'm using the CS by Vexorian; I also use the Knockback function by Silvenon. The error with it is that it never knocks them back at the right angle, for example, if you shoot the guy who is 180 degrees from you on your left, he will fly back towards you like you pulled him, but if you shoot at a 230 degrees horizontally down left he will fly back as directed; I can't find a pattern in the madness of angles they fly at. I have not cleaned it yet, I realize it probably leaks alot! I'm just trying to get it to work first, then I'll clean it up. JASS:function Trig_ForceBall_Conditions takes nothing returns boolean return GetSpellAbilityId() == 'A000' endfunction function OrbKnockback takes nothing returns nothing local unit h = GetTriggerUnit() local location htuloc = GetUnitLoc(h) local unit cm = GetTriggerCollisionMissile() local location clmloc = GetUnitLoc(cm) local real ang = DEG2RAD(AngleBetweenPoints(htuloc,clmloc)) call Knockback(h,250,ang,1) call CollisionMissile_Destroy(cm) set h = null set cm = null endfunction function Trig_ForceBall_Actions takes nothing returns nothing local unit ucast = GetTriggerUnit() local location ucastloc = GetUnitLoc(ucast) local real casterlocx = GetLocationX(ucastloc) local real casterlocy = GetLocationY(ucastloc) local location targetloc = GetSpellTargetLoc() local real targetlocx = GetLocationX(targetloc) local real targetlocy = GetLocationY(targetloc) local real casterlook = GetUnitFacing(ucast) local real angbtwp = AngleBetweenPoints(ucastloc,targetloc) local location createloc = PolarProjectionBJ(ucastloc,10,angbtwp) local real hypotn = SquareRoot(((targetlocx - casterlocx) * (targetlocx - casterlocx)) +((targetlocy - casterlocy) * (targetlocy - casterlocy))) call CollisionMissile_CreateLoc("Abilities\\Weapons\\DemonHunterMissile\\DemonHunterMissile.mdl",createloc,angbtwp,800,0,1000,50,false,50,function OrbKnockback) endfunction //=========================================================================== function InitTrig_ForceBall takes nothing returns nothing set gg_trg_ForceBall = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_ForceBall, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_ForceBall, Condition( function Trig_ForceBall_Conditions ) ) call TriggerAddAction( gg_trg_ForceBall, function Trig_ForceBall_Actions ) endfunction |
