Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, monk12, TipmyPip, Quad, aliswee), 1,031 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Water block not beeping #452908
06/30/15 06:49
06/30/15 06:49
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I am trying to create swimming/buoyancy functionality in my game. I created a block in a castle moat that represents water. If the player jumps into the block, I want the player to start swimming. However, I am at the very beginning stages of trying to make this happen.

Right now, I am just trying to make my player "sense" the passable and transparent block, by sounding a beep() when the player makes contact with it. So far, the beep() is not sounding when the player jumps into and makes contact with the block.

The block is saved as a map entity in its own WED file.

Here is the code to try to make the beep() sound when the player makes contact with the block:

Code:
action moatSide1()
{
   moat_side_one = me;
}

...


player_code()
{

   ...


   while(my.x)
   {

      ...


      if(you == moat_side_one)
      {
         beep();
      }

      ...

      wait(1)
   }
}



The moat block is given the behaviour action of "moatSide1" in WED, and the player is given the behaviour action of "player_code". Yet when the player jumps in the block, and player passes through it since it is passable, no beep() is sounded off.

Does anyone know why?

Last edited by Ruben; 06/30/15 06:49.
Re: Water block not beeping [Re: Ruben] #452911
06/30/15 09:07
06/30/15 09:07
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
It looks like you forgot to copy the vital parts of the code here in your post. But anyway, what you wanna do is just trace below the player and check the texture (there are possible more alternatives but this works fine). First you need to go to your block and change the texture name of it in MED or whatever to e.g. water_tex or something else suiting, than use this code:

Code:
if (every_blabla_frame_this_reduces_fps) //optionally
{
  if (c_trace(my.x, vector(my.x, my.y, my.z - 1000), IGNORE_CONTENT | IGNORE_ME | SCAN_TEXTURE) > 0)
  {
    if (str_cmpi(hit.texname, "water_tex") == 1)
    {
      //do your thing
    }
  }
}


Last edited by Reconnoiter; 06/30/15 09:08.
Re: Water block not beeping [Re: Reconnoiter] #452912
06/30/15 09:59
06/30/15 09:59
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I tried placing your code in my player_code() function, and inside the while() loop, as follows:

Code:
if (c_trace(my.x, vector(my.x, my.y, my.z - 1000), IGNORE_CONTENT | IGNORE_ME | SCAN_TEXTURE) > 0)
      {
         //if (str_cmpi(hit.texname, "MoatSide1_wmb_734") == 1)
         //if (str_cmpi(hit.texname, "water2") == 1)
         if (str_cmpi(hit.texname, "MoatSide1") == 1)
         {
            beep();
         }
      }



The name of the block after being imported into a castle WED file as a map entity from its own WED file is "MoatSide1_wmb_734". The name of this same block sitting in its own WED file is "MoatSide1". The name of the texture on this same block is "*water2", taken straight from standard.wad. Yet none of these are producing the beep(). Am I doing something wrong to make this happen?

Last edited by Ruben; 06/30/15 10:01.
Re: Water block not beeping [Re: Ruben] #452915
06/30/15 12:45
06/30/15 12:45
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
what is while (my.x) ?

anyway , just use a region or the min max size to determine if the player has entered the area .

without the actual code which you use to detect whether the player is inside the water ,plus how you set up that events (I am assuming) no one will know WHY what's happening.

we don't even know if your windows system sounds has a sound assigned to the relevant beep (I dont know if GS has its own but usually its taken from system sounds) , I assume there's nothing wrong with the sound aspect as is normal but you really need to provide the relevant code , for people to help you .


Compulsive compiler
Re: Water block not beeping [Re: Wjbender] #452922
06/30/15 15:16
06/30/15 15:16
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Small note: I also personally never use beep for debugging, I find error("hey_it_works!"); better for that.

@Ruben, try a beep/error() before the c_trace, and see if that works.

Re: Water block not beeping [Re: Reconnoiter] #452933
06/30/15 19:16
06/30/15 19:16
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Quote:
IGNORE_CONTENT
wont work with water ents btw.


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Water block not beeping [Re: Reconnoiter] #452941
07/01/15 05:28
07/01/15 05:28
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: Reconnoiter

@Ruben, try a beep/error() before the c_trace, and see if that works.

I put a beep before the c_trace, and I am definitely hearing a bunch of beeps over and over. However, the c_trace is not catching anything to initiate its own beep. Here is the code I tried:

Code:
...

action player_code()
{
   ...

   while(1)
   {

      ...

      //beep();  // DEFINITELY IS SOUNDING OFF WHEN UNCOMMENTED.

      if (c_trace(my.x, vector(my.x, my.y, my.z - 1000), IGNORE_ME | SCAN_TEXTURE) > 0)
      {
         if (str_cmpi(hit.texname, "*water2") == 1)
         {
            beep();
         }
      }

      ...

      wait(1);
   }
}



I am using the texture from standard.wad titled *water2 for the water block in question. Does anyone know why the beep() sounds before the c_trace(), but not in the c_trace()?

Last edited by Ruben; 07/01/15 05:30.
Re: Water block not beeping [Re: Ruben] #452945
07/01/15 09:59
07/01/15 09:59
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Try a beep right after the c_trace (before the if).

If that works/beeps, try your code with a model: e.g. some flat transparent model with your water texture and change the skin name it has in MED to "water2" without the quotes ofcoures. If that still won't work something is wrong with the code, if that will work than the WAD skin name isn't called water2 or isn't detected correctly by str_cmpi (I don't use WAD so much so I can't help you there).

Re: Water block not beeping [Re: Reconnoiter] #452946
07/01/15 11:42
07/01/15 11:42
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
okay so i did a little test , i created a block ,set it passable , applied a texture "grey" to it
then i assigned the test action script to a object (dont have time to create a player) and used
the camera to trace from.

now here comes the catch with that c_trace approach , the trace hits the surface and when
the surface is hit , the tex name is retrieved , if you are inside of the block there will be NO HIT
and it wil not help .

like i suggested , use a region or min max sizes ,so that you can detect when the player ,like its
center point or something is INSIDE the area ,or whatever other event detection /code/flags stuff you think up .

here is the code i used to test it , now fly around and see for yourseld that , the trace will work
only when you are above the surface of the block because i you are tracing down against the surface here

Code:
#include <acknex.h>
#include <default.c>

action test()
{
	while(1)
	{
		if(c_trace(camera.x,vector(camera.x,camera.y,camera.z-1000),IGNORE_ME | SCAN_TEXTURE))
		{
			if(str_cmpi(hit.texname,"grey"))
			{
				DEBUG_VAR(1,100);
			}
			else DEBUG_VAR(0,100);
		}
		
		wait(1);
	}
}

function main()
{
	warn_level = 4;	
	def_move();
	level_load("1.wmb");
}



for example try a c_intersect approach

Last edited by Wjbender; 07/01/15 11:47.

Compulsive compiler
Re: Water block not beeping [Re: Wjbender] #452950
07/01/15 15:14
07/01/15 15:14
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Your right, the c_trace method is indeed not a good one for this example.

Page 1 of 3 1 2 3

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1