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 / Enemy movement

Author
Message
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 25th Oct 2012 12:54 Edited at: 8th Nov 2012 11:58
Okay, I've worked out some stuff. It's time to refresh my post.

NPC Movement through waypoints:
Currently I've got boxes in 3D Studio Max named as :

waypoint_01_01
waypoint_01_02
waypoint_01_03
waypoint_01_04

And so on.

I position them as I want in my 3DS Max World, export them as "Waypoints.X".
Then read the limb names from the waypoint object in Dark Basic Pro.
Use the limb coordinates and write them in an array.
Using all of this, I let the NPCs move around the world.
Code :


Now I'd like to add some traffic lights into the game.
I've been thinking for a few ways to do this, and the best I could come up with is:

Name the limbs in 3DSMax : waypoint_XX_XX_TRAF
If the limb name ends with TRAF
Place the limb coordinates from TRAF in an array.
Use traffic light timers to simulate red and green light.
Distance check from NPC to traffic lights.
If the NPC gets close to the traffic light, check if the light is red or green and stop/move.

Now I'd like to read "traf" from the end of the limb names in the same piece of code I've posted somewhere up ^^^^^ there.

But I can't get it to work

The waypoints that have "traf" at the end, will have the coords 0,0,0 and are ignored by the NPCS.

Edit -

Okay, I've made things easier.
Instead of :



I'm using :


Now I'd have to add a piece of code that reads the last 4 characters "traf".

If so, fill the traffic_light array with these coords.

I'm going to update this post again, later.
darkvee
19
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 27th Oct 2012 16:18
Very funny Ramon156 haha

darkvee
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 27th Oct 2012 20:33
Took a look at your code and made some minor changes. Here, hope this helps


RP Functions Library v1.0

Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 8th Nov 2012 14:53
I've got quite a bit working now, it took me a good week to get things sorted.
NPCS are reacting to traffic lights.








When the NPC is in wander mode, it only moves around following waypoints.


Ideas tips tricks hints are always welcome.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Nov 2012 16:41
Did I miss something here? What's so funny?

"You're not going crazy. You're going sane in a crazy world!" ~Tick
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 8th Nov 2012 18:02
@Phaelax:
Quote: "Did I miss something here? What's so funny?"


Ramon156 originally posted the following code snippet:

Then he asked for help with why his code (the above) wouldn't work.
He since edited that post:
Posted: 25th Oct 2012 04:54 Edited: 8th Nov 2012 04:58
Tbh, I'm not sure how this thread wasn't locked. Dunno if he's serious now though.

RP Functions Library v1.0

My signature has not been erased by a mod.
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 8th Nov 2012 19:48 Edited at: 8th Nov 2012 19:56
Hello NonZero, that was because my snippet was not working with my DBPro code at that time. I could not use "code" tags and it posted the whole code without snippets.
That's why I edited it and tried making a snippet with just a simple line.

It's working now though, and I am serious. I am making a video at this moment for youtube to show what has been done!

I will update this post with a video in the next hour (slow upload speed at my gfs place! )

According to youtube this should be the link :

http://www.youtube.com/watch?v=INS09hMCW8k&feature=youtu.be
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 9th Nov 2012 11:38
I see... Perhaps next time put a comment like "Code not posting correctly" as we get a lot of trolls here (even long time members do it sometimes).

Btw, watched you video, progress is looking good.

RP Functions Library v1.0

My signature has not been erased by a mod.
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 9th Nov 2012 14:22
Thank you nonZero, I edited that in one of my first posts but I can't really remember. It has been edited too many times

I again have a question that I'm sure of I can't solve

When the NPC reaches a traffic-light-tagged waypoint it will go into "Traffic Light" mode, in this mode the NPC will break from the normal waypoint path.
I'd like to let the NPC check for the closest traffic light route doing a distance check, and pick the closest traffic light waypoint.

Also I need the"closest distance check" , for fleeing.
When the NPC flees, it will flee for 300Meters, but then they'll still have their old waypoint stored to follow.
The NPC needs to distance check the array and pick the closest waypoint to follow, so it doesnt walk back to the chaos every time.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 11th Nov 2012 18:19
Ah, waypoints aren't really my strong point (I'm more 2D game and data/file manipulation).

