| 04-09-2005, 11:53 PM | #1 |
I originally made a trigger that does some stuff to damage a unit using the gui action 'Unit - Damage Target Unit' or whatever its called so i figured now that the maps expanded its time to turn it into a function so i can keep things more organized and compartmentalize the functions for reuse and such only problem is call UnitDamageTargetBJ() doesn't seem to be working anymore in the function (yes i sent it all the right parameters, and yes the function actually gets the the statement since i put a debug msg before and after it and they both run) so now i'm at a loss, any ideas? maybe i forgot something really stupid and small? |
| 04-10-2005, 12:02 AM | #2 |
posting the function wouldn't hurt |
| 04-10-2005, 01:15 AM | #3 |
Code:
//***************************************************************************
//Does physical damage to a unit, takes a damage, type of damage, and target
//unit. Accounts for armor and resistance
//***************************************************************************
function causePhysicalDamage takes unit attacking, unit attacked, integer dam, string t returns nothing
local real resistance
local real realdam
local integer armor
local location p
local unit u
call DebugMsg( "RAN" )
//Getting the resistance modifier
if ( t == "unarmed" ) then
set resistance = GetHandleReal( attacked, "var_fUnarmedDam" )
elseif ( t == "pierce" ) then
set resistance = GetHandleReal( attacked, "var_fPierceDam" )
elseif ( t == "slash" ) then
set resistance = GetHandleReal( attacked, "var_fSlashDam" )
elseif ( t == "crush" ) then
set resistance = GetHandleReal( attacked, "var_fCrushDam" )
else
//Default case (full damage)
set resistance = 1.00
endif
call DebugMsg( "Resistance: " + R2S(resistance) )
set armor = GetHandleInt( attacked, "var_nArmor" )
call DebugMsg( "Armor: " + I2S(armor) )
set realdam = ( (I2R(dam) * resistance) - I2R(armor) )
call DebugMsg( "Damage: " + R2S(realdam) )
set p = GetRectCenter(gg_rct_Temp_Area)
call CreateNUnitsAtLoc( 1, 'hfoo', GetOwningPlayer(attacking), udg_XTEMP_point01, bj_UNIT_FACING )
set u = GetLastCreatedUnit()
//ARG START WORKING
call UnitDamageTargetBJ( u, attacked, realdam, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
//call SetUnitLifeBJ( attacked, ( GetUnitStateSwap(UNIT_STATE_LIFE, attacked) - realdam ) )
call RemoveUnit( u )
call RemoveLocation( p )
endfunctionalso notable, it started working a few minutes into a game one time only after it wasn't working for a while for some random reason... and i don't see why this should happen since the function doesn't rely on any globals (at least not for the damaging part, the other parts were getting values fine the whole time) |
| 04-10-2005, 10:23 PM | #4 |
so, um, noone has a clue? i can safely say this is driving me nuts, cause i just tested it again, didn't work for 10 minutes, then just started doing damage all of a sudden... though the entire function was working the entire time :S... it must be something small i'm overlooking or something, if only i could figure out when it started working |
| 04-12-2005, 04:22 AM | #5 |
yup... wow, i overlooked something small... apparently i used a global point, and for some reason that global point wasn't working so the actual footman wasn't being created in the first place... :S lesson learned |
