Clientside Quest API

View previous topic View next topic Go down

Clientside Quest API

Post by rc on Tue Apr 19, 2016 5:01 pm

Here are the planned client-side functions:

n.newClientEvent(id:string,event:function)
n.newClientVariable(variable:object)
c.get(id:string)
c.set(id:string,val:number)
c.add(id:string,incr:number)
c.getPosition(key:string)
c.encodeTimestamp(time:number)
c.decodeTimestamp(time:number)
c.getRandomActor(mapId:string,tag:object)

actor attribute:
tagClient (tag sent to client)

rc
Admin

Posts : 164
Reputation : 9
Join date : 2016-04-04
Age : 22
Location : Montreal

View user profile http://rainingchain.com

Back to top Go down

Re: Clientside Quest API

Post by Ark on Thu Apr 21, 2016 10:24 am

As requested the pseudocode showing possibilities of the clientside API I requested:
The code for the shield rotating around the boss in shield phase one and always facing the player in shield phase two:
Code:
//SHARED
var shieldRotationCenter = any vector;
var shieldRotationSpeed = any number;
var shieldRotationCenterDistance = any number;
newVariable(name: 'spawnTimeByShield', value: { });
newVariable(name: 'lockTargetByShield', value: { });
newEvent(name: 'setShieldLock', handler: (args) { set(name: 'lockTargetByShield', key: args.shield, value: args.target); });
onMapLoad(() {
   var shield = spawnActor(type: 'shield');
   var spawnTime = currentSyncedTime;
   set(name: 'spawnTimeByShield', key: shield, value: spawnTime);
   if(isServer) { triggerEvent(name: 'syncShieldSpawnTime', client: true, server: false, args: { shield: shield, spawnTime: spawnTime }); }
});
newActor(type: 'shield', defense: MAX_DEFENSE, blocksPiercingProjectiles: true, behaviour: (shield) {
   var lockTarget = get(name: 'lockTargetByShield', key: shield);
   if(lockTarget == null) {
      // rotate around center
      var spawnTime = get(name: 'spawnTimeByShield', key: shield);
      var angle = ((currentSyncedTime- spawnTime) * shieldRotationSpeed) % (2 * PI);
      shield.setPosition(x: shieldRotationCenter.x + cos(angle) * shieldRotationCenterDistance, y: shieldRotationCenter.y + sin(angle) * shieldRotationCenterDistance);
   } else {
      // face lockTarget
      shield.setPosition(shieldRotationCenter + (lockTarget.Position - shieldRotationCenter).Normalize().ScalarMultiply(shieldRotationCenterDistance));
   }
});
//SERVER
var shieldLockTargetSensingAngle = any number;
newMapLoop(() {
   getMapPlayers.forEach((player) {
      getMapActors.forEach((actor) {
         if(actor.type != 'shield') return;
         var playerVector = player.Position - shieldRotationCenter;
         var shieldVector = actor.Position - shieldRotationCenter;
         if(dotProduct(playerVector.normalized, shieldVector.normalized) < cos(shieldLockTargetSensingAngle)) {
            triggerEvent(name: 'lockTargetByShield', client: true, server: true, args: { shield: actor, target: player });
         }
      });
   });
})
//CLIENT
newEvent(name: 'syncShieldSpawnTime', handler: (args) { set(name: spawnTimeByShield, key: args.shield, value: args.spawnTime); });

Ark

Posts : 59
Reputation : 3
Join date : 2016-04-10

View user profile

Back to top Go down

Re: Clientside Quest API

Post by rc on Sun Apr 24, 2016 9:20 pm

That would be feasible with the current Actor system.

One trick for advanced bullet movement is to create an actor to looks like a bullet.

rc
Admin

Posts : 164
Reputation : 9
Join date : 2016-04-04
Age : 22
Location : Montreal

View user profile http://rainingchain.com

Back to top Go down

Re: Clientside Quest API

Post by Sponsored content Today at 9:27 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum