Permalink
Browse files

Begin work on improved weapon sync

  • Loading branch information...
Medo42 committed Dec 22, 2011
1 parent 97b273d commit 3b08388a29c7afc18b0c7b73a7c8ec63e0a89062
View
@@ -51,6 +51,7 @@
<constant name="HAXXY_CHALLENGE_CODE" value="51"/>
<constant name="HAXXY_CHALLENGE_RESPONSE" value="52"/>
<constant name="MESSAGE_STRING" value="53"/>
+ <constant name="WEAPON_FIRE" value="54"/>
<constant name="HAXXY_PUBLIC_KEY" value="&quot;70095e0fd9754e5a3ce2cb32f109148e&quot;"/>
<constant name="TEAM_RED" value="0"/>
<constant name="TEAM_BLUE" value="1"/>
@@ -13,27 +13,14 @@
<not>false</not>
<appliesTo>.self</appliesTo>
<arguments>
- <argument kind="STRING">{
- if(readyToShoot == true &amp;&amp; ammoCount &gt;0 and lobbed&lt;maxMines) {
- var oid, newx, newy;
- playsound(x,y,MinegunSnd);
- ammoCount -= 1;
-
- oid = instance_create(x+lengthdir_x(10,owner.aimDirection),y+lengthdir_y(10,owner.aimDirection), Mine);
-
- oid.direction=owner.aimDirection;
- oid.speed=12;
- oid.owner=owner;
- oid.ownerPlayer=ownerPlayer;
- oid.team=owner.team;
- oid.weapon=WEAPON_MINEGUN;
- lobbed += 1;
- justShot=true;
- readyToShoot = false;
- alarm[0] = refireTime;
- alarm[5] = reloadBuffer + reloadTime;
- }
+ <argument kind="STRING">if(readyToShoot and ammoCount &gt;0 and lobbed&lt;maxMines and global.isHost)
+{
+ var seed;
+ seed = irandom(65535);
+ sendEventFireWeapon(ownerPlayer, seed);
+ doEventFireWeapon(ownerPlayer, seed);
}
+
</argument>
</arguments>
</action>
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<event category="OTHER" id="13">
+ <actions>
+ <action id="603" library="1">
+ <!--action name: Code-->
+ <kind>CODE</kind>
+ <allowRelative>false</allowRelative>
+ <question>false</question>
+ <canApplyTo>true</canApplyTo>
+ <actionType>CODE</actionType>
+ <functionName/>
+ <relative>false</relative>
+ <not>false</not>
+ <appliesTo>.self</appliesTo>
+ <arguments>
+ <argument kind="STRING">var oid, newx, newy;
+playsound(x,y,MinegunSnd);
+ammoCount = max(0, ammoCount-1);
+
+oid = instance_create(x+lengthdir_x(10,owner.aimDirection),y+lengthdir_y(10,owner.aimDirection), Mine);
+
+oid.direction=owner.aimDirection;
+oid.speed=12;
+oid.owner=owner;
+oid.ownerPlayer=ownerPlayer;
+oid.team=owner.team;
+oid.weapon=WEAPON_MINEGUN;
+lobbed += 1;
+justShot=true;
+readyToShoot = false;
+alarm[0] = refireTime;
+alarm[5] = reloadBuffer + reloadTime;
+</argument>
+ </arguments>
+ </action>
+ </actions>
+</event>
@@ -13,23 +13,15 @@
<not>false</not>
<appliesTo>.self</appliesTo>
<arguments>
- <argument kind="STRING">{
- if(readyToShoot == true) {
- playsound(x,y,RocketSnd);
- var oid, newx, newy;
-
- oid = instance_create(x+lengthdir_x(20,owner.aimDirection),y+lengthdir_y(20,owner.aimDirection), QRocket);
-
- oid.direction=owner.aimDirection;
- oid.speed=4;
- oid.ownerPlayer=ownerPlayer;
- oid.team=owner.team;
- oid.weapon=WEAPON_QROCKETLAUNCHER;
-
- readyToShoot = false;
- alarm[0] = reloadTime;
- }
-}</argument>
+ <argument kind="STRING">if(readyToShoot and global.isHost)
+{
+ var seed;
+ seed = irandom(65535);
+ sendEventFireWeapon(ownerPlayer, seed);
+ doEventFireWeapon(ownerPlayer, seed);
+}
+
+</argument>
</arguments>
</action>
</actions>
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<event category="OTHER" id="13">
+ <actions>
+ <action id="603" library="1">
+ <!--action name: Code-->
+ <kind>CODE</kind>
+ <allowRelative>false</allowRelative>
+ <question>false</question>
+ <canApplyTo>true</canApplyTo>
+ <actionType>CODE</actionType>
+ <functionName/>
+ <relative>false</relative>
+ <not>false</not>
+ <appliesTo>.self</appliesTo>
+ <arguments>
+ <argument kind="STRING">playsound(x,y,RocketSnd);
+var oid, newx, newy;
+
+oid = instance_create(x+lengthdir_x(20,owner.aimDirection),y+lengthdir_y(20,owner.aimDirection), QRocket);
+
+oid.direction=owner.aimDirection;
+oid.speed=4;
+oid.ownerPlayer=ownerPlayer;
+oid.team=owner.team;
+oid.weapon=WEAPON_QROCKETLAUNCHER;
+
+readyToShoot = false;
+alarm[0] = reloadTime;
+</argument>
+ </arguments>
+ </action>
+ </actions>
+</event>
@@ -13,50 +13,34 @@
<not>false</not>
<appliesTo>.self</appliesTo>
<arguments>
- <argument kind="STRING">{
- if(readyToShoot &amp;&amp; !owner.cloak &amp;&amp; ammoCount &gt; 0) {
- ammoCount-=1;
- playsound(x,y,RevolverSnd);
- var shot;
- randomize();
-
- shot = instance_create(x,y + yoffset + 1,Shot);
- shot.direction=owner.aimDirection+ random(2)-1;
- shot.speed=21;
- shot.owner=owner;
- shot.ownerPlayer=ownerPlayer;
- shot.team=owner.team;
- shot.hitDamage = 28;
- shot.weapon=WEAPON_REVOLVER;
- with(shot)
- hspeed+=owner.hspeed;
- justShot=true;
- readyToShoot=false;
- alarm[0]=refireTime;
- alarm[5] = reloadBuffer + reloadTime;
- }
- else
+ <argument kind="STRING">if(readyToShoot &amp;&amp; !owner.cloak &amp;&amp; ammoCount &gt; 0)
+{
+ if(global.isHost)
{
- if(readyToStab &amp;&amp; owner.cloak)
- {
- owner.runPower = 0;
- owner.jumpStrength = 0;
- owner.stabbing = 1;
-
- stabdirection = owner.aimDirection;
- stab = instance_create(x,y,StabAnim);
- stab.direction = owner.aimDirection;
- stab.speed = 0;
- stab.owner = owner;
- stab.ownerPlayer = ownerPlayer;
- stab.team = owner.team;
- stab.hitDamage = 0;
- stab.weapon = WEAPON_KNIFE;
- readyToStab = false;
- alarm[1] = StabreloadTime;
- }
+ var seed;
+ seed = irandom(65535);
+ sendEventFireWeapon(ownerPlayer, seed);
+ doEventFireWeapon(ownerPlayer, seed);
}
}
+else if(readyToStab &amp;&amp; owner.cloak)
+{
+ owner.runPower = 0;
+ owner.jumpStrength = 0;
+ owner.stabbing = 1;
+
+ stabdirection = owner.aimDirection;
+ stab = instance_create(x,y,StabAnim);
+ stab.direction = owner.aimDirection;
+ stab.speed = 0;
+ stab.owner = owner;
+ stab.ownerPlayer = ownerPlayer;
+ stab.team = owner.team;
+ stab.hitDamage = 0;
+ stab.weapon = WEAPON_KNIFE;
+ readyToStab = false;
+ alarm[1] = StabreloadTime;
+}
</argument>
</arguments>
</action>
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<event category="OTHER" id="13">
+ <actions>
+ <action id="603" library="1">
+ <!--action name: Code-->
+ <kind>CODE</kind>
+ <allowRelative>false</allowRelative>
+ <question>false</question>
+ <canApplyTo>true</canApplyTo>
+ <actionType>CODE</actionType>
+ <functionName/>
+ <relative>false</relative>
+ <not>false</not>
+ <appliesTo>.self</appliesTo>
+ <arguments>
+ <argument kind="STRING">ammoCount = max(0, ammoCount-1);
+playsound(x,y,RevolverSnd);
+var shot;
+
+shot = instance_create(x,y + yoffset + 1,Shot);
+shot.direction=owner.aimDirection+ random(2)-1;
+shot.speed=21;
+shot.owner=owner;
+shot.ownerPlayer=ownerPlayer;
+shot.team=owner.team;
+shot.hitDamage = 28;
+shot.weapon=WEAPON_REVOLVER;
+with(shot)
+ hspeed+=owner.hspeed;
+justShot=true;
+readyToShoot=false;
+alarm[0]=refireTime;
+alarm[5] = reloadBuffer + reloadTime;
+</argument>
+ </arguments>
+ </action>
+ </actions>
+</event>
@@ -13,121 +13,14 @@
<not>false</not>
<appliesTo>.self</appliesTo>
<arguments>
- <argument kind="STRING">{
- if(readyToShoot == true) {
- playsound(x,y,SniperSnd);
- shot=true;
- justShot=true;
- readyToShoot = false;
- alarm[0] = reloadTime + 20*owner.zoomed;
-
- var hit;
- var x1,y1,xm,ym, len;
- var hitline;
- len=2000;
- x1=x;
- y1=y;
- x2=x+lengthdir_x(len,owner.aimDirection);
- y2=y+lengthdir_y(len,owner.aimDirection);
-
- while(len&gt;1) {
- xm=(x1+x2)/2;
- ym=(y1+y2)/2;
-
- hitline = false;
- with(owner) {
- if (collision_line(x1,y1,xm,ym,Generator,true,true)&gt;=0) {
- hitline = true;
- if instance_nearest(x1,y1,Generator).team == team hitline = false;
- }
- if(collision_line(x1,y1,xm,ym,Obstacle,true,true)&gt;=0) {
- hitline = true;
- } else if (collision_line(x1,y1,xm,ym,Character,true,true)&gt;=0) {
- hitline = true;
- } else if (collision_line(x1,y1,xm,ym,Sentry,true,false)&gt;=0) {
- hitline = true;
- } else if (collision_line(x1,y1,xm,ym,TeamGate,true,true)&gt;=0) {
- hitline = true;
- } else if (collision_line(x1,y1,xm,ym,IntelGate,true,true)&gt;=0) {
- hitline = true;
- } else if (collision_line(x1,y1,xm,ym,ControlPointSetupGate,true,true)&gt;=0) {
- if ControlPointSetupGate.solid == true hitline = true;
- } else if (collision_line(x1,y1,xm,ym,BulletWall,true,true)&gt;=0) {
- hitline = true;
- }
- }
-
- if(hitline) {
- x2=xm;
- y2=ym;
- } else {
- x1=xm;
- y1=ym;
- }
- len/=2;
- }
-
- with(Player) {
- if(id != other.ownerPlayer and team != other.owner.team and object != -1) {
- if(collision_line(other.x,other.y,other.x2,other.y2,object,true,false)&gt;=0) &amp;&amp; object.ubered == 0 {
- object.hp -= other.hitDamage;
- object.timeUnscathed = 0;
- if (object.lastDamageDealer != other.ownerPlayer &amp;&amp; object.lastDamageDealer != object.player){
- object.secondToLastDamageDealer = object.lastDamageDealer;
- object.alarm[4] = object.alarm[3]
- }
- object.alarm[3] = ASSIST_TIME;
- object.lastDamageDealer = other.ownerPlayer;
- object.cloakAlpha = min(object.cloakAlpha + 0.3, 1);
- if(global.gibLevel &gt; 0){
- blood = instance_create(object.x,object.y,Blood);
- blood.direction = other.owner.aimDirection-180;
- }
- if (!other.owner.zoomed)
- object.lastDamageSource = WEAPON_RIFLE;
- else
- object.lastDamageSource = WEAPON_RIFLE_CHARGED;
- exit;
- }
- }
- }
-
- with(Sentry) {
- if(team != other.owner.team) {
- if(collision_line(other.x,other.y,other.x2,other.y2,id,false,false)&gt;=0) {
- hp -= other.hitDamage;
- lastDamageDealer = other.ownerPlayer;
- if (!other.owner.zoomed)
- lastDamageSource = WEAPON_RIFLE;
- else
- lastDamageSource = WEAPON_RIFLE_CHARGED;
- exit;
- }
- }
- }
-
- with(Generator) {
- if(team != other.owner.team) {
- if(collision_line(other.x,other.y,other.x2,other.y2,id,true,false)&gt;=0) {
- alarm[0] = regenerationBuffer;
- isShieldRegenerating = false;
- //allow overkill to be applied directly to the target
- if (other.hitDamage &gt; shieldHp) {
- hp -= other.hitDamage - shieldHp;
- hp -= shieldHp * shieldResistance;
- shieldHp = 0;
- }
- else
- {
- hp -= other.hitDamage * shieldResistance;
- shieldHp -= other.hitDamage;
- }
- exit;
- }
- }
- }
- }
+ <argument kind="STRING">if(readyToShoot and global.isHost)
+{
+ var seed;
+ seed = irandom(65535);
+ sendEventFireWeapon(ownerPlayer, seed);
+ doEventFireWeapon(ownerPlayer, seed);
}
+
</argument>
</arguments>
</action>
Oops, something went wrong.

0 comments on commit 3b08388

Please sign in to comment.