Quote: "When the NPC flees, it will flee for 300Meters, but then they'll still have their old waypoint stored to follow."


Well, I can only approach it from my perspective (Top-down games like shooters, RTS, etc although your game seems to be in that perspective too). So maybe add another state, and use a simplified following system eg:

I named the variables quite literally but if it's confusing then please ask what something means. Essentially each NPC is given a random Traffic light they'll go to after "flee" ends. This table can be refreshed every time there are 0 flee statuses. The NPC's flag goes from flee to Post-Flee where they will head for a target light until they reach it. Then it's back to "wander". That's the best I can think of as I use these sort of systems for my own enemy AI.

RP Functions Library v1.0

My signature has not been erased by a mod.
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 19th Nov 2012 09:36 Edited at: 19th Nov 2012 10:13
Nevermind this

I've found a TDK tutorial on how to write information to a txt file and open it up with notepad.
When I wrote my own piece of code it wouldn't work, when I copied the code from TDK's post it worked.. strange
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 20th Nov 2012 12:07
This is just hilarious!
After printing out every single line of information to a text file and looking into my code for hours I decided to rewrite the traffic light waypoint part.

The NPC was deciding and moving around fine, BUT when it was at traffic light waypoint 5 it was not taking over the normal waypoint information.
This also happened when I rewrote the code!

A part of the working code, where also the mistake was made:



Look at :

When this variable reached 6 it would take over the normal path and waypoint from Current_Traffic_Waypoint 6 (DOES NOT EXIST!) that resulted in taking over "0" and "0".
All I had to do in my new code is add a "-1" to :


This way, the npc would take over the normal path and waypoint number when the npc reached waypoint 5.

I will be working on my code to add traffic light timers and random NPCS using the traffic lights.

A new video will be uploaded soon.
Thank you nonZero for the heads up and special thanks to 29-games for helping me earlier this year
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 20th Nov 2012 21:30
Quote: "When I wrote my own piece of code it wouldn't work, when I copied the code from TDK's post it worked.. strange"


DBP is a little temperamental with file and data. It feels a little pointless me posting the examples I prepared since you got your text file working, but for reference (since I boiled them up anyway):

Both these focus on a human-readable type text file using different techniques and delimeters.

1. Using basic DBP alone. I've used low number for dimensions (10x20) because this method is slow. If you crank it to 99x99 it'll practically freeze.


2. VERY FAST: Using direct memory access & pointers. I've used 99x99 as apposed to 10x20 in this example. (Requires RPLib to be included. You can download it from the link in my sig if you're curious)


Hope there aren't too many typos and clumsy bits.

Good luck with the game and glad things came right.

RP Functions Library v1.0

My signature has not been erased by a mod.
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 21st Nov 2012 14:40 Edited at: 21st Nov 2012 15:07
Thank you nonZero. I will take a look at your code.
I did it like this :



Resulting in the TXT as :



The only problem here is that these lines can't be converted to values (I guess).
When using "read string 1, T$: Player.Money = Val(T$)"
that exact line in the txt file has to exist out of a value only.


would have to be saved as this instead :




**
Before rewriting my code I had a "Decision" variable being a RND(3) integer inside my loop.
If the value changed to 1, it would go into traffic mode.
When I do this now, the value changes each loop. Before this, I had somehow created a piece of code (probably by accident) that it would only choose a RND number once.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 22nd Nov 2012 19:40
Quote: "


The only problem here is that these lines can't be converted to values (I guess)."


This may be good news then:


Just a crude little example. You could use the above as a stencil. There's a quicker way to do it with pointers if this isn't sufficient performance-wise.

RP Functions Library v1.0

My signature has not been erased by a mod.
Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 23rd Nov 2012 12:42 Edited at: 23rd Nov 2012 12:43
Argh, ofcourse! I forgot to use the Right / Left commands.
It might be time to

Login to post a reply

Server time is: 2024-11-21 18:20:14
Your offset time is: 2024-11-21 18:20:14