Page 6 of 7
Re: Creatures that attack
Posted: May 5th, 2010, 8:10 am
by Cypress
Code: Select all
r_meleeweapon = [
r_usetype 1
r_damage $arg1
r_attackrate $arg2
r_maxrange $arg3
r_maxangle $arg4
r_action_use [ r_dodamage (r_eff_melee) ]
]
r_rangedweapon = [
r_usetype 2
r_damage $arg1
r_attackrate $arg2
r_maxrange $arg3
r_useamount 10 // comes with arrows included
r_action_use [ r_dodamage (r_eff_ranged) ]
r_sound "free/tick"
]
r_spell = [
r_usetype 3
r_damage $arg1
r_attackrate $arg2
r_manacost $arg3
r_maxrange $arg4
r_effect $arg5
r_sound $arg6
r_action_use $arg7
]
Here you go.
Re: Creatures that attack
Posted: May 5th, 2010, 8:17 am
by arcones
Interesting.
Cypress wrote:Code: Select all
r_meleeweapon = [
r_usetype 1
r_damage $arg1
r_attackrate $arg2
r_maxrange $arg3
r_maxangle $arg4
r_action_use [ r_dodamage (r_eff_melee) ]
]
r_rangedweapon = [
r_usetype 2
r_damage $arg1
r_attackrate $arg2
r_maxrange $arg3
r_useamount 10 // comes with arrows included
r_action_use [ r_dodamage (r_eff_ranged) ]
r_sound "free/tick"
]
r_spell = [
r_usetype 3
r_damage $arg1
r_attackrate $arg2
r_manacost $arg3
r_maxrange $arg4
r_effect $arg5
r_sound $arg6
r_action_use $arg7
]
Here you go.
What I don't get is how they can have the $arg's to be applicable for each attack. It would seem that each $arg has different definitions. It makes sense, but
Code: Select all
r_friendly_creature = [
r_model $arg1
r_ai 2
]
that has an $arg1 while in each of the attacks, there is an $arg1 that pertains to damage. I guess it could be a type of proxy... I think I'm gonna need to get MCO

