Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==========================================================================
- //
- // Function: InvAmount
- //
- //==========================================================================
- class FxGlobalFunctionCall_InvAmount : public FxGlobalFunctionCall
- {
- public:
- GLOBALFUNCTION_DEFINE(InvAmount);
- FxExpression *Resolve(FCompileContext& ctx)
- {
- CHECKRESOLVED();
- if (!ResolveArgs(ctx, 1, 1, false))
- return NULL;
- switch ((*ArgList)[0]->ValueType.Type)
- {
- case VAL_Class: case VAL_Name:break;
- default:
- ScriptPosition.Message(MSG_ERROR, "actor class expected for parameter");
- delete this;
- return NULL;
- }
- ValueType = VAL_Float;
- return this;
- }
- ExpVal EvalExpression(AActor *self)
- {
- ExpVal ret;
- ret.Type = VAL_Int;
- ExpVal v = (*ArgList)[0]->EvalExpression(self);
- const PClass * invclass;
- {
- invclass = v.GetClass();
- if (!invclass)
- {
- invclass = PClass::FindClass(v.GetName());
- if (!invclass){ ret.Int = -1; return ret; }
- }
- }
- AInventory *item = self->FindInventory(invclass);
- int pick_pointer = AAPTR_DEFAULT;
- self = COPY_AAPTR(self, pick_pointer);
- ret.Int = (item == NULL) ? -1 : item->Amount;
- return ret;
- }
- };
- GLOBALFUNCTION_ADDER(InvAmount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement