| 03-02-2009, 10:05 AM | #1 |
Right now , I am trying to create a spell that expands outwards from the caster to the caster, for some reason I don't want to use Polarprojection BJ so I decided to do this. Yet it does not work , any ideas or clues to help me ? JASS:scope Fire initializer Init globals private constant integer SPELL = 'A002' private constant string EFFECT = "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" endglobals private struct data location CasterLoc unit caster real distance real angle real x real y static method create takes nothing returns data local data d = data.allocate() set d.caster = GetTriggerUnit() set d.x = GetUnitX(d.caster) set d.y = GetUnitY(d.caster) set d.distance = 350 set d.angle = 30 return d endmethod endstruct //..function PolarProjectionBJ takes location source, real dist, real angle returns location // local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD) // local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD) // return Location(x, y) //endfunction private function Conditions takes nothing returns boolean return GetSpellAbilityId() == SPELL endfunction private function Actions takes nothing returns nothing local data d = data.create() local integer i = 0 local real x local real y loop exitwhen i > 12 set d.x = d.x + d.distance * Cos(d.angle * i ) set d.y = d.y + d.distance * Sin(d.angle * i ) call DestroyEffect(AddSpecialEffect(EFFECT,d.x,d.y)) set i = i + 1 endloop endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t= CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition(t,Condition(function Conditions)) call TriggerAddAction( t, function Actions ) endfunction endscope |
| 03-02-2009, 11:14 AM | #2 |
Okay, seriously. You really need to work on your indenting man. This is unreadable. JASS:static method create takes nothing returns data local data d = data.allocate() set d.caster = GetTriggerUnit() set d.x = GetUnitX(d.caster) set d.y = GetUnitY(d.caster) set d.distance = 350 set d.angle = 30 return d endmethod Okay, first of all, GetTriggerUnit() doesn't work in that method, since it is definitely not an callback. JASS:loop exitwhen i > 12 set d.x = d.x + d.distance * Cos(d.angle * i ) set d.y = d.y + d.distance * Sin(d.angle * i ) call DestroyEffect(AddSpecialEffect(EFFECT,d.x,d.y)) set i = i + 1 endloop Second of all, you're not increasing the value of d.distance, so it wouldn't expand even if it did work. Ah, one more thing: JASS:local real x local real y You never use these local variables. |
| 03-02-2009, 12:51 PM | #3 |
GetTriggerUnit() does work in that method. I can read my unindented code ![]() One problem now , it works for outer layer , but I don;'t know how to make it shrink back to the caster location JASS:scope Fire initializer Init globals private constant integer SPELL = 'A002' private constant string EFFECT = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" endglobals private function DISTANCE takes integer level returns integer return level * 150 endfunction private struct data location CasterLoc unit caster real distance real angle real x real y static method create takes nothing returns data local data d = data.allocate() set d.caster = GetTriggerUnit() set d.x = GetUnitX(d.caster) set d.y = GetUnitY(d.caster) set d.distance = DISTANCE(GetUnitAbilityLevel(d.caster,SPELL)) set d.angle = 30 return d endmethod endstruct //..function PolarProjectionBJ takes location source, real dist, real angle returns location // local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD) // local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD) // return Location(x, y) //endfunction private function Conditions takes nothing returns boolean return GetSpellAbilityId() == SPELL endfunction private function Actions takes nothing returns nothing local data d = data.create() local integer i = 0 local integer maxi = 36 local real angle loop exitwhen i >= maxi set angle = 2 * bj_PI * i / maxi call AddSpecialEffect(EFFECT, d.x + d.distance * Cos(angle), d.y + d.distance * Sin(angle)) set i = i + 1 endloop endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t= CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition(t,Condition(function Conditions)) call TriggerAddAction( t, function Actions ) endfunction endscope |
| 03-02-2009, 02:18 PM | #4 |
You may be able to read your code fine, but asking for help (and thus, part of being a good coder) is to make your code legible to allow us to better help you, and in real world applications, so it isn't a pain in the ass to update/maintain software you didn't write. I need to head out, but some food for thought. If you can make it extend outward, then simply reversing the process would bring it inward, yes? |
| 03-02-2009, 02:26 PM | #5 |
Why don't you null the local trigger variable since the trigger is .. um.. local? xD |
| 03-02-2009, 02:37 PM | #6 |
reduce the radius at a constant timer interval... You would actually need a struct in this case, what you were doing before could have been accomplished just with locals. I'd recommend first using Timer Utils to attach your struct to a timer and then iterate about every .25 seconds or something like that, and depending on the size of the war stomp, reduce the radius by 100 or something around there every iteration. |
| 03-02-2009, 10:05 PM | #7 |
I'm curious how GetTriggerUnit() is working in his create method... |
| 03-02-2009, 10:43 PM | #8 |
GetTriggerUnit stays working after a unit event is fired until the next unit-event is fired... So if you dont have any waits (or timers) in your code it will work in every code you call from triggeraction/condition of a unitevent-trigger ... However i dont think it would still work when you switch to another thread... |
| 03-02-2009, 11:01 PM | #9 |
Though it still works when ForGroup is called, if I recall. |
