PoLlama Forums  

Go Back   PoLlama Forums > WarCraft > World Editor Help > JASS Help

Reply
 
LinkBack Thread Tools
Old 06-25-2008   #1
 
Join Date: Jun 2008
Posts: 33
Phoenix is on a distinguished road
respawn hero code

a friend of mine gave me this code to revive heros on my orpg map, but i seem to be getting errors, it works on his map but not on mine, what am i doing wrong?

this is the code:
  1. //TESH.scrollpos=0
  2. //TESH.alwaysfold=0
  3. function Revive_Conditions takes nothing returns boolean
  4. return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true
  5. endfunction
  6. function Revive_Actions takes nothing returns nothing
  7. local unit u = GetDyingUnit()
  8. local real x = -145 // The X co-ordinate of the revival point.
  9. local real y = -3811 // The Y co-ordinate of the revival point.
  10. local real a = 30 // Base revival time.
  11. local real b = 0 // Additional revival time per level.
  12. local real c = 0 // The number to be multiplied by the distance from the revival point. Further away = more time. Use very small numbers or else the respawn time will become gigantic (ex: use 0.002).
  13. local boolean d = true // Show revival beam?
  14. local real z = a + (b * GetHeroLevel(u)) + (c * SquareRoot(((GetUnitX(u) - x) * (GetUnitX(u) - x)) + ((GetUnitY(u) - y) * (GetUnitY(u) - y))))
  15. call DisplayTimedTextToPlayer(Player(0), 0, 0, 3, "Revival Time: |cffffcc00" + I2S(R2I(z)) + "|r")
  16. // Remove the above line in the actual game, it is for testing only.
  17. call TriggerSleepAction( z )
  18. call ReviveHero( u, x, y, d )
  19. set u = null
  20. endfunction
  21. //================================================== =========================
  22. function InitTrig_Revive takes nothing returns nothing
  23. set gg_trg_Revive = CreateTrigger( )
  24. call TriggerRegisterAnyUnitEventBJ( gg_trg_Revive, EVENT_PLAYER_UNIT_DEATH )
  25. call TriggerAddCondition( gg_trg_Revive, Condition( function Revive_Conditions ) )
  26. call TriggerAddAction( gg_trg_Revive, function Revive_Actions )
  27. endfunction


ive included my map to show the errors.

can anyone help me out? would be greatly appricieted

thanks in advance, Phoenix
Attached Files
File Type: w3x untold legends ver 1.4g bug.w3x (186.3 KB, 3 views)
Phoenix is offline   Reply With Quote
Old 06-25-2008   #2
 
Mr. Zero's Avatar
 
Join Date: Sep 2006
Location: Denmark (GMT+1)
Posts: 2,173
Mr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond repute
Re: respawn hero code

