ive only hacked one map but as part of my cheatpack i have -hp = restore full health and -mp = restore full MP, on targetted unit.
can also of course be done just on hero but if hero is selected anyway its better to do a universal target-heal (can be useful to heal town guards or something else crazy, like an NPC who cant die or you fail a quest etc)
anyway here's the very, very, simple code in jass...ive chopped out only the variables that are needed and the altered it just for your exact purpose...this function out of my main cheat function is of course much bigger, with a big if-elseif block to check every -<cheat> command that i put in there.
Code: Select all
local player p=GetTriggerPlayer()
local group g=CreateGroup()
local string s=GetEventPlayerChatString()
local unit u
call GroupEnumUnitsSelected(g,p,null)
loop
set u=FirstOfGroup(g)
exitwhen u==null
if SubString(s,0,3)=="-hp" then
call SetUnitLifePercentBJ(u,100)
elseif SubString(s,0,3)=="-mp" then
call SetUnitManaPercentBJ(u,100)
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
Code: Select all
function SetUnitLifeBJ takes unit whichUnit, real newValue returns nothing
theres a few functions for nearly everything.
SetUnitLifeBJ is just a function that ends up calling SetUnitState, anyway...just a wrapper function, but its part of the library, so...