-
-
Save SanyaWaffles/48995482515a5a1bdd4c91a2ed70ad63 to your computer and use it in GitHub Desktop.
Revised base_weapon stuff (all put in TryPickup this time)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ******************************************************************* | |
* base_weapons.zsc | |
* | |
* Base weapon for Ruby 3D | |
* | |
* As long as you attribute it to me in some | |
* way I don't mind people using this. Considering how much | |
* some people have caused an uproar over the lack of proper | |
* examples and the like. | |
* | |
* Copyright Sanya K. C. Waffles 2013-2017 | |
* | |
* ****************************************************************** */ | |
// Weapon | |
Class DD2_Weapon : Weapon | |
{ | |
Default | |
{ | |
//$NotAngled | |
//$Category "Weapons" | |
//$Color 14 | |
Radius 26; | |
Height 12; | |
Scale 0.10; | |
Weapon.Kickback 100; | |
Weapon.MinSelectionAmmo1 0; | |
Weapon.MinSelectionAmmo2 0; | |
Weapon.BobStyle "Smooth"; | |
Weapon.BobSpeed 1.0; | |
Weapon.UpSound "weapons/raiseA"; | |
Inventory.PickupSound "pickups/weapon"; | |
+WEAPON.NODEATHINPUT | |
} | |
action bool func_CheckButtonPressed(int button) | |
{ | |
return ((GetPlayerInput(-1, INPUT_BUTTONS) & button) && !((GetPlayerInput(-1, INPUT_OLDBUTTONS) & button))); | |
} | |
// Check if a key or button is being held down | |
action bool func_CheckButtonHeld(int button) | |
{ | |
return !!(GetPlayerInput(-1, INPUT_BUTTONS) & button); | |
} | |
// Check if a key or button is NOT being held down | |
action bool func_CheckButtonUp(int button) | |
{ | |
return !(GetPlayerInput(-1, INPUT_BUTTONS) & button); | |
} | |
action void A_DD2_Ready() | |
{ | |
A_WeaponReady(); | |
} | |
States | |
{ | |
LightDone: | |
TNT1 A 0 A_Light0; | |
Stop; | |
} | |
} | |
/*************************************** | |
* This can be used in two ways. | |
* | |
* A.) Make a derived class that assigns the following properties | |
* so they can be placed around the map. | |
* | |
* B.) be dropped directly using ZSCript's "Spawn" and have the properties assigned | |
* directly via the Spawn static method. | |
*/ | |
Class DD2_WeaponPickup : CustomInventory | |
{ | |
Class<DD2_Weapon> WeaponToGive; // Assign a weapon to give | |
Class<Ammo> AmmoToGive; // Assign the ammo to give | |
int AmmoAmount; // Assign the ammo amount to give | |
int WeaponIndex; // Index (for pickup message purposes) | |
int pickuptime; | |
property WeaponToGive: WeaponToGive; | |
property AmmoToGive: AmmoToGive; | |
property AmmoAmount: AmmoAmount; | |
property WeaponIndex: WeaponIndex; | |
Default | |
{ | |
//$NotAngled | |
//$Category "Weapons" | |
//$Color 14 | |
Radius 26; | |
Height 12; | |
Scale 0.10; | |
Inventory.PickupSound "pickups/weapon"; | |
} | |
// Pickup Strings thus far | |
static const String DD2_PICKUPINDEX[] = | |
{ | |
"$DD2_GOTBAZOOKA", | |
"$DD2_GOTHEATSEEKER", | |
"$DD2_GOTTRIPLESHOTGUN", | |
"$DD2_GOTHTB", | |
"$DD2_GOTTEXTWALL" | |
}; | |
// Weapons thus far | |
static const Class<DD2_Weapon> DD2_WPNINDEX[] = | |
{ | |
"DD2_Bazooka", | |
"DD2_HeatSeeker", | |
"DD2_TripleShotgun", | |
"DD2_HTBRifle", | |
"DD2_TextWall" | |
}; | |
// Ammo thus far | |
static const Class<Ammo> DD2_AMMOINDEX[] = | |
{ | |
"DD2_BazookaAmmo", | |
"DD2_HeatSeekerAmmo", | |
"DD2_TripleShellAmmo", | |
"DD2_HTBAmmo", | |
"DD2_TextwallAmmo" | |
}; | |
// Sprite index | |
static const String DD2_WPNSPRINDEX[] = | |
{ | |
"ROCK", | |
"HEAT", | |
"TSHT", | |
"HTBW", | |
"FWAL" | |
}; | |
const SPRINDEX = 5; // Amount of ammo thus far | |
// We wanna override the pickup message because we can't dynamically | |
// override the Pickup Message in code | |
override String PickupMessage() | |
{ | |
return DD2_PICKUPINDEX[weaponIndex]; | |
} | |
// only pick up every 5 tics | |
override bool TryPickup (in out Actor toucher) | |
{ | |
bool pickupauto = CVar.FindCVar('dd2_autoweaponpickup').GetBool(); | |
// This part is giving me trouble. | |
// This is where I currently check to see if +use is being pressed | |
if(pickupauto && pickuptime < 15 || (toucher.player.cmd.buttons & BT_USE) && (toucher.player.original_cmd.buttons & BT_USE)) | |
{ | |
Console.Printf("161"); | |
pickuptime++; | |
// Display a message if the player | |
// hasn't learned to pick up weapons before | |
if (toucher && pickuptime == 1) | |
{ | |
let plyr = DD2_PlayerPawn(toucher); | |
if (plyr) | |
{ | |
if (!plyr.learnedToPickup) | |
{ | |
plyr.A_Print(Stringtable.Localize("$DD2_PICKUP_MESSAGE"), 0, "Smallfont"); | |
plyr.learnedToPickup = true; | |
} | |
} | |
} | |
// If pickuptime has been 15 tics | |
// Start the pickup process | |
if (pickuptime == 15) | |
{ | |
return Super.TryPickup(toucher); | |
} | |
} | |
else | |
{ | |
pickuptime = 0; | |
} | |
return false; | |
} | |
States | |
{ | |
// Dummy State with all the pickup sprites, so we can | |
// dynamically change the sprite/frame later. | |
Kek: | |
ROCK A 0; | |
HEAT A 0; | |
TSHT A 0; | |
HTBW A 0; | |
FWAL A 0; | |
Stop; | |
Spawn: | |
TNT1 A 1 | |
{ | |
// Loop through the sprites | |
for (int i = 0; i < invoker.SPRINDEX; i++) | |
{ | |
// check to see if we have a proper WeaponToGive | |
if (invoker.WeaponToGive == invoker.DD2_WPNINDEX[i]) | |
{ | |
// Set the pickup's sprite and frame based on what properties it has | |
invoker.sprite = GetSpriteIndex(invoker.DD2_WPNSPRINDEX[i]); | |
invoker.frame = 0; // A | |
break; | |
} | |
} | |
} | |
Loop; | |
Pickup: | |
TNT1 A 0 | |
{ | |
// Give the weapon and ammo assigned | |
A_GiveInventory(invoker.WeaponToGive, 1); | |
A_GiveInventory(invoker.AmmoToGive, invoker.AmmoAmount); | |
// loop through the weapons | |
for (int i = 0; i < invoker.SPRINDEX; i++) | |
{ | |
Console.Printf(String.Format("%s %i", "TryPickup::DD2_WeaponPickup L237\nSPRINDEX is", i)); | |
// If we currently have a weapon, drop it. | |
if (CountInv(invoker.DD2_WPNINDEX[i]) && !(invoker.DD2_WPNINDEX[i] is invoker.WeaponToGive) && CountInv(invoker.DD2_AMMOINDEX[i]) > 0) | |
{ | |
// begin the drop | |
Actor aa = Spawn("DD2_WeaponPickup", pos, ALLOW_REPLACE); | |
// Assign some values/physics | |
aa.bDropped = true; | |
aa.vel.x = random(-1, 1); | |
aa.vel.y = random(-1, 1); | |
aa.vel.z = 8; | |
// Assign the properties specific to DD2_WeaponPickup | |
let aaa = DD2_WeaponPickup(aa); | |
if (aaa) | |
{ | |
// Assign dropped pickup the WeaponToGive | |
aaa.WeaponToGive = invoker.DD2_WPNINDEX[i]; | |
// Assign dropped pickup AmmoToGive | |
aaa.AmmoToGive = invoker.DD2_AMMOINDEX[i]; | |
// Assign amount of ammo we currently have | |
aaa.AmmoAmount = CountInv(invoker.DD2_AMMOINDEX[i]) - 1; | |
// Assign index just for good measure | |
aaa.weaponIndex = i; | |
// Take Weapon from our inventory | |
RemoveInventory(FindInventory(invoker.DD2_WPNINDEX[i])); | |
// Take Ammo from our inventory | |
RemoveInventory(FindInventory(invoker.DD2_AMMOINDEX[i])); | |
} | |
} | |
} | |
} | |
stop; | |
} | |
} | |
// Blank Dummy Weapon | |
Class DD2_WeaponBlank : DD2_Weapon | |
{ | |
Default | |
{ | |
Weapon.SelectionOrder 10000; | |
Weapon.UpSound "weapons/raiseNone"; | |
} | |
States | |
{ | |
Ready: | |
TNT1 A 1 | |
{ | |
A_SetCrosshair(8); | |
A_WeaponReady(WRF_NOFIRE); | |
} | |
Wait; | |
Deselect: | |
TNT1 A 1 | |
{ | |
A_SetCrosshair(0); | |
A_Lower(); | |
} | |
Wait; | |
Select: | |
TNT1 A 1 | |
{ | |
A_SetCrosshair(8); | |
A_Raise(); | |
} | |
Wait; | |
Fire: | |
TNT1 A 5; | |
Goto Ready; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ******************************************************************* | |
* bazooka.zsc | |
* | |
* Bazooka stuff | |
* | |
* As long as you attribute these functions to me in some | |
* way I don't mind people using these. Considering how much | |
* some people have caused an uproar over the lack of proper | |
* examples and the like. | |
* | |
* Copyright Sanya K. C. Waffles 2013-2017 | |
* | |
* ****************************************************************** */ | |
// A straight-firing | |
Class DD2_BazookaRocket : DD2_ProjectileActor | |
{ | |
Default | |
{ | |
Radius 11; | |
Height 8; | |
Speed 20; | |
Damage 20; | |
DamageType "Rocket"; | |
SeeSound "weapons/rocklf"; | |
DeathSound "weapons/rocklx"; | |
Scale 0.08; | |
} | |
States | |
{ | |
Spawn: | |
MISL A 1 Bright; | |
Loop; | |
Death: | |
EXPL A 3 Bright | |
{ | |
A_SetScale(0.12, 0.12); | |
A_SetRenderStyle(0.66, STYLE_Add); | |
A_Explode(64, 96); | |
} | |
EXPL B 3 Bright A_Quake(2, 8, 0, 1096); | |
EXPL CD 3 Bright A_FadeOut(0.3); | |
Stop; | |
} | |
} | |
// Rocket Ammo Pickup | |
Class DD2_BazookaAmmo : Ammo | |
{ | |
Default | |
{ | |
// Inventory.Icon "AMM5A0"; | |
Inventory.Amount 1; | |
Inventory.MaxAmount 10; | |
Ammo.BackpackAmount 0; | |
Ammo.BackpackMaxAmount 10; | |
} | |
} | |
Class DD2_Bazooka : DD2_Weapon | |
{ | |
Default | |
{ | |
Scale 0.10; | |
Radius 24; | |
Height 20; | |
Inventory.PickupMessage "$DD2_GOTBAZOOKA"; | |
Inventory.Icon "ROCKA0"; | |
Weapon.SelectionOrder 10; | |
Weapon.UpSound "weapons/raiseHeavy"; | |
Weapon.BobSpeed 0.3; | |
Weapon.AmmoUse 1; | |
Weapon.AmmoGive 1; | |
Weapon.AmmoType "DD2_BazookaAmmo"; | |
Weapon.Kickback 750; | |
Tag "$DD2_TAG_BAZOOKA"; | |
Obituary "$DD2_OBIT_BAZOOKA"; | |
Scale 0.12; | |
} | |
// Rocket launcher 'weapon ready' function | |
action void A_DDRLReady() | |
{ | |
A_WeaponReady(); | |
} | |
action void A_DDRLReady2() | |
{ | |
A_WeaponReady(); | |
A_WeaponOffset(0, 32); | |
} | |
States | |
{ | |
Ready: | |
RLNG A 1 A_DDRLReady(); | |
RLNG A 1 | |
{ | |
A_WeaponReady(); | |
} | |
Loop; | |
Deselect: | |
RLNG A 0 A_Lower(); | |
RLNG A 0 A_Lower(); | |
RLNG A 0 A_Lower(); | |
RLNG A 1 A_Lower(); | |
Wait; | |
Select: | |
RLNG A 1 A_Raise(); | |
Wait; | |
Fire: | |
RLNG B 12 | |
{ | |
A_GunFlash(); | |
A_FireProjectile("DD2_BazookaRocket"); | |
} | |
RLNG C 6; | |
RLNG C 12 A_ReFire; | |
Goto Ready; | |
Flash: | |
MISF A 3 Bright A_Light2(); | |
MISF B 3 Bright A_Light1(); | |
TNT1 A 0 A_Light0(); | |
Stop; | |
} | |
} | |
Class DD2_BazookaPickup : DD2_WeaponPickup | |
{ | |
Default | |
{ | |
//$Title "Bazooka" | |
//$Sprite ROCKA0 | |
//$NotAngled | |
//$Category "Weapons" | |
//$Color 14 | |
Radius 26; | |
Height 12; | |
Scale 0.10; | |
Inventory.PickupSound "pickups/weapon"; | |
DD2_WeaponPickup.WeaponToGive "DD2_Bazooka"; | |
DD2_WeaponPickup.AmmoToGive "DD2_BazookaAmmo"; | |
DD2_WeaponPickup.AmmoAmount 10; | |
DD2_WeaponPickup.WeaponIndex 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment