Page 1 of 1
Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 9:04 am
by nambona890
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?
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 1:08 pm
by Ænima
I don't think so. The decorate variables you defined don't work?
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 1:33 pm
by nambona890
Æ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
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 2:25 pm
by ZZYZX
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 3:11 pm
by Ænima
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:
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 3:23 pm
by Ivan
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
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 5:35 pm
by Ænima
Wait you can use ACS_ExecuteWithResult as part of an argument? That's cool.
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 6:03 pm
by Ivan
You can use it with more than that. You can use it as an argument to Damage properties and stuff.
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 7:14 pm
by Ænima
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?
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 8:31 pm
by Arctangent
Æ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.
RE: Help with converting an inventory count to integers
Posted: Sat Mar 14, 2015 10:12 pm
by nambona890
If you want to see what it does,
http://puu.sh/gAobs/c449bdeaf7.wad
Also, you will have to spawn the actor manually.
RE: Help with converting an inventory count to integers
Posted: Sun Mar 15, 2015 3:03 am
by Arctangent
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.
RE: Help with converting an inventory count to integers
Posted: Sun Mar 15, 2015 3:37 am
by Ænima
Ohhh I forgot about that. What's the recursion limit exactly?
There's also probably a cleaner way to do this.
RE: Help with converting an inventory count to integers
Posted: Fri Mar 27, 2015 6:21 am
by nambona890
Ænima wrote:
There's also probably a cleaner way to do this.
What way do you think would work?
RE: Help with converting an inventory count to integers
Posted: Fri Mar 27, 2015 6:57 am
by ZZYZX
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.