| 07-15-2003, 10:44 PM | #1 |
I noticed that one of the really annoying things you have to deal with when making JASS spells is experience. The game if you use the kill unit action or the set life action to kill a unit, Event Response - Killing Unit doesn't work, so the game doesn't give XP to the hero that cast the JASS spell. This code is a work around for that. You'll need to setup an invulnerable unit called XP Bringer, and set the XP Bringer variable in the code to be of its unittype. You'll also need to give this unit death coil that does 999999 damage :) Lastly, you'll need to setup a region where the temporary units spawned to make this code work will appear. You pass it 3 things: The player to get XP credit, the unit they're to get XP credit for killing, and the killbox region. If somebody can come up with a version of this code that doesn't require the region or unit spawning, that'd be uber cool :) Newbies read on below :) Code:
//This function gives XP credit to a player's heroes (now that heroes gain XP from any unit killed anywhere
//on the map. I use this because I have JASS spells that kill enemies, and I still want the player to get XP.
//The killBox region is where the game will spawn the
//temporary units the function needs to give the player XP credit. This should be a region on your map
//surrounded by boundary.
function GivePlayerXPCredit takes player whichPlayer, unit whichUnit, rect killBox returns nothing
//Setup local variables
local unit Creditor
local unit XPBringer
local integer XPBringerType = 'h00B' //Really a unit-type, not an integer
//Create unit to be killed
call CreateNUnitsAtLoc( 1, GetUnitTypeId(whichUnit), Player(PLAYER_NEUTRAL_AGGRESSIVE), GetRectCenter(killBox), bj_UNIT_FACING )
set Creditor = GetLastCreatedUnit()
call SetUnitPathing( Creditor, false ) //Collision turned off to make sure they really fit in box
call SetUnitPositionLoc( Creditor, GetRectCenter(killBox) )
//Check to see if creditor is a hero, if so set his level
if(IsUnitType(whichUnit, UNIT_TYPE_HERO) == true) then
call SetHeroLevelBJ( Creditor, GetHeroLevel(whichUnit), false )
endif
call CreateNUnitsAtLoc( 1, XPBringerType, whichPlayer, GetRectCenter(killBox), bj_UNIT_FACING )
set XPBringer = GetLastCreatedUnit()
call SetUnitPathing( XPBringer, false )
call SetUnitPositionLoc( XPBringer, GetRectCenter(killBox) )
call SetUnitLifeBJ( Creditor, 1.00 ) //Just in case they have tons of HP
call SetUnitPositionLoc( Creditor, GetRectCenter(killBox) )
call SetUnitPositionLoc( XPBringer, GetRectCenter(killBox) )
call IssueTargetOrderBJ( XPBringer, "deathcoil", Creditor ) //Kill him for credit
call SetUnitPathing( Creditor, true ) //In case they're a hero to be respawned
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', XPBringer )
endfunctionNOTE: You don't need to be a total JASS expert to use this code. Just go into the trigger editor, and click the filename of your map (it'll be the very top thing listed in your triggers/categories). Copy and paste this in there. Then use the custom script action whenever you want to use this function. Example: Code:
Custom script: call GivePlayerXPCredit(ConvertedPlayer(R2I(GetUnitFlyHeight(GetEnumUnit()))), udg_SYS_Units[GetUnitUserData(GetEnumUnit())], gg_rct_Kill_box) |
| 07-17-2003, 01:40 AM | #2 |
does he really need to do 999999999 damage and why not use something more universal like a stormbolt with no stun instead of death coil which is Anyone other then ud (meaning the UD guy will be healed to max after thats cast on him not so good eh?) other then that neat-o bandit-o. As you do a wonderfully horrible job of explaining what your code does I'll do it for you. Basically DA code finds out the level of the dude your killing and then creates the Giver of death and the reciever of death. The reciever is given the level of the the unit which is getting the death inflicting spell cast upon him then raped horrendously by 9999999 (also theres a check if its a hero or not). That said nifty work around but it requires a region (not so major he can definetly do it at game map center with 2 flying units at obscene hieghts who have ghost set to 100% transparency) and the spawning of units which in the heat of battle may cause the needed lag to give some an edge. |
| 07-17-2003, 04:04 AM | #3 | |
Quote:
Thanks ;) This code is featured in Battledome ]|[... only 3 hero skills to go! w00t! (of course 2 of them are bugged horribly and I can't figure out what's wrong) |