Re: Creatures that attack
Posted: May 5th, 2010, 8:38 am
by Cypress
Code: Select all
struct rpgent : dynent
{
rpgobj *ro;
rpgclient &cl;
int lastaction, lastpain;
bool attacking;
int lastpickupmillis, checkpoint;
vector<mproj *> magicproj;
rpgent *enemy;
enum { R_STARE, R_ROAM, R_SEEK, R_ATTACK, R_BLOCKED, R_BACKHOME };
int npcstate;
int trigger;
float sink;
vec home;
enum { ROTSPEED = 200 };
rpgent(rpgobj *_ro, rpgclient &_cl, const vec &_pos, float _yaw, int _maxspeed = 40, int _type = ENT_AI) : ro(_ro), cl(_cl), lastaction(0), lastpain(0), attacking(false), lastpickupmillis(0), checkpoint(-1), enemy(NULL), npcstate(R_STARE), trigger(0), sink(0)
{
o = _pos;
home = _pos;
yaw = _yaw;
maxspeed = _maxspeed;
type = _type;
enemy = &cl.player1;
magicproj.setsize(0);
}
I believe this might be an AI script, if dynent = dynamic entity
Re: Creatures that attack
Posted: May 5th, 2010, 10:08 am
by arcones
I can see why you'd think so...
However, I believe that this pertains to a certain spell that includes a dynlight entity. Dynent.
Code: Select all
struct rpgent : dynent
{
rpgobj *ro;
rpgclient &cl;
int lastaction, lastpain;
bool attacking;
int lastpickupmillis, checkpoint;
The interaction for the last action, and pickup. Then once that is completed, a checkpoint.
Code: Select all
vector<mproj *> magicproj;
rpgent *enemy;
enum { R_STARE, R_ROAM, R_SEEK, R_ATTACK, R_BLOCKED, R_BACKHOME };
int npcstate;
int trigger;
float sink;
vec home;
enum { ROTSPEED = 200 };
rpgent(rpgobj *_ro, rpgclient &_cl, const vec &_pos, float _yaw, int _maxspeed = 40, int _type = ENT_AI) : ro(_ro), cl(_cl), lastaction(0), lastpain(0), attacking(false), lastpickupmillis(0), checkpoint(-1), enemy(NULL), npcstate(R_STARE), trigger(0), sink(0)
The rotation speed, the vector <mproj*> magicproj, and other's seem to indicate a spell/projectile from magic and what will happen when it connects with an int_type = ENT_AI. (interaction type with and AI entity) That's just what I'm thinking. I don't know if I'm right or not

Re: Creatures that attack
Posted: May 6th, 2010, 1:06 am
by Cypress
Oh, hence the line
Guess there is no other way besides waiting for the next release.
Can't seem to find anything relevant in MCO.
Either way, the script goes on to this
Code: Select all
rpgent(rpgobj *_ro, rpgclient &_cl, const vec &_pos, float _yaw, int _maxspeed = 40, int _type = ENT_AI) : ro(_ro), cl(_cl), lastaction(0), lastpain(0), attacking(false), lastpickupmillis(0), checkpoint(-1), enemy(NULL), npcstate(R_STARE), trigger(0), sink(0)
{
o = _pos;
home = _pos;
yaw = _yaw;
maxspeed = _maxspeed;
type = _type;
enemy = &cl.player1;
magicproj.setsize(0);
}
float vecyaw(vec &t) { return -(float)atan2(t.x-o.x, t.y-o.y)/RAD+180; }
static const int ATTACKSAMPLES = 32;
void tryattackobj(rpgobj &eo, rpgobj &weapon)
{
if(!eo.s_ai || (eo.s_ai==ro->s_ai && eo.ent!=enemy)) return;
rpgent &e = *eo.ent;
if(e.state!=CS_ALIVE) return;
vec d = e.o;
d.sub(o);
d.z = 0;
if(d.magnitude()>e.radius+weapon.s_maxrange) return;
if(o.z+aboveeye<=e.o.z-e.eyeheight || o.z-eyeheight>=e.o.z+e.aboveeye) return;
vec p(0, 0, 0), closep;
float closedist = 1e10f;
loopj(ATTACKSAMPLES)
{
p.x = e.xradius * cosf(2*M_PI*j/ATTACKSAMPLES);
p.y = e.yradius * sinf(2*M_PI*j/ATTACKSAMPLES);
p.rotate_around_z((e.yaw+90)*RAD);
p.x += e.o.x;
p.y += e.o.y;
float tyaw = vecyaw(p);
normalize_yaw(tyaw);
if(fabs(tyaw-yaw)>weapon.s_maxangle) continue;
float dx = p.x-o.x, dy = p.y-o.y, dist = dx*dx + dy*dy;
if(dist<closedist) { closedist = dist; closep = p; }
}
if(closedist>weapon.s_maxrange*weapon.s_maxrange) return;
weapon.useaction(eo, *this, true);
}
#define loopallrpgobjsexcept(ro) loop(i, cl.os.set.length()+1) for(rpgobj *eo = i ? cl.os.set[i-1] : cl.os.playerobj; eo; eo = NULL) if((ro)!=eo)
void tryattack(vec &lookatpos, rpgobj &weapon)
{
if(lastmillis-lastaction<weapon.s_attackrate) return;
lastaction = lastmillis;
switch(weapon.s_usetype)
{
case 1:
if(!weapon.s_damage) return;
weapon.usesound(this);
loopallrpgobjsexcept(ro) tryattackobj(*eo, weapon);
break;
case 2:
{
if(!weapon.s_damage) return;
weapon.usesound(this);
vec flarestart = o;
flarestart.z -= 2;
particle_flare(flarestart, lookatpos, 600, PART_STREAK, 0x7FFF00); // FIXME hudgunorigin(), and shorten to maxrange
float bestdist = 1e16f;
rpgobj *best = NULL;
loopallrpgobjsexcept(ro)
{
if(eo->ent->state!=CS_ALIVE) continue;
if(!intersect(eo->ent, o, lookatpos)) continue;
float dist = o.dist(eo->ent->o);
if(dist<weapon.s_maxrange && dist<bestdist)
{
best = eo;
bestdist = dist;
}
}
if(best) weapon.useaction(*best, *this, true);
break;
}
case 3:
if(weapon.s_maxrange) // projectile, cast on target
{
if(!ro->usemana(weapon)) return;
vec dir;
float worlddist = lookatpos.dist(o, dir);
dir.normalize();
magicproj.add(new mproj(o, dir, &weapon, min(float(weapon.s_maxrange), worlddist)));
}
else
{
weapon.useaction(*ro, *this, true); // cast on self
cl.fx.addfx(weapon.s_effect, *ro->ent);
}
break;
}
}
Re: Creatures that attack
Posted: May 6th, 2010, 8:18 am
by arcones
wow... that's a lot of code
Looks a lot like what the attack does
Cypress wrote:Guess there is no other way besides waiting for the next release.
Can't seem to find anything relevant in MCO.
Yep, unfortunately. Unless you can code a wicked AI.

(I'm not that good

)
Re: Creatures that attack
Posted: May 7th, 2010, 12:09 am
by Cypress
Looking at things from my point of view, I think the RPG mode is still at its early stages
Cube 2 Engine is more for FPS after all. xD
Hopefully Regen comes out early =D.
Does the FPS mode contain an default ai script?
I can try tinkering around with it =D, although RPG has better spell configs =(.
Re: Creatures that attack
Posted: May 7th, 2010, 4:39 am
by Leo_V117
The FPS for Regen?
Heres what the coding contains for Regen:
Vital
Extra
Intel
Achievements
Map Editor
Development
Weapon Customisation
Character Customisation
Re: Creatures that attack
Posted: May 7th, 2010, 8:23 am
by arcones
Yep, not to mention everything inside the game... But Hirato has some good stuff coming along and I hope he did the more important priority stuff first
Like AI...

Re: Creatures that attack
Posted: May 7th, 2010, 6:41 pm
by Cypress
How do you attack in FPS mode ??

I did not expect the gun feature to be excluded from PAS.
Isn't PAS based on Sauerbraten's engine?

Is it necessary to code the gun in?