Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / timer()s and strings in a datatype

Author
Message
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 8th Mar 2012 15:02
Today I've runned into some interesting forum posts and tutorials. They showed me the use of datatypes and that it would be great for basically any game that has variaty in weapons, items and so on.
I'm running into a couple of problems, I will try to explain as good as possible what they are. I'm completely new to datatypes so bare with me !

1 ) Having a string into a datatype and get it printed on the screen.



When I set any of these lines in my loop :
text 0,600,"WeaponName : ="+str$($WEAPON_TYPE.name)
text 0,600,"WeaponName : ="+str$($PrimaryWeapon.name)

It will return a 0.
Without the "$" behind the bracket open it gives me the error:

Parameter for 'str$' do not match 'Value' at line 97.

What I want to accomplish is having WEAPON_TYPE.name return the string and set parameters according to what string it returns.
So when it would return WEAPON_TYPE.name = "Glock" I can set the HUD and characterstics of the weapon.

As I'm writing this post and reading my code at the same time it doesn't seem to make sense why one would do it like that. I need to put in the right direction again, please help


=========== Problem 2

2) WeaponRate in the DataType was meant to be in there together with a timer for each weapon.

I did it like this without having it into a DataType

Part above the main loop:


In the main loop I'd refer to a Function called WeaponController()

Wich does the following : (Thanks to a fellow forum member)


WeaponGlock is used to detect if the player has the glock or not (Wich goes back to the String question).

I think that's about it !
Thank you for your time
Millenium7
19
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 8th Mar 2012 18:34 Edited at: 8th Mar 2012 18:44
errr the STR$() command is used for converting values to strings. Since the .Name parameter is already a string you don't need it (and it is the cause of your error message)

So write it out as
text 0,600,"WeaponName : ="+PrimaryWeapon.name

also don't use
text 0,600,"WeaponName : ="+WEAPON_TYPE.name
as this is invalid. WEAPON_TYPE is a data type NOT a variable.
WEAPON_TYPE is only ever used to define a class name for your data types. I.e. setting PrimaryWeapon as WEAPON_TYPE ensures that PrimaryWeapon has the following parameters you set for WEAPON_TYPE, i.e. '.ammo', '.clip', '.damage' etc

As for problem2, i'd start by rewriting the structure you've used. Here's my repost of your initial code snippet
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 9th Mar 2012 14:47 Edited at: 9th Mar 2012 14:48
Thanks again Millenium. It's so annoying to get stuck in programming!
I'm turning red reading your post,I feel like a dummy. It's such an easy answer to my problems, it drove me mad at the time though!


I have indeed edited my structures. I've been progressing allot today with programming when it comes to DataTypes.



The Weapon Type is fully functional. The player Type is fully functional also but I haven't implemented the old and X/Y/Z coordinates yet. (Using sparkys DLL at the moment).

Here's the weapon handling function :



And yes I do know the code is messy!
For some reason it gets even more of a mess after posting hehe
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 12th Mar 2012 10:03 Edited at: 13th Mar 2012 08:30
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".



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 :



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.





When the wave increases to 2, I simply copy the same code to create objects and change the array to :



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.



I will take a look at that, and have more breaks so my brains dont blackout

Login to post a reply

Server time is: 2024-11-23 20:24:17
Your offset time is: 2024-11-23 20:24:17