Not logged inOpenClonk Forum
Up Topic General / Help and Questions / [QUESTION] Object Reloading and Map drawing
- - By Sayned [kz] Date 2013-06-13 09:52 Edited 2013-06-13 10:06
I have got two questions.

First question:
I'm going to make something like spells in my maps, so I decided to learn how to make at least existing spell working with cooldown. For example I have removed "RemoveObject" from fireball spell and now I need to make some cooldown, because if I don't do it, clonks will be able to cast fireballs without cooldown.
Also I tried to make spells periodically spawn again in inventory, but I don't like this idea. It may cause a lot of bugs, errors and lags.

Also a small question: is it possible to make player be not able to throw items away? I have tried it once, but I have failed, so I make a limit on same items in clonk's inventory

Second question:
How to draw a map? I have tried to draw a map with different tools (Paint, Photshop, etc.) But it doesn't work right. I have saved it as .bmp and it still didn't work. Maybe there are some special tools for drawing maps for clonks? Or at least there is a best one? Because making generated landscape is not always good/useful/easy.
Parent - - By ala [nl] Date 2013-06-13 10:35
I just answer the first question, I just have a minute:

As far as I know there is no magic in OC, right? For ClonkRage:

>First question:


It is slightly tricky to do it, because you have to modify the really messy combo system In Clonk Rage, but it's possible. I build a system in a scenario called "Fireland" (search for my MagicLeagueExtra packet on CCAN),
I also used a variant of that in my Blackfield modification and added cooldown to some spamming spells.

At last there is Etagenkampf ("Floor Fight"), which uses a System by Limeoux. So check it out, but be warned: It was for me (not beeing a programmer) really advanced shit.
Parent - - By Sayned [kz] Date 2013-06-13 10:54
I actually was not thinking about making something like system in Clonk Rage. I want to make a different system. So these spells will look like items, but they won't remove from Inventory. Hope you understand what I'm talking about :DD

So Actually I want to make a map with 4 different teams, 6 "permanent" spells and one choosable. So If I will get answers to my questions, probably I will make exactly what I'm thinking about
Parent - - By Newton [de] Date 2013-06-13 14:49
Cool, looking forward to it. You can also change the number of items a clonk can carry.
Parent - By Sayned [kz] Date 2013-06-14 07:48
I think if I will need to change number of items a clonk can carry, I will reduce them, but  I think 7 is the right number for spells.
Parent - By Gurkenglas [de] Date 2013-06-20 13:47
Like the Alchemist from CRs Xeron/Queron/whatsitcalled? Most of the common items (Flints, rocks, wood, coal, etc.) had a spell assigned to them that you could use every so often per item without additional cost. Each item in the inventory had a halo around them whose color depended on how much of the cooldown was done.
Reply
Parent - - By Caesar [de] Date 2013-06-13 10:41

>I'm going to make something like spells in my maps, so I decided to learn how to make at least existing spell working with cooldown. For example I have removed "RemoveObject" from fireball spell and now I need to make some cooldown, because if I don't do it, clonks will be able to cast fireballs without cooldown.


You could add an effect to the spell that wears off after time and doesn't allow the spell to be casted while it's on. Or you could save the last cast time and check if enough time has passed since that.

>Drawing maps


I think the question has already been answered here, still: The thing that matters with clonk maps is not the actual color, but the palette-index. mspaint is not really good at preserving it. You can draw maps in the console/editor mode of openclonk.
Parent - - By Sayned [kz] Date 2013-06-13 11:01
Ok. I will try to draw maps.

But what scripts or functions do I need to use in order to make cooldown? I have tried to find it, but I only found this: GetActTime
Parent - - By Caesar [de] Date 2013-06-13 13:59
Either, you work with effects, or with FrameCounter, a local variable and comparisons.
Parent - - By Sayned [kz] Date 2013-06-14 07:45 Edited 2013-06-14 07:55
I have got one problem. Still wonder why, but I have no idea what to do, so cooldown will work like it must. Here is my code:

public func ControlUse(object pClonk, int ix, int iy)
{
  AddEffect("Cooldown",this,100,4+Random(2),this,this->GetID());
  AddEffect("Fireball", nil, 100, 1, nil, GetID(), pClonk->GetOwner(), Angle(0,0,ix,iy),pClonk->GetX(), pClonk->GetY());
  Sound("Fireball");
  Sound("Fireball");
  return 1;
}

func FxCooldownTimer(object target, effect, int timer)
{
  if(timer>500) target->
  return 1;
}


What must I place after "if(timer>500) target->"?
I tried to use different things, but everything was making wrong effect. For example once I have got effect like this: charging Fireball and after some time shots, I don't need such effect.
Parent - - By Sven2 [de] Date 2013-06-14 09:26
You need to check whether the spell is still on cooldown in ControlUse (if(GetEffect(...))) and just remove the effect when the time is up (return FX_Execute_Kill in FxCooldownTimer).
Parent - By Caesar [de] Date 2013-06-14 11:47
Not implementing the timer also means that the effect will be removed when it's called.
Parent - By Sayned [kz] Date 2013-06-15 04:56
Thank you, everything works fine!
Parent - - By Sayned [kz] Date 2013-06-15 05:20
I have got another question >.<

