I have another question.
My game will be a survival. Enemies will spawn based on timers and waves.
If Wave_1 is complete then it should spawn the next amount of enemies.
At a wave start it can never spawn all of the zombies. They will be spawned through the time of a wave.
There will be different types of enemies, and their values should increase each wave.
I want to set these values myself by multiplying the statistics.
Enemie_Zombie.Health=Health*2 and so on.
I have made a piece of code that spawns boxes(Or load in Objects). The objectnumber increases from "Start" to "End".
Also it will check if an objectslot is free.
When an enemie dies, it wont give me an error code "Object does not exist".
If Timer()-ZombieTimer=>6000
ZombieTimer = Timer()
For FreeSlotCheck = Enemy_Zombie.StartSpawn to Enemy_Zombie.EndSpawn
If object exist(FreeSlotCheck) = 0 then exit
next FreeSlotCheck
load object "Zombie.X",FreeSlotCheck
position object FreeSlotCheck,RND(400),5,RND(400)
SC_SetupComplexObject FreeSlotCheck,1,2
StartMoving = 1
Endif
How can I set Values such as Health, Damage, Speed to the objects being created/spawned.
And another thing.
I have a limb positioned in front of the player that can check for shooting. However, when I shoot and 5 enemies are behind eachother they will all get damaged.
I thought about making a distance check function and scan for the closest object between the limb and the player.
The idea is there, but I don't know how to accomplish this.
I've found this piece of code for distance checking :
function ObjDistToObj(Obj1 as word, Obj2 as word)
dx# = object position x(Obj1) - object position x(Obj2)
dy# = object position y(Obj1) - object position y(Obj2)
dz# = object position z(Obj1) - object position z(Obj2)
dx# = dx# * dx#: dy# = dy# * dy#: dz# = dz# * dz#
Dist# = (dx# + dy# + dz#) ^ 0.5
endfunction Dist#
Would it be possible to get this working together with a "bulletspread" I have currently in my game.
Thank you for your time.
Edit -
As for adding statistics to the objects I might have an idea myself.
Rem - Make Enemy Type
Type Enemy_Type
Health as integer
Damage as integer
Speed as Float
EndType
Rem - Make an Array for enemy
Dim Enemies(100) as Enemy_Type
Rem - Question, the DIM command is global already?
Rem - To say "Global Dim Enemies(100) is not needed?
Enemies.Health(100)=100
Enemies.Damage(100)=5
Enemies.Speed(100)=1.2
At the last line before endif in my creation code I'd add something like :
Rem - Here I assign an object to the Enemies array
Rem - FreeSlotCheck-6000 is made because my object range is
Rem - 6000 - 6100 so it starts at adding Enemies(1) first etc.
Enemies = Enemies(FreeSlotCheck-6000)
When the wave increases to 2, I simply copy the same code to create objects and change the array to :
Enemies.Health(100)=100*2
Enemies.Damage(100)=5*2
Enemies.Speed(100)=1.2*1.2
I have actually got this whole piece of code added to my game and it worked without even giving one single error, that can't be good!
The problem I'm having is the following :
When I use
Text 400,900,"Enemies"+str$(EnemiesZombie)
It outputs a long number such as 70402465 and when it creates an object it adds 20 to that number, so in this case 70402485
Forget the LIMB/Bullet part. I just found a whole list of commands for Sparkys DLL.
SC_rayCast
SYNTAX
return integer=SC_rayCast ( objNum, oldx, oldy, oldz, x, y, z, excludeObj )
-objNum: the object you want to check for collision use 0 for all objects
-oldx...z: the start and end points of the ray to check.
-excludeObj: an object to exclude from the collision check.
returns: if objNum=0 then the object number collided with is returned
if checking a specific object then a 1 is returned if a collision occured.
returns 0 if no collision occured.
will check if the ray starting at oldx#,oldy#,oldz# and ending at
x#,y#,z# collides with the specified object (obj=0 for all).
does not collide with backfaces, will return the number of the object
hit first, or 0 for no collision.
Ray casting commands are useful for calculating the collisions of bullets with
levels and objects, or for representing the line of sight of an enemy to detect
if they can see the player.
I will take a look at that, and have more breaks so my brains dont blackout