Hi there, I have been away from the WC3 editor for so long that I have even forgot the very basics, just came back to it to make a map with a friend and bumped into something that is probably very easy to solve but I have no idea what is wrong.
Basically I'm trying to make a so called KnockBack system, which will handle all forms of knockbacks caused during the game. For this I created global variables;
(AUD = AllUnitData)
AUDID - Integer Array
AUDUnit - Unit Array
AUDKBForce - Real Array
AUDKBAngle - Real Array
I begin with adding all the already existing units in the game to the data when the game starts, currently while testing two Footman are in the center of the map, no additional units are yet created.
Here is the knockback system code that I need help with, the loop is run the correct amount of times but nothing happens to the footman.
This is just a test ability trigger to test push a target, a simple single target spell both Footman possess.
Anyone who can see what I have missed? I have looked it over and even rewrote the whole thing trying to make it work. It has to be some sort of problem in the Index or something...
Basically I'm trying to make a so called KnockBack system, which will handle all forms of knockbacks caused during the game. For this I created global variables;
(AUD = AllUnitData)
AUDID - Integer Array
AUDUnit - Unit Array
AUDKBForce - Real Array
AUDKBAngle - Real Array
I begin with adding all the already existing units in the game to the data when the game starts, currently while testing two Footman are in the center of the map, no additional units are yet created.
Code:
Init 1
Events
Map initialization
Conditions
Actions
Set TempGroup = (Units in (Playable map area))
Set tempInt = 1
Unit Group - Pick every unit in TempGroup and do (Actions)
Loop - Actions
Game - Display to (All players) the text: (Roar + (String(tempInt)))
Set tempInt = (tempInt + 1)
Set AUDID[tempInt] = tempInt
Unit - Set the custom value of (Picked unit) to AUDID[tempInt]
Here is the knockback system code that I need help with, the loop is run the correct amount of times but nothing happens to the footman.
Code:
function takevalues takes real kraft, real angle returns nothing
endfunction
function KBActions takes nothing returns nothing
local integer LC = 1
local unit U = null
local real kraft = 0
local real angle = 0
loop
set LC = LC + 1
//This message is shown with the correct number and value.
call DisplayTextToForce( GetPlayersAll(), I2S(LC) + " - Looped" )
set kraft = udg_AUDKBForce[LC]
set angle = udg_AUDKBAngle[LC]
set U = udg_AUDUnit[LC]
//Here I'm just testing if it at all refers to any of the two units, nothing happens.
call DisplayTextToForce( GetPlayersAll(), GetUnitName(U) )
call AddSpecialEffectLocBJ( GetUnitLoc(U), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
call SetUnitX(U, GetUnitX(U) + kraft * Cos(angle * bj_DEGTORAD))
call SetUnitY(U, GetUnitY(U) + kraft * Sin(angle * bj_DEGTORAD))
//set udg_AUDKBForce[LoopCounter] = -5
exitwhen LC == udg_AUDID[LC]
endloop
endfunction
//===========================================================================
function InitTrig_KnockBackSystem2 takes nothing returns nothing
set gg_trg_KnockBackSystem2 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_KnockBackSystem2, 1 )
call TriggerAddAction( gg_trg_KnockBackSystem2, function KBActions )
endfunction
This is just a test ability trigger to test push a target, a simple single target spell both Footman possess.
Code:
Knuff
Events
Unit - A unit Starts the effect of an ability
Conditions
Actions
Game - Display to (All players) the text: Casting
Set AUDKBForce[AUDID[(Custom value of (Target unit of ability being cast))]] = 100.00
Set AUDKBAngle[AUDID[(Custom value of (Target unit of ability being cast))]] = 100.00
Anyone who can see what I have missed? I have looked it over and even rewrote the whole thing trying to make it work. It has to be some sort of problem in the Index or something...