Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trouble with changing entity / function #369803
05/07/11 11:40
05/07/11 11:40
Joined: Apr 2011
Posts: 2
S
Smushi Offline OP
Guest
Smushi  Offline OP
Guest
S

Joined: Apr 2011
Posts: 2
Hi everyone!

I hope you can help me because this problem is driving me mad >.<

Ok so in the game there are enemies moving towards you with a constant speed. Once they are close to you I want to closes one to chang his model und move towards me.
Now I managed to reach the two required functions seperatly but never together...

Like this it constantly scans and creates a new entity for each frame... well at least they change their model and move towards me and everything works (apart from the freaky effect and waste of resources.
Quote:
c_scan(my.x, my.pan, vector(45, 45, 1500), IGNORE_ME | SCAN_ENTS); // scan for any entities that are closer than xxx quants to this entity

if (you) // a target was detected?

{
if ((you == player))//, || (you.skill1 == 1234))// an entity that verifies the conditions was detected || skill??
{
set(my,PASSABLE|INVISIBLE); //make normal fish invisible and passable to save memory and keep entity pointer (ent_remove removes pointer))
ent_create("mdl_wuerfelfisch_attack.mdl",vector(my.x,my.y,my.z),move_attack_fish); //create new model with attack finction

}
}


Now if I use ent_morph when I get scanned I don't get a freaky effect, but I can't change the entities function using my.event = "attack function";

So the model simply changes, but won't move towards me...

I guess I somehow have to make the enemy only scan until he finds me and then start the new behaviour. Sadly I could not find any tutorials on this smirk

Help me Game Studio Forum, you're my only hope!

Re: Trouble with changing entity / function [Re: Smushi] #369808
05/07/11 12:24
05/07/11 12:24
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Use a skill of the entity to mark different 'states' within the same function.
If the first state is given let the entity do the first task.
As soon as the next condition is given, switch to the second state.
In the second state ent_morph the entity and switch to the third state where it follows the second task.

Re: Trouble with changing entity / function [Re: Pappenheimer] #369871
05/08/11 10:37
05/08/11 10:37
Joined: Apr 2011
Posts: 2
S
Smushi Offline OP
Guest
Smushi  Offline OP
Guest
S

Joined: Apr 2011
Posts: 2
Thanks for the hint.

I stumbled upon the Skills from time to time but couldn't make any sense of them... They seem like some kind of variable to me.

Can you give me a hint on how to use skills, maybe an example? The Manual doesn't help me much, but I'll keep trying ^^

thanks again

Re: Trouble with changing entity / function [Re: Smushi] #369907
05/08/11 21:12
05/08/11 21:12
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Yes, I think that you can say that skills are a sort of local variable, but a local variable is bound to a function, the skill is bound to the entity, means you can use it from different functions of the entity.
And, you can use it with a pointer from other functions f.i. from other entities, as well.
F.i. you scan or trace another entity, then you have access to that entiy with the 'you' pointer, and you can change that entity's skills like this:
you.skill22 = 0;
It is a sort of 'private' variable of the entity.

#define _state skill2

// for skill _state:
#define _state_watch 1
#define _state_switch 2
#define _state_attack 3

in the function/action of the entity use it this way:

Code:
function enemy_behaviour()
{
	while(1)
	{
		if(my._state == _state_watch)
		{
			watch();
		}
		if(my._state == _state_switch)
		{
			ent_morph(me...
			my._state = _state_attack;
		}
		if(my._state == _state_attack)
		{
			attack();
		}
		wait(1):
	}
}




Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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