| 01-31-2005, 08:33 PM | #1 |
Hey, I'm just getting started with JASS though I'm familiar with programming as a whole. I made some edits to an ability that Lord Vexorian coded, Raging Charge. The ability lets a unit move very quickly across the screen, killing any trees in its path. The edit I made was because I needed it to kill all destructibles, rather than just trees. What I'm looking for is someone who can verify if my thoughts of how things work are on the right track, or that can correct me if I'm wrong about something. The basis of the ability is that every .04 seconds the unit is moved some distance to make it appear that the unit is moving very fast. When the unit is moved, a check is performed (I think) within a set radius, and all trees in the area are removed. So, here's what I added. It's fairly simple. These two functions were added to the global area of the map, so they could be called from any trigger. Code:
function KillBarricadeInCircleEnum takes nothing returns nothing
local destructable d=GetEnumDestructable()
call KillDestructable(d)
set u=null
endfunctionCode:
function KillBarricadesInCircle takes real x, real y, real radius returns nothing
local rect r=Rect(x - radius,y - radius,x + radius,y + radius)
call EnumDestructablesInRect(r,null,function KillBarricadeInCircleEnum)
call RemoveRect(r)
set r=null
endfunctionI added this call to the code that happens every .04 seconds. This is just a snippet from the entire thing. X and Y are the coordinates of the casting unit, RagingCharge_KillBarricades is a constant that's always true, and RagingCharge_ImpactRange is also a constant set to 200. Code:
// Added by Aaero 1-31-05
// Functionality to Kill barricade
if RagingCharge_KillBarricades(1) then
call KillBarricadesInCircle(x,y,RagingCharge_ImpactRange(l))
endifI was fortunate because I had Lord Vexorian's code to look at, and a lot of this is modeled after what he did. Now what I think is happening is this. Every .04 seconds, Im calling my function that basically just determines a rectangle, then calls EnumDestructablesInRect and passes that rectangle along with my function that kills a destructable. I'm thinking that maybe EnumDestructablesInRect goes through every destructable that in finds in a radius around a given point and calls the function you passed it? Hmm, and that GetEnumDestructable gets an object variable that's been set by EnumDestructablesInRect? Is all of this correct? Extra Note: Edit: Added an if statement to verify that the Destructable was of the right type if ( GetDestructableTypeId(d) == 'LTba'). Note to Lord Vexorian: I've taken pains to insure that my code stays separate and is clearly marked as "not yours". In the credits, I also mention that Im using an edited version of your caster system and provide a link where they can get the "real thing". |
| 02-10-2005, 09:53 AM | #2 |
Code:
function KillBarricadeInCircleEnum takes nothing returns nothing
local destructable d=GetEnumDestructable()
call KillDestructable(d)
set u=null
endfunctionShouldn't it be set d = null ? |
| 02-23-2005, 05:34 PM | #3 |
Yeah...um...whoops. Thanks for catching that, it caused me to go back and look at that function and realize I was doing something dumb. For the overly curious, here is what the function looked like: Code:
function KillBarricadeInCircleEnum takes nothing returns nothing
local destructable d=GetEnumDestructable()
local unit u=udg_currentcaster
if (( GetDestructableTypeId(d) == 'LTba')) then
call KillDestructable(d)
endif
set udg_currentcaster=u
set u=null
set d=null
endfunctionYeah, that u sure is useful. DELETED! Anyway, I'll take it that if you caught that, you read through the rest of the post and didn't see anything glaringly wrong conceptually so.....good! |
