1 /// This global gets set to the verb in question each time the stack manager calls verb_call
\r
3 //.entity current_verb;
\r
6 /// Execure this verb
\r
8 /// Return the value of this verb. Return VS_CALL_REMOVE to delete it.
\r
10 /// This verb is beeing removed NOW (not sent when verb_call returns VS_CALL_REMOVE)
\r
11 #define VCM_REMOVE 2
\r
14 .float(float message) verb_call;
\r
16 /// Points to this verb's stack.
\r
19 /// Static value of this verb
\r
20 .float verb_static_value;
\r
22 /// verb_call returns this when a verb in not doable
\r
23 #define VS_CALL_NO 0
\r
24 /// verb_call(VCM_DO) returns this when a verb is executing
\r
25 #define VS_CALL_YES_DOING -1
\r
26 /// verb_call(VCM_DO) returns this when a verb did execure and is done
\r
27 #define VS_CALL_YES_DONE -2
\r
28 /// verb_call(VCM_DO) returns this when a verb should be deleted by the stack manager
\r
29 #define VS_CALL_REMOVE -3
\r
32 void verbstack_updatechain(entity stack)
\r
38 dprint("verbstack_updatechain\n");
\r
40 vrb = findchainentity(verbstack, stack);
\r
43 stack.vchain = world;
\r
58 void verbstack_remove(entity vverb)
\r
61 dprint("verbstack_remove\n");
\r
63 vstack = verb.verbstack;
\r
65 vverb.verbstack = world;
\r
66 verbstack_updatechain(vstack);
\r
68 //vverb.think = SUB_Remove;
\r
69 //vverb.nextthink = time;
\r
72 void verbstack_thinkremove()
\r
74 dprint("verbstack_thinkremove\n");
\r
75 verbstack_remove(self);
\r
80 Push a new verb onto the specified stack. Set vrb_life to make it time-limited.
\r
82 entity verbstack_push(entity stack, float(float eval) vrb_call, float val_static, float vrb_life,entity verb_owner)
\r
93 vrb.owner = verb_owner;
\r
94 vrb.verbstack = stack;
\r
95 vrb.verb_call = vrb_call;
\r
96 vrb.verb_static_value = val_static;
\r
98 vrb.classname = "verb";
\r
99 stack.classname = "verbstack";
\r
103 //vrb.think = verbstack_thinkremove;
\r
104 vrb.think = SUB_Remove;
\r
105 vrb.nextthink = time + vrb_life;
\r
108 //verbstack_updatechain(stack);
\r
114 Find the best verb in this stack and execurte it.
\r
115 ALso remove any verbs returning VS_CALL_REMOVE on VCM_EVAL or VCM_DO
\r
117 float verbstack_pop(entity stack)
\r
119 entity vrb, bestverb, oldself;
\r
120 float value, bestvalue;
\r
124 vrb = findchainentity(verbstack,stack);
\r
125 //vrb = stack.vchain;
\r
126 //dprint("owner:", stack.owner.classname, " vsn:", stack.classname,"\n");
\r
129 //dprint("vn:", vrb.classname,"\n");
\r
133 value = verb.verb_call(VCM_EVAL);
\r
137 if(value == VS_CALL_REMOVE)
\r
142 if(value > bestvalue)
\r
154 value = verb.verb_call(VCM_DO);
\r
156 if(value == VS_CALL_REMOVE)
\r
165 float verbstack_popfifo(entity stack)
\r
171 verb = findentity(stack,verbstack,stack);
\r
177 ret = verb.verb_call(VCM_DO);
\r
179 if(ret == VS_CALL_REMOVE)
\r
188 Find the best verb in this stack and return it.
\r
189 ALso remove any verbs returning VS_CALL_REMOVE on VCM_EVAL.
\r
191 entity verbstack_pull(entity stack)
\r
194 entity bestverb, oldself;
\r
195 float value, bestvalue;
\r
199 vrb = findchainentity(verbstack,stack);
\r
206 value = verb.verb_call(VCM_EVAL);
\r
210 if(value == VS_CALL_REMOVE)
\r
215 if(value > bestvalue)
\r
228 entity verbstack_pullfifo(entity stack)
\r
230 return findentity(stack,verbstack,stack);
\r
234 Delete every verb on this stack, signaling them with VCM_REMOVE first.
\r
236 void verbstack_flush(entity stack)
\r
238 entity vrb, oldself;
\r
242 vrb = findchainentity(verbstack,stack);
\r
249 verb.verb_call(VCM_REMOVE);
\r
255 //stack.vchain = world;
\r
258 void verbstack_doverb(entity vrb)
\r
264 value = verb.verb_call(VCM_DO);
\r
266 if(value == VS_CALL_REMOVE)
\r