Help with converting an inventory count to integers

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
nambona890
Banned
Posts: 31
Joined: Sat Aug 02, 2014 9:38 am
Location: Australia
Clan Tag: [BAF]
Banned: Permanently

Help with converting an inventory count to integers

#1

Post by nambona890 » Sat Mar 14, 2015 9:04 am

Code: Select all

ACTOR VariableTest 8806
{
Health 5000
Radius 20
Height 43
speed 10
damagefactor thing , 0.0
Scale 0.05
MONSTER
+shootable
+solid
var int user_angle;
var int user_pitchthing;
states
{
	spawn:
		TEST A 1 a_look
		loop
	see:
		TEST A 1 a_chase
		TEST A 0 a_takeinventory("anglevar",999)
		TEST A 0 a_takeinventory("pitchvar",999)
		loop
	missile:
		TEST A 0 a_custommissile("testrocket",10,0,AmountOfPitchVar,CMF_ABSOLUTEPITCH,AmountOfAngleVar)
		TEST A 0 a_jumpifinventory("anglevar",360,"pitchshit")
		TEST A 0 a_giveinventory("anglevar",1)
		loop
	pitchshit:
		TEST A 0 a_takeinventory("anglevar",999)
		TEST A 0 a_giveinventory("pitchvar",1)
		TEST A 0 a_jumpifinventory("anglevar",90,"see")
		goto missile
	death:
		TNT1 A 0 a_die
		stop
	}
}

ACTOR AngleVar : Inventory
{
   Inventory.MaxAmount 360
}

ACTOR PitchVar : Inventory
{
   Inventory.MaxAmount 90
}

ACTOR TestRocket : Rocket
{
DamageType thing
}
In other words, is there a CheckInventory alternative for DECORATE?
Last edited by nambona890 on Sat Mar 14, 2015 9:16 am, edited 1 time in total.

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: Help with converting an inventory count to integers

#2

Post by Ænima » Sat Mar 14, 2015 1:08 pm

I don't think so. The decorate variables you defined don't work?
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
nambona890
Banned
Posts: 31
Joined: Sat Aug 02, 2014 9:38 am
Location: Australia
Clan Tag: [BAF]
Banned: Permanently

RE: Help with converting an inventory count to integers

#3

Post by nambona890 » Sat Mar 14, 2015 1:33 pm

Ænima wrote: I don't think so. The decorate variables you defined don't work?

Code: Select all

ACTOR VariableTest 8806
{
Health 5000
Radius 20
Height 43
speed 10
damagefactor thing , 0.0
Scale 0.05
MONSTER
+shootable
+solid
states
{
	spawn:
		TEST A 1 a_look
		loop
	see:
		TEST A 1 a_chase
		TEST A 0 a_takeinventory("anglevar",999)
		TEST A 0 a_takeinventory("pitchvar",999)
		loop
	missile:
		TEST A 0 a_custommissile("testrocket",10,0,ACS_ExecuteWithResult(923,0),CMF_AIMDIRECTION,ACS_ExecuteWithResult(923,1))
		TEST A 0 a_jumpif(ACS_ExecuteWithResult(923,0)>359,"pitchshist")
		TEST A 0 a_giveinventory("anglevar",45)
		loop
	pitchshit:
		TEST A 0 a_takeinventory("anglevar",999)
		TEST A 0 a_giveinventory("pitchvar",11)
		TEST A 0 a_jumpif(ACS_ExecuteWithResult(923,1)>359,"see")
		goto missile
	death:
		TNT1 A 0 a_die
		stop
	}
}

ACTOR AngleVar : Inventory
{
   Inventory.MaxAmount 360
}

ACTOR PitchVar : Inventory
{
   Inventory.MaxAmount 90
}

ACTOR TestRocket : Rocket
{
DamageType thing
}



ACTOR SpecialBaronOfHell : BaronOfHell
{
  States
  {
  Spawn:
    BOSS A 0 NoDelay A_CustomMissile("OrbitBall", 32, 0, 0, CMF_AIMDIRECTION)
  Idle:
    Goto Super::Spawn
  }
}

ACTOR OrbitBall
{
  RenderStyle "Add"
  Translation "0:255=%[0,0,0]:[0.93,2,0.87]" // Makes it green-colored
  +MISSILE
  +NOINTERACTION

  var int user_angle; // See user variables

  States
  {
  Spawn:
    BAL1 A 1 Bright NoDelay A_Warp(AAPTR_TARGET, 32, 0, 32, user_angle, WARPF_ABSOLUTEANGLE|WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE)
    TNT1 A 0 A_SetUserVar("user_angle", user_angle + 8)
    Loop
  }
}

Code: Select all

#include "zcommon.acs"

int inventoryshit[2]={"anglevar","pitchvar"};

script 923 (int i)
{
	SetResultValue(checkinventory(inventoryshit[i]));
}
it completely bricks zandronum

User avatar
ZZYZX
Posts a lot
Posts: 742
Joined: Thu Jun 07, 2012 5:56 pm
Location: Ukraine
Clan: A3
Clan Tag: [A3]

RE: Help with converting an inventory count to integers

#4

Post by ZZYZX » Sat Mar 14, 2015 2:25 pm

http://zdoom.org/wiki/A_JumpIfInventory
http://zdoom.org/wiki/A_JumpIfInTargetInventory

