Clientside Quest API
2 posters
Page 1 of 1
Clientside Quest API
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)
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)
Re: Clientside Quest API
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:
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
Re: Clientside Quest API
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.
One trick for advanced bullet movement is to create an actor to looks like a bullet.
Similar topics
» Quest Creator: Map will not update
» [Bug] UI Quest Window Glitch
» Planned - Balance Quest Reward
» [Bug] Side Quest Death Resets Scaling
» [Bug] UI Quest Window Glitch
» Planned - Balance Quest Reward
» [Bug] Side Quest Death Resets Scaling
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|