Gunpowder Sparks

» Siedler Map Source Forum » Mapping » Gunpowder Sparks

Seiten: 1

PPPCSC
#1
18.12.2013 16:57
Beiträge: 43

Gunpowder Sparks

And today's problem is...

How do I create gunpowder sparks?

This is a good little visual effect I've seen in a lot of maps, but I'm having trouble recreating it in my own.

I presumed that this is just an invisible entity with a flame effect attached, which is told to move to a different position, and then disappear upon arrival. So I created this very, very simple function to move a pair of rocks:

function ExplosionSparksMove()
Move("geologist_spark_1", "geologist_spark_1_d" )
Move("geologist_spark_2", "geologist_spark_2_d" )
end


with, somewhere earlier,
Logic.SetVisible("geologist_spark_1", false)
Logic.SetVisible("geologist_spark_2", false)


The entities are rocks. I couldn't get it to allow me to attach a flame effect to an invisible script entity.

But...
1. I still can't get the invisible rocks to move, and
2. I haven't yet worked out which is the correct effect to use

I am using QSB3.9.

____________________
'The greatest fortress that a prince may possess is the affection of his people.'
- Niccolò di Bernardo dei Machiavelli (call him Nick)

totalwarANGEL
#2
18.12.2013 18:33
Beiträge: 2123

Move is a broken relicte from DEdK. It does not work. Use this instead:

function MoveEx(_entity,_pos,_distance,_faceToFace,_moveAsEntity)
	if not IsExisting(_entity)then
		return
	end
	if not _distance then
		_distance = 0;
	end
	local eID = GetID(_entity);
	local tID = GetID(_pos);
	local pos = GetRelativePos(_pos,_distance);
	if type(_faceToFace) == "number" then
		pos = GetRelativePos(_pos,_distance,_faceToFace);
	end
	
	if _moveAsEntity then
		Logic.MoveEntity(eID,pos.X,pos.Y);
	else
		Logic.MoveSettler(eID,pos.X,pos.Y);
	end
	
	if _faceToFace ~= nil and _faceToFace ~= false then
		StartSimpleJobEx( function()
			if not Logic.IsEntityMoving(eID) then
				if _faceToFace == true then
					LookAt(eID,tID);
				else
					Logic.SetOrientation(eID,_faceToFace);
				end
				return true;
			end
	    end);
	end
end

function GetRelativePos(_target,_distance,_angle)
	if not IsExisting(_target)then
		return
	end
	if not _angle then
		_angle = 0;
	end
	local eID = GetID(_target);
	local pos2 = GetPosition(eID);
	local ori = Logic.GetEntityOrientation(eID)+_angle;
	if Logic.IsBuilding(eID) == 1 then
		x, y = Logic.GetBuildingApproachPosition(eID);
		pos2 = {X= x, Y= y};
        ori = ori -90;
	end
	local pos1 = { X= pos2.X+_distance * math.cos(math.rad(ori)),
				   Y= pos2.Y+_distance * math.sin(math.rad(ori))};
	return pos1;
end


To create a effect you only need to create it with Logic.CreateEffect or Logic.CreateEffectWithOrientation. Why do you want to let a geologist walking?

____________________
Die Welt ist arschlochförmig und wir leben in der Mitte.

PPPCSC
#3
11.01.2014 11:47
Beiträge: 43

Zitat von totalwarANGEL:

To create a effect you only need to create it with Logic.CreateEffect or Logic.CreateEffectWithOrientation. Why do you want to let a geologist walking?



The entities are not actually geologists, this is just the names of the entities, because the sequence is:

1. A geologist is sent from an AI storehouse - this bit I have working already
2. The geologist lights a spark - this spark is just an effect, attached to an invisible entity called "geologist_spark_1".
3. This spark remains attached to the invisible entity as the entity is moved to a destination, so it looks like the spark is following a detonation line. The destination is determined by the position of another entity, "geolgist_spark_1_d".
4. Using the quest scripting template sent to me by LordFWD, created by OldMacDonald I think, I use this line in a quest:

"Goal_EntityDistance","geologist_spark_1","geologist_spark_2","<",100,



with these rewards, to make it look like the gunpowder has exploded, and destroyed a large rock:

"Reward_DestroyEffect","e0010",
"Reward_DestroyEntity","glacier_rock_1",



There is a second spark attached to "geologist_spark_2" which goes to "geologist_spark_2_d" in the same way, where it destroys "glacier_rock_2".

____________________
'The greatest fortress that a prince may possess is the affection of his people.'
- Niccolò di Bernardo dei Machiavelli (call him Nick)

PPPCSC
#4
28.02.2014 23:02
Beiträge: 43

Screenshot

