Attempting to make reincarnation revive with a % of max hp

For fulfilled maps that most likely don't work on the latest patch (1.24 or later).

Moderator: Cheaters

4Duck7
Newcomer
Posts: 5
Joined: November 26th, 2007, 10:23 pm

Attempting to make reincarnation revive with a % of max hp

Post by 4Duck7 »

Code: Select all

ReincarnationHalved
    Events
        Unit - A unit comes within 1000000000.00 of Ultimate Bosses 0013 <gen>
    Conditions
    Actions
        Wait until ((Life of (Triggering unit)) Less than 1.00), checking every 0.10 seconds
        Trigger - Turn off (This trigger)
        Wait 0.25 seconds
        Trigger - Turn on (This trigger)
        If (((Triggering unit) is alive) Equal to True) then do (Unit - Set life of (Triggering unit) to 50.00%) else do (Do nothing)
The power of google+ingenuity prevails again! (Ultimate Bosses is a waygate in the middle of my map)
Let me know if there's any way to sharpen it up; I'm not sure if I have stuff I don't need or if I'm missing something, but it freakin works 8) It doesn't lag for me, but it might if I play with other people.


So basically a unit with 1000 max hp would reincarnate to 500hp or some other fraction of health, instead of a full 1000. This is possible in GUI, right? I can't seem to come up with the correct way of programming it. :?
Last edited by 4Duck7 on January 31st, 2008, 8:06 am, edited 2 times in total.
User avatar
lightwing
Newcomer
Posts: 15
Joined: December 2nd, 2007, 8:13 pm
Title: Clan I3c Chieftain

Re: How do I make reincarnation revive with a % of max hp?

Post by lightwing »

Hi,

I think this should work ( for an unit )

Untitled Trigger 001
Events
Unit - A unit Dies
Conditions
Actions
Unit - Create 1 (Unit-type of (Dying unit)) for Player 1 (Red) at (Center of (Playable map area)) facing (Position of (Triggering unit))
Unit - Set life of (Last created unit) to 75.00%

Hero;

Untitled Trigger 002
Events
Unit - A unit Dies
Conditions
((Triggering unit) is A Hero) Equal to True
Actions
Wait 5.00 seconds
Hero - Instantly revive (Triggering unit) at (Center of (Playable map area)), Hide revival graphics
Unit - Set life of (Triggering unit) to 75.00%
lightwing
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: How do I make reincarnation revive with a % of max hp?

Post by Aero »

This is easily reproduced using triggers (JASS for sure).

I have a few questions though...

What type of units will be using it?
How many units will be using it (And the owner of these units too)?
Item Ability, Unit Ability or Hero Ability?
Want it to work exactly like reincarnation or different (With different effects)?
User avatar
Bartimaeus
Tyrannical Drama Queen
Posts: 4430
Joined: November 19th, 2007, 5:05 am
Been thanked: 2 times

Re: How do I make reincarnation revive with a % of max hp?

Post by Bartimaeus »

lightwing wrote:Hi,

I think this should work ( for an unit )

Untitled Trigger 001
Events
Unit - A unit Dies
Conditions
Actions
Unit - Create 1 (Unit-type of (Dying unit)) for Player 1 (Red) at (Center of (Playable map area)) facing (Position of (Triggering unit))
Unit - Set life of (Last created unit) to 75.00%

Hero;

Untitled Trigger 002
Events
Unit - A unit Dies
Conditions
((Triggering unit) is A Hero) Equal to True
Actions
Wait 5.00 seconds
Hero - Instantly revive (Triggering unit) at (Center of (Playable map area)), Hide revival graphics
Unit - Set life of (Triggering unit) to 75.00%
Uh, you might want to set it to 50.00%, and also, the conditions should be "Triggering Unit has item of type equal to Ankh of Reincarnation" or something very similar to that.
4Duck7
Newcomer
Posts: 5
Joined: November 26th, 2007, 10:23 pm

Re: How do I make reincarnation revive with a % of max hp?

Post by 4Duck7 »

Sorry, I should have been more specific.

What type of units will be using it?
-Heros

How many units will be using it (And the owner of these units too)?
-its a custom hero map, so any player can choose it as their hero's ultimate

Item Ability, Unit Ability or Hero Ability?
-hero ability

Want it to work exactly like reincarnation or different (With different effects)?
I basically want reincarnation to stay how it is, but have 50% max hp taken off either during the process of being reincarnated or very soon afterwards.

The game is Custom Hero Arena, so if you played that, then you know that Reincarnation needs to be nerfed :?
Last edited by 4Duck7 on January 27th, 2008, 10:43 pm, edited 1 time in total.
User avatar
lightwing
Newcomer
Posts: 15
Joined: December 2nd, 2007, 8:13 pm
Title: Clan I3c Chieftain

Re: How do I make reincarnation revive with a % of max hp?

Post by lightwing »

Hi,

I used the 75% as an example :)
lightwing
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: How do I make reincarnation revive with a % of max hp?

Post by Aero »

I'm currently not at my home computer so I can't develop anything at the moment.

Stay tuned though.
I'll come up with something nice and authentic.

Just a few more questions...

How many levels will the ability have?
If there is a unit array that records the players' heros please tell me it's name...
What world editor do you use?
Do you have a boolean array in your map? (For recycling purposes...I hate using more arrays than necessary)
4Duck7
Newcomer
Posts: 5
Joined: November 26th, 2007, 10:23 pm

Re: How do I make reincarnation revive with a % of max hp?

