Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.

In the meantime please join the new Discord Server!

If you have any questions please e-mail me through the Platinum Arts website.

Creatures that attack

Having issues not related to a specific Sandbox game mode? Get help here!
Please also read the rules for support when posting support requests.
Failure to comply with the forum rules may result in your topic being locked without resolution.
Cypress
Member
Member
Posts: 23
Joined: April 17th, 2010, 10:55 am

Re: Creatures that attack

Post 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.
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: Creatures that attack

Post 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 :)
Image
Want a user bar like this one? PM Leo!
Cypress
Member
Member
Posts: 23
Joined: April 17th, 2010, 10:55 am

Re: Creatures that attack

Post 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
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: Creatures that attack

Post 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 :roll:
Image
Want a user bar like this one? PM Leo!
Cypress
Member
Member
Posts: 23
Joined: April 17th, 2010, 10:55 am

Re: Creatures that attack

Post by Cypress »

Oh, hence the line

Code: Select all

vector<mproj *> magicproj;


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;
        }

    }
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: Creatures that attack

Post 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. :P (I'm not that good :lol: )
Image
Want a user bar like this one? PM Leo!
Cypress
Member
Member
Posts: 23
Joined: April 17th, 2010, 10:55 am

Re: Creatures that attack

Post by Cypress »

Looking at things from my point of view, I think the RPG mode is still at its early stages :lol:
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 =(.
User avatar
Leo_V117
Support Team
Support Team
Posts: 1640
Joined: February 16th, 2010, 8:00 pm
Name: Leo
IRC Username: Leo_V117
Location: That one place...
Contact:

Re: Creatures that attack

Post by Leo_V117 »

The FPS for Regen?

Heres what the coding contains for Regen:
  • Vital
    • Save/Load
      AI
      Weapons
    Extra
    • Intel
      Achievements
      Map Editor
    Development
    • Weapon Customisation
      Character Customisation
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: Creatures that attack

Post 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... :lol: ;)
Image
Want a user bar like this one? PM Leo!
Cypress
Member
Member
Posts: 23
Joined: April 17th, 2010, 10:55 am

Re: Creatures that attack

Post by Cypress »

How do you attack in FPS mode ?? :lol:

I did not expect the gun feature to be excluded from PAS.

Isn't PAS based on Sauerbraten's engine? :roll:

Is it necessary to code the gun in?
Locked