Hi all,

The effect I'm still trying to re-create, with a lot of difficulty, is shown in my latest screenshot:

http://www.siedler-maps.de/screenshots/screenshot-3360.htm

So, this is the stone quarry effect used in nearly every map by Sokrates, about whom I can only say he was an absolute map script genius. (The map shown is Der Geysire, if you're interested.)

I'd love to hear if anyone knows how he used to do it!

PPPCSC

____________________
'The greatest fortress that a prince may possess is the affection of his people.'
- Niccolò di Bernardo dei Machiavelli (call him Nick)

totalwarANGEL
#5
01.03.2014 18:29
Beiträge: 2123

Genie's

This will manage your problem.

GameCallback_Feedback_OnGeologistRefill_OrigMines = GameCallback_Feedback_OnGeologistRefill;
GameCallback_Feedback_OnGeologistRefill = function(_GeologistPlayerID, _RefilledObjectID, _GeologistID)
	GameCallback_Feedback_OnGeologistRefill_OrigMines(_GeologistPlayerID, _RefilledObjectID, _GeologistID);
	
	local pos = GetPosition(_RefilledObjectID);
	GUI.SendScripcCommand("Logic.CreateEffect(EGL_Effects.FXWallImpact,"..pos.X..","..pos.Y..",0)");
end


Bacause of it's a GameCallback_Feedback it must be copied into the local script.

____________________
Die Welt ist arschlochförmig und wir leben in der Mitte.

PPPCSC
#6
07.03.2014 23:23
Beiträge: 43

So near, yet...

Hi twA,

I'm not sure how I can fit your script around what I already have.

The geologist arrives as an NPC, and creates a spark effect, on reaching a position. (The player does not call the geologist, it is part of the story and happens as a quest reward.)

So, when the geologist arrives at the position, a quest uses

"Goal_EntityDistance","geologist","geologist_arrive","<",500,
"Reward_CreateEffect","e0004","geologist_spark_1","Effect_Fire01",0,-1,

--okay, I can't quite remember what CreateEffect actually looks like in the script, but I think you get the idea here ;) 



Where:
geologist_spark_1 is the spark effect, attached to an invisible script entity,
geologist is the geologist,
and geologist_arrive is an invisible script entity, which he arrives at.

So far, all good. All this works in the map.

* * * * *

Next, I need the spark effect to move to the R_StoneMine entity, which is illogically called geologist_spark_1_d

Then the explosion can happen, and the mine can refill. Refilling the mine is not a problem, I have this working on its own as script... but in the final version of the sequence, it will be triggered by

"Goal_EntityDistance","geologist_spark","geologist_spark_1_d","<",500



Now I try to integrate your script...

But of course, the situation is difficult.
Any ideas how I can get the spark to move?

Bear in mind also that I am not using the Eastern Realm, which I should have said earlier.


PPPCSC

____________________
'The greatest fortress that a prince may possess is the affection of his people.'
- Niccolò di Bernardo dei Machiavelli (call him Nick)

totalwarANGEL
#7
08.03.2014 21:09
Beiträge: 2123

Bear in mind also that I am not using the Eastern Realm, which I should have said earlier.


Of course, that would maybe a good idea...

You can use this function in a loop to get positions relative to the mine, create a effect and destroy it a 1/10 sec later.

function GetRelativePos(_target,_distance,_angle)
    if not IsExisting(_target)then
        return
    end
    if not _angle then
        _angle = 0;
    end
    local eID = GetID(_target);
    local pos2 = GetPosition(eID);
    local ori = Logic.GetEntityOrientation(eID)+_angle;
    if Logic.IsBuilding(eID) == 1 then
        x, y = Logic.GetBuildingApproachPosition(eID);
        pos2 = {X= x, Y= y};
        ori = ori -90;
    end
    local pos1 = { X= pos2.X+_distance * math.cos(math.rad(ori)),
                   Y= pos2.Y+_distance * math.sin(math.rad(ori))};
    return pos1;
end



____________________
Die Welt ist arschlochförmig und wir leben in der Mitte.

PPPCSC
#8
14.03.2014 22:35
Beiträge: 43

Danke

Wow! Now this looks exactly the sort of thing...

Now, as you well know by now, I am a total novice with scripting, especially on this level

I haven't tried it yet, so I may well need some more assistance, probably in the not-so-distant future

However... for now at least...

Thanks a lot!

____________________
'The greatest fortress that a prince may possess is the affection of his people.'
- Niccolò di Bernardo dei Machiavelli (call him Nick)

Seiten: 1

SiteEngine v1.5.0 by nevermind, ©2005-2007
Design by SpiderFive (www.siedler-games.de) - English translation by juja

Impressum