And do the variables work? If they do then why are you using inventory like this?
Last edited by ZZYZX on Sat Mar 14, 2015 2:32 pm, edited 1 time in total.

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: Help with converting an inventory count to integers

#5

Post by Ænima » Sat Mar 14, 2015 3:11 pm

Are you basically trying to make a FOR loop to spawn a rocket at every degree 0-360? I think it's been done before but I forgot where, otherwise you'll have to have a new line of decorate for every rocket. D:
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
Ivan
Addicted to Zandronum
Posts: 2229
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: Help with converting an inventory count to integers

#6

Post by Ivan » Sat Mar 14, 2015 3:23 pm

Code: Select all

Script X (void) {
    SetResultValue(CheckInventory("Item"));
}
In actor code, do:

Code: Select all

LoopState:
    TNT1 A 0 A_JumpIfInventory("Item", MY_ITEM_LIMIT, "LeaveLoop")
    TNT1 A 0 A_CustomMissile("MyMissile", 0, 0, ACS_ExecuteWithResult(X) * 45)
    TNT1 A 0 A_GiveInventory("Item", 1)
Loop
LeaveLoop:
    TNT1 A 0 A_TakeInventory("Item", MY_ITEM_LIMIT)
Goto Whatever
Last edited by Ivan on Sat Mar 14, 2015 3:23 pm, edited 1 time in total.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: Help with converting an inventory count to integers

#7

Post by Ænima » Sat Mar 14, 2015 5:35 pm

Wait you can use ACS_ExecuteWithResult as part of an argument? That's cool.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
Ivan
Addicted to Zandronum
Posts: 2229
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

RE: Help with converting an inventory count to integers

#8

Post by Ivan » Sat Mar 14, 2015 6:03 pm

You can use it with more than that. You can use it as an argument to Damage properties and stuff.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: Help with converting an inventory count to integers

#9

Post by Ænima » Sat Mar 14, 2015 7:14 pm

Whaaaaaa. I never knew about this. That opens up so many possibilities for accessing information which would normally be unavailable to DECORATE, maybe even account-saved information.

So does the DECORATE action special have to wait until it gets a result to execute? Does that delay that state?
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

Arctangent
 
Posts: 82
Joined: Mon Nov 24, 2014 8:19 am

RE: Help with converting an inventory count to integers

#10

Post by Arctangent » Sat Mar 14, 2015 8:31 pm

Ænima wrote: So does the DECORATE action special have to wait until it gets a result to execute? Does that delay that state?
Probably? It's not a real question, though, I don't think, since you can't return a result after Delay or similar functions are used. Pretty sure it just acts like you returned 0 if SetResultValue hasn't been called before a waiting function has.

Quick edit: Actually, it'll return 1 by default, and it seems like you can call SetResultValue multiple times and it'll return the final value once either the script ends or the script waits its first tic.
Last edited by Arctangent on Sat Mar 14, 2015 8:33 pm, edited 1 time in total.

User avatar
nambona890
Banned
Posts: 31
Joined: Sat Aug 02, 2014 9:38 am
Location: Australia
Clan Tag: [BAF]
Banned: Permanently

RE: Help with converting an inventory count to integers

#11

Post by nambona890 » Sat Mar 14, 2015 10:12 pm

If you want to see what it does, http://puu.sh/gAobs/c449bdeaf7.wad
Also, you will have to spawn the actor manually.

Arctangent
 
Posts: 82
Joined: Mon Nov 24, 2014 8:19 am

RE: Help with converting an inventory count to integers

#12

Post by Arctangent » Sun Mar 15, 2015 3:03 am

Just a moment of looking through the code makes me wonder if Zandronum's just detecting this as an infinite loop, because that's approximately 90720 states going by in a single tic. The only ( or at least, standard ) way to check for a zero-tic infinite loop is to limit how many x occur within a single tic, and you might just plain the tripping to maximum number of states allowed in that tic.

User avatar
Ænima
Addicted to Zandronum
Posts: 3579
Joined: Tue Jun 05, 2012 6:12 pm

RE: Help with converting an inventory count to integers

#13

Post by Ænima » Sun Mar 15, 2015 3:37 am

Ohhh I forgot about that. What's the recursion limit exactly?

There's also probably a cleaner way to do this.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)
Image

User avatar
nambona890
Banned
Posts: 31
Joined: Sat Aug 02, 2014 9:38 am
Location: Australia
Clan Tag: [BAF]
Banned: Permanently

RE: Help with converting an inventory count to integers

#14

Post by nambona890 » Fri Mar 27, 2015 6:21 am

Ænima wrote: There's also probably a cleaner way to do this.
What way do you think would work?

User avatar
ZZYZX
Posts a lot
Posts: 742
Joined: Thu Jun 07, 2012 5:56 pm
Location: Ukraine
Clan: A3
Clan Tag: [A3]

RE: Help with converting an inventory count to integers

#15

Post by ZZYZX » Fri Mar 27, 2015 6:57 am

I don't think ZDooms detect infinite loops in DECORATE, since I was able to write a broken loop earlier and hang everything up for a minute until I killed the game with taskmanager.
Don't know about Zan but it shouldn't too, otherwise it's a compatibility bug.
Last edited by ZZYZX on Fri Mar 27, 2015 6:57 am, edited 1 time in total.

Post Reply