Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,395 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
event impact with the right entity #406436
08/20/12 01:01
08/20/12 01:01
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
I know how to code an impact event but how would you make a object like a goblin tell if it impacted with the right entity like a fireball?


boolean my.awesomeness = so true;
Re: event impact with the right entity [Re: Dega] #406437
08/20/12 04:34
08/20/12 04:34
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Code:
#define id skill100
#define goblin 1

action Goblin()
{
 my.id = goblin;
 ..
}

void a_event() //event of bullet fex
{
 ..
 if(you)if(you.id == goblin) _do_something(); //hit a goblin
 ..
}


greets

Last edited by rayp; 08/20/12 04:36.

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: event impact with the right entity [Re: rayp] #406440
08/20/12 07:01
08/20/12 07:01
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
ty i have been up all night. cant think or normally i could figure this out. lol


boolean my.awesomeness = so true;
Re: event impact with the right entity [Re: Dega] #406441
08/20/12 07:26
08/20/12 07:26
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
i slept 6 hours since friday. Today i will sleep until tomorrow when work is done. greets


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: event impact with the right entity [Re: rayp] #406450
08/20/12 17:04
08/20/12 17:04
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
Well i hope u do good.


boolean my.awesomeness = so true;
Re: event impact with the right entity [Re: Dega] #406525
08/23/12 00:41
08/23/12 00:41
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
I have a problem again. I want the fireball to have a guided missle ability and then make the goblin lose hp which is actually a local variable. I guess I could use something like this code here for both the fireball and goblin but what would I use for """something""" ? Also the goblins are models I placed in WED and I assigned the actions to them if that matters.

Code:
void fireball()
{

while(1)
    {
        c_move(me,vector(50 * time_step,0,0),nullvector,GLIDE);
        if (vec_dist(my.x,"""something""".x) <= 50)
        {
            vec_set(temp.x,"""something""".x);
            vec_sub(temp.x,my.x);
            vec_to_angle(my.pan,temp);
        }
    }
}




boolean my.awesomeness = so true;
Re: event impact with the right entity [Re: Dega] #406530
08/23/12 04:41
08/23/12 04:41
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Code:
// --------------------------------------------------------------------------------------------
function find_nearest(ENTITY* ent)
{
 var you_handle; 
 var _dist=1000;
 var _ndist;
 var dist_to_nearest;
 for(you = ent_next(NULL); you; you = ent_next(you)) 
  {
    if(you.id == goblin) 
    {
    	_ndist = vec_dist(ent.x, you.x);
    	if (_ndist < _dist) { _dist = _ndist; you_handle = handle(you); }
    }
  }
  dist_to_nearest = _dist; //nearest entity to "ent"
  you = ptr_for_handle(you_handle); //you to nearest found
  if(you)
  {
   VECTOR temp;
   vec_set(temp.x,you.x);
   vec_sub(temp.x,my.x);
   vec_to_angle(my.pan,temp);
   if(vec_dist(ent.x, you.x) < 50) _goblin_loose_hp(); //maybe take some hp when close
  }
 }
// --------------------------------------------------------------------------------------------



Code:
..
find_nearest(me);
c_move(me, vector(50*time_step,0,0), nullvector, GLIDE);
..



I took my function find_nearest and modified it. I think it should find the nearest goblin, and looks into that direction. When close to a goblin (<50) hp are taken.

greets

Edit Reason: Added the TEMP vector declaration which was missing above.

Last edited by rayp; 08/27/12 14:50.

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: event impact with the right entity [Re: rayp] #406539
08/23/12 12:47
08/23/12 12:47
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
thanks again!

Another problem appeared sorry! I want to include a second script in my main script and still be able to use the second script's actions in WED just by having the first script only in the map properties. What is the "proper" thing to do?

Last edited by Dega; 08/24/12 00:01.

boolean my.awesomeness = so true;
Re: event impact with the right entity [Re: Dega] #406564
08/24/12 03:35
08/24/12 03:35
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Code:
#include "iamascript.c"




Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: event impact with the right entity [Re: Espér] #406566
08/24/12 04:30
08/24/12 04:30
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
I did that but for some reason. It says can't open "player_scr.c"... it is in a different folder though but I did type the folder name like this:

Code:
#include "codes\player_scr.c"



This error message appears in WED.


boolean my.awesomeness = so true;
Page 1 of 2 1 2

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