forked from Mirrors/openclonk
Add magic wand as an editor-assignable usage item
parent
f9349721e4
commit
f6b3a6efb8
|
@ -356,6 +356,7 @@ func Definition(def)
|
||||||
Offset = new Evaluator.Offset { EditorHelp="$PositionOffsetOffsetHelp$", Priority=21 }
|
Offset = new Evaluator.Offset { EditorHelp="$PositionOffsetOffsetHelp$", Priority=21 }
|
||||||
} } );
|
} } );
|
||||||
AddEvaluator("Position", nil, "$ObjectPosition$", "$ObjectPositionHelp$", "object_position", [def, def.EvalPositionObject], { Object={Function="triggering_object"} }, new Evaluator.Object { EditorHelp="$ObjectPositionObjectHelp$" }, "Object");
|
AddEvaluator("Position", nil, "$ObjectPosition$", "$ObjectPositionHelp$", "object_position", [def, def.EvalPositionObject], { Object={Function="triggering_object"} }, new Evaluator.Object { EditorHelp="$ObjectPositionObjectHelp$" }, "Object");
|
||||||
|
AddEvaluator("Position", nil, "$LastUsePosition$", "$LastUsePositionHelp$", "use_position", [def, def.EvalPos_LastUse]);
|
||||||
AddEvaluator("Position", "$RandomPosition$", "$RandomRectAbs$", "$RandomRectAbsHelp$", "random_pos_rect_abs", [def, def.EvalPos_RandomRect, false], def.GetDefaultRect, { Type="rect", Name="$Rectangle$", Relative=false, Color=0xffff00 }, "Area");
|
AddEvaluator("Position", "$RandomPosition$", "$RandomRectAbs$", "$RandomRectAbsHelp$", "random_pos_rect_abs", [def, def.EvalPos_RandomRect, false], def.GetDefaultRect, { Type="rect", Name="$Rectangle$", Relative=false, Color=0xffff00 }, "Area");
|
||||||
AddEvaluator("Position", "$RandomPosition$", "$RandomRectRel$", "$RandomRectRelHelp$", "random_pos_rect_rel", [def, def.EvalPos_RandomRect, true], { Area=[-30,-30,60,60] }, { Type="rect", Name="$Rectangle$", Relative=true, Color=0x00ffff }, "Area");
|
AddEvaluator("Position", "$RandomPosition$", "$RandomRectRel$", "$RandomRectRelHelp$", "random_pos_rect_rel", [def, def.EvalPos_RandomRect, true], { Area=[-30,-30,60,60] }, { Type="rect", Name="$Rectangle$", Relative=true, Color=0x00ffff }, "Area");
|
||||||
AddEvaluator("Position", "$RandomPosition$", "$RandomCircleAbs$", "$RandomCircleAbsHelp$", "random_pos_circle_abs", [def, def.EvalPos_RandomCircle, false], def.GetDefaultCircle, { Type="circle", Name="$Circle$", Relative=false, CanMoveCenter=true, Color=0xff00ff }, "Area");
|
AddEvaluator("Position", "$RandomPosition$", "$RandomCircleAbs$", "$RandomCircleAbsHelp$", "random_pos_circle_abs", [def, def.EvalPos_RandomCircle, false], def.GetDefaultCircle, { Type="circle", Name="$Circle$", Relative=false, CanMoveCenter=true, Color=0xff00ff }, "Area");
|
||||||
|
@ -497,7 +498,7 @@ public func EvaluateValue(string eval_type, proplist props, proplist context)
|
||||||
return cb[0]->Call(cb[1], props, context, cb[2]);
|
return cb[0]->Call(cb[1], props, context, cb[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public func EvaluateAction(proplist props, object action_object, object triggering_object, int triggering_player, string progress_mode, bool allow_parallel, finish_callback)
|
public func EvaluateAction(proplist props, object action_object, object triggering_object, int triggering_player, string progress_mode, bool allow_parallel, finish_callback, array position)
|
||||||
{
|
{
|
||||||
// No action
|
// No action
|
||||||
if (!props) if (finish_callback) return action_object->Call(finish_callback); else return;
|
if (!props) if (finish_callback) return action_object->Call(finish_callback); else return;
|
||||||
|
@ -525,7 +526,7 @@ public func EvaluateAction(proplist props, object action_object, object triggeri
|
||||||
// Prevent duplicate parallel execution
|
// Prevent duplicate parallel execution
|
||||||
if (!allow_parallel && (context.hold && !context.suspended)) return false;
|
if (!allow_parallel && (context.hold && !context.suspended)) return false;
|
||||||
// Init context settings
|
// Init context settings
|
||||||
context->InitContext(action_object, triggering_player, triggering_object, props, finish_callback);
|
context->InitContext(action_object, triggering_player, triggering_object, props, finish_callback, position);
|
||||||
// Execute action
|
// Execute action
|
||||||
EvaluateValue("Action", props, context);
|
EvaluateValue("Action", props, context);
|
||||||
FinishAction(context);
|
FinishAction(context);
|
||||||
|
@ -1134,6 +1135,8 @@ private func EvalPositionObject(proplist props, proplist context)
|
||||||
return [0,0]; // undefined object: Position is 0/0 default
|
return [0,0]; // undefined object: Position is 0/0 default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func EvalPos_LastUse(proplist props, proplist context) { return context.position; }
|
||||||
|
|
||||||
private func EvalPos_RandomRect(proplist props, proplist context, bool relative)
|
private func EvalPos_RandomRect(proplist props, proplist context, bool relative)
|
||||||
{
|
{
|
||||||
// Constant random distribution in rectangle
|
// Constant random distribution in rectangle
|
||||||
|
@ -1253,7 +1256,7 @@ public func Initialize()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public func InitContext(object action_object, int triggering_player, object triggering_object, proplist props, finish_callback)
|
public func InitContext(object action_object, int triggering_player, object triggering_object, proplist props, finish_callback, position)
|
||||||
{
|
{
|
||||||
// Determine triggering player+objects
|
// Determine triggering player+objects
|
||||||
var triggering_clonk;
|
var triggering_clonk;
|
||||||
|
@ -1273,11 +1276,15 @@ public func InitContext(object action_object, int triggering_player, object trig
|
||||||
triggering_object = triggering_clonk;
|
triggering_object = triggering_clonk;
|
||||||
else if (triggering_object->~IsClonk())
|
else if (triggering_object->~IsClonk())
|
||||||
triggering_clonk = triggering_object;
|
triggering_clonk = triggering_object;
|
||||||
|
// Position default
|
||||||
|
if (!position && triggering_object)
|
||||||
|
position = [triggering_object->GetX(), triggering_object->GetY()];
|
||||||
// Init context settings
|
// Init context settings
|
||||||
this.action_object = action_object;
|
this.action_object = action_object;
|
||||||
this.triggering_object = triggering_object;
|
this.triggering_object = triggering_object;
|
||||||
this.triggering_clonk = triggering_clonk;
|
this.triggering_clonk = triggering_clonk;
|
||||||
this.triggering_player = triggering_player;
|
this.triggering_player = triggering_player;
|
||||||
|
this.position = position;
|
||||||
this.root_action = props;
|
this.root_action = props;
|
||||||
this.suspended = false;
|
this.suspended = false;
|
||||||
this.finish_callback = finish_callback;
|
this.finish_callback = finish_callback;
|
||||||
|
|
|
@ -342,3 +342,5 @@ Smoke=Rauch
|
||||||
Sphere=Kreis
|
Sphere=Kreis
|
||||||
StarFlash=Stern
|
StarFlash=Stern
|
||||||
StarSpark=Sonne
|
StarSpark=Sonne
|
||||||
|
LastUsePosition=Aktivierungsposition
|
||||||
|
LastUsePositionHelp=Fuer aktivierbare Gegenstaende wie den Zauberstab: Mausposition, an der der Spieler das Objekt aktiviert hat.
|
||||||
|
|
|
@ -341,3 +341,5 @@ Smoke=Smoke
|
||||||
Sphere=Sphere
|
Sphere=Sphere
|
||||||
StarFlash=Star
|
StarFlash=Star
|
||||||
StarSpark=Sun
|
StarSpark=Sun
|
||||||
|
LastUsePosition=Activation position
|
||||||
|
LastUsePositionHelp=Valid for activated items such as the magic wand: Mouse position where the player activated the item.
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
[DefCore]
|
||||||
|
id=MagicWand
|
||||||
|
Version=8,0
|
||||||
|
Category=C4D_Object
|
||||||
|
Width=3
|
||||||
|
Height=16
|
||||||
|
Offset=-1,-8
|
||||||
|
Vertices=2
|
||||||
|
VertexX=0,0
|
||||||
|
VertexY=-7,7
|
||||||
|
VertexFriction=50,50
|
||||||
|
Value=100
|
||||||
|
Mass=20
|
||||||
|
Rotate=1
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
Magic wand
|
||||||
|
Item to be made magical with editor actions/
|
||||||
|
|
||||||
|
@author Sven2
|
||||||
|
--*/
|
||||||
|
|
||||||
|
public func Initialize()
|
||||||
|
{
|
||||||
|
// We don't have nice graphics yet :(
|
||||||
|
SetGraphics(nil, Torch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public func Hit()
|
||||||
|
{
|
||||||
|
Sound("Hits::Materials::Wood::WoodHit?");
|
||||||
|
}
|
||||||
|
|
||||||
|
public func ControlUse(object clonk, int x, int y)
|
||||||
|
{
|
||||||
|
// No clonk?
|
||||||
|
if (!clonk) return false;
|
||||||
|
// Cooldown?
|
||||||
|
if (last_use_frame != nil)
|
||||||
|
if (FrameCounter() - last_use_frame < cooldown)
|
||||||
|
{
|
||||||
|
PlayerMessage(clonk->GetController(), "$NoUseCooldown$");
|
||||||
|
Sound("UI::Error", true, nil, clonk->GetController());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Action go!
|
||||||
|
UserAction->EvaluateAction(use_action, this, clonk, nil, nil, action_allow_parallel, nil, [x+GetX(), y+GetY()]);
|
||||||
|
last_use_frame = FrameCounter();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public func SetUseAction(new_action)
|
||||||
|
{
|
||||||
|
use_action = new_action;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public func SetCooldown(int new_cooldown)
|
||||||
|
{
|
||||||
|
cooldown = new_cooldown;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-- Display --*/
|
||||||
|
|
||||||
|
public func GetCarryMode(object clonk, bool idle, bool nohand)
|
||||||
|
{
|
||||||
|
if (idle || nohand)
|
||||||
|
return CARRY_Back;
|
||||||
|
|
||||||
|
return CARRY_Spear;
|
||||||
|
}
|
||||||
|
|
||||||
|
func Definition(def)
|
||||||
|
{
|
||||||
|
// Display
|
||||||
|
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(2500, -1500, 0), Trans_Rotate(-30, 0, 0, 1)), def);
|
||||||
|
// Actions
|
||||||
|
if (!def.EditorProps) def.EditorProps = {};
|
||||||
|
def.EditorProps.use_action = new UserAction.Prop { Name="$MagicAction$", Priority=100, Set="SetUseAction", Save="Action", Priority=100 };
|
||||||
|
def.EditorProps.cooldown = { Name="$Cooldown$", Type="int", EditorHelp="$CooldownHelp$", Set="SetCooldown", Save="Cooldown", Min=0 };
|
||||||
|
def.EditorProps.action_allow_parallel = UserAction.PropParallel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-- Properties --*/
|
||||||
|
|
||||||
|
local last_use_frame;
|
||||||
|
local Name = "$Name$";
|
||||||
|
local Description = "$Description$";
|
||||||
|
local Collectible = true;
|
||||||
|
local Components = {Wood = 1, Diamond = 1};
|
||||||
|
local use_action = nil, action_allow_parallel = false;
|
||||||
|
local cooldown = 40;
|
|
@ -0,0 +1,6 @@
|
||||||
|
Name=Zauberstab
|
||||||
|
Description=Enthaellt verborgene Kraefte.
|
||||||
|
NoUseCooldown=Abklingzeit noch nicht verstrichen
|
||||||
|
MagicAction=Zauberaktion
|
||||||
|
Cooldown=Abklingzeit
|
||||||
|
CooldownHelp=Minimalzeit zwischen zwei Zaubern
|
|
@ -0,0 +1,6 @@
|
||||||
|
Name=Magic wand
|
||||||
|
Description=Contains hidden powers.
|
||||||
|
NoUseCooldown=Cooldown hasn't passed yet.
|
||||||
|
MagicAction=Magic action
|
||||||
|
Cooldown=Cooldown time
|
||||||
|
CooldownHelp=Minimal time in frames between two spellcast actions.
|
Loading…
Reference in New Issue