2 registered members (AndrewAMD, 1 invisible),
1,395
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
event impact with the right entity
#406436
08/20/12 01:01
08/20/12 01:01
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
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: rayp]
#406440
08/20/12 07:01
08/20/12 07:01
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
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]
#406525
08/23/12 00:41
08/23/12 00:41
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
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.
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
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
// --------------------------------------------------------------------------------------------
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
}
}
// --------------------------------------------------------------------------------------------
..
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
Dega
OP
Member
|
OP
Member
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: Espér]
#406566
08/24/12 04:30
08/24/12 04:30
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
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:
#include "codes\player_scr.c"
This error message appears in WED.
boolean my.awesomeness = so true;
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|