Post by 4Duck7 »

How many levels will the ability have?
4, with the only difference being the cooldown times (200sec, 170sec, 140sec, 120sec). Alternatively, if it's easier to program, the cooldown could be static (like 150sec) and the %hp slightly increased per level.

What world editor do you use?
The standard one.

Do you have a boolean array in your map? (For recycling purposes...I hate using more arrays than necessary)
If there is a unit array that records the players' heros please tell me it's name...


In all honesty, I just used xdep to deprotect the map, and I can't view any of the original triggers/variables/etc. I hope that isn't too much of a problem...I'm sorta learning as I go. I appreciate your help :D

EDIT:
ReincarnationHalved
Events
Unit - Unit's life becomes Less than 1.00
Conditions
Actions
Wait 0.10 seconds
If (((Triggering unit) is alive) Equal to True) then do (Unit - Set life of (Triggering unit) to 50.00%) else do (Do nothing)
This almost works...but when I try to do the Unit - Life event, it will only let me select a unit on the map already. I need to be able to select one of the games heroes that are "bought" at the beginning of the game with a wisp, but I don't know how.

(The wait is only 0.1 because I don't want a hero to die right before a duel...revive in the duel... and then get its health zapped. I changed the reincarnation delays to 0)


User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: SOLVED- make reincarnation revive with a % of max hp

Post by Aero »

Sorry for being slow on this. I was busy.
Anyways, try this out.

Features:
-Completely accurate--When hero reincarnates, there is no delay between having full hp bar and half hp bar (None that a human could tell ;)).
-Compatible with any reincarnation delay.
-Multi-unit instanceable.
-Configurable revive hp (%).

Drawbacks:
-Hero must actually learn the skill for triggers to work correctly; currently not compatible with it being a unit ability.
-The delay between dying and respawning should be less than the delay between dying and reincarnating.

The above means that if the unit dies (Reincarnation is in CD), the delay of the reincarnation ability must be less than the time it takes to respawn (This shouldn't be a problem...since respawn time is usually 10+ seconds).
The above also means that when a duel starts, there should be a delay before reviving/moving all heros (Longer than the reincarnation delay)

If you want to not have these drawbacks, I can customize the triggers, given the map, as to not have these problems.

//////
System consists of two triggers.
Simply copy the variable in variable editor, the triggers and then configure them and you're ready to go.

Code: Select all

Trigger: Reg on Learn

//Configuration
constant function ReincarnationDelay takes nothing returns real
return 7.00
endfunction
constant function AbilityRawcode takes nothing returns integer 
return 'AOre' //The rawcode of the ability
endfunction
constant function PercentRevive takes nothing returns real
return .50 //The %hp of the reincarnation
endfunction 
//Endconfiguration

function RegOnDeath takes nothing returns nothing
call TriggerRegisterUnitEvent(gg_trg_Reincarnate_Percent,GetLearningUnit(),EVENT_UNIT_DAMAGED)
endfunction

//===========================================================================
function RegOnDeathCond takes nothing returns boolean
return(GetLearnedSkill()==AbilityRawcode())
endfunction
function InitTrig_Reg_on_Learn takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t,Condition(function RegOnDeathCond))
call TriggerAddAction(t,function RegOnDeath)
set t=null
endfunction

Code: Select all

Trigger: Reincarnate Percent

//Handle Functions..Leave alone...
function H2I takes handle h returns integer
return h
return 0
endfunction
function GetHandleId takes handle h returns integer
local integer i=H2I(h)
set i=i*2134900736
set i=i/ 524288+4096
return i
endfunction
/////////////////////////////////////

function NerfLife takes nothing returns nothing
local timer t=GetExpiredTimer()
local integer i=GetHandleId(t)
call SetWidgetLife(udg_ReincarnationUnits[i],GetUnitState(udg_ReincarnationUnits[i],UNIT_STATE_MAX_LIFE)*PercentRevive())
call DestroyTimer(t)
set t=null
endfunction

function ReinPercent takes nothing returns nothing
local timer t=CreateTimer()
local integer i=GetHandleId(t)
set udg_ReincarnationUnits[i]=GetTriggerUnit()
call TimerStart(t,0.001+ReincarnationDelay(),false,function NerfLife)
set t=null
endfunction

//===========================================================================
function ReinPCond takes nothing returns boolean
return(GetWidgetLife(GetTriggerUnit())-.405 <= GetEventDamage())
endfunction
function InitTrig_Reincarnate_Percent takes nothing returns nothing
set gg_trg_Reincarnate_Percent=CreateTrigger()
call TriggerAddCondition(gg_trg_Reincarnate_Percent,Condition(function ReinPCond))
call TriggerAddAction(gg_trg_Reincarnate_Percent,function ReinPercent)
endfunction
Refer to this for an example.
4Duck7
Newcomer
Posts: 5
Joined: November 26th, 2007, 10:23 pm

Re: SOLVED- make reincarnation revive with a % of max hp

Post by 4Duck7 »

I made both triggers, the first one being on at init and the other not, but both enabled, just like in your example. I made the ReincarnationUnits unit array variable. I changed the reincarnation stats back to the original cooldowns just to be safe. Everything saved fine...but the trigger didn't work when I tested the map.

The skill is a hero ability and its raw code is "AOre." There are no other instances of "AOre" in any trigger besides the trigger that gives the hero the skill from the shop in the beginning. I copied what you did on to a blank map to make sure that I'm not missing anything, and sure enough it worked.

Any ideas? lol