Where is editor mode for openclonk?
Parent - By ker [de] Date 2013-06-15 07:18
run clonk from the console with --editor as an argument. (you can create a shortcut that has this argument in it so you don't have to use the console every time)
Parent - - By Sven2 [de] Date 2013-06-13 14:50

> Also a small question: is it possible to make player be not able to throw items away? I have tried it once, but I have failed, so I make a limit on same items in clonk's inventory


If we don't have the option to "lock" an item in its slot yet (i.e., make it so you cannot throw it away), then we should definitely add that functionality.
Parent - By Zapper [de] Date 2013-06-14 08:49
I can put that on my controls to-do
Parent - By Zapper [de] Date 2013-06-30 16:25
Eventually (when I push) the following callbacks exist (in the Controls-branch):
QueryRejectDeparture(object clonk); // lock in inventory (no throw/drop)
QueryRejectDeselection(object clonk, int hand); // lock in hand, with one hand, "hand" is always = 0
Parent - - By Sayned [kz] Date 2013-06-15 09:31
I was making new spell and then I realised that I want to make unusual way to remove cooldown.
Here is my code:

protected func Initialize()
{
  var y = pClonk->GetYDir();
  var x = pClonk->GetXDir();
  if(x=0) target->RemoveEffect("Cooldown",this);
  if(y=0) target->RemoveEffect("Cooldown",this);
  return 1;
}

protected func ControlUse(object pClonk, iX, iY)
{
  if(GetEffect("Cooldown",this))
  { 
    pClonk->Message("Reloading!");
    return true;
  }
  else
  {
    AddEffect("Cooldown",this,100,4+Random(2),this,this->GetID());
    var y = pClonk->GetYDir();
    var x = pClonk->GetXDir();
    pClonk->SetYDir((y) * 2);
    pClonk->SetXDir((x) * 2);
    return 1;
  }
}

func FxCooldownTimer(object target, effect, int timer)
{
  if(timer>50) target->RemoveEffect("Cooldown",this);
  return 1;
}


And as I can see, function "Initialize" causes an error and doesn't work. It supposed to cause removing cooldown if Clonk's speed by X or Y is 0.
I'm sure problem is in "Initialize"

And yes, this spell is increasing clonk's speed by 2 *lol*
Parent - - By Zapper [de] Date 2013-06-15 10:15
There are some issues:
Initialize is called when the object (the scroll) is created. Your variables pClonk is not known at that time! Which Clonk do you mean?
In Initialize you use if(x=0). Be careful there: X=Y means "set X to Y". You want X==Y which means "Is X the same as Y?".

And a smaller thing in your FxCooldownTimer function:
If you want to remove the effect from the timer function you can simply do return -1; or return FX_Execute_Kill; (which is the same).
So the line in your Fx*Timer could look like this:
if (timer > 50) return -1;
Parent - - By Sayned [kz] Date 2013-06-15 10:59 Edited 2013-06-16 08:03
Strange, but when I use pClonk, it works fine. I mean Clonk, which uses the scroll.
What must I use instead of Initialize? I think if I put if ((x==0) && (y==0)) return -1 in FxCooldownTimer, it won't work. Or will it?

Actually I tried return FX_Execute_Kill seems like I used it wrong way.

I Still don't know what must I use istead of Initialize.
Parent - - By Zapper [de] Date 2013-06-18 18:15
What do you want the stuff in Initialize to do?

You want to remove the effect when the Clonk is not moving?
Parent - - By Sayned [kz] Date 2013-06-20 05:33
Yes, I want to remove the effect when Clonk is not moving.
Parent - - By Zapper [de] Date 2013-06-20 08:23
Then Initialize would be the wrong place - it is only executed once when the object (the scroll) is created.

You should put the check in the Fx*Timer function, as you already wrote:
if ((x == 0) && (y == 0)) return -1;

With var x = target->GetXDir(); not pClonk->GetXDir(), because "pClonk" is not known at that point.

PS: I see that your effect target is not the Clonk but the scroll. So if you want to use "target" in the Fx*Timer function and target should be your Clonk, then you should add the effect to the Clonk and not to the scroll:
AddEffect("Cooldown",pClonk,100,4+Random(2),this,this->GetID());
Parent - By Sayned [kz] Date 2013-06-20 10:26
Thank you.

I know, that cooldown effect is on scroll, I think it's better, because if I will put it on clonk, I will probably need to rename all Cooldown effects for all spells, so spells will have cooldown effect separately. Also if someday I will be able to lock item slot, It will be not necessary to put cooldown on clonks (except of this spell, probably)
Up Topic General / Help and Questions / [QUESTION] Object Reloading and Map drawing

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill