I'm really new at this, but can anyone tell me what you need to change in the custom script for it to compile. I have exactly what it says above but I can't save my progress because it wont compile. I've spent the last 30 hours absorbing all the information a I can so it's possible i missed something obvious
Rrowland I have a question for you? How did your trace line to affect a Mutalisk in that first video? I put some air units in the map and I have to aim low still to view their information? A heads up Rrowland I am an Engineer IRL and I have taken alot of physics classes what I meant by basically the friction caused by wind resistance is minimal. When we as humans shoot bullets from the perspective of where the gun is it is impossible to see the speed of the bullet decrease. The biggest objective of this happening is speed decreasing. For the purpose of third person shooters gravity will play a large enough role to stop the bullet and bring it back down.
But you are correct if I really wanted to put physics into the map I could also use wind resistance to decrease the speed of the bullet and possibly arc the trajectory to the left or right if there were wind in that direction. But because a bullet travels starting off at about 250m/s the arc is usually going to be no more or less then a couple inches in either direction.
I appreciate all the help and look forward to discussing this further maybe you could help out with make bullets do the same effect but traveling on that line. That is if your game on helping out a non programmer such as myself.
I'm really new at this, but can anyone tell me what you need to change in the custom script for it to compile. I have exactly what it says above but I can't save my progress because it wont compile. I've spent the last 30 hours absorbing all the information a I can so it's possible i missed something obvious
Paste where the error is.
I also haven't been able to get the camera to work the way I think it's supposed to. The map linked here that has it working doesn't really work because targeting is based off of mouse XYZ and doesn't seem to use the traceline. This of course means it won't be possible to get headshots or shoot at the sky for example.
I think the whole traceline idea is great. But the problem with it is that we need to create a vector system in order to create a very realistic shooting system.
Right now, what I've been doing is simply using the point that the center of the camera is looking at and create a sniper damage from the main unit to any unit within that point. Now this is the problem, because what happens if you are targeting the head of a unit, but that is actually pointing to a point far far away from the unit's head? Aha see, that is a problem! Hence we need to create a vector system, instead of using the dumb environment effect that blizzard creates, we need to create an actual missile that goes to that point. If the missile hits something, kill it and it will do damage.
This map so far uses a line system, so it is much more accurate than sherardt's way of using circle region at the point clicked. It will create circle regions from main unit to target point and figure out which unit is the closest at that "line". But it doesn't make sense because you can pretty much target at a point beyond an enemy unit and still kill it if u get the angle right... So it does not replace the missile system I'm talking about.
Rrowland I have a question for you? How did your trace line to affect a Mutalisk in that first video? I put some air units in the map and I have to aim low still to view their information?
Yeah, you need to set a Z value for flying units. I went over this briefly in the tutorial, you will have to replace the 0.0 in
with c_heightMapAir. The way I handled this is by creating structs (basically a variable with multiple variables inside) that describe each type of unit I will have in my game. Then at the beginning of the game I iterated through every unit and set their custom values to some of my custom values such as radius, heightmap, hitboxes etc.
I store some enumerated values in constants to make my code more readable, here are the relative constants:
//--------------------------------------------------------------------------------------------------// General//--------------------------------------------------------------------------------------------------constintc_EnemyTypes=4;constintc_MaxPlayers=4;constfixedc_MaxRange=30.0;//--------------------------------------------------------------------------------------------------// Custom Unit Values//--------------------------------------------------------------------------------------------------constintc_CustomValues_UnitType=0;constintc_CustomValues_OffsetZ=1;constintc_CustomValues_Height=2;constintc_CustomValues_HeightMap=3;constintc_CustomValues_Radius=4;constintc_CustomValues_PhysicsIndex=5;
Then I apply the properties to all existing units by placing them into custom unit values:
// Initialize Enemies (Existing on map creation) \\//--------------------------------------------------------------------------------------------------//voidcf_InitEnemies(){unitgrouplv_tempUnitGroup;unitlv_tempUnit;inti=0;intj=0;while(i<c_EnemyTypes){lv_tempUnitGroup=UnitGroup(gv_enemyTypes[i].name,c_playerAny,RegionEntireMap(),UnitFilter(0,0,(1<<c_targetFilterMissile),(1<<(c_targetFilterDead-32))|(1<<(c_targetFilterHidden-32))),0);while(j<=UnitGroupCount(lv_tempUnitGroup,c_unitCountAll)){lv_tempUnit=UnitGroupUnit(lv_tempUnitGroup,j);UnitSetCustomValue(lv_tempUnit,c_CustomValues_UnitType,i);UnitSetCustomValue(lv_tempUnit,c_CustomValues_OffsetZ,gv_enemyTypes[i].hitboxes[0].offsetZ);UnitSetCustomValue(lv_tempUnit,c_CustomValues_Height,gv_enemyTypes[i].hitboxes[0].height);UnitSetCustomValue(lv_tempUnit,c_CustomValues_HeightMap,gv_enemyTypes[i].heightMap);UnitSetCustomValue(lv_tempUnit,c_CustomValues_Radius,gv_enemyTypes[i].hitboxes[0].radius);j+=1;}j=0;i+=1;}}
I also have a trigger to add these values to newly created units:
//--------------------------------------------------------------------------------------------------// Trigger: Unit Is Created//--------------------------------------------------------------------------------------------------boolgt_UnitCreated_Func(booltestConds,boolrunActions){inti=0;while(i<c_EnemyTypes){if(UnitGetType(EventUnit())==gv_enemyTypes[i].name){UnitSetCustomValue(EventUnit(),0,i);UnitSetCustomValue(EventUnit(),1,gv_enemyTypes[i].hitboxes[0].offsetZ);UnitSetCustomValue(EventUnit(),2,gv_enemyTypes[i].hitboxes[0].height);UnitSetCustomValue(EventUnit(),3,gv_enemyTypes[i].heightMap);UnitSetCustomValue(EventUnit(),4,gv_enemyTypes[i].hitboxes[0].radius);}i+=1;}returntrue;}//--------------------------------------------------------------------------------------------------voidgt_UnitCreated_Init(){gt_UnitCreated=TriggerCreate("gt_UnitCreated_Func");TriggerAddEventUnitCreated(gt_UnitCreated,null,null,null);}
And now finally I am able to use these values in my traceline by using the custom values of the target I'm looking at:
I also haven't been able to get the camera to work the way I think it's supposed to. The map linked here that has it working doesn't really work because targeting is based off of mouse XYZ and doesn't seem to use the traceline. This of course means it won't be possible to get headshots or shoot at the sky for example.
Here are my camera functions, straight from my code:
I think the whole traceline idea is great. But the problem with it is that we need to create a vector system in order to create a very realistic shooting system.
Right now, what I've been doing is simply using the point that the center of the camera is looking at and create a sniper damage from the main unit to any unit within that point. Now this is the problem, because what happens if you are targeting the head of a unit, but that is actually pointing to a point far far away from the unit's head? Aha see, that is a problem! Hence we need to create a vector system, instead of using the dumb environment effect that blizzard creates, we need to create an actual missile that goes to that point. If the missile hits something, kill it and it will do damage.
This map so far uses a line system, so it is much more accurate than sherardt's way of using circle region at the point clicked. It will create circle regions from main unit to target point and figure out which unit is the closest at that "line". But it doesn't make sense because you can pretty much target at a point beyond an enemy unit and still kill it if u get the angle right... So it does not replace the missile system I'm talking about.
PRESS ESC for the 3rd person view
You're talking about two different things. You're saying you want to treat bullets like missiles, in which case yes you'd use vectors. The minimum amount of time spent between steps is "0.0" which actually means 1/32 of a second (I believe) due to the fixed point (reals) system. Assuming that a bullet should span an entire map in less than 0.1 seconds, that means each step would be approximately 1/3 of the map. You can't simply check for a hit every step this way, or you would only ever hit a unit if the bullet happened to land on him at one of the wide steps. You would need to generate a heightmap of the entire map to get the planes of the terrain, and you'd have to create a box of planes around every unit that is shootable. Then you'd need to run some vector calculations to determine whether or not the bullet's directional vector intersects any of those planes. In the case of multiple, you'd have to figure out which one it hit first.
The most obvious downside is you won't be able to see which unit the player is looking at without a traceline. You could implement both, but that's a much bigger load you're throwing on the processor.
And yes the traceline works on my map all the trace line is implementing is pulling up the boss bar. This is a sign that it is selected if you want to fire you can bastically use a mouse click function off just the trace line and make it attack the traceline_currentTarget. Right now mine is using a seperate mouse click feature but its because I was having problems making it 100% accurate. A traceline function does just this because now you have selected a target on the x-y plane along that line. The code I asked Rrowland for is to actually turn allow you to trace a line on the x-y-z plane.
If you both want to post your most updated code I have no problem looking at it trying to figure out your problem.
Rrowland thats not correct basically the fastest time you can implement is .0001 of a second well if you input 0.0 is actually refreshing as fast as possible which is even faster. I noticed with the traceline function there is no need to do it faster than .2 seconds because you will eat alot of ram the other method just redoing the same feature. This will cause latency problems later on with multi-player maps and for slower machines.
Rrowland thats not correct basically the fastest time you can implement is .0001 of a second well if you input 0.0 is actually refreshing as fast as possible which is even faster. I noticed with the traceline function there is no need to do it faster than .2 seconds because you will eat alot of ram the other method just redoing the same feature. This will cause latency problems later on with multi-player maps and for slower machines.
Well just to make sure, I just ran a test:
A variable to count how many times our fastest timer has elapsed:
So every 0.00 seconds it will increase the integer by 1. After 1 second, it displays the number of iterations and then sets the integer back to 0.
Here are the results (plugging in different times for the fast timer):
0.00 seconds = 23 loops
0.0001 seconds = 23 loops
0.001 seconds = 23 loops
0.01 seconds = 23 loops
0.1 seconds = 8 loops
Those results show that really 0.045 is actually the fastest time you can implement using real time. If we switch our fastest loop to game time and switch our game speed to 'fastest', we get the results:
0.00 seconds = 23 loops
0.0001 seconds = 23 loops
0.001 seconds = 23 loops
0.01 seconds = 23 loops
0.1 seconds = 11 loops
So yes, I was wrong that the shortest loop interval is 1/32 of a second, it is in fact worse at 1/23 of a second. Using game time does not affect this limit, only the rate at which you reach the limit.
This will double your maximum loops per second to 46. If you remove the Wait statement you will exceed 128 which will cause a stack overflow, so it's necessary.
I did a periodic event every 0 secs and input Traceline(position of main unit, camera height: 1, 1); And the traceline_targetPoint is always at the main unit... My camera works just like urs its not pointing at the unit.
I did a periodic event every 0 secs and input Traceline(position of main unit, camera height: 1, 1); And the traceline_targetPoint is always at the main unit... My camera works just like urs its not pointing at the unit.
That's because 1.0 is under the world height, which is 8.0 by default. Pass camera height as WorldHeight + 1.0 instead of 1.0.
hi,
i've used your traceline in my map but there is a problem once i look up from the ground. when i'm looking at the ground the camera is ok, but one i look at the sky (the crosshair is no longer touching the ground) i get these error messages.
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetY' (value: 0)
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetX' (value: 0)
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetY' (value: 0)
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetX' (value: 0)
any idea why?
my camera is currently set to follow the target point of the traceline.
also i've tried to use the target point variable to spawn a unit at that location however it spawns at the current position of the camera. (even when its not attached to a unit.)
any help you could provide would be much apriciated.
Post your maps as an attachment to the reply and this way I can help take a look and determine why they are not working. Keep in mind that that all trace line does is looks for a unit or object in front that the cross hair is on, and if it doesn't see something after a certain distance it returns the point of the ground that is selected.
On a side note, I tried to add the traceline action to a library yesterday and for some reason I got an error message. I do not have time this morning to try it again so you can see it but I would like to figure it out for the library use. Ill post the exact message later but if anyone wanted to try to figure out the problem earlier before I get off work today, that would be awesome.
you have probably named your main unit variable something else. or your misplaced a capitol letter. check what your main unit variable is called, i had the same problem last night.
@rrowland:
ok i included my map. still got the same problem i havent added anything fancy like moving yet. i am just trying to get the shooting mechanic to work first.
I'm really new at this, but can anyone tell me what you need to change in the custom script for it to compile. I have exactly what it says above but I can't save my progress because it wont compile. I've spent the last 30 hours absorbing all the information a I can so it's possible i missed something obvious
Rrowland I have a question for you? How did your trace line to affect a Mutalisk in that first video? I put some air units in the map and I have to aim low still to view their information? A heads up Rrowland I am an Engineer IRL and I have taken alot of physics classes what I meant by basically the friction caused by wind resistance is minimal. When we as humans shoot bullets from the perspective of where the gun is it is impossible to see the speed of the bullet decrease. The biggest objective of this happening is speed decreasing. For the purpose of third person shooters gravity will play a large enough role to stop the bullet and bring it back down.
But you are correct if I really wanted to put physics into the map I could also use wind resistance to decrease the speed of the bullet and possibly arc the trajectory to the left or right if there were wind in that direction. But because a bullet travels starting off at about 250m/s the arc is usually going to be no more or less then a couple inches in either direction.
I appreciate all the help and look forward to discussing this further maybe you could help out with make bullets do the same effect but traveling on that line. That is if your game on helping out a non programmer such as myself.
Paste where the error is.
I also haven't been able to get the camera to work the way I think it's supposed to. The map linked here that has it working doesn't really work because targeting is based off of mouse XYZ and doesn't seem to use the traceline. This of course means it won't be possible to get headshots or shoot at the sky for example.
I think the whole traceline idea is great. But the problem with it is that we need to create a vector system in order to create a very realistic shooting system.
Right now, what I've been doing is simply using the point that the center of the camera is looking at and create a sniper damage from the main unit to any unit within that point. Now this is the problem, because what happens if you are targeting the head of a unit, but that is actually pointing to a point far far away from the unit's head? Aha see, that is a problem! Hence we need to create a vector system, instead of using the dumb environment effect that blizzard creates, we need to create an actual missile that goes to that point. If the missile hits something, kill it and it will do damage.
This map so far uses a line system, so it is much more accurate than sherardt's way of using circle region at the point clicked. It will create circle regions from main unit to target point and figure out which unit is the closest at that "line". But it doesn't make sense because you can pretty much target at a point beyond an enemy unit and still kill it if u get the angle right... So it does not replace the missile system I'm talking about.
PRESS ESC for the 3rd person view
Yeah, you need to set a Z value for flying units. I went over this briefly in the tutorial, you will have to replace the 0.0 in
with the height of the unit. You will also need to replace the c_heightMapGround in
with c_heightMapAir. The way I handled this is by creating structs (basically a variable with multiple variables inside) that describe each type of unit I will have in my game. Then at the beginning of the game I iterated through every unit and set their custom values to some of my custom values such as radius, heightmap, hitboxes etc.
I store some enumerated values in constants to make my code more readable, here are the relative constants:
Here are my two struct definitions:
I initialize a variable as an array of structs. c_EnemyTypes represents how many unit hitboxes I have customized:
Next I initialize all of my custom unit info. This is run only once at the very beginning of the game:
Then I apply the properties to all existing units by placing them into custom unit values:
I also have a trigger to add these values to newly created units:
And now finally I am able to use these values in my traceline by using the custom values of the target I'm looking at:
Here are my camera functions, straight from my code:
You're talking about two different things. You're saying you want to treat bullets like missiles, in which case yes you'd use vectors. The minimum amount of time spent between steps is "0.0" which actually means 1/32 of a second (I believe) due to the fixed point (reals) system. Assuming that a bullet should span an entire map in less than 0.1 seconds, that means each step would be approximately 1/3 of the map. You can't simply check for a hit every step this way, or you would only ever hit a unit if the bullet happened to land on him at one of the wide steps. You would need to generate a heightmap of the entire map to get the planes of the terrain, and you'd have to create a box of planes around every unit that is shootable. Then you'd need to run some vector calculations to determine whether or not the bullet's directional vector intersects any of those planes. In the case of multiple, you'd have to figure out which one it hit first.
The most obvious downside is you won't be able to see which unit the player is looking at without a traceline. You could implement both, but that's a much bigger load you're throwing on the processor.
I appreciate it Rrowland thanks for the support.
And yes the traceline works on my map all the trace line is implementing is pulling up the boss bar. This is a sign that it is selected if you want to fire you can bastically use a mouse click function off just the trace line and make it attack the traceline_currentTarget. Right now mine is using a seperate mouse click feature but its because I was having problems making it 100% accurate. A traceline function does just this because now you have selected a target on the x-y plane along that line. The code I asked Rrowland for is to actually turn allow you to trace a line on the x-y-z plane.
If you both want to post your most updated code I have no problem looking at it trying to figure out your problem.
Rrowland thats not correct basically the fastest time you can implement is .0001 of a second well if you input 0.0 is actually refreshing as fast as possible which is even faster. I noticed with the traceline function there is no need to do it faster than .2 seconds because you will eat alot of ram the other method just redoing the same feature. This will cause latency problems later on with multi-player maps and for slower machines.
Well just to make sure, I just ran a test:
A variable to count how many times our fastest timer has elapsed:
Our fast timer:
Every 1 second of real time display how many times the fast timer has run and reset the count:
So every 0.00 seconds it will increase the integer by 1. After 1 second, it displays the number of iterations and then sets the integer back to 0.
Here are the results (plugging in different times for the fast timer):
0.00 seconds = 23 loops
0.0001 seconds = 23 loops
0.001 seconds = 23 loops
0.01 seconds = 23 loops
0.1 seconds = 8 loops
Those results show that really 0.045 is actually the fastest time you can implement using real time. If we switch our fastest loop to game time and switch our game speed to 'fastest', we get the results:
0.00 seconds = 23 loops
0.0001 seconds = 23 loops
0.001 seconds = 23 loops
0.01 seconds = 23 loops
0.1 seconds = 11 loops
So yes, I was wrong that the shortest loop interval is 1/32 of a second, it is in fact worse at 1/23 of a second. Using game time does not affect this limit, only the rate at which you reach the limit.
As a follow-up to my previous post, here's a way to double the maximum. Change your fast trigger to this:
This will double your maximum loops per second to 46. If you remove the Wait statement you will exceed 128 which will cause a stack overflow, so it's necessary.
@rrowland, ur traceline still does not work @@...
I did a periodic event every 0 secs and input Traceline(position of main unit, camera height: 1, 1); And the traceline_targetPoint is always at the main unit... My camera works just like urs its not pointing at the unit.
That's because 1.0 is under the world height, which is 8.0 by default. Pass camera height as WorldHeight + 1.0 instead of 1.0.
hi,
i've used your traceline in my map but there is a problem once i look up from the ground. when i'm looking at the ground the camera is ok, but one i look at the sky (the crosshair is no longer touching the ground) i get these error messages.
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetY' (value: 0)
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetX' (value: 0)
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetY' (value: 0)
00:00:03.69 Trigger Error in 'gt_Camerafollow_Func': Could not get 'p' from parameter in 'PointGetX' (value: 0)
any idea why?
my camera is currently set to follow the target point of the traceline.
also i've tried to use the target point variable to spawn a unit at that location however it spawns at the current position of the camera. (even when its not attached to a unit.)
any help you could provide would be much apriciated.
Post your maps as an attachment to the reply and this way I can help take a look and determine why they are not working. Keep in mind that that all trace line does is looks for a unit or object in front that the cross hair is on, and if it doesn't see something after a certain distance it returns the point of the ground that is selected.
On a side note, I tried to add the traceline action to a library yesterday and for some reason I got an error message. I do not have time this morning to try it again so you can see it but I would like to figure it out for the library use. Ill post the exact message later but if anyone wanted to try to figure out the problem earlier before I get off work today, that would be awesome.
Hello!
I have done everything exactly as you said, but when I try to run the map I get a Syntax Error in line 99 in the code:
lv_closestUnit != gv_mainunit &&
could you help me out with this? It would have been appreciated!
Other than that very good work! Im still learning things about the ditor, and I must say that tutorials like these help a LOT!
Once again, thanks!
Sincerly
Scarx398 (Who took my name? Scarx) :P
@Scarx398:
you have probably named your main unit variable something else. or your misplaced a capitol letter. check what your main unit variable is called, i had the same problem last night.
@HaVoC373: Go
gt_Camerafollow_Func isn't one of my functions. Are you calling traceline from it? If so, post your map or the Camera Follow trigger.
@rrowland:
ok i included my map. still got the same problem i havent added anything fancy like moving yet. i am just trying to get the shooting mechanic to work first.
@HaVoC373: Go
Tq now it works, I'm really new to this editor, in wc3 the metrics completely diferent, distance in hundreds not tenths...