- Joined
- Oct 12, 2011
- Messages
- 3,449
Guys, I'm new vJasser and still learning how to use Bribe's table. Here is my code
I dont know why but this part
wont save the real there D:
can someone show me what's I'm doing wrong there? thnks..
JASS:
library SRS initializer Ini
/*****************************************************************************************************/
/** **/
/** 'Safe Revive System v1.4' **/
/** ***** **/
/** by Dalvengyr aka ..... **/
/** **/
/* Why safe? This revive system allows you to revive any organic non-Hero units without recreating */
/* them. In the demo map there will be shown floating shits that shows units handle that is not */
/* changed after revived. What are the advantages of using this system? This method is faster than */
/* recreating new unit, and save spaces in memory. The only thing you need to do is set units death */
/* type to 'can raise, does decay'. */
/* */
/* Requirements: */
/* - Table */
/* - RegAnyUnitEvent */
/* - Any unit indexer */
/* */
/* Disadvantages: */
/* - None */
/* */
/* Implementation: */
/* 1. Copy SRS folder into your map */
/* 2. Copy dummy unit and spell into your map */
/* 3. Make sure dummy and spell id below is the same with their rawcode at OE */
/* 4. If you have dummy.mdx in your map, then open OE, set dummy units file model to that */
/* dummy.mdx is better */
/* 5. Nuff said. Done. */
/* */
/* APIs: */
/* 1. Revive any unit you want at their current position */
/* */
/* function ReviveUnit takes unit whichUnit returns boolean */
/* */
/* 2. Revive any unit you want at certain point */
/* Set boolean flag to true to check target point pathability */
/* Keep in mind that checking pathability is always slower than not */
/* */
/* function ReviveUnitAtPoint takes unit whichUnit, real x, real y, boolean flag returns boolean */
/** **/
/*****************************************************************************************************/
/*****************************************************************************************************/
globals
/* 'CONFIGURATIONS
1. Dummy Id */
private constant integer DUMMY_ID = 'SRSd'
/* 2. Spell Id */
private constant integer SPELL_ID = 'SRSa'
/* 3. Ressurection Order Id */
private constant integer ORDER_ID = 852094
/* 4. Size of table */
private constant integer SIZE = 8192
/* 'END-OF-CONFIGURATIONS' */
private unit DUMMY
endglobals
private function filter takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_STRUCTURE) and not IsUnitType(u, UNIT_TYPE_MECHANICAL) and not IsUnitType(u, UNIT_TYPE_HERO)
endfunction
private struct sr
Table array tab[SIZE]
static method save takes unit u returns nothing
local integer h
local thistype this
set h = GetUnitUserData(u)
set tab[h].real[1] = GetUnitX(u)
// Stopped here :(
set tab[h].real[2] = GetUnitY(u)
endmethod
method revive takes unit u returns boolean
local integer h
if filter(u) then
if IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0 then
set h = GetUnitUserData(u)
call SetUnitOwner(DUMMY, GetOwningPlayer(u), false)
call SetUnitX(DUMMY, tab[h][1])
call SetUnitY(DUMMY, tab[h][2])
call IssueImmediateOrderById(DUMMY, ORDER_ID)
return true
endif
endif
return false
endmethod
endstruct
private function onDeath takes nothing returns boolean
local sr this
local unit u = GetTriggerUnit()
if filter(u) then
call this.save(u)
endif
set u = null
return false
endfunction
private function Ini takes nothing returns nothing
call RegisterAnyUnitEvent(EVENT_PLAYER_UNIT_DEATH, function onDeath, null)
set DUMMY = CreateUnit(Player(15), DUMMY_ID, 0.0, 0.0, 270.0)
call UnitAddAbility(DUMMY, SPELL_ID)
endfunction
function ReviveUnit takes unit whichUnit returns boolean
local sr this
if this.revive(whichUnit) then
return true
endif
return false
endfunction
function ReviveUnitAtPoint takes unit whichUnit, real x, real y, boolean flag returns boolean
if ReviveUnit(whichUnit) then
if flag then
call SetUnitPosition(whichUnit, x, y)
else
call SetUnitX(whichUnit, x)
call SetUnitY(whichUnit, y)
endif
return true
endif
return false
endfunction
endlibrary
I dont know why but this part
JASS:
static method save takes unit u returns nothing
local integer h
local thistype this
set h = GetUnitUserData(u)
set tab[h].real[1] = GetUnitX(u)
// Stopped here :(
set tab[h].real[2] = GetUnitY(u)
endmethod
can someone show me what's I'm doing wrong there? thnks..