Powerups not spawning at nodes [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
LRKfm946
Master Sergeant
Master Sergeant
Posts: 163
Joined: Sun Feb 02, 2014 6:13 pm
Projects :: Battlefront II Hunger Games
Games I'm Playing :: SWBF2 BF3
Contact:

Powerups not spawning at nodes [Solved]

Post by LRKfm946 »

In my lua, I'm spawning powerups at nodes around the map, but many of the powerups don't spawn at the nodes they're supposed to. Instead they spawn at the center point of the map. All the path names are correct, and the nodes are not obstructed in any way (not underground or inside any objects). What's going on? :?

EDIT: I should add that it happens to every powerup on the affected paths, not just 1 or 2.
Last edited by LRKfm946 on Mon Apr 07, 2014 4:07 pm, edited 3 times in total.
User avatar
Locutus
1st Lieutenant
1st Lieutenant
Posts: 420
Joined: Fri Jun 04, 2010 10:08 am
Projects :: Stargate Battlefront Pegasus
Location: Germany
Contact:

Re: Powerups not spawning at nodes

Post by Locutus »

I could imagine that this is caused by different "counting", for example in ZE you have node 0-2 but in lua you're trying to spawn on node 1-3 or vice versa.
LRKfm946
Master Sergeant
Master Sergeant
Posts: 163
Joined: Sun Feb 02, 2014 6:13 pm
Projects :: Battlefront II Hunger Games
Games I'm Playing :: SWBF2 BF3
Contact:

Re: Powerups not spawning at nodes

Post by LRKfm946 »

Nope, I have them all indexed correctly; n nodes, 0 thru n-1.

Here's the function I'm using to test them:
Hidden/Spoiler:
[code]function spawnAll(self)

testSpawnTimer = CreateTimer("testSpawnTimer")
SetTimerValue(testSpawnTimer, 1)
testSpawnTimer2 = CreateTimer("testSpawnTimer2")
SetTimerValue(testSpawnTimer2, 1)
local i = 0
local j = 0

OnTimerElapse(
function(timer)
local point = GetPathPoint("normal_ammo_spawn2", i)
print("Spawning normal ammo ", i)
CreateEntity("com_item_powerup_dual", powerspawn, "powerup"..i)
SetEntityMatrix(players_alive[1].playerUnit, point)
i = i + 1
if i > 19 then
StartTimer(testSpawnTimer2)
else
SetTimerValue(testSpawnTimer, 1)
StartTimer(testSpawnTimer)
end
end,
testSpawnTimer
)

OnTimerElapse(
function(timer)
local point = GetPathPoint("special_ammo_spawn3", j)
print("Spawning special ammo ", j)
CreateEntity("com_item_powerup_antiammo", powerspawn, "powerup"..j)
SetEntityMatrix(players_alive[1].playerUnit, point)
j = j + 1
if j <= 11 then
SetTimerValue(testSpawnTimer2, 1)
StartTimer(testSpawnTimer2)
end
end,
testSpawnTimer2
)

StartTimer(testSpawnTimer)

for i = 0, 15 do
armorspawn = GetPathPoint("armor_spawn2", i)
print("Spawning armor ", i)
CreateEntity("com_item_powerup_armor", armorspawn, "armor"..i)
end

cp1_ammospawn1 = GetPathPoint("cp1_spawn", 0)
cp1_ammospawn2 = GetPathPoint("cp1_spawn", 1)
cp2_ammospawn1 = GetPathPoint("cp2_spawn", 0)
cp2_ammospawn2 = GetPathPoint("cp2_spawn", 1)
cp3_ammospawn1 = GetPathPoint("cp3_spawn", 0)
cp3_ammospawn2 = GetPathPoint("cp3_spawn", 1)
cp4_ammospawn1 = GetPathPoint("cp4_spawn2", 0)
cp4_ammospawn2 = GetPathPoint("cp4_spawn2", 1)
CreateEntity("com_item_powerup_dual", cp1_ammospawn1, "ammo1")
CreateEntity("com_item_powerup_dual", cp1_ammospawn2, "ammo2")
CreateEntity("com_item_powerup_dual", cp2_ammospawn1, "ammo3")
CreateEntity("com_item_powerup_dual", cp2_ammospawn2, "ammo4")
CreateEntity("com_item_powerup_dual", cp2_ammospawn1, "ammo5")
CreateEntity("com_item_powerup_dual", cp3_ammospawn2, "ammo6")
CreateEntity("com_item_powerup_dual", cp4_ammospawn1, "ammo7")
CreateEntity("com_item_powerup_dual", cp4_ammospawn2, "ammo8")
return

end[/code]
There's a line in there that teleports me to each node as it checks it, and I never got teleported to the center. A few nodes must have gotten moved because a couple times I was teleported in mid air or inside an object but I fixed them all and it still didn't work.




EDIT: The teleporting line just gave me an idea: after the powerup is created, teleport it to the node. I tested it, and it works! :D Le solved
The fix:

Code: Select all

CreateEntity("com_item_powerup_dual", powerspawn, "powerup"..i)
local powerupPtr = GetEntityPtr("powerup"..i)
SetEntityMatrix(powerupPtr, point)
EDIT 2: Oh wow, now I see my original error... I copied and pasted another loop and changed the node name but forgot to change it in CreateEntity()... Well now I feel dumb :P
Although now it crashes after node 8 in the special_power_spawn loop with no error... :? Unsolved now.

EDIT 3 yet again: Okay so I removed the line that teleports me to each node and it stopped crashing, so I'm guessing that means everything's working. I'm going to go around and make sure each node works.

FINAL EDIT: After testing each node, they're all good! :D
Post Reply