Functions optimized and renamed for better overview (You don't need to rename the functions to one letters to save space as Vex's optimizer does that for you).

  1. constant function Revival_BaseTime takes nothing returns real
  2. return 30.00 // The base waiting time.
  3. endfunction
  4. constant function Revival_LevelMultiply takes nothing returns real
  5. return 0.00 // Adds the heroes level to the time with a multiplier.
  6. // E.g. return 1 will cause heroes to wait basetime + the hero's level + distance.
  7. // Return 2 will cause basetime + hero's level * 2 + distance and so on...
  8. endfunction
  9. constant function Revival_DistMultiply takes nothing returns real
  10. return 0.00 // Will add more time the futher away the hero dies from revival point.
  11. // Return 0 will remove the add distance time.
  12. // Return 1 will simply add the distance to the time. E.g. a unit is 400 units away from revival point means it will add 400 seconds to the time.
  13. // So try keep it low.
  14. endfunction
  15. constant function Revival_ShowBeam takes nothing returns boolean
  16. return true // Show revival beam.
  17. endfunction
  18. constant function Revival_X takes nothing returns real
  19. return -145.00 // X coord of revival.
  20. endfunction
  21. constant function Revival_Y takes nothing returns real
  22. return -3811.00 // Y coord of revival.
  23. endfunction
  24. function Revive_Conditions takes nothing returns boolean
  25. return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO)
  26. endfunction
  27. function Revive_Actions takes nothing returns nothing
  28. local unit hero = GetDyingUnit()
  29. local real x = GetUnitX(hero) - Revival_X() // Get x distance from revival point to hero x.
  30. local real y = GetUnitY(hero) - Revival_Y() // Get y distance from revival point to hero y.
  31. local real sleepTime = Revival_BaseTime() + (Revival_LevelMultiply() * GetHeroLevel(hero)) + (Revival_DistMultiply() * SquareRoot((x * x) + (y * y)))
  32. call BJDebugMsg("Revival Time: |cffffcc00"+R2S(sleepTime)) // Debug
  33. call TriggerSleepAction( sleepTime )
  34. call ReviveHero( hero, Revival_X(), Revival_Y(), Revival_ShowBeam() )
  35. set hero = null
  36. endfunction
  37. //================================================== =========================
  38. function InitTrig_Revive takes nothing returns nothing
  39. local integer index = 0
  40. set gg_trg_Revive = CreateTrigger( )
  41. loop
  42. call TriggerRegisterPlayerUnitEvent(gg_trg_Revive, Player(index), EVENT_PLAYER_UNIT_DEATH, null)
  43. set index = index + 1
  44. exitwhen index == bj_MAX_PLAYER_SLOTS
  45. endloop
  46. call TriggerAddCondition( gg_trg_Revive, Condition( function Revive_Conditions ) )
  47. call TriggerAddAction( gg_trg_Revive, function Revive_Actions )
  48. endfunction


Do notice through if a hero dies while another is waiting to get revival, it will bug out and not revive the second hero. This is because of the trigger sleep.

[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]

"In the end there is no greater motivation than revenge"
SO I HERD U LEIK MUDKIPZ?!

Last edited by Mr. Zero; 06-25-2008 at 04:50 PM.
Mr. Zero is offline   Reply With Quote
Old 06-25-2008   #3
 
Join Date: Jun 2008
Posts: 33
Phoenix is on a distinguished road
Re: respawn hero code

dam xD ideas on fixing that trigger sleep problem?

also theres a worry that it will revive enemy bosses and spawn them at the hero spawn? xD

nearly there! after this i just need to figure how to make creeps spawn after death, im not much for spawn creeps every 30 seconds method, due to the fact it will lag alot if nobody kills them

edit: im still geting errors :S such as : expected a name, expected a variable name and expected a function name

ideas? it wont let me enable the trigger till they are sorted xD sorry to sound greedy but im terrible with jass related code :P

thanks in advance
Phoenix is offline   Reply With Quote
Old 06-25-2008   #4
 
Mr. Zero's Avatar
 
Join Date: Sep 2006
Location: Denmark (GMT+1)
Posts: 2,173
Mr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond repute
Re: respawn hero code

Make sure your trigger is called "Revive" (without quotes). It's likely you just made a copy and paste the code.

The trigger sleep workaround takes some time to make so let me sleep on it (00:03 over here ) and I will get back to you.

[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]

"In the end there is no greater motivation than revenge"
SO I HERD U LEIK MUDKIPZ?!
Mr. Zero is offline   Reply With Quote
Old 06-26-2008   #5
 
Mr. Zero's Avatar
 
Join Date: Sep 2006
Location: Denmark (GMT+1)
Posts: 2,173
Mr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond reputeMr. Zero has a reputation beyond repute
Re: respawn hero code

!! Important !!
The trigger shall be called "Revival"

Code:
constant function Revival_BaseTime takes nothing returns real
    return 30.00 // The base waiting time.
endfunction

constant function Revival_LevelMultiply takes nothing returns real
    return 0.00 // Adds the heroes level to the time with a multiplier.
    // E.g. return 1 will cause heroes to wait basetime + the hero's level + distance.
    // Return 2 will cause basetime + hero's level * 2 + distance and so on...
endfunction

constant function Revival_DistMultiply takes nothing returns real
    return 0.00 // Will add more time the futher away the hero dies from revival point.
    // Return 0 will remove the add distance time.
    // Return 1 will simply add the distance to the time. E.g. a unit is 400 units away from revival point means it will add 400 seconds to the time.
    // So try keep it low (Like 0.002).
endfunction

constant function Revival_ShowBeam takes nothing returns boolean
    return true // Show revival beam.
endfunction

constant function Revival_X takes nothing returns real
    return -145.00 // X coord of revival.
endfunction

constant function Revival_Y takes nothing returns real
    return -3811.00 // Y coord of revival.
endfunction
  
function Revival_Cond takes nothing returns boolean
    return (IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetPlayerController(GetOwningPlayer(GetTriggerUnit())) == MAP_CONTROL_USER)
    // Is the dying unit a hero and owned by a player then return true
endfunction
  
function Revival_MainFunc takes nothing returns nothing
    local unit hero = GetTriggerUnit() // Get dying hero
    local real x = GetUnitX(hero) - Revival_X() // Get x distance from revival point to hero x.
    local real y = GetUnitY(hero) - Revival_Y() // Get y distance from revival point to hero y.
    local real sleepTime = Revival_BaseTime() + (Revival_LevelMultiply() * GetHeroLevel(hero)) + (Revival_DistMultiply() * SquareRoot((x * x) + (y * y))) // Basetime + ( LevelMultiplier * Hero Level ) + ( DistanceMultiplier * Distance from revival point )
    call PolledWait(sleepTime)
    call ReviveHero( hero, Revival_X(), Revival_Y(), Revival_ShowBeam() )
    set hero = null
endfunction

function InitTrig_Revival takes nothing returns nothing
    local integer index = 0
    set gg_trg_Revival = CreateTrigger( )
    loop
        call TriggerRegisterPlayerUnitEvent(gg_trg_Revival, Player(index), EVENT_PLAYER_UNIT_DEATH, null)
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition( gg_trg_Revival, Condition( function Revival_Cond ) )
    call TriggerAddAction( gg_trg_Revival, function Revival_MainFunc )
endfunction

[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]
[Only registered and activated users can see links. ]

"In the end there is no greater motivation than revenge"
SO I HERD U LEIK MUDKIPZ?!
Mr. Zero is offline   Reply With Quote
Old 06-26-2008   #6
 
Join Date: Jun 2008
Posts: 33
Phoenix is on a distinguished road
Re: respawn hero code

awesome ! it works fine :P

i know its not jass related but ideas on these questions,

raising max level to 80 for all heros?
Bounty on
Spawning creeps in a zone when they have all been killed, not the time elaspse thing



and then i think my maps ready for some fun

thanks so much for all this help !
Phoenix is offline   Reply With Quote
Old 07-30-2008   #7
 
Join Date: Jan 2007
Posts: 44
crazywolf777 is an unknown quantity at this point
Re: respawn hero code

The level 80 thing is in "Gameplay Constants" under Advanced tab. Just change it from 10 to 80.
crazywolf777 is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hero Ideas! luigi_fan64 Broken Alliances 8 01-28-2008 06:51 PM
Some Hero Changes i would like to see luigi_fan64 Broken Alliances 0 01-06-2008 01:17 PM
Unit editor basic guide Halakbalakbalak Submit a Tutorial [World Editor] 1 10-19-2007 02:18 PM
Respawning + Hero Selection on Circle DarkBlade Tutorials 4 09-07-2007 07:56 PM
Final Hero Killzor2 New Feature Requests 15 12-04-2006 05:16 PM


All times are GMT -5. The time now is 10:07 AM.

A friend of Wc3Happy
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165