1 /// Some default stacks.
7 /// This global gets set to the verb in question each time the stack manager calls verb_call
9 //.entity current_verb;
14 /// Return the value of this verb. Return VS_CALL_REMOVE to delete it.
16 /// This verb is beeing removed NOW (not sent when verb_call returns VS_CALL_REMOVE)
20 .float(float message) verb_call;
22 /// Points to this verb's stack.
25 /// Static value of this verb
26 .float verb_static_value;
28 /// verb_call returns this when a verb in not doable
30 /// verb_call(VCM_DO) returns this when a verb is executing
31 #define VS_CALL_YES_DOING -1
32 /// verb_call(VCM_DO) returns this when a verb did execure and is done
33 #define VS_CALL_YES_DONE -2
34 /// verb_call(VCM_DO) returns this when a verb should be deleted by the stack manager
35 #define VS_CALL_REMOVE -3
38 void verbstack_updatechain(entity stack)
44 dprint("verbstack_updatechain\n");
46 vrb = findchainentity(verbstack, stack);
64 void verbstack_remove(entity vverb)
67 dprint("verbstack_remove\n");
69 vstack = verb.verbstack;
71 vverb.verbstack = world;
72 verbstack_updatechain(vstack);
74 //vverb.think = SUB_Remove;
75 //vverb.nextthink = time;
78 void verbstack_thinkremove()
80 dprint("verbstack_thinkremove\n");
81 verbstack_remove(self);
86 Push a new verb onto the specified stack. Set vrb_life to make it time-limited.
88 entity verbstack_push(entity stack, float(float eval) vrb_call, float val_static, float vrb_life,entity verb_owner)
99 vrb.owner = verb_owner;
100 vrb.verbstack = stack;
101 vrb.verb_call = vrb_call;
102 vrb.verb_static_value = val_static;
104 vrb.classname = "verb";
105 stack.classname = "verbstack";
109 //vrb.think = verbstack_thinkremove;
110 vrb.think = SUB_Remove;
111 vrb.nextthink = time + vrb_life;
114 //verbstack_updatechain(stack);
120 Find the best verb in this stack and execurte it.
121 ALso remove any verbs returning VS_CALL_REMOVE on VCM_EVAL or VCM_DO
123 float verbstack_pop(entity stack)
125 entity vrb, bestverb, oldself;
126 float value, bestvalue;
130 vrb = findchainentity(verbstack,stack);
131 //vrb = stack.vchain;
132 //dprint("owner:", stack.owner.classname, " vsn:", stack.classname,"\n");
135 //dprint("vn:", vrb.classname,"\n");
139 value = verb.verb_call(VCM_EVAL);
143 if(value == VS_CALL_REMOVE)
148 if(value > bestvalue)
160 value = verb.verb_call(VCM_DO);
162 if(value == VS_CALL_REMOVE)
171 float verbstack_popfifo(entity stack)
177 verb = findentity(stack,verbstack,stack);
183 ret = verb.verb_call(VCM_DO);
185 if(ret == VS_CALL_REMOVE)
194 Find the best verb in this stack and return it.
195 ALso remove any verbs returning VS_CALL_REMOVE on VCM_EVAL.
197 entity verbstack_pull(entity stack)
200 entity bestverb, oldself;
201 float value, bestvalue;
205 vrb = findchainentity(verbstack,stack);
212 value = verb.verb_call(VCM_EVAL);
216 if(value == VS_CALL_REMOVE)
221 if(value > bestvalue)
234 entity verbstack_pullfifo(entity stack)
236 return findentity(stack,verbstack,stack);
240 Delete every verb on this stack, signaling them with VCM_REMOVE first.
242 void verbstack_flush(entity stack)
248 vrb = findchainentity(verbstack,stack);
255 verb.verb_call(VCM_REMOVE);
261 //stack.vchain = world;
264 void verbstack_doverb(entity vrb)
270 value = verb.verb_call(VCM_DO);
272 if(value == VS_CALL_REMOVE)