Setting max Mp and Hp

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

em100181
Newcomer
Posts: 16
Joined: November 24th, 2007, 12:53 pm

Re: Setting max Mp and Hp

Post by em100181 »

wow i am amazed that none of you know jass well enough to do this.

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)
if you wanted your -hp or -mp function to accept a variable on what % of life you want to set the person at, or a raw #, you can change it....if youre using percents, then the percent functions of course and if you want to be able to accept a variable and set the persons life exactly to that #, then you have to use...

Code: Select all

function SetUnitLifeBJ takes unit whichUnit, real newValue returns nothing
and parsing in the variable is done as always...
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...
User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Re: Setting max Mp and Hp

Post by JJ2197 »

I already know how to set it to a percentage... I want to know how to change the
max hp and mp... >.>
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: Setting max Mp and Hp

Post by Xantan »

they meant giving a unit more hp then normally possible I believe.
HINDYhat
Senior Member
Posts: 101
Joined: June 1st, 2007, 9:05 pm

Re: Setting max Mp and Hp

Post by HINDYhat »

SetUnitMaxState, by Blade.dk
http://www.wc3jass.com/viewtopic.php?t=2652

Bonus Mod, by weaaddar
http://www.wc3jass.com/viewtopic.php?t=202

Both of those snippets can change a unit's max HP and such.
User avatar
JJ2197
Legendary Genius
Posts: 1311
Joined: August 8th, 2007, 8:10 am
Title: Legendary Genius²
Location: St. George Utah

Re: Setting max Mp and Hp

Post by JJ2197 »

Okay just need a little more help...

Okay so I got that inserted at like the top of the functions and this in my chat function

if SubString(s,0,4)=="-set"then
call SetUnitMaxState(u,UNIT_STATE_MAX_LIFE,S2I(SubString(s,5,10)))

I got it under the select unit part (I don't know what else to call it)
Computer Specs:
Motherboard: GA-990FXA-UD3
CPU: FX-8350 @ 4.0GHz
PSU: Corsair CX500
RAM: G.Skill Ripjaws X 8GB @ 1866
GPU: Radeon HD 4870 1GB
HDD: OCZ Vertex series 30GB SSD
Case: Antec 900
Monitor: Toshiba 32"
OS: Windows 7 Ultimate
Dekar
Forum Drunk
Posts: 2918
Joined: January 17th, 2007, 4:22 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Setting max Mp and Hp

Post by Dekar »

hmm? i don't understand... any problems? seems to be fine ;)
Don't pm me with Warcraft questions, this is a forum so just make a post!
In the world of thinking we are all immigrants. -Robert Nozick