Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views5 pages

Creating Weapon System1.0

The document outlines the mechanics for a weapon system in a game, detailing regular and special attack functionalities, including client-server interactions and visual effects (VFX). It describes how attacks are initiated, validated, and replicated across clients, with a focus on preventing hacking through sanity checks. Additionally, it includes pseudo code for managing attack states and cooldowns to ensure proper gameplay flow.

Uploaded by

alex.slukin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Creating Weapon System1.0

The document outlines the mechanics for a weapon system in a game, detailing regular and special attack functionalities, including client-server interactions and visual effects (VFX). It describes how attacks are initiated, validated, and replicated across clients, with a focus on preventing hacking through sanity checks. Additionally, it includes pseudo code for managing attack states and cooldowns to ensure proper gameplay flow.

Uploaded by

alex.slukin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Creating Weapon System

(My Game: )
Left Click: Regular Attack
Special Attack Keys: E, Q, F, V

Scripts:
Client
Server
ReplicationClient

Regular Punch Attack!

A punches B and plays effect on their (A’s) client

1. Client Does Debounce Check


2. Client Does Animation
3. Client Does Effect In this Script

A asks the server to damage B

1. Client Check if it did Damage Server


2. If So, Send Signal To Replication Client of Attack Move With Position etc. Add VFX
Effects. (Only If This is attack with vfx based on Dmg)

Server does some sanity checks, does damage to B

1. Using A Server Sided Debounce, It will make sure that the event doesn’t get fired too
many times

Server tells B and C that they should play a punch effect at B’s location
1. Replicates the Effect
B plays effect.

C plays effect, but maybe a lower quality one/skips rendering it because it’s not directly
involved.
1. Using Setting of Player, and Distance away from attacker and Player not Involved, We
can replicate the effect

Special Hold Punch Attack!


Two Variables
HoldingBefore
SpecialAttackAfter!
A Does Animation for Attack and VFX!
1. Client Sends Signal of Doing Animation and Holding Attack
2. Server States that User is Holding Attack and Can Attack
3. Server Sends Info About VFX to Replication
Sanity Check On Special Attack
1. If Already Special Hold Attack, And Hacker sends info on Hold, Then it is Cancel
2. If There is No special Attack and hacker tries to special Attack, server says NO
3. If Special Attack is Already Attack after hold move, Then server doesn’t allow more
attacks
Player Equips Weapon or Let Go Attack
1. Client Animation Continues playing after pausing
2. Client Does Animation!
3. Client Send Signal to Server Telling it can now Attack
4. Server Takes away special stamina
5. Server Tells That Player is Doing a Special Attack!!! So that It can’t do different Moves!
PlayerDamage
1. Based On Client VFX, Replicate hit boxes and does damage
2. Sanity check of doing special attack = true
VFX Signal To Other Clients
1. Other clients receive info of the attack information by getting info from the attacker. Then
it sends to the other Clients! (Not necessary to do this if there won’t be any body movers
involved!, so Priority would be the server!!!)

(Problem : Hackers can change the attack information!)Sanity Check: Basically Make sure the
size,orientation, etc of the vfx is exactly what we want! For Position, Make sure it is close to
where it’s supposed to be, Else cancel the vfx.
Pseudo Code for Sanity Check Special Attack Move

--Server

Local CoolDownWeapon = 0.5


Local TimeNow = 0

Local Key = F
Local HoldingAttackPlayed = false
Local SpecialAttackPlayed = false

(Will be list of special attacks with Keys to check for the special Attacks!!!!)

Connect Server
If
(F and not HoldingAttackPlayedFalse and CheckDebounce and not SpecialAttack and
CheckSpecialPowerBar )
then

HoldingAttackPlayed = true
SendSignalIsHoldingAttack
Send VFX Info To Replicator

elseIf
(FLifted and HoldingAttackPlayed and not SpecialAttackPlayed and CheckSpecialPowerBar )
then

HoldingAttackPlayedFalse = false
SpeicalAttackPlayed = true
SendVFX Info To Replicator
ReplicateDamage
AfterSomeTime
SendSignal Can Attack
SpeicalAttackPlayed = false
endIf
--Client
WhatToDo = “CanAttack”

If press F and WhatToDo == “CanAttack” then


HoldAttackFiredServer(Key)
PlayVFX
endIf
If LetGo F and CanAttack == “HoldAttack” then
CancelChargeAttackIfItIsChargeVFX
SpecialAttackFiredServer(Key)
PlayVFX
endIf

ConnectServer And Check WhatToDo

Regular Attack

Client
If MouseClick and WhatToDo == “CanAttack” then
RegularAttackServerSignal
PlayVFX
endIf

Server
Server Connection
If
(TypeAttack Is Regular and CheckDebounce and not HoldingAttackPlayedFalse and not
specialAttackPlayed )
Then
ResetCheckDebounceBySetNewTimeNow
ReplicationSignalSentDoVFX
Damage!
End

Let’s Say…

This is a weapon
Weapon:DescendantChangeToBackpack Connection
If HoldAttackPlayed then

Remove HoldVFX

Elseif SpecialAttackPlayed then


Lose SpecialPowerBar
Well It Depends. Either Allow the attack damage. But It truel depends because I
create Jump Attacks Before. Because of that, I would have more booleans in that
process.Depending on the stage like in air, I would prevent the Can Attack Move Landing

endIF
endConnection
If Is A Combat System
WeaponPriorityChange Connection
If HoldAttackPlayed then

Remove HoldVFX
Elseif SpecialAttackPlayed then
Lose SpecialPowerBar
Well It Depends. Either Allow the attack damage. But It truel depends because I
create Jump Attacks Before. Because of that, I would have more booleans in that
process.Depending on the stage like in air, I would prevent the Can Attack Move Landing

endIF
Reset All Booleans
EndConnection

You might also like