- Joined
- Aug 19, 2008
- Messages
- 491
Hey dudes!
I'm making a spell in vJass (you'll see the code below). It is not done yet, but without fixing these two bugs it won't work anyway:
1: This third BJDebugMsg() isn't shown in-game
2: The Area-setting section will only ever target 1000. or 400., which is odd because the % base system works fine.
(Both of these are marked in the code)
Please don't assume I've done stupid things like "wrong rawcode of spell" because - as I said - the first BJDebugMsg() is shown.
Oh and, as for other bugs, leave that to me. If you see someting dumb about the code (i.e unproper group adding) don't mention it because this spell isn't done yet and my only concern is the messages and the returned area.
+Rep to the dude who has the best solution
SOLVED!
by Deaod.
debug_int isn't initialized, so the thread crashed.
And as for the area setting, something was wrong with the if/elseif/elseif/elseif/endif function
I'm making a spell in vJass (you'll see the code below). It is not done yet, but without fixing these two bugs it won't work anyway:
1: This third BJDebugMsg() isn't shown in-game
2: The Area-setting section will only ever target 1000. or 400., which is odd because the % base system works fine.
(Both of these are marked in the code)
Please don't assume I've done stupid things like "wrong rawcode of spell" because - as I said - the first BJDebugMsg() is shown.
Oh and, as for other bugs, leave that to me. If you see someting dumb about the code (i.e unproper group adding) don't mention it because this spell isn't done yet and my only concern is the messages and the returned area.
+Rep to the dude who has the best solution
SOLVED!
by Deaod.
debug_int isn't initialized, so the thread crashed.
And as for the area setting, something was wrong with the if/elseif/elseif/elseif/endif function
JASS:
scope RadiologicDevice initializer Initialize
//***************************************************************************
//********************************** SETUP **********************************
//***************************************************************************
globals
private constant integer SPELL_ID = 'A04F'
private constant real FUSE_DURATION = 5.
endglobals
//Probability functions
private function ProbabilityOfArea1 takes integer level returns integer
return 37 - ( 2 * level )
endfunction
private function ProbabilityOfArea2 takes integer level returns integer
return 31 - level
endfunction
private function ProbabilityOfArea3 takes integer level returns integer
return 24 + level
endfunction
private function ProbabilityOfArea4 takes integer level returns integer
return 8 + ( 2 * level )
endfunction
private function Area takes integer randomized_digit returns real
return 1200. - (200. * randomized_digit )
endfunction
private function AllowedVictims takes unit caster, unit victim returns boolean
return ( GetWidgetLife( victim ) > .405 ) and ( IsUnitType( victim, UNIT_TYPE_MAGIC_IMMUNE ) == true) and ( IsUnitEnemy( victim, GetOwningPlayer( caster ) ) == true ) and ( IsUnitType( victim, UNIT_TYPE_STRUCTURE ) == true ) and ( IsUnitType( victim, UNIT_TYPE_MECHANICAL ) == true )
endfunction
//***************************************************************************
//******************************** END SETUP ********************************
//***************************************************************************
globals
private unit GlobalCaster
private group victims
private boolexpr victim_types
endglobals
private function Pick takes nothing returns boolean
return AllowedVictims( GlobalCaster, GetFilterUnit() )
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
//***************************************************************************
private function Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local player owner = GetOwningPlayer( caster )
local location spell_loc = GetSpellTargetLoc()
local real spellX = GetLocationX( spell_loc )
local real spellY = GetLocationY( spell_loc )
local integer level = GetUnitAbilityLevel( caster, SPELL_ID )
local integer p_of_area_1 = ProbabilityOfArea1(level)
local integer p_of_area_2 = ProbabilityOfArea2(level)
local integer p_of_area_3 = ProbabilityOfArea3(level)
local integer p_of_area_4 = ProbabilityOfArea4(level)
local real area
local integer random = GetRandomInt( 1, 100 )
local integer debug_int
local unit debug_unit
call BJDebugMsg( "This is just some random text" ) //FIRST BJDebugMsg()
if ( random <= p_of_area_1 ) then
set area = Area(1)
elseif ( random > p_of_area_1 ) and ( random <= p_of_area_2 ) then
set area = Area(2)
elseif ( random > p_of_area_2 ) and ( random <= p_of_area_3 ) then
set area = Area(3)
elseif ( random > p_of_area_3 ) then
set area = Area(4)
endif
call BJDebugMsg( "area = " + R2S(area) ) //SECOND BJDebugMsg(). This only shows "area = 400." or "area = 1000."
set GlobalCaster = caster
call GroupEnumUnitsInRange( victims, spellX, spellY, area, victim_types )
loop
set debug_unit = FirstOfGroup( victims )
exitwhen debug_unit == null
set debug_int = debug_int + 1
call GroupRemoveUnit( victims, debug_unit )
endloop
call TriggerSleepAction( 1. )
call BJDebugMsg( "Debug_int == " + I2S( debug_int ) ) //THIRD BJDebugMsg(). This is not shown at all.
set caster = null
set owner = null
call RemoveLocation( spell_loc )
set spell_loc = null
endfunction
//***************************************************************************
private function Initialize 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 )
//Globals
set victims = CreateGroup()
set victim_types = Condition( function Pick )
endfunction
endscope
Last edited: