new BaseNetController()
the net controller class this handles all net traffic for the multiplayer mod.
it is made to send and receive json packets, that contain as many or as few commands as we want,
for instance, a packet could contain a move cmd, or a mov cmd and a bunch
of others.
Members
-
netPlayers :Array.<PlayerModel>
-
-
netPlayers :Object.<string, PlayerModel>
-
-
peerId
-
the id of this peer
-
player :PlayerModel
-
the player on the local machine
-
players
-
list of player models
-
started
-
has the game started?
Methods
-
acceptBtnTypedConnectionFix()
-
if the user's accept button is a letter then when they hit accept for the connection code then it will
append the letter aswell which will mess up the code.- Deprecated:
- dont use this
-
additionalOutfitActions(outfitChangeData, id)
-
additional actions separate to the actual forwarding of the outfit change event that also get run alongside it
Parameters:
Name Type Description outfitChangeDataObject the data object defined in the emitter above
idUUID the id of the original sender
-
battleEndRemoveCombatant(troopId, id)
-
removes a combatant to the gameTroop's combat arr. This matches based on name and id,
this is to help with some of the spegetti that the dev does with battle eventsParameters:
Name Type Description troopId* id* -
battleStartAddCombatant(troopId, id)
-
adds a combatant to the gameTroop's combat arr. This matches based on name and id, this is to help with some of the
spegetti that the dev does with battle eventsParameters:
Name Type Description troopId* id* -
connect()
-
a method ment to be overriden by client and host
-
emitAppearEnemyEvent(enemyIndex)
-
emit the transform enemy event
Parameters:
Name Type Description enemyIndex* the index of the enemy to appear
Fires:
- event:appearEnemy
-
emitBattleEndEvent(troopId, enemy)
-
a function to emit the battle end event
Parameters:
Name Type Description troopIdint the id of the troop
enemyobj the net obj for an enemy
-
emitBattleStartEvent(eventId, mapId, troopId)
-
send the battle start event to connections
Parameters:
Name Type Description eventId* the id of the event tile the battle was triggered from
mapId* the id of the map that that tile is on
troopId* the troop id that the player is now incombat with
-
emitChangeInBattlersEvent()
-
called whenever anyone enters or leaves a battle, contains the id of the player and the battle
-
emitCommandEvent()
-
Fires:
- event:commandEvent
-
emitDashEvent(isDashing)
-
emit the dash event to clients
Parameters:
Name Type Description isDashingboolean is this player dashing or not
Fires:
- event:dashEvent
-
emitEnemyStateEvent(enemyIndex, addState, stateId)
-
emit the state enemy event
Parameters:
Name Type Description enemyIndexint the index of the enemy to appear
addStatebool add or remove the state
stateIdint the state id
Fires:
- event:enemyState
-
emitEquipmentChange()
-
emits the event for changing equipment
Fires:
- event:equipChange
-
emitEventMoveEvent()
-
Fires:
- event:eventMoveEvent
-
emitEventSpawn(data)
-
Parameters:
Name Type Description data* data of the event
Fires:
- event:spawnEvent
-
emitMarriageRequest(targetIds, response, responseBool)
-
emits the event for changing equipment
Parameters:
Name Type Default Description targetIdsan array of the peerIds of all persons (excluding host involved in this request)
responsefalse whether this is emitting a response to the request
responseBoolfalse whether this player says yes or no to the response
Fires:
- event:marriageReq
-
emitMarriageResponse(consent, hostId)
-
send the marraige response to all clients
Parameters:
Name Type Description consentboolean whether the local player said yes or no
hostIdboolean the id of the person who initiated the marriage request
Fires:
- event:marriageResponse
-
emitMoveEvent(direction)
-
Parameters:
Name Type Description directionnumber see below:
8: up
6: left
4: right
2: downFires:
- event:moveEvent
-
emitPvpEvent(targetedPlayerId, bool)
-
emit the pvp event to trigger combat with a net player
Parameters:
Name Type Default Description targetedPlayerId* boolbool true whether this is starting or ending a fight
Fires:
- event:"pvpEvent"
-
emitReadyEvent(an)
-
trigger the ready event. This event is called when a player enters the ready state in combat.
Parameters:
Name Type Description anArray.<Game_Action> array of the actions that the player has entered.
Fires:
- event:ready
-
emitRequestedVarSync()
-
used by the client to request vars to be synced
Fires:
- event:requestedVarSync
-
emitRuntimeTroopEvent(troopId)
-
emit the runtime troop event
Parameters:
Name Type Description troopId* the id of the troop being added
Fires:
- event:runtimeTroopSpawn
-
emitSaveEvent()
-
used for syncing saves
Fires:
- event:saveEvent
-
emitSaveEventLocationEvent(mapId, event)
-
send to all players the event location save event
Parameters:
Name Type Description mapIdint the id of the map
eventGame_Event the id of the event
Fires:
- event:saveEventLocationEvent
-
emitSetCharacterImageEvent(characterName, characterIndex, actorId)
-
emit the set charecter image event to the connected peers
Parameters:
Name Type Description characterNamestring the name of the charsheet (the file within www/imgs/charecters excluding .png)
characterIndexint the index within that sprite sheet
actorIdint the id of the actor this is occurring to
Fires:
- event:setCharImgEvent
-
emitSetTransparentEvent(bool)
-
emit the set transparent event to the connected peers
Parameters:
Name Type Description boolboolean whether the player is transparent or visible
Fires:
- event:transparentEvent
-
emitSpectateEvent(bool, id,)
-
emit the spectate event
Parameters:
Name Type Description boolboolean true if spectating, false if nolonger spectating
id,UUID the id of the user that is changing specatting
Fires:
- event:spectate
-
emitSpeedEvent(moveSpeed)
-
emit the event for a move speed change to clients
Parameters:
Name Type Description moveSpeednumber the new movespeed
Fires:
- event:"moveSpeedEvent"
-
emitSwitchEvent()
-
Fires:
- event:ctrlSwitch
-
emitTransferEvent(direction)
-
a function to emit the move event for the client
Parameters:
Name Type Description directionnumber see below:
8: up
6: left
4: right
2: downFires:
- event:transferEvent
-
emitTransformEvent(enemyIndex, transformIndex)
-
emit the transform enemy event
Parameters:
Name Type Description enemyIndex* the index of the enemy to transform
transformIndex* the transform index
Fires:
- event:transformEnemy
-
emitTurnEndEvent(enemyHps, enemyHps)
-
emit the turnend event, sending data to connected peers.
Parameters:
Name Type Description enemyHpsArray.<int> an array of ints corrispoding to the enemy hps
enemyHpsArray.<Array.<int>> an array of arrays of ints which are the state ids of the enemies
Fires:
- event:turnend
-
emitUnreadyEvent()
-
trigger the unready event. This event is called when a player exits the ready state in combat.
Fires:
- event:unready
-
emitUpdateSyncedVars()
-
send the local synced vars to connection
Fires:
- event:randomVars
-
initializeNetPlayer()
-
add a new player to the list of netPlayers.
-
moveNetPlayer(moveData, id)
-
move a net player 1 tile
Parameters:
Name Type Description moveData* which direction on the key pad the player pressed, up/down/left/right as a number 8/6/4/2
id* the id of the peer who's player moved
-
onAppearEnemyEventData(enemyAppearObj, id)
-
appear an enemy based on net event
Parameters:
Name Type Description enemyAppearObj* the net obj for enemy transform
id* sender id, make sure local player is in combat with this troop before doing anything
-
onCmdEventData()
-
the cmd object
-
onDashEventData(dashData, id)
-
process and perform actions when a dash event is received
Parameters:
Name Type Description dashDataObject the dash event net object defined in the method above
idUUID the id of the original sender
-
onData(data, conn)
-
the main controller receiving data
Parameters:
Name Type Description datathe data obj
connthe connection object
-
onEnemyStateEventData(enemyStateObj, id)
-
change enemy state based on net eobj
Parameters:
Name Type Description enemyStateObj* the net obj for enemy state event
id* sender id, make sure local player is in combat with this troop before doing anything
-
onEquipmentChangeData(equipChangeObj)
-
updates the given net party's actor's equipment
Parameters:
Name Type Description equipChangeObj* the net obj for equip change
-
onEventSpawn(data, id)
-
Parameters:
Name Type Description data* event net obj
idunused
-
onMarriageRequestData(marriageReqObj)
-
process the data of a marriage request
Parameters:
Name Type Description marriageReqObj* the net obj for marriagereq change
-
onMarriageResponseData()
-
process a marriage response
-
onMoveData(moveData, id)
-
triggers when the receiving movement data from a netPlayer
Parameters:
Name Type Description moveData* up/down/left/right as num 8 6 4 2
id* the peer id of the player who moved
-
onPvpEventData()
-
process the pvp data event from the client and start a combat if they are targeting this player
-
onReadyData(readyObj, senderId)
-
handles logic for readying and unreadying in combat.
Parameters:
Name Type Description readyObj* the net obj for the ready event
senderId* the sender's id
-
onRuntimeTroopEvent(enemiesData, id)
-
process the enemiesdata object and add a new run time troop to the current combat if in combat with same troop as sender
Parameters:
Name Type Description enemiesDataArray.<MATTIE.troopAPI.runtimeTroop> idUUID the sender's id
-
onSaveEventData()
-
open save menu
-
onSaveEventLocationEventData(saveEventLocationData, id)
-
handle the event
Parameters:
Name Type Description saveEventLocationData* an obj as structured in the method above
iduuid the id of the original sender
-
onSetCharacterImageEventData(outfitChangeData, id)
-
process and act upon the charecter image change event
Parameters:
Name Type Description outfitChangeDataObject the data object defined in the emitter above
idUUID the id of the original sender
-
onSetTransparentEventData(transparentEventData, id)
-
process and act upon the set transparent event when received.
Parameters:
Name Type Description transparentEventDataObject see emitSetTransparent event defined above for what this object looks like
idUUID the id of the original sender
-
onSpectateEventData(spectateObj, id)
-
Parameters:
Name Type Description spectateObj* the net spectate event,
id* the sender id
-
onSpeedEventData(moveSpeedData, id)
-
process the move speed change event
Parameters:
Name Type Description moveSpeedDataObject see method above
idObject the id of the original sender
-
onTransferData(transData, id)
-
triggers when the receiving transfer data from a netPlayer
Parameters:
Name Type Description transData* x,y,map
id* the peer id of the player who moved
-
onTransformEventData(enemyTransformObj, id)
-
transform an enemy based on net event
Parameters:
Name Type Description enemyTransformObj* the net obj for enemy transform
id* sender id, make sure local player is in combat with this troop before doing anything
-
onTurnEndData(data)
-
Parameters:
Name Type Description data* the turnEnd obj, for now just contains an array of enemy healths
-
onUpdateNetPlayersData()
-
handle when the host sends an updated list of netplayers
Fires:
- event:updateNetPlayers
-
onUpdateSyncedSwitchData({{dict[]})
-
process the data for synced var updates
Parameters:
Name Type Description {{dict[]}syncedSwitch an array of key pair values
-
onUpdateSyncedVarsData(syncedVars)
-
process the data for synced var updates
Parameters:
Name Type Description syncedVarsArray.<dict> an array of key pair values
-
performCosmeticAttack(target)
-
perform a solely cosmetic attack
Parameters:
Name Type Default Description targetGame_Battler null -
performCosmeticDamageAnimation(subject, targets, animId)
-
trigger a damage animation (purely cosmetic)
Parameters:
Name Type Description subjectGame_Battler the subject performing the attack
targetsArray.<Game_Battler> the targets to display the animation on
animIdint -
preprocessData(data, conn)
-
a function that will preprocess the data for onData, before it is read/
this is overridden by host and clientParameters:
Name Type Description datathe data that was sent
connthe connection that is sending the data
-
processNormalAction(actor, action, isExtraTurn, senderId)
-
add a action to a net battler when not in pvp
Parameters:
Name Type Description actorGame_Actor actor that these actions are for
actionGame_Action the action itself
isExtraTurnbool whether this is an extra turn
senderIdUUID id of the net user that sent these actions
-
processNormalEnemyAction(enemy, action, isExtraTurn, senderId)
-
add a action to an enemy
Parameters:
Name Type Description enemyGame_Enemy actor that these actions are for
actionGame_Action the action itself
isExtraTurnbool whether this is an extra turn
senderIdUUID id of the net user that sent these actions
-
processPvpAction(actor, action, isExtraTurn, senderId)
-
handle pvp action
Parameters:
Name Type Description actorGame_Actor actor that these actions are for
actionGame_Action the action itself
isExtraTurnbool whether this is an extra turn
senderIdUUID id of the net user that sent these actions
-
sendViaMainRoute(obj)
-
que a json object to be sent to the main connection.
For host this will send to all, for client this will send to host.
this is left blank intentionally as it is overridden by host and clientParameters:
Name Type Description obj* the object to send
-
smoothMoveNetPlayer(numSteps, player, delayPerStep, location)
-
smoothly move a net player to a location
Parameters:
Name Type Default Description numSteps* number of steps to take
player* the game char to move
delayPerStep* 150 the delay between each step
location* {x:x, y:y} the location obj
-
stateSpecificActions(enemyIndex, stateId, add)
-
additional actions that the ned controller needs to perform on specific states triggered
Parameters:
Name Type Description enemyIndexint the enemyIndex
stateIdint the stateid
addbool true if the state should be added or removed
-
transferNetPlayer(transData, id)
-
transfer a net player to a location
Parameters:
Name Type Description transData* x,y,map
id* the id of the peer who's player moved
-
updateNetPlayers()
-
updates net players
Fires:
- event:updateNetPlayers
-
updatePlayersOnCurrentMap()
-
transfers all players on the current map to their locations on the current map